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

Function cleanup_xaddrs_gateway

freebsd/net/rtsock.c:1351–1405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1349}
1350
1351static int
1352cleanup_xaddrs_gateway(struct rt_addrinfo *info)
1353{
1354 struct sockaddr *gw = info->rti_info[RTAX_GATEWAY];
1355
1356 if (info->rti_flags & RTF_LLDATA)
1357 return (cleanup_xaddrs_lladdr(info));
1358
1359 switch (gw->sa_family) {
1360#ifdef INET
1361 case AF_INET:
1362 {
1363 struct sockaddr_in *gw_sin = (struct sockaddr_in *)gw;
1364 if (gw_sin->sin_len < sizeof(struct sockaddr_in)) {
1365 printf("gw sin_len too small\n");
1366 return (EINVAL);
1367 }
1368 fill_sockaddr_inet(gw_sin, gw_sin->sin_addr);
1369 }
1370 break;
1371#endif
1372#ifdef INET6
1373 case AF_INET6:
1374 {
1375 struct sockaddr_in6 *gw_sin6 = (struct sockaddr_in6 *)gw;
1376 if (gw_sin6->sin6_len < sizeof(struct sockaddr_in6)) {
1377 printf("gw sin6_len too small\n");
1378 return (EINVAL);
1379 }
1380 fill_sockaddr_inet6(gw_sin6, &gw_sin6->sin6_addr, 0);
1381 break;
1382 }
1383#endif
1384 case AF_LINK:
1385 {
1386 struct sockaddr_dl_short *gw_sdl;
1387
1388 gw_sdl = (struct sockaddr_dl_short *)gw;
1389 if (gw_sdl->sdl_len < sizeof(struct sockaddr_dl_short)) {
1390 printf("gw sdl_len too small\n");
1391 return (EINVAL);
1392 }
1393
1394 const struct sockaddr_dl_short sdl = {
1395 .sdl_family = AF_LINK,
1396 .sdl_len = sizeof(struct sockaddr_dl_short),
1397 .sdl_index = gw_sdl->sdl_index,
1398 };
1399 *gw_sdl = sdl;
1400 break;
1401 }
1402 }
1403
1404 return (0);
1405}
1406
1407static void
1408remove_netmask(struct rt_addrinfo *info)

Callers 2

cleanup_xaddrs_inetFunction · 0.70
cleanup_xaddrs_inet6Function · 0.70

Calls 4

cleanup_xaddrs_lladdrFunction · 0.70
fill_sockaddr_inetFunction · 0.70
fill_sockaddr_inet6Function · 0.70
printfFunction · 0.50

Tested by

no test coverage detected