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

Function LibAliasInLocked

freebsd/netinet/libalias/alias.c:1324–1409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1322}
1323
1324static int
1325LibAliasInLocked(struct libalias *la, struct ip *pip, int maxpacketsize)
1326{
1327 struct in_addr alias_addr;
1328 int iresult;
1329
1330 if (la->packetAliasMode & PKT_ALIAS_REVERSE) {
1331 la->packetAliasMode &= ~PKT_ALIAS_REVERSE;
1332 iresult = LibAliasOutLocked(la, pip, maxpacketsize, 1);
1333 la->packetAliasMode |= PKT_ALIAS_REVERSE;
1334 goto getout;
1335 }
1336 HouseKeeping(la);
1337 ClearCheckNewLink(la);
1338 alias_addr = pip->ip_dst;
1339
1340 /* Defense against mangled packets */
1341 if (ntohs(pip->ip_len) > maxpacketsize
1342 || (pip->ip_hl << 2) > maxpacketsize) {
1343 iresult = PKT_ALIAS_IGNORED;
1344 goto getout;
1345 }
1346
1347 iresult = PKT_ALIAS_IGNORED;
1348 if ((ntohs(pip->ip_off) & IP_OFFMASK) == 0) {
1349 switch (pip->ip_p) {
1350 case IPPROTO_ICMP:
1351 iresult = IcmpAliasIn(la, pip);
1352 break;
1353 case IPPROTO_UDP:
1354 iresult = UdpAliasIn(la, pip);
1355 break;
1356 case IPPROTO_TCP:
1357 iresult = TcpAliasIn(la, pip);
1358 break;
1359#ifdef _KERNEL
1360 case IPPROTO_SCTP:
1361 iresult = SctpAlias(la, pip, SN_TO_LOCAL);
1362 break;
1363#endif
1364 case IPPROTO_GRE: {
1365 int error;
1366 struct alias_data ad = {
1367 .lnk = NULL,
1368 .oaddr = NULL,
1369 .aaddr = NULL,
1370 .aport = NULL,
1371 .sport = NULL,
1372 .dport = NULL,
1373 .maxpktsize = 0
1374 };
1375
1376 /* Walk out chain. */
1377 error = find_handler(IN, IP, la, pip, &ad);
1378 if (error == 0)
1379 iresult = PKT_ALIAS_OK;
1380 else
1381 iresult = ProtoAliasIn(la, pip->ip_src,

Callers 2

LibAliasInFunction · 0.85
LibAliasOutLockedFunction · 0.85

Calls 12

LibAliasOutLockedFunction · 0.85
HouseKeepingFunction · 0.85
ClearCheckNewLinkFunction · 0.85
IcmpAliasInFunction · 0.85
UdpAliasInFunction · 0.85
TcpAliasInFunction · 0.85
SctpAliasFunction · 0.85
find_handlerFunction · 0.85
ProtoAliasInFunction · 0.85
FindFragmentIn1Function · 0.85
SetFragmentAddrFunction · 0.85
FragmentInFunction · 0.85

Tested by

no test coverage detected