MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ff_veth_setaddr

Function ff_veth_setaddr

lib/ff_veth.c:437–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435}
436
437static int
438ff_veth_setaddr(struct ff_veth_softc *sc, const char *if_name)
439{
440 struct in_aliasreq req;
441 bzero(&req, sizeof req);
442
443 if (if_name) {
444 strcpy(req.ifra_name, if_name);
445 } else {
446 strcpy(req.ifra_name, sc->ifp->if_dname);
447 }
448
449 struct sockaddr_in sa;
450 bzero(&sa, sizeof(sa));
451 sa.sin_len = sizeof(sa);
452 sa.sin_family = AF_INET;
453 sa.sin_addr.s_addr = sc->ip;
454 bcopy(&sa, &req.ifra_addr, sizeof(sa));
455
456 sa.sin_addr.s_addr = sc->netmask;
457 bcopy(&sa, &req.ifra_mask, sizeof(sa));
458
459 sa.sin_addr.s_addr = sc->broadcast;
460 bcopy(&sa, &req.ifra_broadaddr, sizeof(sa));
461
462 struct socket *so = NULL;
463 socreate(AF_INET, &so, SOCK_DGRAM, 0, curthread->td_ucred, curthread);
464 int ret = ifioctl(so, SIOCAIFADDR, (caddr_t)&req, curthread);
465
466 soclose(so);
467
468 return ret;
469}
470
471static int
472ff_veth_set_gateway(struct ff_veth_softc *sc, uint32_t fib_num)

Callers 1

ff_veth_setup_interfaceFunction · 0.85

Calls 4

bzeroFunction · 0.85
socreateFunction · 0.85
ifioctlFunction · 0.85
socloseFunction · 0.85

Tested by

no test coverage detected