summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Bailey <joshb@google.com>2012-03-21 17:13:39 -0700
committerAvneesh Sachdev <avneesh@opensourcerouting.org>2012-04-08 01:19:41 -0700
commit51d4ef832c1e58150325630e25c442866e5a6cf5 (patch)
treedf155c4193531a37f651d4151866f18224f8ca4b /lib
parent2dd04c5dc8b5a09cce1c251361fa58f26398fd9f (diff)
zebra: include hardware addr in if up/down messages
Change interface up/down notification messages to also include the hardware address of the interface. The format of these messages is now identical to the interface add message -- move the serialization code to common functions. * lib/zclient.c: Modify zebra_interface_if_set_value() to also parse the hardware address. Invoke it from zebra_interface_add_read() and and zebra_interface_state_read(). * zebra/zserv.c: Add zserv_encode_interface(). Invoke it from zserv_interface_add(), zserv_interface_delete() and zserv_interface_update().
Diffstat (limited to 'lib')
-rw-r--r--lib/zclient.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index 52a3627d..85aa737e 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -611,24 +611,8 @@ zebra_interface_add_read (struct stream *s)
/* Lookup/create interface by name. */
ifp = if_get_by_name_len (ifname_tmp, strnlen(ifname_tmp, INTERFACE_NAMSIZ));
- /* Read interface's index. */
- ifp->ifindex = stream_getl (s);
+ zebra_interface_if_set_value (s, ifp);
- /* Read interface's value. */
- ifp->status = stream_getc (s);
- ifp->flags = stream_getq (s);
- ifp->metric = stream_getl (s);
- ifp->mtu = stream_getl (s);
- ifp->mtu6 = stream_getl (s);
- ifp->bandwidth = stream_getl (s);
-#ifdef HAVE_STRUCT_SOCKADDR_DL
- stream_get (&ifp->sdl, s, sizeof (ifp->sdl));
-#else
- ifp->hw_addr_len = stream_getl (s);
- if (ifp->hw_addr_len)
- stream_get (ifp->hw_addr, s, ifp->hw_addr_len);
-#endif /* HAVE_STRUCT_SOCKADDR_DL */
-
return ifp;
}
@@ -656,16 +640,7 @@ zebra_interface_state_read (struct stream *s)
if (! ifp)
return NULL;
- /* Read interface's index. */
- ifp->ifindex = stream_getl (s);
-
- /* Read interface's value. */
- ifp->status = stream_getc (s);
- ifp->flags = stream_getq (s);
- ifp->metric = stream_getl (s);
- ifp->mtu = stream_getl (s);
- ifp->mtu6 = stream_getl (s);
- ifp->bandwidth = stream_getl (s);
+ zebra_interface_if_set_value (s, ifp);
return ifp;
}
@@ -715,6 +690,13 @@ zebra_interface_if_set_value (struct stream *s, struct interface *ifp)
ifp->mtu = stream_getl (s);
ifp->mtu6 = stream_getl (s);
ifp->bandwidth = stream_getl (s);
+#ifdef HAVE_STRUCT_SOCKADDR_DL
+ stream_get (&ifp->sdl, s, sizeof (ifp->sdl));
+#else
+ ifp->hw_addr_len = stream_getl (s);
+ if (ifp->hw_addr_len)
+ stream_get (ifp->hw_addr, s, ifp->hw_addr_len);
+#endif /* HAVE_STRUCT_SOCKADDR_DL */
}
static int