Lines Matching +full:conf +full:- +full:rst

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
33 TCP connection state, protocol-specific aliasing routines,
59 - A more generalized method for handling incoming
60 connections, without the 0-1023 restriction, is
62 - Improved ICMP support in alias.c. Traceroute
64 - TCP connection closing logic simplified in
66 "grace period" after FIN or RST is observed.
77 - Out-of-order fragment handling.
78 - IP checksum error fixed for ftp transfers
80 - Integer return codes added to all
81 aliasing/de-aliasing functions.
82 - Some obsolete comments cleaned up.
83 - Differential checksum computations for
88 - Added support for outgoing ICMP error
90 - Added two functions PacketAliasIn2()
92 control (e.g. round-robin allocation of
96 - Rationalized API function names to begin
98 - Eliminated PacketAliasIn2() and
102 - Major bounds checking additions, see FreeBSD/CVS
105 - Added hooks to handle PPTP.
108 - Added PacketUnaliasOut routine.
109 - Added hooks to handle RTSP/RTP.
176 TcpMonitorIn() -- These routines monitor TCP connections, and
179 These routines look for SYN, FIN and RST flags to determine when TCP
240 any incoming packets. For TCP and UDP, ports are also re-mapped.
285 De-alias incoming echo and timestamp replies.
298 lnk = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1); in IcmpAliasIn1()
306 accumulate = ic->icmp_id; in IcmpAliasIn1()
307 accumulate -= original_id; in IcmpAliasIn1()
308 ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); in IcmpAliasIn1()
311 ic->icmp_id = original_id; in IcmpAliasIn1()
318 DifferentialChecksum(&pip->ip_sum, in IcmpAliasIn1()
319 &original_address, &pip->ip_dst, 2); in IcmpAliasIn1()
320 pip->ip_dst = original_address; in IcmpAliasIn1()
343 ip = &ic->icmp_ip; in IcmpAliasIn2()
349 if (ip->ip_p == IPPROTO_UDP) in IcmpAliasIn2()
350 lnk = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src, in IcmpAliasIn2()
351 ud->uh_dport, ud->uh_sport, in IcmpAliasIn2()
353 else if (ip->ip_p == IPPROTO_TCP) in IcmpAliasIn2()
354 lnk = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src, in IcmpAliasIn2()
355 tc->th_dport, tc->th_sport, in IcmpAliasIn2()
357 else if (ip->ip_p == IPPROTO_ICMP) { in IcmpAliasIn2()
358 if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP) in IcmpAliasIn2()
359 lnk = FindIcmpIn(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0); in IcmpAliasIn2()
366 if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) { in IcmpAliasIn2()
375 accumulate = twowords(&ip->ip_src); in IcmpAliasIn2()
376 accumulate -= twowords(&original_address); in IcmpAliasIn2()
377 accumulate += ud->uh_sport; in IcmpAliasIn2()
378 accumulate -= original_port; in IcmpAliasIn2()
380 accumulate2 += ip->ip_sum; in IcmpAliasIn2()
381 ADJUST_CHECKSUM(accumulate, ip->ip_sum); in IcmpAliasIn2()
382 accumulate2 -= ip->ip_sum; in IcmpAliasIn2()
383 ADJUST_CHECKSUM(accumulate2, ic->icmp_cksum); in IcmpAliasIn2()
385 /* Un-alias address in IP header */ in IcmpAliasIn2()
386 DifferentialChecksum(&pip->ip_sum, in IcmpAliasIn2()
387 &original_address, &pip->ip_dst, 2); in IcmpAliasIn2()
388 pip->ip_dst = original_address; in IcmpAliasIn2()
390 /* Un-alias address and port number of in IcmpAliasIn2()
393 ip->ip_src = original_address; in IcmpAliasIn2()
394 ud->uh_sport = original_port; in IcmpAliasIn2()
395 } else if (ip->ip_p == IPPROTO_ICMP) { in IcmpAliasIn2()
404 accumulate = twowords(&ip->ip_src); in IcmpAliasIn2()
405 accumulate -= twowords(&original_address); in IcmpAliasIn2()
406 accumulate += ic2->icmp_id; in IcmpAliasIn2()
407 accumulate -= original_id; in IcmpAliasIn2()
409 accumulate2 += ip->ip_sum; in IcmpAliasIn2()
410 ADJUST_CHECKSUM(accumulate, ip->ip_sum); in IcmpAliasIn2()
411 accumulate2 -= ip->ip_sum; in IcmpAliasIn2()
412 ADJUST_CHECKSUM(accumulate2, ic->icmp_cksum); in IcmpAliasIn2()
414 /* Un-alias address in IP header */ in IcmpAliasIn2()
415 DifferentialChecksum(&pip->ip_sum, in IcmpAliasIn2()
416 &original_address, &pip->ip_dst, 2); in IcmpAliasIn2()
417 pip->ip_dst = original_address; in IcmpAliasIn2()
419 /* Un-alias address of original IP packet and in IcmpAliasIn2()
421 ip->ip_src = original_address; in IcmpAliasIn2()
422 ic2->icmp_id = original_id; in IcmpAliasIn2()
438 dlen = ntohs(pip->ip_len) - (pip->ip_hl << 2); in IcmpAliasIn()
442 /* Return if proxy-only mode is enabled */ in IcmpAliasIn()
443 if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) in IcmpAliasIn()
449 switch (ic->icmp_type) { in IcmpAliasIn()
452 if (ic->icmp_code == 0) { in IcmpAliasIn()
475 De-alias outgoing echo and timestamp replies.
487 lnk = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, create); in IcmpAliasOut1()
495 accumulate = ic->icmp_id; in IcmpAliasOut1()
496 accumulate -= alias_id; in IcmpAliasOut1()
497 ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); in IcmpAliasOut1()
500 ic->icmp_id = alias_id; in IcmpAliasOut1()
507 DifferentialChecksum(&pip->ip_sum, in IcmpAliasOut1()
508 &alias_address, &pip->ip_src, 2); in IcmpAliasOut1()
509 pip->ip_src = alias_address; in IcmpAliasOut1()
532 ip = &ic->icmp_ip; in IcmpAliasOut2()
538 if (ip->ip_p == IPPROTO_UDP) in IcmpAliasOut2()
539 lnk = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src, in IcmpAliasOut2()
540 ud->uh_dport, ud->uh_sport, in IcmpAliasOut2()
542 else if (ip->ip_p == IPPROTO_TCP) in IcmpAliasOut2()
543 lnk = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src, in IcmpAliasOut2()
544 tc->th_dport, tc->th_sport, in IcmpAliasOut2()
546 else if (ip->ip_p == IPPROTO_ICMP) { in IcmpAliasOut2()
547 if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP) in IcmpAliasOut2()
548 lnk = FindIcmpOut(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0); in IcmpAliasOut2()
555 if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) { in IcmpAliasOut2()
564 accumulate = twowords(&ip->ip_dst); in IcmpAliasOut2()
565 accumulate -= twowords(&alias_address); in IcmpAliasOut2()
566 accumulate += ud->uh_dport; in IcmpAliasOut2()
567 accumulate -= alias_port; in IcmpAliasOut2()
568 ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); in IcmpAliasOut2()
574 if (pip->ip_src.s_addr == ip->ip_dst.s_addr) { in IcmpAliasOut2()
575 DifferentialChecksum(&pip->ip_sum, in IcmpAliasOut2()
576 &alias_address, &pip->ip_src, 2); in IcmpAliasOut2()
577 pip->ip_src = alias_address; in IcmpAliasOut2()
581 ip->ip_dst = alias_address; in IcmpAliasOut2()
582 ud->uh_dport = alias_port; in IcmpAliasOut2()
583 } else if (ip->ip_p == IPPROTO_ICMP) { in IcmpAliasOut2()
592 accumulate = twowords(&ip->ip_dst); in IcmpAliasOut2()
593 accumulate -= twowords(&alias_address); in IcmpAliasOut2()
594 accumulate += ic2->icmp_id; in IcmpAliasOut2()
595 accumulate -= alias_id; in IcmpAliasOut2()
596 ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); in IcmpAliasOut2()
602 if (pip->ip_src.s_addr == ip->ip_dst.s_addr) { in IcmpAliasOut2()
603 DifferentialChecksum(&pip->ip_sum, in IcmpAliasOut2()
604 &alias_address, &pip->ip_src, 2); in IcmpAliasOut2()
605 pip->ip_src = alias_address; in IcmpAliasOut2()
609 ip->ip_dst = alias_address; in IcmpAliasOut2()
610 ic2->icmp_id = alias_id; in IcmpAliasOut2()
626 /* Return if proxy-only mode is enabled */ in IcmpAliasOut()
627 if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) in IcmpAliasOut()
633 switch (ic->icmp_type) { in IcmpAliasOut()
636 if (ic->icmp_code == 0) { in IcmpAliasOut()
666 /* Return if proxy-only mode is enabled */ in ProtoAliasIn()
667 if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) in ProtoAliasIn()
670 lnk = FindProtoIn(la, ip_src, pip->ip_dst, ip_p); in ProtoAliasIn()
678 &original_address, &pip->ip_dst, 2); in ProtoAliasIn()
679 pip->ip_dst = original_address; in ProtoAliasIn()
699 /* Return if proxy-only mode is enabled */ in ProtoAliasOut()
700 if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) in ProtoAliasOut()
706 lnk = FindProtoOut(la, pip->ip_src, ip_dst, ip_p); in ProtoAliasOut()
714 &alias_address, &pip->ip_src, 2); in ProtoAliasOut()
715 pip->ip_src = alias_address; in ProtoAliasOut()
722 #define MF_ISSET(_pip) (ntohs((_pip)->ip_off) & IP_MF)
723 #define FRAG_NO_HDR(_pip) (ntohs((_pip)->ip_off) & IP_OFFMASK)
732 KASSERT(!FRAG_NO_HDR(pip), ("header-less fragment isn't expected here")); in ValidateUdpLength()
734 dlen = ntohs(pip->ip_len) - (pip->ip_hl << 2); in ValidateUdpLength()
738 if (!MF_ISSET(pip) && dlen < ntohs(ud->uh_ulen)) in ValidateUdpLength()
755 lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst, in UdpAliasIn()
756 ud->uh_sport, ud->uh_dport, in UdpAliasIn()
757 IPPROTO_UDP, !(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)); in UdpAliasIn()
771 .sport = &ud->uh_sport, in UdpAliasIn()
772 .dport = &ud->uh_dport, in UdpAliasIn()
779 alias_port = ud->uh_dport; in UdpAliasIn()
780 ud->uh_dport = GetOriginalPort(lnk); in UdpAliasIn()
792 if (ud->uh_sum != 0) { in UdpAliasIn()
794 accumulate -= ud->uh_dport; in UdpAliasIn()
796 accumulate -= twowords(&original_address); in UdpAliasIn()
801 accumulate += ud->uh_sport; in UdpAliasIn()
802 accumulate -= proxy_port; in UdpAliasIn()
806 accumulate += twowords(&pip->ip_src); in UdpAliasIn()
807 accumulate -= twowords(&proxy_address); in UdpAliasIn()
810 ADJUST_CHECKSUM(accumulate, ud->uh_sum); in UdpAliasIn()
816 ud->uh_sport = proxy_port; in UdpAliasIn()
819 DifferentialChecksum(&pip->ip_sum, in UdpAliasIn()
820 &proxy_address, &pip->ip_src, 2); in UdpAliasIn()
821 pip->ip_src = proxy_address; in UdpAliasIn()
825 DifferentialChecksum(&pip->ip_sum, in UdpAliasIn()
826 &original_address, &pip->ip_dst, 2); in UdpAliasIn()
827 pip->ip_dst = original_address; in UdpAliasIn()
851 /* Return if proxy-only mode is enabled and not proxyrule found.*/ in UdpAliasOut()
853 pip->ip_src, pip->ip_dst, ud->uh_dport, pip->ip_p); in UdpAliasOut()
854 if (proxy_type == 0 && (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)) in UdpAliasOut()
859 dest_port = ud->uh_dport; in UdpAliasOut()
860 dest_address = pip->ip_dst; in UdpAliasOut()
865 accumulate = twowords(&pip->ip_dst); in UdpAliasOut()
866 accumulate -= twowords(&proxy_server_address); in UdpAliasOut()
868 ADJUST_CHECKSUM(accumulate, pip->ip_sum); in UdpAliasOut()
870 if (ud->uh_sum != 0) { in UdpAliasOut()
871 accumulate = twowords(&pip->ip_dst); in UdpAliasOut()
872 accumulate -= twowords(&proxy_server_address); in UdpAliasOut()
873 accumulate += ud->uh_dport; in UdpAliasOut()
874 accumulate -= proxy_server_port; in UdpAliasOut()
875 ADJUST_CHECKSUM(accumulate, ud->uh_sum); in UdpAliasOut()
877 pip->ip_dst = proxy_server_address; in UdpAliasOut()
878 ud->uh_dport = proxy_server_port; in UdpAliasOut()
880 lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst, in UdpAliasOut()
881 ud->uh_sport, ud->uh_dport, in UdpAliasOut()
891 .sport = &ud->uh_sport, in UdpAliasOut()
892 .dport = &ud->uh_dport, in UdpAliasOut()
914 if (ud->uh_sum != 0) { in UdpAliasOut()
917 accumulate = ud->uh_sport; in UdpAliasOut()
918 accumulate -= alias_port; in UdpAliasOut()
919 accumulate += twowords(&pip->ip_src); in UdpAliasOut()
920 accumulate -= twowords(&alias_address); in UdpAliasOut()
921 ADJUST_CHECKSUM(accumulate, ud->uh_sum); in UdpAliasOut()
924 ud->uh_sport = alias_port; in UdpAliasOut()
927 DifferentialChecksum(&pip->ip_sum, in UdpAliasOut()
928 &alias_address, &pip->ip_src, 2); in UdpAliasOut()
929 pip->ip_src = alias_address; in UdpAliasOut()
945 dlen = ntohs(pip->ip_len) - (pip->ip_hl << 2); in TcpAliasIn()
950 lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst, in TcpAliasIn()
951 tc->th_sport, tc->th_dport, in TcpAliasIn()
953 !(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)); in TcpAliasIn()
973 .sport = &tc->th_sport, in TcpAliasIn()
974 .dport = &tc->th_dport, in TcpAliasIn()
984 alias_port = tc->th_dport; in TcpAliasIn()
985 tc->th_dport = GetOriginalPort(lnk); in TcpAliasIn()
999 .sport = &ud->uh_sport, in TcpAliasIn()
1000 .dport = &ud->uh_dport, in TcpAliasIn()
1013 accumulate -= tc->th_dport; in TcpAliasIn()
1015 accumulate -= twowords(&original_address); in TcpAliasIn()
1020 accumulate += tc->th_sport; in TcpAliasIn()
1021 tc->th_sport = proxy_port; in TcpAliasIn()
1022 accumulate -= tc->th_sport; in TcpAliasIn()
1023 accumulate += twowords(&pip->ip_src); in TcpAliasIn()
1024 accumulate -= twowords(&proxy_address); in TcpAliasIn()
1031 delta = GetDeltaAckIn(tc->th_ack, lnk); in TcpAliasIn()
1033 accumulate += twowords(&tc->th_ack); in TcpAliasIn()
1034 tc->th_ack = htonl(ntohl(tc->th_ack) - delta); in TcpAliasIn()
1035 accumulate -= twowords(&tc->th_ack); in TcpAliasIn()
1038 ADJUST_CHECKSUM(accumulate, tc->th_sum); in TcpAliasIn()
1041 accumulate = twowords(&pip->ip_dst); in TcpAliasIn()
1042 pip->ip_dst = original_address; in TcpAliasIn()
1043 accumulate -= twowords(&pip->ip_dst); in TcpAliasIn()
1048 accumulate += twowords(&pip->ip_src); in TcpAliasIn()
1049 pip->ip_src = proxy_address; in TcpAliasIn()
1050 accumulate -= twowords(&pip->ip_src); in TcpAliasIn()
1052 ADJUST_CHECKSUM(accumulate, pip->ip_sum); in TcpAliasIn()
1077 dlen = ntohs(pip->ip_len) - (pip->ip_hl << 2); in TcpAliasOut()
1084 &proxy_server_port, pip->ip_src, pip->ip_dst, in TcpAliasOut()
1085 tc->th_dport, pip->ip_p); in TcpAliasOut()
1089 if (proxy_type == 0 && (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)) in TcpAliasOut()
1094 dest_port = tc->th_dport; in TcpAliasOut()
1095 dest_address = pip->ip_dst; in TcpAliasOut()
1099 accumulate = tc->th_dport; in TcpAliasOut()
1100 tc->th_dport = proxy_server_port; in TcpAliasOut()
1101 accumulate -= tc->th_dport; in TcpAliasOut()
1102 accumulate += twowords(&pip->ip_dst); in TcpAliasOut()
1103 accumulate -= twowords(&proxy_server_address); in TcpAliasOut()
1104 ADJUST_CHECKSUM(accumulate, tc->th_sum); in TcpAliasOut()
1106 accumulate = twowords(&pip->ip_dst); in TcpAliasOut()
1107 pip->ip_dst = proxy_server_address; in TcpAliasOut()
1108 accumulate -= twowords(&pip->ip_dst); in TcpAliasOut()
1109 ADJUST_CHECKSUM(accumulate, pip->ip_sum); in TcpAliasOut()
1111 lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst, in TcpAliasOut()
1112 tc->th_sport, tc->th_dport, in TcpAliasOut()
1125 .sport = &tc->th_sport, in TcpAliasOut()
1126 .dport = &tc->th_dport, in TcpAliasOut()
1152 accumulate = tc->th_sport; in TcpAliasOut()
1153 tc->th_sport = alias_port; in TcpAliasOut()
1154 accumulate -= tc->th_sport; in TcpAliasOut()
1155 accumulate += twowords(&pip->ip_src); in TcpAliasOut()
1156 accumulate -= twowords(&alias_address); in TcpAliasOut()
1163 delta = GetDeltaSeqOut(tc->th_seq, lnk); in TcpAliasOut()
1165 accumulate += twowords(&tc->th_seq); in TcpAliasOut()
1166 tc->th_seq = htonl(ntohl(tc->th_seq) + delta); in TcpAliasOut()
1167 accumulate -= twowords(&tc->th_seq); in TcpAliasOut()
1170 ADJUST_CHECKSUM(accumulate, tc->th_sum); in TcpAliasOut()
1173 accumulate = twowords(&pip->ip_src); in TcpAliasOut()
1174 pip->ip_src = alias_address; in TcpAliasOut()
1175 accumulate -= twowords(&pip->ip_src); in TcpAliasOut()
1176 ADJUST_CHECKSUM(accumulate, pip->ip_sum); in TcpAliasOut()
1209 lnk = FindFragmentIn2(la, ip_src, pip->ip_dst, ip_id); in FragmentIn()
1215 &original_address, &pip->ip_dst, 2); in FragmentIn()
1216 pip->ip_dst = original_address; in FragmentIn()
1229 alias_address = FindAliasAddress(la, pip->ip_src); in FragmentOut()
1231 &alias_address, &pip->ip_src, 2); in FragmentOut()
1232 pip->ip_src = alias_address; in FragmentOut()
1258 lnk = AddFragmentPtrLink(la, pip->ip_src, pip->ip_id); in LibAliasSaveFragment()
1277 lnk = FindFragmentPtr(la, pip->ip_src, pip->ip_id); in LibAliasGetFragment()
1291 void *ptr, /* Points to correctly de-aliased header fragment */ in LibAliasFragmentIn()
1292 void *ptr_fragment /* fragment which must be de-aliased */ in LibAliasFragmentIn()
1303 DifferentialChecksum(&fpip->ip_sum, in LibAliasFragmentIn()
1304 &pip->ip_dst, &fpip->ip_dst, 2); in LibAliasFragmentIn()
1305 fpip->ip_dst = pip->ip_dst; in LibAliasFragmentIn()
1334 if (la->packetAliasMode & PKT_ALIAS_REVERSE) { in LibAliasInLocked()
1335 la->packetAliasMode &= ~PKT_ALIAS_REVERSE; in LibAliasInLocked()
1337 la->packetAliasMode |= PKT_ALIAS_REVERSE; in LibAliasInLocked()
1341 alias_addr = pip->ip_dst; in LibAliasInLocked()
1344 if (ntohs(pip->ip_len) > maxpacketsize in LibAliasInLocked()
1345 || (pip->ip_hl << 2) > maxpacketsize) { in LibAliasInLocked()
1351 iresult = FragmentIn(la, pip->ip_src, pip, pip->ip_id, in LibAliasInLocked()
1352 &pip->ip_sum); in LibAliasInLocked()
1357 switch (pip->ip_p) { in LibAliasInLocked()
1389 iresult = ProtoAliasIn(la, pip->ip_src, in LibAliasInLocked()
1390 pip, pip->ip_p, &pip->ip_sum); in LibAliasInLocked()
1394 iresult = ProtoAliasIn(la, pip->ip_src, pip, in LibAliasInLocked()
1395 pip->ip_p, &pip->ip_sum); in LibAliasInLocked()
1402 lnk = FindFragmentIn1(la, pip->ip_src, alias_addr, pip->ip_id); in LibAliasInLocked()
1405 SetFragmentAddr(lnk, pip->ip_dst); in LibAliasInLocked()
1417 /* 10.0.0.0 -> 10.255.255.255 */
1421 /* 172.16.0.0 -> 172.31.255.255 */
1425 /* 192.168.0.0 -> 192.168.255.255 */
1429 /* 100.64.0.0 -> 100.127.255.255 (RFC 6598 - Carrier Grade NAT) */
1465 if (la->packetAliasMode & PKT_ALIAS_REVERSE) { in LibAliasOutLocked()
1466 la->packetAliasMode &= ~PKT_ALIAS_REVERSE; in LibAliasOutLocked()
1468 la->packetAliasMode |= PKT_ALIAS_REVERSE; in LibAliasOutLocked()
1474 if (ntohs(pip->ip_len) > maxpacketsize in LibAliasOutLocked()
1475 || (pip->ip_hl << 2) > maxpacketsize) { in LibAliasOutLocked()
1481 if (la->packetAliasMode & PKT_ALIAS_UNREGISTERED_ONLY || in LibAliasOutLocked()
1482 la->packetAliasMode & PKT_ALIAS_UNREGISTERED_CGN) { in LibAliasOutLocked()
1487 addr = ntohl(pip->ip_src.s_addr); in LibAliasOutLocked()
1495 la->packetAliasMode & PKT_ALIAS_UNREGISTERED_CGN) in LibAliasOutLocked()
1499 SetDefaultAliasAddress(la, pip->ip_src); in LibAliasOutLocked()
1501 } else if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY) { in LibAliasOutLocked()
1502 SetDefaultAliasAddress(la, pip->ip_src); in LibAliasOutLocked()
1506 iresult = FragmentOut(la, pip, &pip->ip_sum); in LibAliasOutLocked()
1511 switch (pip->ip_p) { in LibAliasOutLocked()
1543 pip->ip_dst, pip->ip_p, &pip->ip_sum, create); in LibAliasOutLocked()
1548 pip->ip_dst, pip->ip_p, &pip->ip_sum, create); in LibAliasOutLocked()
1575 if (ntohs(pip->ip_len) > maxpacketsize in LibAliasUnaliasOut()
1576 || (pip->ip_hl << 2) > maxpacketsize) in LibAliasUnaliasOut()
1584 if (pip->ip_p == IPPROTO_UDP) in LibAliasUnaliasOut()
1585 lnk = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src, in LibAliasUnaliasOut()
1586 ud->uh_dport, ud->uh_sport, in LibAliasUnaliasOut()
1588 else if (pip->ip_p == IPPROTO_TCP) in LibAliasUnaliasOut()
1589 lnk = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src, in LibAliasUnaliasOut()
1590 tc->th_dport, tc->th_sport, in LibAliasUnaliasOut()
1592 else if (pip->ip_p == IPPROTO_ICMP) in LibAliasUnaliasOut()
1593 lnk = FindIcmpIn(la, pip->ip_dst, pip->ip_src, ic->icmp_id, 0); in LibAliasUnaliasOut()
1599 if (pip->ip_p == IPPROTO_UDP || pip->ip_p == IPPROTO_TCP) { in LibAliasUnaliasOut()
1608 accumulate = twowords(&pip->ip_src); in LibAliasUnaliasOut()
1609 accumulate -= twowords(&original_address); in LibAliasUnaliasOut()
1611 if (pip->ip_p == IPPROTO_UDP) { in LibAliasUnaliasOut()
1612 accumulate += ud->uh_sport; in LibAliasUnaliasOut()
1613 accumulate -= original_port; in LibAliasUnaliasOut()
1614 ADJUST_CHECKSUM(accumulate, ud->uh_sum); in LibAliasUnaliasOut()
1616 accumulate += tc->th_sport; in LibAliasUnaliasOut()
1617 accumulate -= original_port; in LibAliasUnaliasOut()
1618 ADJUST_CHECKSUM(accumulate, tc->th_sum); in LibAliasUnaliasOut()
1622 DifferentialChecksum(&pip->ip_sum, in LibAliasUnaliasOut()
1623 &original_address, &pip->ip_src, 2); in LibAliasUnaliasOut()
1625 /* Un-alias source address and port number */ in LibAliasUnaliasOut()
1626 pip->ip_src = original_address; in LibAliasUnaliasOut()
1627 if (pip->ip_p == IPPROTO_UDP) in LibAliasUnaliasOut()
1628 ud->uh_sport = original_port; in LibAliasUnaliasOut()
1630 tc->th_sport = original_port; in LibAliasUnaliasOut()
1633 } else if (pip->ip_p == IPPROTO_ICMP) { in LibAliasUnaliasOut()
1642 accumulate = twowords(&pip->ip_src); in LibAliasUnaliasOut()
1643 accumulate -= twowords(&original_address); in LibAliasUnaliasOut()
1644 accumulate += ic->icmp_id; in LibAliasUnaliasOut()
1645 accumulate -= original_id; in LibAliasUnaliasOut()
1646 ADJUST_CHECKSUM(accumulate, ic->icmp_cksum); in LibAliasUnaliasOut()
1649 DifferentialChecksum(&pip->ip_sum, in LibAliasUnaliasOut()
1650 &original_address, &pip->ip_src, 2); in LibAliasUnaliasOut()
1652 /* Un-alias source address and port number */ in LibAliasUnaliasOut()
1653 pip->ip_src = original_address; in LibAliasUnaliasOut()
1654 ic->icmp_id = original_id; in LibAliasUnaliasOut()
1669 char buf[256], conf[] = "/etc/libalias.conf"; in LibAliasRefreshModules() local
1673 fd = fopen(conf, "r"); in LibAliasRefreshModules()
1675 err(1, "fopen(%s)", conf); in LibAliasRefreshModules()
1690 buf[len - 1] = '\0'; in LibAliasRefreshModules()
1722 strncpy(t->name, p->name, DLL_LEN); in LibAliasLoadModule()
1723 t->handle = handle; in LibAliasLoadModule()
1730 m = dlsym(t->handle, "handlers"); in LibAliasLoadModule()
1751 dlclose(t->handle); in LibAliasUnLoadAllModule()
1761 * m_megapullup() - this function is a big hack.
1777 if (len > m->m_pkthdr.len) in m_megapullup()
1780 if (m->m_next == NULL && M_WRITABLE(m)) in m_megapullup()
1796 mcl->m_len = mcl->m_pkthdr.len = len; in m_megapullup()