test-lldp.c revision 889cec8d58a00c8362ab0c6493bad39e9c6849bc
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 Tom Gundersen
Copyright (C) 2014 Susant Sahani
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <linux/if_ether.h>
#include <net/ethernet.h>
#include "macro.h"
#include "lldp.h"
#include "lldp-tlv.h"
#define TEST_LLDP_PORT "em1"
#define TEST_LLDP_TYPE_SYSTEM_NAME "systemd-lldp"
#define TEST_LLDP_TYPE_SYSTEM_DESC "systemd-lldp-desc"
static struct ether_addr mac_addr = {
};
struct ether_header ether;
/* Append ethernet header */
assert_se(tlv_packet_new(&m) >= 0);
assert_se(lldp_tlv_packet_close_container(m) >= 0);
/* port name */
assert_se(lldp_tlv_packet_close_container(m) >= 0);
/* ttl */
assert_se(lldp_tlv_packet_close_container(m) >= 0);
/* system name */
strlen(TEST_LLDP_TYPE_SYSTEM_NAME)) >= 0);
assert_se(lldp_tlv_packet_close_container(m) >= 0);
/* system descrition */
strlen(TEST_LLDP_TYPE_SYSTEM_DESC)) >= 0);
assert_se(lldp_tlv_packet_close_container(m) >= 0);
/* Mark end of packet */
assert_se(lldp_tlv_packet_close_container(m) >= 0);
*ret = m;
m = NULL;
return 0;
}
switch (subtype) {
break;
default:
assert_not_reached("Unhandled option");
}
assert_se(lldp_tlv_packet_exit_container(m) >= 0);
return 0;
}
static int lldp_parse_port_id_tlv(tlv_packet *m) {
switch (subtype) {
assert_se(p);
break;
default:
assert_not_reached("Unhandled option");
}
assert_se(lldp_tlv_packet_exit_container(m) >= 0);
return 0;
}
static int lldp_parse_system_name_tlv(tlv_packet *m) {
assert_se(lldp_tlv_packet_exit_container(m) >= 0);
return 1;
}
static int lldp_parse_system_desc_tlv(tlv_packet *m) {
assert_se(p);
assert_se(lldp_tlv_packet_exit_container(m) >= 0);
return 0;
}
static int lldp_parse_ttl_tlv(tlv_packet *m) {
assert_se(lldp_tlv_packet_exit_container(m) >= 0);
return 0;
}
assert_se(lldp_parse_port_id_tlv(m) >= 0);
assert_se(lldp_parse_system_name_tlv(m) >= 0);
assert_se(lldp_parse_ttl_tlv(m) >= 0);
assert_se(lldp_parse_system_desc_tlv(m) >= 0);
return 0;
}
/* form a packet */
/* parse the packet */
/* verify */
return 0;
}