X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=tests%2Ftest-aa.c;h=eedefeb7299392ff09ea5ed63a83d24745469017;hb=f76def2592cc5cb449a3360430ee9cc0f208765d;hp=4fb26188f51e8ae46a5f2ee5aa80a8e9096e4f6b;hpb=bdd0bd2873415838643e42a1e4c08319fe8d3b8b;p=cascardo%2Fovs.git diff --git a/tests/test-aa.c b/tests/test-aa.c index 4fb26188f..eedefeb72 100644 --- a/tests/test-aa.c +++ b/tests/test-aa.c @@ -26,11 +26,11 @@ #define ETH_TYPE_LLDP 0x88cc /* Dummy MAC addresses */ -static uint8_t chassis_mac[ETH_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad }; -static uint8_t eth_src[ETH_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad }; +static const struct eth_addr chassis_mac = { { { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad } } }; +static const struct eth_addr eth_src = { { { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad } } }; /* LLDP multicast address */ -static const uint8_t eth_addr_lldp[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x0e}; +static const struct eth_addr eth_addr_lldp = { { { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0e } } }; /* Count of tests run */ static int num_tests = 0; @@ -84,26 +84,16 @@ check_received_aa(struct lldpd_port *sport, assert(rport->p_element.type == sport->p_element.type); assert(rport->p_element.mgmt_vlan == sport->p_element.mgmt_vlan); - assert(rport->p_element.system_id.system_mac[0] == - sport->p_element.system_id.system_mac[0]); - assert(rport->p_element.system_id.system_mac[1] == - sport->p_element.system_id.system_mac[1]); - assert(rport->p_element.system_id.system_mac[2] == - sport->p_element.system_id.system_mac[2]); - assert(rport->p_element.system_id.system_mac[3] == - sport->p_element.system_id.system_mac[3]); - assert(rport->p_element.system_id.system_mac[4] == - sport->p_element.system_id.system_mac[4]); - assert(rport->p_element.system_id.system_mac[5] == - sport->p_element.system_id.system_mac[5]); + assert(eth_addr_equals(rport->p_element.system_id.system_mac, + sport->p_element.system_id.system_mac)); assert(rport->p_element.system_id.conn_type == sport->p_element.system_id.conn_type); - assert(rport->p_element.system_id.smlt_id == - sport->p_element.system_id.smlt_id); - assert(rport->p_element.system_id.mlt_id[0] == - sport->p_element.system_id.mlt_id[0]); - assert(rport->p_element.system_id.mlt_id[1] == - sport->p_element.system_id.mlt_id[1]); + assert(rport->p_element.system_id.rsvd == + sport->p_element.system_id.rsvd); + assert(rport->p_element.system_id.rsvd2[0] == + sport->p_element.system_id.rsvd2[0]); + assert(rport->p_element.system_id.rsvd2[1] == + sport->p_element.system_id.rsvd2[1]); /* Should receive 2 mappings */ assert(!list_is_empty(&rport->p_isid_vlan_maps)); @@ -160,23 +150,20 @@ test_aa_send(void) hardware.h_lport.p_mfs = 1516; /* Auto attach element discovery info */ - hardware.h_lport.p_element.type = LLDP_TLV_AA_ELEM_TYPE_TAG_CLIENT; + hardware.h_lport.p_element.type = + LLDP_TLV_AA_ELEM_TYPE_CLIENT_VIRTUAL_SWITCH; hardware.h_lport.p_element.mgmt_vlan = 0xCDC; - hardware.h_lport.p_element.system_id.system_mac[0] = 0x1; - hardware.h_lport.p_element.system_id.system_mac[1] = 0x2; - hardware.h_lport.p_element.system_id.system_mac[2] = 0x3; - hardware.h_lport.p_element.system_id.system_mac[3] = 0x4; - hardware.h_lport.p_element.system_id.system_mac[4] = 0x5; - hardware.h_lport.p_element.system_id.system_mac[5] = 0x6; + eth_addr_from_uint64(0x010203040506ULL, + &hardware.h_lport.p_element.system_id.system_mac); hardware.h_lport.p_element.system_id.conn_type = 0x5; - hardware.h_lport.p_element.system_id.smlt_id = 0x3CC; - hardware.h_lport.p_element.system_id.mlt_id[0] = 0xB; - hardware.h_lport.p_element.system_id.mlt_id[1] = 0xE; + hardware.h_lport.p_element.system_id.rsvd = 0x3CC; + hardware.h_lport.p_element.system_id.rsvd2[0] = 0xB; + hardware.h_lport.p_element.system_id.rsvd2[1] = 0xE; /* Local chassis info */ chassis.c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; - chassis.c_id = chassis_mac; + chassis.c_id = CONST_CAST(uint8_t *, chassis_mac.ea); chassis.c_id_len = ETH_ADDR_LEN; chassis.c_name = "Dummy chassis"; chassis.c_descr = "Long dummy chassis description"; @@ -227,27 +214,17 @@ test_aa_send(void) hw->h_lport.p_element.type = hardware.h_lport.p_element.type; hw->h_lport.p_element.mgmt_vlan = hardware.h_lport.p_element.mgmt_vlan; - hw->h_lport.p_element.system_id.system_mac[0] = - hardware.h_lport.p_element.system_id.system_mac[0]; - hw->h_lport.p_element.system_id.system_mac[1] = - hardware.h_lport.p_element.system_id.system_mac[1]; - hw->h_lport.p_element.system_id.system_mac[2] = - hardware.h_lport.p_element.system_id.system_mac[2]; - hw->h_lport.p_element.system_id.system_mac[3] = - hardware.h_lport.p_element.system_id.system_mac[3]; - hw->h_lport.p_element.system_id.system_mac[4] = - hardware.h_lport.p_element.system_id.system_mac[4]; - hw->h_lport.p_element.system_id.system_mac[5] = - hardware.h_lport.p_element.system_id.system_mac[5]; + hw->h_lport.p_element.system_id.system_mac = + hardware.h_lport.p_element.system_id.system_mac; hw->h_lport.p_element.system_id.conn_type = hardware.h_lport.p_element.system_id.conn_type; - hw->h_lport.p_element.system_id.smlt_id = - hardware.h_lport.p_element.system_id.smlt_id; - hw->h_lport.p_element.system_id.mlt_id[0] = - hardware.h_lport.p_element.system_id.mlt_id[0]; - hw->h_lport.p_element.system_id.mlt_id[1] = - hardware.h_lport.p_element.system_id.mlt_id[1]; + hw->h_lport.p_element.system_id.rsvd = + hardware.h_lport.p_element.system_id.rsvd; + hw->h_lport.p_element.system_id.rsvd2[0] = + hardware.h_lport.p_element.system_id.rsvd2[0]; + hw->h_lport.p_element.system_id.rsvd2[1] = + hardware.h_lport.p_element.system_id.rsvd2[1]; /* Populate instance with two auto attach isid/vlan mappings */ map[0].isid_vlan_data.status = map_init[0].isid_vlan_data.status; @@ -290,6 +267,11 @@ test_aa_send(void) /* Verify auto attach values */ check_received_aa(&hardware.h_lport, nport, map_init); + lldpd_chassis_cleanup(nchassis, true); + lldpd_port_cleanup(nport, true); + free(nport); + lldp_destroy_dummy(lldp); + return 0; }