From 15ad172a847fa667c57a4594ef4158405db9a984 Mon Sep 17 00:00:00 2001 From: Angelo Mantellini Date: Tue, 31 Mar 2020 17:50:43 +0200 Subject: [HICN-554] hicn-light refactoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I36f2d393741d4502ce14d3791158e43e3e9cd4cf Signed-off-by: Jordan Augé --- hicn-light/src/hicn/platforms/linux/system.c | 65 +++++----------------------- 1 file changed, 12 insertions(+), 53 deletions(-) (limited to 'hicn-light/src/hicn/platforms/linux/system.c') diff --git a/hicn-light/src/hicn/platforms/linux/system.c b/hicn-light/src/hicn/platforms/linux/system.c index 3bf23cf57..31a8d79b2 100644 --- a/hicn-light/src/hicn/platforms/linux/system.c +++ b/hicn-light/src/hicn/platforms/linux/system.c @@ -13,6 +13,8 @@ * limitations under the License. */ +#if 0 + #include #include #include @@ -37,8 +39,6 @@ #include -#include - /** * Returns the MTU for a named interface * @@ -66,11 +66,9 @@ static int getMtu(const char *ifname) { return ifr.ifr_mtu; } -InterfaceSet *system_Interfaces(Forwarder *forwarder) { +InterfaceSet *system_Interfaces(forwarder_t * forwarder) { InterfaceSet *set = interfaceSetCreate(); - Logger *logger = forwarder_GetLogger(forwarder); - // this is the dynamically allocated head of the list struct ifaddrs *ifaddr; int failure = getifaddrs(&ifaddr); @@ -93,60 +91,18 @@ InterfaceSet *system_Interfaces(Forwarder *forwarder) { interfaceSetAdd(set, iface); } - int family = next->ifa_addr->sa_family; - switch (family) { - case AF_INET: { - Address *address = - addressCreateFromInet((struct sockaddr_in *)next->ifa_addr); - interfaceAddAddress(iface, address); - break; - } - - case AF_INET6: { - Address *address = - addressCreateFromInet6((struct sockaddr_in6 *)next->ifa_addr); - interfaceAddAddress(iface, address); - break; - } - - case AF_PACKET: { - struct sockaddr_ll *addr_ll = (struct sockaddr_ll *)next->ifa_addr; - - if (logger_IsLoggable(logger, LoggerFacility_IO, PARCLogLevel_Debug)) { - logger_Log(logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__, - "sockaddr_ll family %d proto %d ifindex %d hatype %d " - "pkttype %d halen %d", - addr_ll->sll_family, addr_ll->sll_protocol, - addr_ll->sll_ifindex, addr_ll->sll_hatype, - addr_ll->sll_pkttype, addr_ll->sll_halen); - } - - switch (addr_ll->sll_hatype) { - // list of the ARP hatypes we can extract a MAC address from - case ARPHRD_ETHER: - // fallthrough - case ARPHRD_IEEE802: { - Address *address = addressCreateFromLink( - (uint8_t *)addr_ll->sll_addr, addr_ll->sll_halen); - interfaceAddAddress(iface, address); - break; - } - default: - break; - } - - break; - } - } + address_t * address = (address_t *)next->ifa_addr; + interfaceAddAddress(iface, address); } freeifaddrs(ifaddr); return set; } -Address *system_GetMacAddressByName(Forwarder *forwarder, +#if 0 +address_t *system_GetMacAddressByName(Forwarder *forwarder, const char *interfaceName) { - Address *linkAddress = NULL; + address_t *linkAddress = NULL; InterfaceSet *interfaceSet = system_Interfaces(forwarder); Interface *interface = interfaceSetGetByName(interfaceSet, interfaceName); @@ -156,7 +112,7 @@ Address *system_GetMacAddressByName(Forwarder *forwarder, size_t length = addressListLength(addressList); for (size_t i = 0; i < length && !linkAddress; i++) { - const Address *a = addressListGetItem(addressList, i); + const address_t *a = addressListGetItem(addressList, i); if (addressGetType(a) == ADDR_LINK) { linkAddress = addressCopy(a); } @@ -167,6 +123,7 @@ Address *system_GetMacAddressByName(Forwarder *forwarder, return linkAddress; } +#endif unsigned system_InterfaceMtu(Forwarder *forwarder, const char *interfaceName) { unsigned mtu = 0; @@ -182,3 +139,5 @@ unsigned system_InterfaceMtu(Forwarder *forwarder, const char *interfaceName) { return mtu; } + +#endif -- cgit 1.2.3-korg