MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ff_veth_vlan_config

Function ff_veth_vlan_config

lib/ff_veth.c:151–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151static int
152ff_veth_vlan_config(struct ff_veth_softc *sc, struct ff_vlan_cfg *cfg)
153{
154 int i, j;
155
156 inet_pton(AF_INET, cfg->addr, &sc->ip);
157 inet_pton(AF_INET, cfg->netmask, &sc->netmask);
158 inet_pton(AF_INET, cfg->broadcast, &sc->broadcast);
159 inet_pton(AF_INET, cfg->gateway, &sc->gateway);
160
161 if (cfg->nb_vip) {
162 for (i = 0, j = 0; i < cfg->nb_vip; ++i) {
163 if (inet_pton(AF_INET, cfg->vip_addr_array[i], &sc->vip[j])) {
164 j++;
165 } else {
166 printf("ff_veth_vlan_config inet_pton vip %s failed.\n", cfg->vip_addr_array[i]);
167 }
168 }
169
170 sc->nb_vip = j;
171 }
172
173#ifdef INET6
174 if (cfg->addr6_str) {
175 inet_pton(AF_INET6_LINUX, cfg->addr6_str, &sc->ip6);
176 printf("%s: Addr6: %s\n", sc->host_ifname, cfg->addr6_str);
177
178 if (cfg->gateway6_str) {
179 inet_pton(AF_INET6_LINUX, cfg->gateway6_str, &sc->gateway6);
180 printf("%s: Gateway6: %s\n", sc->host_ifname, cfg->gateway6_str);
181 } else {
182 printf("%s: No gateway6 config found.\n", sc->host_ifname);
183 }
184
185 sc->prefix_length = cfg->prefix_len == 0 ? 64 : cfg->prefix_len;
186 } else {
187 printf("%s: No addr6 config found.\n", sc->host_ifname);
188 }
189
190 if (cfg->nb_vip6) {
191 for (i = 0, j = 0; i < cfg->nb_vip6; ++i) {
192 if (inet_pton(AF_INET6_LINUX, cfg->vip_addr6_array[i], &sc->vip6[j])) {
193 j++;
194 } else {
195 printf("ff_veth_vlan_config inet_pton vip6 %s failed.\n", cfg->vip_addr6_array[i]);
196 }
197 }
198
199 sc->nb_vip6 = j;
200 sc->vip_prefix_length = cfg->vip_prefix_len == 0 ? 64 : cfg->vip_prefix_len;
201 }
202#endif /* INET6 */
203
204 return 0;
205}
206
207
208static void

Callers 1

ff_veth_setup_interfaceFunction · 0.85

Calls 2

inet_ptonFunction · 0.85
printfFunction · 0.70

Tested by

no test coverage detected