summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-10-10 12:39:34 +0200
committerThomas Haller <thaller@redhat.com>2017-10-10 12:54:22 +0200
commit71e668b5c3df25236a3c1e84aacb59f64f41c6b6 (patch)
tree18c17218c1f814afddf542aca1c0e813b8844ce6
parent7cc817ebfa2d76e5b288f3fcd12611992d756126 (diff)
downloadNetworkManager-th/ndisc-routing.tar.gz
-rw-r--r--src/nm-types.h2
-rw-r--r--src/platform/nmp-object.c28
-rw-r--r--src/platform/nmp-object.h22
3 files changed, 52 insertions, 0 deletions
diff --git a/src/nm-types.h b/src/nm-types.h
index e01c48b0a5..82b05fb308 100644
--- a/src/nm-types.h
+++ b/src/nm-types.h
@@ -176,6 +176,8 @@ typedef enum {
NMP_OBJECT_TYPE_IP4_ROUTE,
NMP_OBJECT_TYPE_IP6_ROUTE,
+ NMP_OBJECT_TYPE_NDISC_GATEWAY,
+
NMP_OBJECT_TYPE_LNK_GRE,
NMP_OBJECT_TYPE_LNK_INFINIBAND,
NMP_OBJECT_TYPE_LNK_IP6TNL,
diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c
index e58868645e..d5c4eafb44 100644
--- a/src/platform/nmp-object.c
+++ b/src/platform/nmp-object.c
@@ -968,6 +968,9 @@ _vt_cmd_plobj_id_copy (ip6_route, NMPlatformIP6Route, {
*dst = *src;
nm_assert (nm_platform_ip6_route_cmp (dst, src, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID) == 0);
});
+_vt_cmd_plobj_id_copy (ndisc_gateway, NMPNDiscGateway, {
+ dst->address = src->address;
+});
/* Uses internally nmp_object_copy(), hence it also violates the const
* promise for @obj.
@@ -1060,6 +1063,10 @@ _vt_cmd_plobj_id_cmp_ip6_route (const NMPlatformObject *obj1, const NMPlatformOb
return nm_platform_ip6_route_cmp ((NMPlatformIP6Route *) obj1, (NMPlatformIP6Route *) obj2, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID);
}
+_vt_cmd_plobj_id_cmp (ndisc_gateway, NMPNDiscGateway,
+ NM_CMP_FIELD_IN6ADDR (obj1, obj2, address);
+)
+
guint
nmp_object_id_hash (const NMPObject *obj)
{
@@ -1118,6 +1125,10 @@ _vt_cmd_plobj_id_hash (ip6_route, NMPlatformIP6Route, {
hash = (guint) 1233384151u;
hash = NM_HASH_COMBINE (hash, nm_platform_ip6_route_hash (obj, NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID));
})
+_vt_cmd_plobj_id_hash (ndisc_gateway, NMPNDiscGateway, {
+ hash = (guint) 977597377u;
+ hash = NM_HASH_COMBINE (hash, nm_utils_in6_addr_hash (&obj->address));
+})
gboolean
nmp_object_is_alive (const NMPObject *obj)
@@ -2577,6 +2588,23 @@ const NMPClass _nmp_classes[NMP_OBJECT_TYPE_MAX] = {
.cmd_plobj_hash = (guint (*) (const NMPlatformObject *obj)) nm_platform_ip6_route_hash_full,
.cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_ip6_route_cmp_full,
},
+ [NMP_OBJECT_TYPE_NDISC_GATEWAY - 1] = {
+ .parent = DEDUP_MULTI_OBJ_CLASS_INIT(),
+ .obj_type = NMP_OBJECT_TYPE_NDISC_GATEWAY,
+ .sizeof_data = sizeof (NMPObjectNDiscGateway),
+ .sizeof_public = sizeof (NMPNDiscGateway),
+ .obj_type_name = "ndisc-gateway",
+ .addr_family = AF_INET6,
+ .cmd_plobj_id_copy = _vt_cmd_plobj_id_copy_ndisc_gateway,
+ .cmd_plobj_id_cmp = _vt_cmd_plobj_id_cmp_ndisc_gateway,
+ .cmd_plobj_id_hash = _vt_cmd_plobj_id_hash_ndisc_gateway,
+ /*
+ .cmd_plobj_to_string_id = (const char *(*) (const NMPlatformObject *obj, char *buf, gsize len)) nm_platform_ndisc_gateway_to_string,
+ .cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj, char *buf, gsize len)) nm_platform_ndisc_gateway_to_string,
+ .cmd_plobj_hash = (guint (*) (const NMPlatformObject *obj)) nm_platform_ndisc_gateway_hash_full,
+ .cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_ndisc_gateway_cmp_full,
+ */
+ },
[NMP_OBJECT_TYPE_LNK_GRE - 1] = {
.parent = DEDUP_MULTI_OBJ_CLASS_INIT(),
.obj_type = NMP_OBJECT_TYPE_LNK_GRE,
diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h
index c2310eb971..c257350908 100644
--- a/src/platform/nmp-object.h
+++ b/src/platform/nmp-object.h
@@ -279,6 +279,28 @@ struct _NMPObject {
};
};
+/*****************************************************************************/
+
+/* also define NDisc related types as NMPObject. They are mostly independent from
+ * platform code, so we could go ahead and implement them as an independent type
+ * hierarchie deriving from NMDedupMultiObj/NMObjBaseInst.
+ *
+ * However, it's convenient if the existing object accessors (NMP_OBJECT_GET_TYPE(), etc)
+ * work for all objects alive. Hence, implement them also as NMPObject. */
+
+typedef struct {
+ struct in6_addr address;
+ guint32 timestamp;
+ guint32 lifetime;
+ NMIcmpv6RouterPref preference;
+} NMPNDiscGateway;
+
+typedef struct {
+ NMPNDiscGateway _public;
+} NMPObjectNDiscGateway;
+
+/*****************************************************************************/
+
static inline gboolean
NMP_CLASS_IS_VALID (const NMPClass *klass)
{