| 928 | } |
| 929 | |
| 930 | static int |
| 931 | TcpAliasIn(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 |
no test coverage detected