summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2012-04-16 18:24:40 +0200
committerDavid Lamparter <equinox@diac24.net>2012-04-16 18:24:43 +0200
commitd75318cc8de91d94649106f4ea3122d0d21ac9eb (patch)
tree6d7c674c4026bccd1384e60ee228d8d67750fbf7 /lib
parent6e493a44836d3b034ed3421e866878de3fbfcc5b (diff)
parent48d8bea8b7c83cf186460f711ab166455b5ed676 (diff)
isisd: merge osr/google-is-is
this is essentially half of a rewrite of isisd. please note that a lot of things are still broken and isisd is not ready for production use.
Diffstat (limited to 'lib')
-rw-r--r--lib/if.c4
-rw-r--r--lib/linklist.h14
-rw-r--r--lib/md5.h3
-rw-r--r--lib/memtypes.c2
-rw-r--r--lib/stream.c20
-rw-r--r--lib/stream.h1
-rw-r--r--lib/zclient.c36
7 files changed, 41 insertions, 39 deletions
diff --git a/lib/if.c b/lib/if.c
index 1e99ffbc..e26aa046 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -146,7 +146,7 @@ if_delete_retain (struct interface *ifp)
(*if_master.if_delete_hook) (ifp);
/* Free connected address list */
- list_delete (ifp->connected);
+ list_delete_all_node (ifp->connected);
}
/* Delete and free interface structure. */
@@ -157,6 +157,8 @@ if_delete (struct interface *ifp)
if_delete_retain(ifp);
+ list_free (ifp->connected);
+
XFREE (MTYPE_IF, ifp);
}
diff --git a/lib/linklist.h b/lib/linklist.h
index cc6867cd..f0ae3625 100644
--- a/lib/linklist.h
+++ b/lib/linklist.h
@@ -54,9 +54,9 @@ struct list
void (*del) (void *val);
};
-#define listnextnode(X) ((X)->next)
-#define listhead(X) ((X)->head)
-#define listtail(X) ((X)->tail)
+#define listnextnode(X) ((X) ? ((X)->next) : NULL)
+#define listhead(X) ((X) ? ((X)->head) : NULL)
+#define listtail(X) ((X) ? ((X)->tail) : NULL)
#define listcount(X) ((X)->count)
#define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL)
#define listgetdata(X) (assert((X)->data != NULL), (X)->data)
@@ -88,10 +88,10 @@ extern void list_add_list (struct list *, struct list *);
* It is safe to delete the listnode using this macro.
*/
#define ALL_LIST_ELEMENTS(list,node,nextnode,data) \
- (node) = listhead(list); \
+ (node) = listhead(list), ((data) = NULL); \
(node) != NULL && \
((data) = listgetdata(node),(nextnode) = listnextnode(node), 1); \
- (node) = (nextnode)
+ (node) = (nextnode), ((data) = NULL)
/* read-only list iteration macro.
* Usage: as per ALL_LIST_ELEMENTS, but not safe to delete the listnode Only
@@ -100,9 +100,9 @@ extern void list_add_list (struct list *, struct list *);
* of previous macro.
*/
#define ALL_LIST_ELEMENTS_RO(list,node,data) \
- (node) = listhead(list); \
+ (node) = listhead(list), ((data) = NULL);\
(node) != NULL && ((data) = listgetdata(node), 1); \
- (node) = listnextnode(node)
+ (node) = listnextnode(node), ((data) = NULL)
/* these *do not* cleanup list nodes and referenced data, as the functions
* do - these macros simply {de,at}tach a listnode from/to a list.
diff --git a/lib/md5.h b/lib/md5.h
index 3ce83a63..a03bf22a 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -83,6 +83,7 @@ do { \
} while (0)
/* From RFC 2104 */
-void hmac_md5(unsigned char* text, int text_len, unsigned char* key, int key_len, caddr_t digest);
+void hmac_md5(unsigned char* text, int text_len, unsigned char* key,
+ int key_len, caddr_t digest);
#endif /* ! _LIBZEBRA_MD5_H_*/
diff --git a/lib/memtypes.c b/lib/memtypes.c
index 245c8d8a..acbd16b9 100644
--- a/lib/memtypes.c
+++ b/lib/memtypes.c
@@ -248,6 +248,8 @@ struct memory_list memory_list_isis[] =
{ MTYPE_ISIS_ROUTE_INFO, "ISIS route info" },
{ MTYPE_ISIS_NEXTHOP, "ISIS nexthop" },
{ MTYPE_ISIS_NEXTHOP6, "ISIS nexthop6" },
+ { MTYPE_ISIS_DICT, "ISIS dictionary" },
+ { MTYPE_ISIS_DICT_NODE, "ISIS dictionary node" },
{ -1, NULL },
};
diff --git a/lib/stream.c b/lib/stream.c
index 983330ff..b226a25e 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -52,7 +52,7 @@
* using stream_put..._at() functions.
*/
#define STREAM_WARN_OFFSETS(S) \
- zlog_warn ("&(struct stream): %p, size: %lu, endp: %lu, getp: %lu\n", \
+ zlog_warn ("&(struct stream): %p, size: %lu, getp: %lu, endp: %lu\n", \
(S), \
(unsigned long) (S)->size, \
(unsigned long) (S)->getp, \
@@ -214,6 +214,20 @@ stream_set_getp (struct stream *s, size_t pos)
s->getp = pos;
}
+void
+stream_set_endp (struct stream *s, size_t pos)
+{
+ STREAM_VERIFY_SANE(s);
+
+ if (!GETP_VALID (s, pos))
+ {
+ STREAM_BOUND_WARN (s, "set endp");
+ pos = s->endp;
+ }
+
+ s->endp = pos;
+}
+
/* Forward pointer. */
void
stream_forward_getp (struct stream *s, size_t size)
@@ -934,9 +948,9 @@ stream_fifo_pop (struct stream_fifo *fifo)
if (fifo->head == NULL)
fifo->tail = NULL;
- }
- fifo->count--;
+ fifo->count--;
+ }
return s;
}
diff --git a/lib/stream.h b/lib/stream.h
index 3e4ba7b4..f10aa6d4 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -146,6 +146,7 @@ extern size_t stream_get_size (struct stream *);
extern u_char *stream_get_data (struct stream *);
extern void stream_set_getp (struct stream *, size_t);
+extern void stream_set_endp (struct stream *, size_t);
extern void stream_forward_getp (struct stream *, size_t);
extern void stream_forward_endp (struct stream *, size_t);
diff --git a/lib/zclient.c b/lib/zclient.c
index 3521d99e..61c6f730 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -654,24 +654,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;
}
@@ -699,16 +683,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;
}
@@ -758,6 +733,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