Lines Matching refs:ifname

44 static void ql_set_mtu(const char *ifname, int ifru_mtu) {  in ql_set_mtu()  argument
51 ifc_init_ifr(ifname, &ifr); in ql_set_mtu()
86 static short ifc_get_flags(const char *ifname) in ifc_get_flags() argument
95 ifc_init_ifr(ifname, &ifr); in ifc_get_flags()
107 static int ql_netcard_ipv4_address_check(const char *ifname, in_addr_t ip) { in ql_netcard_ipv4_address_check() argument
110 ifc_get_addr(ifname, &addr); in ql_netcard_ipv4_address_check()
114 static int ql_raw_ip_mode_check(const char *ifname, uint32_t ip) { in ql_raw_ip_mode_check() argument
121 if (ql_netcard_ipv4_address_check(ifname, qmi2addr(ip))) in ql_raw_ip_mode_check()
124 snprintf(raw_ip, sizeof(raw_ip), "/sys/class/net/%s/qmi/raw_ip", ifname); in ql_raw_ip_mode_check()
137 snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s down", ifname); in ql_raw_ip_mode_check()
139 dbg_time("echo Y > /sys/class/net/%s/qmi/raw_ip", ifname); in ql_raw_ip_mode_check()
143 snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s up", ifname); in ql_raw_ip_mode_check()
243 void update_ipv4_address(const char *ifname, const char *ip, const char *gw, unsigned prefix) in update_ipv4_address() argument
247 if (!ifname) in update_ipv4_address()
251 snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address flush dev %s", 4, ifname); in update_ipv4_address()
254 … snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address add %s/%u dev %s", 4, ip, prefix, ifname); in update_ipv4_address()
258 … snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d route add default via %s dev %s", 4, gw, ifname); in update_ipv4_address()
264 snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s %s netmask %s", ifname, ip, ipv4Str(n)); in update_ipv4_address()
268 snprintf(shell_cmd, sizeof(shell_cmd), "route del default dev %s", ifname); in update_ipv4_address()
271 snprintf(shell_cmd, sizeof(shell_cmd), "route add default gw %s dev %s", gw, ifname); in update_ipv4_address()
276 void update_ipv6_address(const char *ifname, const char *ip, const char *gw, unsigned prefix) { in update_ipv6_address() argument
281 snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address flush dev %s", 6, ifname); in update_ipv6_address()
284 … snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address add %s/%u dev %s", 6, ip, prefix, ifname); in update_ipv6_address()
288 snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d route add default dev %s", 6, ifname); in update_ipv6_address()
291 snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s %s/%d", ifname, ip, prefix); in update_ipv6_address()
294 snprintf(shell_cmd, sizeof(shell_cmd), "route -A inet6 add default dev %s", ifname); in update_ipv6_address()
299 static void update_ip_address_by_qmi(const char *ifname, const IPV4_T *ipv4, const IPV6_T *ipv6) { in update_ip_address_by_qmi() argument
314 update_ipv4_address(ifname, d1, d2, prefix); in update_ip_address_by_qmi()
321 update_resolv_conf(4, ifname, d1, d2); in update_ip_address_by_qmi()
330 update_ipv6_address(ifname, d1, d2, ipv6->PrefixLengthIPAddr); in update_ip_address_by_qmi()
337 update_resolv_conf(6, ifname, d1, d2); in update_ip_address_by_qmi()
366 static int ql_openwrt_is_wan(const char *ifname) { in ql_openwrt_is_wan() argument
371 if (strcmp(ifname, openwrt_wan)) in ql_openwrt_is_wan()
377 static void ql_openwrt_setup_wan(const char *ifname, const IPV4_T *ipv4) { in ql_openwrt_setup_wan() argument
381 snprintf(config, sizeof(config), "/tmp/rmnet_%s_ipv4config", ifname); in ql_openwrt_setup_wan()
384 if (ql_openwrt_is_wan(ifname)) in ql_openwrt_setup_wan()
393 fprintf(fp, "IFNAME=\"%s\"\n", ifname); in ql_openwrt_setup_wan()
404 if (!ql_openwrt_is_wan(ifname)) in ql_openwrt_setup_wan()
410 static void ql_openwrt_setup_wan6(const char *ifname, const IPV6_T *ipv6) { in ql_openwrt_setup_wan6() argument
415 snprintf(config, sizeof(config), "/tmp/rmnet_%s_ipv6config", ifname); in ql_openwrt_setup_wan6()
418 if (ql_openwrt_is_wan(ifname)) in ql_openwrt_setup_wan6()
429 fprintf(fp, "IFNAME=\"%s\"\n", ifname); in ql_openwrt_setup_wan6()
441 if (!ql_openwrt_is_wan(ifname)) in ql_openwrt_setup_wan6()
460 …izeof(shell_cmd), "ip route del %s/%u dev %s", ipv6Str(Address), ipv6->PrefixLengthIPAddr, ifname); in ql_openwrt_setup_wan6()
471 char *ifname = profile->usbnet_adapter; in udhcpc_start() local
477 ifname = profile->qmapnet_adapter; in udhcpc_start()
481 ql_set_mtu(ifname, (profile->ipv4.Mtu)); in udhcpc_start()
484 if (strcmp(ifname, profile->usbnet_adapter)) { in udhcpc_start()
487 if (ifc_get_flags(ifname)&IFF_UP) { in udhcpc_start()
488 snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s down", ifname); in udhcpc_start()
493 snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s up", ifname); in udhcpc_start()
522 update_ip_address_by_qmi(ifname, &profile->ipv4, &profile->ipv6); in udhcpc_start()
531 update_ip_address_by_qmi(ifname, &profile->ipv4, NULL); in udhcpc_start()
544 snprintf(udhcpc_cmd, sizeof(udhcpc_cmd), "dhclient -4 -d --no-pid %s", ifname); in udhcpc_start()
557 snprintf(udhcpc_cmd, sizeof(udhcpc_cmd), "busybox udhcpc -f -n -q -t 5 -i %s", ifname); in udhcpc_start()
566 dbg_time("\toption ifname %s", ifname); in udhcpc_start()
568 dbg_time("should use \"/sbin/ifstaus wan\" to check %s 's status?", ifname); in udhcpc_start()
583 if (ql_raw_ip_mode_check(ifname, profile->ipv4.Address)) { in udhcpc_start()
588 if (!ql_netcard_ipv4_address_check(ifname, qmi2addr(profile->ipv4.Address))) { in udhcpc_start()
590 update_ip_address_by_qmi(ifname, &profile->ipv4, NULL); in udhcpc_start()
596 ql_openwrt_setup_wan(ifname, &profile->ipv4); in udhcpc_start()
615 update_ip_address_by_qmi(ifname, NULL, &profile->ipv6); in udhcpc_start()
628 update_resolv_conf(6, ifname, profile->ipv6.DnsPrimary[0] ? dns1str : NULL, in udhcpc_start()
633 ql_openwrt_setup_wan6(ifname, &profile->ipv6); in udhcpc_start()
637 snprintf(udhcpc_cmd, sizeof(udhcpc_cmd), "dhclient -6 -d --no-pid %s", ifname); in udhcpc_start()
657 snprintf(shell_cmd, sizeof(shell_cmd), "route -A inet6 add default %s", ifname); in udhcpc_start()
669 char *ifname = profile->usbnet_adapter; in udhcpc_stop() local
675 ifname = profile->qmapnet_adapter; in udhcpc_stop()
690 snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s 0.0.0.0", ifname); in udhcpc_stop()
692 snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s down", ifname); in udhcpc_stop()
696 ql_openwrt_setup_wan(ifname, NULL); in udhcpc_stop()
697 ql_openwrt_setup_wan6(ifname, NULL); in udhcpc_stop()