| 92 | }; |
| 93 | |
| 94 | static int |
| 95 | ff_veth_config(struct ff_veth_softc *sc, struct ff_port_cfg *cfg) |
| 96 | { |
| 97 | int i, j; |
| 98 | |
| 99 | memcpy(sc->mac, cfg->mac, ETHER_ADDR_LEN); |
| 100 | inet_pton(AF_INET, cfg->addr, &sc->ip); |
| 101 | inet_pton(AF_INET, cfg->netmask, &sc->netmask); |
| 102 | inet_pton(AF_INET, cfg->broadcast, &sc->broadcast); |
| 103 | inet_pton(AF_INET, cfg->gateway, &sc->gateway); |
| 104 | |
| 105 | if (cfg->nb_vip) { |
| 106 | for (i = 0, j = 0; i < cfg->nb_vip; ++i) { |
| 107 | if (inet_pton(AF_INET, cfg->vip_addr_array[i], &sc->vip[j])) { |
| 108 | j++; |
| 109 | } else { |
| 110 | printf("ff_veth_config inet_pton vip %s failed.\n", cfg->vip_addr_array[i]); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | sc->nb_vip = j; |
| 115 | } |
| 116 | |
| 117 | #ifdef INET6 |
| 118 | if (cfg->addr6_str) { |
| 119 | inet_pton(AF_INET6_LINUX, cfg->addr6_str, &sc->ip6); |
| 120 | printf("%s: Addr6: %s\n", sc->host_ifname, cfg->addr6_str); |
| 121 | |
| 122 | if (cfg->gateway6_str) { |
| 123 | inet_pton(AF_INET6_LINUX, cfg->gateway6_str, &sc->gateway6); |
| 124 | printf("%s: Gateway6: %s\n", sc->host_ifname, cfg->gateway6_str); |
| 125 | } else { |
| 126 | printf("%s: No gateway6 config found.\n", sc->host_ifname); |
| 127 | } |
| 128 | |
| 129 | sc->prefix_length = cfg->prefix_len == 0 ? 64 : cfg->prefix_len; |
| 130 | } else { |
| 131 | printf("%s: No addr6 config found.\n", sc->host_ifname); |
| 132 | } |
| 133 | |
| 134 | if (cfg->nb_vip6) { |
| 135 | for (i = 0, j = 0; i < cfg->nb_vip6; ++i) { |
| 136 | if (inet_pton(AF_INET6_LINUX, cfg->vip_addr6_array[i], &sc->vip6[j])) { |
| 137 | j++; |
| 138 | } else { |
| 139 | printf("ff_veth_config inet_pton vip6 %s failed.\n", cfg->vip_addr6_array[i]); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | sc->nb_vip6 = j; |
| 144 | sc->vip_prefix_length = cfg->vip_prefix_len == 0 ? 64 : cfg->vip_prefix_len; |
| 145 | } |
| 146 | #endif /* INET6 */ |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | static int |
no test coverage detected