summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDon Slice <dslice@cumulusnetworks.com>2017-03-09 15:54:20 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-04-06 16:32:07 +0200
commitcd1964ff38bdbd2b5d36d0a0d89890e9d1bb2a50 (patch)
tree204d8be9bf9c213e4a895b1d335fafc8cc4c7d3f /lib
parentbgpd: labeled unicast config (diff)
downloadfrr-cd1964ff38bdbd2b5d36d0a0d89890e9d1bb2a50.tar.xz
frr-cd1964ff38bdbd2b5d36d0a0d89890e9d1bb2a50.zip
bgpd: labeled unicast processing
Implement support for negotiating IPv4 or IPv6 labeled-unicast address family, exchanging prefixes and installing them in the routing table, as well as interactions with Zebra for FEC registration. This is the implementation of RFC 3107. Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/prefix.h2
-rw-r--r--lib/stream.c25
-rw-r--r--lib/stream.h3
3 files changed, 29 insertions, 1 deletions
diff --git a/lib/prefix.h b/lib/prefix.h
index eb3ae3daf..786c2bf7e 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -244,6 +244,8 @@ union prefixconstptr
/* Count prefix size from mask length */
#define PSIZE(a) (((a) + 7) / (8))
+#define BSIZE(a) ((a) * (8))
+
/* Prefix's family member. */
#define PREFIX_FAMILY(p) ((p)->family)
diff --git a/lib/stream.c b/lib/stream.c
index 301ebc627..32dde1ca0 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -919,6 +919,31 @@ stream_put_prefix (struct stream *s, struct prefix *p)
return stream_put_prefix_addpath (s, p, 0, 0);
}
+/* Put NLRI with label */
+int
+stream_put_labeled_prefix (struct stream *s, struct prefix *p, u_char *label)
+{
+ size_t psize;
+
+ STREAM_VERIFY_SANE(s);
+
+ psize = PSIZE (p->prefixlen);
+
+ if (STREAM_WRITEABLE (s) < (psize + 3))
+ {
+ STREAM_BOUND_WARN (s, "put");
+ return 0;
+ }
+
+ stream_putc (s, (p->prefixlen + 24));
+ stream_putc(s, label[0]);
+ stream_putc(s, label[1]);
+ stream_putc(s, label[2]);
+ memcpy (s->data + s->endp, &p->u.prefix, psize);
+ s->endp += psize;
+
+ return (psize + 3);
+}
/* Read size from fd. */
int
diff --git a/lib/stream.h b/lib/stream.h
index 1e2bc89b3..b7bf31bf7 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -181,7 +181,8 @@ extern int stream_put_prefix_addpath (struct stream *, struct prefix *,
int addpath_encode,
u_int32_t addpath_tx_id);
extern int stream_put_prefix (struct stream *, struct prefix *);
-
+extern int stream_put_labeled_prefix (struct stream *, struct prefix *,
+ u_char *);
extern void stream_get (void *, struct stream *, size_t);
extern void stream_get_from (void *, struct stream *, size_t, size_t);
extern u_char stream_getc (struct stream *);