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

Function TcpAliasIn

freebsd/netinet/libalias/alias.c:930–1055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

928}
929
930static int
931TcpAliasIn(struct libalias *la, struct ip *pip)
932{
933 struct tcphdr *tc;
934 struct alias_link *lnk;
935 size_t dlen;
936
937 LIBALIAS_LOCK_ASSERT(la);
938
939 dlen = ntohs(pip->ip_len) - (pip->ip_hl << 2);
940 if (dlen < sizeof(struct tcphdr))
941 return (PKT_ALIAS_IGNORED);
942 tc = (struct tcphdr *)ip_next(pip);
943
944 lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
945 tc->th_sport, tc->th_dport,
946 IPPROTO_TCP,
947 !(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY));
948 if (lnk != NULL) {
949 struct in_addr alias_address;
950 struct in_addr original_address;
951 struct in_addr proxy_address;
952 u_short alias_port;
953 u_short proxy_port;
954 int accumulate, error;
955
956 /*
957 * The init of MANY vars is a bit below, but aliashandlepptpin
958 * seems to need the destination port that came within the
959 * packet and not the original one looks below [*].
960 */
961
962 struct alias_data ad = {
963 .lnk = lnk,
964 .oaddr = NULL,
965 .aaddr = NULL,
966 .aport = NULL,
967 .sport = &tc->th_sport,
968 .dport = &tc->th_dport,
969 .maxpktsize = 0
970 };
971
972 /* Walk out chain. */
973 error = find_handler(IN, TCP, la, pip, &ad);
974
975 alias_address = GetAliasAddress(lnk);
976 original_address = GetOriginalAddress(lnk);
977 proxy_address = GetProxyAddress(lnk);
978 alias_port = tc->th_dport;
979 tc->th_dport = GetOriginalPort(lnk);
980 proxy_port = GetProxyPort(lnk);
981
982 /*
983 * Look above, if anyone is going to add find_handler AFTER
984 * this aliashandlepptpin/point, please redo alias_data too.
985 * Uncommenting the piece here below should be enough.
986 */
987#if 0

Callers 1

LibAliasInLockedFunction · 0.85

Calls 13

ip_nextFunction · 0.85
FindUdpTcpInFunction · 0.85
find_handlerFunction · 0.85
GetAliasAddressFunction · 0.85
GetOriginalAddressFunction · 0.85
GetProxyAddressFunction · 0.85
GetOriginalPortFunction · 0.85
GetProxyPortFunction · 0.85
twowordsFunction · 0.85
GetAckModifiedFunction · 0.85
GetDeltaAckInFunction · 0.85
TcpMonitorInFunction · 0.85

Tested by

no test coverage detected