bgpd: Fix bgp_btoa to compile

bgp_btoa was abandoned at some point in time in the past.
This commit gets it to compile and to be added to /usr/bin.

At this point in time no work has done for 'correctness' of execution

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2015-10-21 10:00:47 -04:00
parent ff40e335bb
commit 7625a0deea
2 changed files with 40 additions and 17 deletions

View File

@ -9,6 +9,7 @@ AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libbgp.a noinst_LIBRARIES = libbgp.a
sbin_PROGRAMS = bgpd sbin_PROGRAMS = bgpd
bin_PROGRAMS = bgp_btoa
libbgp_a_SOURCES = \ libbgp_a_SOURCES = \
bgpd.c bgp_fsm.c bgp_aspath.c bgp_community.c bgp_attr.c \ bgpd.c bgp_fsm.c bgp_aspath.c bgp_community.c bgp_attr.c \
@ -29,6 +30,9 @@ noinst_HEADERS = \
bgpd_SOURCES = bgp_main.c bgpd_SOURCES = bgp_main.c
bgpd_LDADD = libbgp.a ../lib/libzebra.la @LIBCAP@ @LIBM@ bgpd_LDADD = libbgp.a ../lib/libzebra.la @LIBCAP@ @LIBM@
bgp_btoa_SOURCES = bgp_btoa.c
bgp_btoa_LDADD = libbgp.a ../lib/libzebra.la @LIBCAP@ @LIBM@
examplesdir = $(exampledir) examplesdir = $(exampledir)
dist_examples_DATA = bgpd.conf.sample bgpd.conf.sample2 dist_examples_DATA = bgpd.conf.sample bgpd.conf.sample2

View File

@ -25,12 +25,36 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "log.h" #include "log.h"
#include "prefix.h" #include "prefix.h"
#include "command.h" #include "command.h"
#include "memory.h"
#include "privs.h"
#include "bgpd/bgpd.h" #include "bgpd/bgpd.h"
#include "bgpd/bgp_dump.h" #include "bgpd/bgp_dump.h"
#include "bgpd/bgp_attr.h" #include "bgpd/bgp_attr.h"
#include "bgpd/bgp_aspath.h" #include "bgpd/bgp_aspath.h"
/* privileges */
static zebra_capabilities_t _caps_p [] =
{
ZCAP_BIND,
ZCAP_NET_RAW,
ZCAP_NET_ADMIN,
};
struct zebra_privs_t bgpd_privs =
{
#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP)
.user = QUAGGA_USER,
.group = QUAGGA_GROUP,
#endif
#ifdef VTY_GROUP
.vty_group = VTY_GROUP,
#endif
.caps_p = _caps_p,
.cap_num_p = array_size(_caps_p),
.cap_num_i = 0,
};
enum MRT_MSG_TYPES { enum MRT_MSG_TYPES {
MSG_NULL, MSG_NULL,
MSG_START, /* sender is starting up */ MSG_START, /* sender is starting up */
@ -47,7 +71,7 @@ enum MRT_MSG_TYPES {
MSG_TABLE_DUMP /* routing table dump */ MSG_TABLE_DUMP /* routing table dump */
}; };
int static int
attr_parse (struct stream *s, u_int16_t len) attr_parse (struct stream *s, u_int16_t len)
{ {
u_int flag; u_int flag;
@ -57,14 +81,14 @@ attr_parse (struct stream *s, u_int16_t len)
lim = s->getp + len; lim = s->getp + len;
printf ("attr_parse s->getp %d, len %d, lim %d\n", s->getp, len, lim); printf ("attr_parse s->getp %zd, len %d, lim %d\n", s->getp, len, lim);
while (s->getp < lim) while (s->getp < lim)
{ {
flag = stream_getc (s); flag = stream_getc (s);
type = stream_getc (s); type = stream_getc (s);
if (flag & ATTR_FLAG_EXTLEN) if (flag & BGP_ATTR_FLAG_EXTLEN)
length = stream_getw (s); length = stream_getw (s);
else else
length = stream_getc (s); length = stream_getc (s);
@ -84,15 +108,11 @@ attr_parse (struct stream *s, u_int16_t len)
break; break;
case BGP_ATTR_AS_PATH: case BGP_ATTR_AS_PATH:
{ {
struct aspath aspath; struct aspath *aspath;
aspath.data = (s->data + s->getp); aspath = aspath_parse (s, length, 1);
aspath.length = length; printf ("ASPATH: %s\n", aspath->str);
aspath.str = aspath_make_str_count (&aspath); aspath_free(aspath);
printf ("ASPATH: %s\n", aspath.str);
free (aspath.str);
stream_forward (s, length);
} }
break; break;
case BGP_ATTR_NEXT_HOP: case BGP_ATTR_NEXT_HOP:
@ -100,11 +120,10 @@ attr_parse (struct stream *s, u_int16_t len)
struct in_addr nexthop; struct in_addr nexthop;
nexthop.s_addr = stream_get_ipv4 (s); nexthop.s_addr = stream_get_ipv4 (s);
printf ("NEXTHOP: %s\n", inet_ntoa (nexthop)); printf ("NEXTHOP: %s\n", inet_ntoa (nexthop));
/* stream_forward (s, length); */
} }
break; break;
default: default:
stream_forward (s, length); stream_getw_from (s, length);
break; break;
} }
} }
@ -121,7 +140,7 @@ main (int argc, char **argv)
time_t now; time_t now;
int type; int type;
int subtype; int subtype;
int len; size_t len;
int source_as; int source_as;
int dest_as; int dest_as;
int ifindex; int ifindex;
@ -150,7 +169,7 @@ main (int argc, char **argv)
stream_reset (s); stream_reset (s);
ret = fread (s->data, 12, 1, fp); ret = fread (s->data, 12, 1, fp);
if (feof (fp)) if (!ret || feof (fp))
{ {
printf ("END OF FILE\n"); printf ("END OF FILE\n");
break; break;
@ -213,7 +232,7 @@ main (int argc, char **argv)
} }
} }
printf ("len: %d\n", len); printf ("len: %zd\n", len);
ret = fread (s->data + 12, len, 1, fp); ret = fread (s->data + 12, len, 1, fp);
if (feof (fp)) if (feof (fp))