--- src/rtnl.c | 101 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 52 insertions(+), 49 deletions(-)
diff --git a/src/rtnl.c b/src/rtnl.c index 4e7ef4d..8e103b6 100644 --- a/src/rtnl.c +++ b/src/rtnl.c @@ -193,12 +193,12 @@ static void read_uevent(struct interface_data *interface) } } -enum connman_device_type __connman_rtnl_get_device_type(int index) +enum connman_device_type __connman_rtnl_get_device_type(int ifindex) { struct interface_data *interface; interface = g_hash_table_lookup(interface_list, - GINT_TO_POINTER(index)); + GINT_TO_POINTER(ifindex)); if (interface == NULL) return CONNMAN_DEVICE_TYPE_UNKNOWN; @@ -207,7 +207,7 @@ enum connman_device_type __connman_rtnl_get_device_type(int index) /** * connman_rtnl_add_newlink_watch: - * @index: network device index + * @ifindex: network device index * @callback: callback function * @user_data: callback data; * @@ -215,7 +215,7 @@ enum connman_device_type __connman_rtnl_get_device_type(int index) * * Returns: %0 on failure and a unique id on success */ -unsigned int connman_rtnl_add_newlink_watch(int index, +unsigned int connman_rtnl_add_newlink_watch(int ifindex, connman_rtnl_link_cb_t callback, void *user_data) { struct watch_data *watch; @@ -225,7 +225,7 @@ unsigned int connman_rtnl_add_newlink_watch(int index, return 0; watch->id = ++watch_id; - watch->index = index; + watch->index = ifindex; watch->newlink = callback; watch->user_data = user_data; @@ -235,7 +235,8 @@ unsigned int connman_rtnl_add_newlink_watch(int index, DBG("id %d", watch->id); if (callback) { - unsigned int flags = __connman_ipconfig_get_flags_from_index(index); + unsigned int flags = + __connman_ipconfig_get_flags_from_index(ifindex); if (flags > 0) callback(flags, 0, user_data); @@ -270,24 +271,26 @@ void connman_rtnl_remove_watch(unsigned int id) } } -static void trigger_rtnl(int index, void *user_data) +static void trigger_rtnl(int ifindex, void *user_data) { struct connman_rtnl *rtnl = user_data; if (rtnl->newlink) { - unsigned short type = __connman_ipconfig_get_type_from_index(index); - unsigned int flags = __connman_ipconfig_get_flags_from_index(index); + unsigned short type = + __connman_ipconfig_get_type_from_index(ifindex); + unsigned int flags = + __connman_ipconfig_get_flags_from_index(ifindex); - rtnl->newlink(type, index, flags, 0); + rtnl->newlink(type, ifindex, flags, 0); } if (rtnl->newgateway) { const char *gateway = - __connman_ipconfig_get_gateway_from_index(index, + __connman_ipconfig_get_gateway_from_index(ifindex, CONNMAN_IPCONFIG_TYPE_ALL); if (gateway != NULL) - rtnl->newgateway(index, gateway); + rtnl->newgateway(ifindex, gateway); } } @@ -393,7 +396,7 @@ static void extract_link(struct ifinfomsg *msg, int bytes, } } -static void process_newlink(unsigned short type, int index, unsigned flags, +static void process_newlink(unsigned short type, int ifindex, unsigned flags, unsigned change, struct ifinfomsg *msg, int bytes) { struct ether_addr address = {{ 0, 0, 0, 0, 0, 0 }}; @@ -430,29 +433,29 @@ static void process_newlink(unsigned short type, int index, unsigned flags, case ARPHRD_LOOPBACK: case ARPHDR_PHONET_PIPE: case ARPHRD_NONE: - __connman_ipconfig_newlink(index, type, flags, + __connman_ipconfig_newlink(ifindex, type, flags, str, mtu, &stats); break; } if (memcmp(&address, &compare, ETH_ALEN) != 0) connman_info("%s {newlink} index %d address %s mtu %u", - ifname, index, str, mtu); + ifname, ifindex, str, mtu); if (operstate != 0xff) connman_info("%s {newlink} index %d operstate %u <%s>", - ifname, index, operstate, + ifname, ifindex, operstate, operstate2str(operstate)); - interface = g_hash_table_lookup(interface_list, GINT_TO_POINTER(index)); + interface = g_hash_table_lookup(interface_list, GINT_TO_POINTER(ifindex)); if (interface == NULL) { interface = g_new0(struct interface_data, 1); - interface->index = index; + interface->index = ifindex; interface->name = g_strdup(ifname); interface->ident = g_strdup(ident); g_hash_table_insert(interface_list, - GINT_TO_POINTER(index), interface); + GINT_TO_POINTER(ifindex), interface); if (type == ARPHRD_ETHER) read_uevent(interface); @@ -465,13 +468,13 @@ static void process_newlink(unsigned short type, int index, unsigned flags, struct connman_rtnl *rtnl = list->data; if (rtnl->newlink) - rtnl->newlink(type, index, flags, change); + rtnl->newlink(type, ifindex, flags, change); } for (list = watch_list; list; list = list->next) { struct watch_data *watch = list->data; - if (watch->index != index) + if (watch->index != ifindex) continue; if (watch->newlink) @@ -479,7 +482,7 @@ static void process_newlink(unsigned short type, int index, unsigned flags, } } -static void process_dellink(unsigned short type, int index, unsigned flags, +static void process_dellink(unsigned short type, int ifindex, unsigned flags, unsigned change, struct ifinfomsg *msg, int bytes) { struct rtnl_link_stats stats; @@ -492,25 +495,25 @@ static void process_dellink(unsigned short type, int index, unsigned flags, if (operstate != 0xff) connman_info("%s {dellink} index %d operstate %u <%s>", - ifname, index, operstate, + ifname, ifindex, operstate, operstate2str(operstate)); for (list = rtnl_list; list; list = list->next) { struct connman_rtnl *rtnl = list->data; if (rtnl->dellink) - rtnl->dellink(type, index, flags, change); + rtnl->dellink(type, ifindex, flags, change); } switch (type) { case ARPHRD_ETHER: case ARPHRD_LOOPBACK: case ARPHRD_NONE: - __connman_ipconfig_dellink(index, &stats); + __connman_ipconfig_dellink(ifindex, &stats); break; } - g_hash_table_remove(interface_list, GINT_TO_POINTER(index)); + g_hash_table_remove(interface_list, GINT_TO_POINTER(ifindex)); } static void extract_ipv4_addr(struct ifaddrmsg *msg, int bytes, @@ -566,7 +569,7 @@ static void extract_ipv6_addr(struct ifaddrmsg *msg, int bytes, } static void process_newaddr(unsigned char family, unsigned char prefixlen, - int index, struct ifaddrmsg *msg, int bytes) + int ifindex, struct ifaddrmsg *msg, int bytes) { const char *label = NULL; void *src; @@ -592,7 +595,7 @@ static void process_newaddr(unsigned char family, unsigned char prefixlen, if (inet_ntop(family, src, ip_string, INET6_ADDRSTRLEN) == NULL) return; - __connman_ipconfig_newaddr(index, family, label, + __connman_ipconfig_newaddr(ifindex, family, label, prefixlen, ip_string); if (family == AF_INET6) { @@ -602,7 +605,7 @@ static void process_newaddr(unsigned char family, unsigned char prefixlen, * have now properly configured interface with proper * autoconfigured address. */ - char *interface = connman_inet_ifname(index); + char *interface = connman_inet_ifname(ifindex); __connman_resolver_redo_servers(interface); @@ -611,7 +614,7 @@ static void process_newaddr(unsigned char family, unsigned char prefixlen, } static void process_deladdr(unsigned char family, unsigned char prefixlen, - int index, struct ifaddrmsg *msg, int bytes) + int ifindex, struct ifaddrmsg *msg, int bytes) { const char *label = NULL; void *src; @@ -637,11 +640,11 @@ static void process_deladdr(unsigned char family, unsigned char prefixlen, if (inet_ntop(family, src, ip_string, INET6_ADDRSTRLEN) == NULL) return; - __connman_ipconfig_deladdr(index, family, label, + __connman_ipconfig_deladdr(ifindex, family, label, prefixlen, ip_string); } -static void extract_ipv4_route(struct rtmsg *msg, int bytes, int *index, +static void extract_ipv4_route(struct rtmsg *msg, int bytes, int *ifindex, struct in_addr *dst, struct in_addr *gateway) { @@ -659,14 +662,14 @@ static void extract_ipv4_route(struct rtmsg *msg, int bytes, int *index, *gateway = *((struct in_addr *) RTA_DATA(attr)); break; case RTA_OIF: - if (index != NULL) - *index = *((int *) RTA_DATA(attr)); + if (ifindex != NULL) + *ifindex = *((int *) RTA_DATA(attr)); break; } } } -static void extract_ipv6_route(struct rtmsg *msg, int bytes, int *index, +static void extract_ipv6_route(struct rtmsg *msg, int bytes, int *ifindex, struct in6_addr *dst, struct in6_addr *gateway) { @@ -685,8 +688,8 @@ static void extract_ipv6_route(struct rtmsg *msg, int bytes, int *index, *((struct in6_addr *) RTA_DATA(attr)); break; case RTA_OIF: - if (index != NULL) - *index = *((int *) RTA_DATA(attr)); + if (ifindex != NULL) + *ifindex = *((int *) RTA_DATA(attr)); break; } } @@ -697,17 +700,17 @@ static void process_newroute(unsigned char family, unsigned char scope, { GSList *list; char dststr[INET6_ADDRSTRLEN], gatewaystr[INET6_ADDRSTRLEN]; - int index = -1; + int ifindex = -1; if (family == AF_INET) { struct in_addr dst = { INADDR_ANY }, gateway = { INADDR_ANY }; - extract_ipv4_route(msg, bytes, &index, &dst, &gateway); + extract_ipv4_route(msg, bytes, &ifindex, &dst, &gateway); inet_ntop(family, &dst, dststr, sizeof(dststr)); inet_ntop(family, &gateway, gatewaystr, sizeof(gatewaystr)); - __connman_ipconfig_newroute(index, family, scope, dststr, + __connman_ipconfig_newroute(ifindex, family, scope, dststr, gatewaystr); /* skip host specific routes */ @@ -722,12 +725,12 @@ static void process_newroute(unsigned char family, unsigned char scope, struct in6_addr dst = IN6ADDR_ANY_INIT, gateway = IN6ADDR_ANY_INIT; - extract_ipv6_route(msg, bytes, &index, &dst, &gateway); + extract_ipv6_route(msg, bytes, &ifindex, &dst, &gateway); inet_ntop(family, &dst, dststr, sizeof(dststr)); inet_ntop(family, &gateway, gatewaystr, sizeof(gatewaystr)); - __connman_ipconfig_newroute(index, family, scope, dststr, + __connman_ipconfig_newroute(ifindex, family, scope, dststr, gatewaystr); /* skip host specific routes */ @@ -745,7 +748,7 @@ static void process_newroute(unsigned char family, unsigned char scope, struct connman_rtnl *rtnl = list->data; if (rtnl->newgateway) - rtnl->newgateway(index, gatewaystr); + rtnl->newgateway(ifindex, gatewaystr); } } @@ -754,17 +757,17 @@ static void process_delroute(unsigned char family, unsigned char scope, { GSList *list; char dststr[INET6_ADDRSTRLEN], gatewaystr[INET6_ADDRSTRLEN]; - int index = -1; + int ifindex = -1; if (family == AF_INET) { struct in_addr dst = { INADDR_ANY }, gateway = { INADDR_ANY }; - extract_ipv4_route(msg, bytes, &index, &dst, &gateway); + extract_ipv4_route(msg, bytes, &ifindex, &dst, &gateway); inet_ntop(family, &dst, dststr, sizeof(dststr)); inet_ntop(family, &gateway, gatewaystr, sizeof(gatewaystr)); - __connman_ipconfig_delroute(index, family, scope, dststr, + __connman_ipconfig_delroute(ifindex, family, scope, dststr, gatewaystr); /* skip host specific routes */ @@ -779,12 +782,12 @@ static void process_delroute(unsigned char family, unsigned char scope, struct in6_addr dst = IN6ADDR_ANY_INIT, gateway = IN6ADDR_ANY_INIT; - extract_ipv6_route(msg, bytes, &index, &dst, &gateway); + extract_ipv6_route(msg, bytes, &ifindex, &dst, &gateway); inet_ntop(family, &dst, dststr, sizeof(dststr)); inet_ntop(family, &gateway, gatewaystr, sizeof(gatewaystr)); - __connman_ipconfig_delroute(index, family, scope, dststr, + __connman_ipconfig_delroute(ifindex, family, scope, dststr, gatewaystr); /* skip host specific routes */ @@ -802,7 +805,7 @@ static void process_delroute(unsigned char family, unsigned char scope, struct connman_rtnl *rtnl = list->data; if (rtnl->delgateway) - rtnl->delgateway(index, gatewaystr); + rtnl->delgateway(ifindex, gatewaystr); } } -- 1.7.9.5 _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman