Also enable warnings when we try to. Compatibility with gcc 2.96 requires that.
AX_CFLAGS_GCC_OPTION([-Winline])
AX_CFLAGS_GCC_OPTION([-fstack-protector])
AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2])
+AX_CFLAGS_GCC_OPTION([-Wdeclaration-after-statement])
AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter])
AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later
AX_LDFLAGS_OPTION([-Wl,-z,relro])
{
struct lldpd_hardware *hardware;
int i;
+ oid index[2];
if (!header_index_init(vp, name, length, exact, var_len, write_method)) return NULL;
TAILQ_FOREACH(hardware, &scfg->g_hardware, h_entries) {
for (i = 0; i < LLDPMED_APPTYPE_LAST; i++) {
if (hardware->h_lport.p_med_policy[i].type != i+1)
continue;
- oid index[2] = { hardware->h_ifindex,
- i + 1 };
+ index[0] = hardware->h_ifindex;
+ index[1] = i + 1;
if (header_index_add(index, 2,
&hardware->h_lport.p_med_policy[i]))
return &hardware->h_lport.p_med_policy[i];
{
struct lldpd_hardware *hardware;
int i;
+ oid index[2];
if (!header_index_init(vp, name, length, exact, var_len, write_method)) return NULL;
TAILQ_FOREACH(hardware, &scfg->g_hardware, h_entries) {
for (i = 0; i < LLDPMED_LOCFORMAT_LAST; i++) {
if (hardware->h_lport.p_med_location[i].format != i+1)
continue;
- oid index[2] = { hardware->h_ifindex,
- i + 2 };
+ index[0] = hardware->h_ifindex;
+ index[1] = i + 2;
if (header_index_add(index, 2,
&hardware->h_lport.p_med_location[i]))
return &hardware->h_lport.p_med_location[i];
{
struct lldpd_hardware *hardware;
struct lldpd_port *port;
+ oid index[3];
if (!header_index_init(vp, name, length, exact, var_len, write_method)) return NULL;
TAILQ_FOREACH(hardware, &scfg->g_hardware, h_entries) {
TAILQ_FOREACH(port, &hardware->h_rports, p_entries) {
if (SMART_HIDDEN(port)) continue;
if (withmed && !port->p_chassis->c_med_cap_available) continue;
- oid index[3] = { lastchange(port),
- hardware->h_ifindex,
- port->p_chassis->c_index };
+ index[0] = lastchange(port);
+ index[1] = hardware->h_ifindex;
+ index[2] = port->p_chassis->c_index;
if (header_index_add(index, 3,
port))
return port;
struct lldpd_hardware *hardware;
struct lldpd_port *port;
int j;
+ oid index[4];
if (!header_index_init(vp, name, length, exact, var_len, write_method)) return NULL;
TAILQ_FOREACH(hardware, &scfg->g_hardware, h_entries) {
j++) {
if (port->p_med_policy[j].type != j+1)
continue;
- oid index[4] = { lastchange(port),
- hardware->h_ifindex,
- port->p_chassis->c_index,
- j+1 };
+ index[0] = lastchange(port);
+ index[1] = hardware->h_ifindex;
+ index[2] = port->p_chassis->c_index;
+ index[3] = j+1;
if (header_index_add(index, 4,
&port->p_med_policy[j]))
return &port->p_med_policy[j];
j++) {
if (port->p_med_location[j].format != j+1)
continue;
- oid index[4] = { lastchange(port),
- hardware->h_ifindex,
- port->p_chassis->c_index,
- j+2 };
+ index[0] = lastchange(port);
+ index[1] = hardware->h_ifindex;
+ index[2] = port->p_chassis->c_index;
+ index[3] = j+2;
if (header_index_add(index, 4,
&port->p_med_location[j]))
return &port->p_med_location[j];
agent_h_local_med_power(struct variable *vp, oid *name, size_t *length,
int exact, size_t *var_len, WriteMethod **write_method)
{
+ struct lldpd_med_power *power = NULL;
+ struct lldpd_hardware *hardware;
+ int pse = 0;
+
if (!LOCAL_CHASSIS(scfg)->c_med_cap_available)
return NULL;
if (header_generic(vp, name, length, exact, var_len, write_method))
least, all PD values are global and not per-port. We try to
do our best. For device type, we decide on the number of
PD/PSE ports. */
- struct lldpd_med_power *power = NULL;
- struct lldpd_hardware *hardware;
- int pse = 0;
TAILQ_FOREACH(hardware, &scfg->g_hardware, h_entries) {
if (hardware->h_lport.p_med_power.devicetype ==
LLDPMED_POW_TYPE_PSE) {
int exact, size_t *var_len, WriteMethod **write_method)
{
struct lldpd_port *port;
+ u_char *a;
if ((port = header_tprindexed_table(vp, name, length,
exact, var_len, write_method, 1)) == NULL)
return NULL;
- u_char *a;
if ((a = agent_v_med_power(vp, var_len, &port->p_med_power)) != NULL)
return a;
TRYNEXT(agent_h_remote_med_power);
agent_h_local_med(struct variable *vp, oid *name, size_t *length,
int exact, size_t *var_len, WriteMethod **write_method)
{
+ u_char *a;
+
if (!LOCAL_CHASSIS(scfg)->c_med_cap_available)
return NULL;
if (header_generic(vp, name, length, exact, var_len, write_method))
return NULL;
- u_char *a;
if ((a = agent_v_med(vp, var_len,
LOCAL_CHASSIS(scfg), NULL)) != NULL)
return a;
int exact, size_t *var_len, WriteMethod **write_method)
{
struct lldpd_port *port;
+ u_char *a;
if ((port = header_tprindexed_table(vp, name, length,
exact, var_len, write_method, 1)) == NULL)
return NULL;
- u_char *a;
if ((a = agent_v_med(vp, var_len,
port->p_chassis, port)) != NULL)
return a;
static int
agent_log_callback(int major, int minor,
void *serverarg, void *clientarg) {
- (void)major; (void)minor; (void)clientarg;
struct snmp_log_message *slm = (struct snmp_log_message *)serverarg;
char *msg = strdup(slm->msg);
+ (void)major; (void)minor; (void)clientarg;
if (msg) msg[strlen(msg)-1] = '\0';
switch (slm->priority) {
case LOG_EMERG: log_warnx("snmp[emerg]: %s", msg?msg:slm->msg); break;
cdp_send(struct lldpd *global,
struct lldpd_hardware *hardware, int version)
{
+ const char *platform = "Linux";
struct lldpd_chassis *chassis;
struct lldpd_mgmt *mgmt;
u_int8_t mcastaddr[] = CDP_MULTICAST_ADDR;
goto toobig;
/* Platform */
- char *platform = "Linux";
if (global && global->g_platform_override) platform = global->g_platform_override;
if (!(
POKE_START_CDP_TLV(CDP_TLV_PLATFORM) &&
{
struct lldpd_interface *iff, *iff_next;
struct lldpd_hardware *hardware;
+ int output_len;
/* Build the list of interfaces */
struct lldpd_interface_list ifs;
TAILQ_INSERT_TAIL(&ifs, iff, next);
}
- int output_len = marshal_serialize(lldpd_interface_list, &ifs, output);
+ output_len = marshal_serialize(lldpd_interface_list, &ifs, output);
if (output_len <= 0) {
output_len = 0;
*type = NONE;
client_handle_get_interface(struct lldpd *cfg, enum hmsg_type *type,
void *input, int input_len, void **output)
{
- /* Get name of the interface */
char *name;
+ struct lldpd_hardware *hardware;
+
+ /* Get name of the interface */
if (marshal_unserialize(string, input, input_len, &name) <= 0) {
*type = NONE;
return 0;
}
/* Search appropriate hardware */
- struct lldpd_hardware *hardware;
TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries)
if (!strcmp(hardware->h_ifname, name)) {
int output_len = marshal_serialize(lldpd_hardware, hardware, output);
void *input, int input_len, void **output)
{
int ret = 0;
- struct lldpd_port_set *set;
+ struct lldpd_port_set *set = NULL;
+ struct lldpd_hardware *hardware = NULL;
+ struct lldpd_med_loc *loc = NULL;
if (marshal_unserialize(lldpd_port_set, input, input_len, &set) <= 0) {
*type = NONE;
}
/* Search the appropriate hardware */
- struct lldpd_hardware *hardware;
TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries)
if (!strcmp(hardware->h_ifname, set->ifname)) {
struct lldpd_port *port = &hardware->h_lport;
set->med_location->format);
goto set_port_finished;
}
- struct lldpd_med_loc *loc = \
+ loc = \
&port->p_med_location[set->med_location->format - 1];
free(loc->data);
memcpy(loc, set->med_location, sizeof(struct lldpd_med_loc));
ctl_msg_recv(int fd, enum hmsg_type *type, void **t)
{
int n, flags = -1;
+ struct hmsg_header hdr;
*type = NONE; *t = NULL;
/* First, we read the header to know the size of the message */
- struct hmsg_header hdr;
if ((n = read(fd, &hdr, sizeof(struct hmsg_header))) == -1) {
LLOG_WARN("unable to read message header");
return -1;
{
int i;
struct writer * w;
+ char sep[80];
+ struct lldpd_interface *iff;
+ struct lldpd_interface_list *ifs;
+ struct lldpd_port *port;
+ struct lldpd_chassis *chassis;
+ struct lldpd_hardware *hardware;
+
if ( strcmp(fmt,"plain") == 0 ) {
w = txt_init( stdout );
} else if (strcmp(fmt, "keyvalue") == 0) {
w = txt_init( stdout );
}
- char sep[80];
memset(sep, '-', 79);
sep[79] = 0;
- struct lldpd_interface *iff;
- struct lldpd_interface_list *ifs = get_interfaces(s);
+ ifs = get_interfaces(s);
tag_start(w, "lldp", "LLDP neighbors");
TAILQ_FOREACH(iff, ifs, next) {
continue;
}
- struct lldpd_port *port;
- struct lldpd_chassis *chassis;
- struct lldpd_hardware *hardware = get_interface(s, iff->name);
+ hardware = get_interface(s, iff->name);
if (TAILQ_EMPTY(&hardware->h_rports))
continue;
TAILQ_FOREACH(port, &hardware->h_rports, p_entries) {
static void
levent_snmp_read(evutil_socket_t fd, short what, void *arg)
{
- (void)what;
struct lldpd *cfg = arg;
fd_set fdset;
+ (void)what;
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
snmp_read(&fdset);
static void
levent_snmp_timeout(evutil_socket_t fd, short what, void *arg)
{
- (void)what; (void)fd;
struct lldpd *cfg = arg;
+ (void)what; (void)fd;
snmp_timeout();
run_alarms();
levent_snmp_update(cfg);
fd_set fdset;
struct timeval timeout;
static int howmany = 0;
+ int added = 0, removed = 0, current = 0;
+ struct lldpd_events *snmpfd, *snmpfd_next;
/* snmp_select_info() can be tricky to understand. We set `block` to
1 to means that we don't request a timeout. snmp_select_info()
/* We need to untrack any event whose FD is not in `fdset`
anymore */
- int added = 0, removed = 0, current = 0;
- struct lldpd_events *snmpfd, *snmpfd_next;
for (snmpfd = TAILQ_FIRST(levent_snmp_fds(cfg));
snmpfd;
snmpfd = snmpfd_next) {
static void
levent_ctl_recv(evutil_socket_t fd, short what, void *arg)
{
- (void)what;
struct lldpd_one_client *client = arg;
enum hmsg_type type;
void *buffer = NULL;
int n;
+ (void)what;
if ((n = ctl_msg_recv(fd, &type, &buffer)) == -1 ||
client_handle_client(client->cfg, fd, type, buffer, n) == -1) {
static void
levent_ctl_accept(evutil_socket_t fd, short what, void *arg)
{
- (void)what;
struct lldpd *cfg = arg;
struct lldpd_one_client *client = NULL;
int s;
+ (void)what;
+
if ((s = accept(fd, NULL, NULL)) == -1) {
LLOG_WARN("unable to accept connection from socket");
return;
static void
levent_dump(evutil_socket_t fd, short what, void *arg)
{
- (void)fd; (void)what;
struct event_base *base = arg;
+ (void)fd; (void)what;
event_base_dump_events(base, stderr);
}
static void
levent_stop(evutil_socket_t fd, short what, void *arg)
{
- (void)fd; (void)what;
struct event_base *base = arg;
+ (void)fd; (void)what;
event_base_loopbreak(base);
}
static void
levent_update_and_send(evutil_socket_t fd, short what, void *arg)
{
- (void)fd; (void)what;
struct lldpd *cfg = arg;
struct timeval tv = {cfg->g_delay, 0};
+ (void)fd; (void)what;
lldpd_loop(cfg);
event_add(cfg->g_main_loop, &tv);
}
static void
levent_hardware_recv(evutil_socket_t fd, short what, void *arg)
{
- (void)what;
struct lldpd_hardware *hardware = arg;
struct lldpd *cfg = hardware->h_cfg;
+ (void)what;
lldpd_recv(cfg, hardware, fd);
}
void
levent_hardware_add_fd(struct lldpd_hardware *hardware, int fd)
{
+ struct lldpd_events *hfd = NULL;
if (!hardware->h_recv) return;
- struct lldpd_events *hfd = calloc(1, sizeof(struct lldpd_events));
+ hfd = calloc(1, sizeof(struct lldpd_events));
if (!hfd) {
LLOG_WARNX("unable to allocate new event for %s",
hardware->h_ifname);
void
levent_hardware_release(struct lldpd_hardware *hardware)
{
+ struct lldpd_events *ev, *ev_next;
if (!hardware->h_recv) return;
- struct lldpd_events *ev, *ev_next;
for (ev = TAILQ_FIRST(levent_hardware_fds(hardware));
ev;
ev = ev_next) {
{
struct ifaddrs *ifa;
struct lldpd_hardware *hardware;
+ char *name = NULL;
if (LOCAL_CHASSIS(cfg)->c_id != NULL &&
LOCAL_CHASSIS(cfg)->c_id_subtype == LLDP_CHASSISID_SUBTYPE_LLADDR)
/* That's odd. Let's skip. */
continue;
- char *name = malloc(sizeof(hardware->h_lladdr));
+ name = malloc(sizeof(hardware->h_lladdr));
if (!name) {
LLOG_WARN("Not enough memory for chassis ID");
return;
int done;
int skip[4] = {0, 0, 0, 0};
int skip_[4];
+ struct lldpd_interface *iff;
+ struct lldpd_interface_list *ifs;
+ struct lldpd_port_set set;
+ int i;
redo_set_port:
memcpy(skip_, skip, sizeof(skip));
}
if (done) return;
- struct lldpd_interface *iff;
- struct lldpd_interface_list *ifs = get_interfaces(s);
- int i;
+ ifs = get_interfaces(s);
TAILQ_FOREACH(iff, ifs, next) {
if (optind < argc) {
for (i = optind; i < argc; i++)
continue;
}
- struct lldpd_port_set set;
memset(&set, 0, sizeof(struct lldpd_port_set));
set.ifname = iff->name;
#ifdef ENABLE_LLDPMED
static void
lldpd_move_chassis(struct lldpd_chassis *ochassis,
struct lldpd_chassis *chassis) {
+ struct lldpd_mgmt *mgmt, *mgmt_next;
+
/* We want to keep refcount, index and list stuff from the current
* chassis */
TAILQ_ENTRY(lldpd_chassis) entries;
TAILQ_INIT(&ochassis->c_mgmt);
/* Copy of management addresses */
- struct lldpd_mgmt *mgmt, *mgmt_next;
for (mgmt = TAILQ_FIRST(&chassis->c_mgmt);
mgmt != NULL;
mgmt = mgmt_next) {
size_t
marshal_serialize_(struct marshal_info *mi, void *unserialized, void **input,
int skip, void *_refs, int osize)
-{
- /* Check if we have already serialized this one. */
+{
struct ref_l *refs = _refs;
+ struct ref *cref;
+ int size;
+ size_t len;
+ struct marshal_subinfo *current;
+ struct marshal_serialized *new = NULL, *serialized = NULL;
+
+ /* Check if we have already serialized this one. */
if (!refs) {
refs = calloc(1, sizeof(struct ref_l));
if (!refs) {
}
TAILQ_INIT(refs);
}
- struct ref *cref;
TAILQ_FOREACH(cref, refs, next) {
if (unserialized == cref->pointer)
return 0;
}
/* Handle special cases. */
- int size = mi->size;
+ size = mi->size;
if (!strcmp(mi->name, "null string"))
size = strlen((char *)unserialized) + 1;
else if (!strcmp(mi->name, "fixed string"))
size = osize;
/* Allocate serialized structure */
- size_t len = sizeof(struct marshal_serialized) + (skip?0:size);
- struct marshal_serialized *serialized = calloc(1, len);
+ len = sizeof(struct marshal_serialized) + (skip?0:size);
+ serialized = calloc(1, len);
if (!serialized) {
LLOG_WARNX("unable to allocate memory to serialize structure %s",
mi->name);
memcpy(serialized->object, unserialized, size);
/* Then, serialize inner structures */
- struct marshal_subinfo *current;
for (current = mi->pointers; current->mi; current++) {
size_t sublen;
void *source;
}
if (sublen == 0) continue; /* This was already serialized */
/* Append the result */
- struct marshal_serialized *new = realloc(serialized, len + sublen);
+ new = realloc(serialized, len + sublen);
if (!new) {
LLOG_WARNX("unable to allocate more memory to serialize structure %s",
mi->name);
static void*
marshal_alloc(struct gc_l *pointers, size_t len, void *orig)
{
+ struct gc *gpointer = NULL;
+
void *result = malloc(len);
if (!result) return NULL;
- struct gc *gpointer = NULL;
if ((gpointer = (struct gc *)calloc(1,
sizeof(struct gc))) == NULL) {
free(result);
{
int total_len = sizeof(struct marshal_serialized) + (skip?0:mi->size);
struct marshal_serialized *serialized = buffer;
+ struct gc_l *pointers = _pointers;
+ int size, already;
+ void *new;
+ struct marshal_subinfo *current;
+ struct gc *apointer;
+
if (len < sizeof(struct marshal_serialized) || len < total_len) {
LLOG_WARNX("data to deserialize is too small for structure %s",
mi->name);
}
/* Initialize garbage collection */
- struct gc_l *pointers = _pointers;
if (!pointers) {
pointers = calloc(1, sizeof(struct gc_l));
if (!pointers) {
}
/* Special cases */
- int size = mi->size;
+ size = mi->size;
if (!strcmp(mi->name, "null string") || !strcmp(mi->name, "fixed string")) {
switch (mi->name[0]) {
case 'n': size = strnlen((char *)serialized->object,
}
/* Then, each substructure */
- struct marshal_subinfo *current;
for (current = mi->pointers; current->mi; current++) {
size_t sublen;
- void *new = (unsigned char *)*output + current->offset;
+ new = (unsigned char *)*output + current->offset;
if (current->kind == ignore) {
memset((unsigned char *)*output + current->offset,
0, sizeof(void *));
if (*(void **)new == NULL) continue;
/* Did we already see this reference? */
- struct gc *pointer;
- int already = 0;
- TAILQ_FOREACH(pointer, pointers, next)
- if (pointer->orig == *(void **)new) {
+ already = 0;
+ TAILQ_FOREACH(apointer, pointers, next)
+ if (apointer->orig == *(void **)new) {
memcpy((unsigned char *)*output + current->offset,
- &pointer->pointer, sizeof(void *));
+ &apointer->pointer, sizeof(void *));
already = 1;
break;
}
0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x00,
0x06, 0x00, 0x09, 0x4c, 0x69, 0x6e, 0x75, 0x78 };
struct packet *pkt;
+ in_addr_t addr;
+ struct lldpd_mgmt *mgmt;
/* Populate port and chassis */
hardware.h_lport.p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME;
chassis.c_descr = "Chassis description";
chassis.c_cap_available = chassis.c_cap_enabled = LLDP_CAP_ROUTER;
TAILQ_INIT(&chassis.c_mgmt);
- in_addr_t addr = inet_addr("172.17.142.37");
- struct lldpd_mgmt *mgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4,
+ addr = inet_addr("172.17.142.37");
+ mgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4,
&addr, sizeof(in_addr_t), 0);
if (mgmt == NULL)
ck_abort();
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00,
0x09, 0x4c, 0x69, 0x6e, 0x75, 0x78 };
struct packet *pkt;
+ in_addr_t addr1;
+ in_addr_t addr2;
+ struct lldpd_mgmt *mgmt1;
+ struct lldpd_mgmt *mgmt2;
/* Populate port and chassis */
hardware.h_lport.p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR;
chassis.c_cap_available = chassis.c_cap_enabled =
LLDP_CAP_ROUTER | LLDP_CAP_BRIDGE;
TAILQ_INIT(&chassis.c_mgmt);
- in_addr_t addr1 = inet_addr("172.17.142.36");
- in_addr_t addr2 = inet_addr("172.17.142.38");
- struct lldpd_mgmt *mgmt1 = lldpd_alloc_mgmt(LLDPD_AF_IPV4,
- &addr1, sizeof(in_addr_t), 0);
- struct lldpd_mgmt *mgmt2 = lldpd_alloc_mgmt(LLDPD_AF_IPV4,
- &addr2, sizeof(in_addr_t), 0);
+ addr1 = inet_addr("172.17.142.36");
+ addr2 = inet_addr("172.17.142.38");
+ mgmt1 = lldpd_alloc_mgmt(LLDPD_AF_IPV4,
+ &addr1, sizeof(in_addr_t), 0);
+ mgmt2 = lldpd_alloc_mgmt(LLDPD_AF_IPV4,
+ &addr2, sizeof(in_addr_t), 0);
if (mgmt1 == NULL || mgmt2 == NULL)
ck_abort();
TAILQ_INSERT_TAIL(&chassis.c_mgmt, mgmt1, m_entries);
#ifdef ENABLE_CDP
TCase *tc_send = tcase_create("Send CDP packets");
+ TCase *tc_receive = tcase_create("Receive CDP packets");
+
tcase_add_checked_fixture(tc_send, pcap_setup, pcap_teardown);
tcase_add_test(tc_send, test_send_cdpv1);
tcase_add_test(tc_send, test_send_cdpv2);
suite_add_tcase(s, tc_send);
- TCase *tc_receive = tcase_create("Receive CDP packets");
tcase_add_test(tc_receive, test_recv_cdpv1);
tcase_add_test(tc_receive, test_recv_cdpv2);
suite_add_tcase(s, tc_receive);
#ifdef ENABLE_EDP
TCase *tc_send = tcase_create("Send EDP packets");
+ TCase *tc_receive = tcase_create("Receive EDP packets");
+
tcase_add_checked_fixture(tc_send, pcap_setup, pcap_teardown);
tcase_add_test(tc_send, test_send_basic);
#ifdef ENABLE_DOT1
#endif
suite_add_tcase(s, tc_send);
- TCase *tc_receive = tcase_create("Receive EDP packets");
tcase_add_test(tc_receive, test_recv_edp);
suite_add_tcase(s, tc_receive);
#endif
lldp_suite(void)
{
Suite *s = suite_create("LLDP");
+ TCase *tc_send = tcase_create("Send LLDP packets");
+ TCase *tc_receive = tcase_create("Receive LLDP packets");
/* Send tests are first run without knowing the result. The
result is then checked with:
be able to do this).
*/
- TCase *tc_send = tcase_create("Send LLDP packets");
tcase_add_checked_fixture(tc_send, pcap_setup, pcap_teardown);
tcase_add_test(tc_send, test_send_rcv_basic);
#ifdef ENABLE_DOT1
#endif
suite_add_tcase(s, tc_send);
- TCase *tc_receive = tcase_create("Receive LLDP packets");
tcase_add_test(tc_receive, test_recv_min);
tcase_add_test(tc_receive, test_recv_lldpd);
suite_add_tcase(s, tc_receive);
struct struct_nestedpointers *destination;
void *buffer;
size_t len, len2;
+ int i, j;
len = marshal_serialize(struct_nestedpointers, &source, &buffer);
fail_unless(len > 0, "Unable to serialize");
memset(&source_simple1, 0, sizeof(struct struct_simple));
memset(&source_onepointer, 0, sizeof(struct struct_onepointer));
memset(&source, 0, sizeof(struct struct_nestedpointers));
- int i, j;
/* Loop 30 times to ease debugging leaks with valgrind */
for (j = 0; j < 30; j++) {
for (i = 0; i < len; i++) {
.g1 = -47,
.g2 = &source_simple,
};
+ struct list_simple *destination;
+ void *buffer;
+ size_t len, len2;
+ struct struct_simpleentry *e1, *e2;
+ struct struct_simple *s;
+
TAILQ_INIT(&source);
TAILQ_INSERT_TAIL(&source, &entry1, s_entries);
TAILQ_INSERT_TAIL(&source, &entry2, s_entries);
TAILQ_INSERT_TAIL(&source, &entry3, s_entries);
TAILQ_INSERT_TAIL(&source, &entry4, s_entries);
- struct list_simple *destination;
- void *buffer;
- size_t len, len2;
len = marshal_serialize(list_simple, &source, &buffer);
fail_unless(len > 0, "Unable to serialize");
memset(&source, 0, sizeof(struct list_simple));
fail_unless(len2 > 0, "Unable to deserialize");
free(buffer);
- struct struct_simpleentry *e1, *e2;
- struct struct_simple *s;
e1 = TAILQ_FIRST(destination);
ck_assert_int_eq(e1->g1, 47);
s = e1->g2;
.g1 = -47,
.g2 = &source_simple,
};
+ struct struct_withlist *destination;
+ void *buffer;
+ size_t len, len2;
+ struct struct_simpleentry *e1, *e2;
+ struct struct_simple *s;
+
TAILQ_INIT(&source.i2);
TAILQ_INSERT_TAIL(&source.i2, &entry1, s_entries);
TAILQ_INSERT_TAIL(&source.i2, &entry2, s_entries);
TAILQ_INSERT_TAIL(&source.i2, &entry3, s_entries);
TAILQ_INSERT_TAIL(&source.i2, &entry4, s_entries);
- struct struct_withlist *destination;
- void *buffer;
- size_t len, len2;
len = marshal_serialize(struct_withlist, &source, &buffer);
fail_unless(len > 0, "Unable to serialize");
memset(&source, 0, sizeof(struct list_simple));
ck_assert_int_eq(destination->i1, 45424);
ck_assert_int_eq(destination->i3, 4542);
- struct struct_simpleentry *e1, *e2;
- struct struct_simple *s;
e1 = TAILQ_FIRST(&destination->i2);
ck_assert_int_eq(e1->g1, 47);
ck_assert_int_eq(e1->g2->a4, 74);
{
static char *buffer[4] = {NULL, NULL, NULL, NULL};
static int current = 0;
+ int i;
+
current = (current + 1)%4;
if (buffer[current]) free(buffer[current]); buffer[current] = NULL;
- int i;
for (i = 0; i < namelen; i++) {
/* Not very efficient... */
char *newbuffer = NULL;
0x8e, 0x25, 0x00, 0x00, 0x04, 0x01, 0x0c, 0x03,
0x01 };
struct packet *pkt;
+ in_addr_t addr;
+ struct lldpd_mgmt *mgmt;
/* Populate port and chassis */
hardware.h_lport.p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME;
chassis.c_id = macaddress;
chassis.c_id_len = ETH_ALEN;
TAILQ_INIT(&chassis.c_mgmt);
- in_addr_t addr = inet_addr("172.17.142.37");
- struct lldpd_mgmt *mgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4,
- &addr, sizeof(in_addr_t), 0);
+ addr = inet_addr("172.17.142.37");
+ mgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4,
+ &addr, sizeof(in_addr_t), 0);
if (mgmt == NULL)
ck_abort();
TAILQ_INSERT_TAIL(&chassis.c_mgmt, mgmt, m_entries);
#ifdef ENABLE_SONMP
TCase *tc_send = tcase_create("Send SONMP packets");
+ TCase *tc_receive = tcase_create("Receive SONMP packets");
+
tcase_add_checked_fixture(tc_send, pcap_setup, pcap_teardown);
tcase_add_test(tc_send, test_send_sonmp);
suite_add_tcase(s, tc_send);
- TCase *tc_receive = tcase_create("Receive SONMP packets");
tcase_add_test(tc_receive, test_recv_sonmp);
suite_add_tcase(s, tc_receive);
#endif