| 1322 | } |
| 1323 | |
| 1324 | static int |
| 1325 | LibAliasInLocked(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, |
no test coverage detected