Make libalias WARNS?=6-clean. This mostly involves renaming variables
named link, foo_link or link_foo to lnk, foo_lnk or lnk_foo, fixing signed / unsigned comparisons, and shoving unused function arguments under the carpet. I was hoping WARNS?=6 might reveal more serious problems, and perhaps the source of the -O2 breakage, but found no smoking gun.
This commit is contained in:
parent
ffcb611a9d
commit
ed01a58215
@ -8,6 +8,6 @@ SRCS= alias.c alias_cuseeme.c alias_db.c alias_ftp.c alias_irc.c \
|
|||||||
alias_nbt.c alias_pptp.c alias_proxy.c alias_skinny.c alias_smedia.c \
|
alias_nbt.c alias_pptp.c alias_proxy.c alias_skinny.c alias_smedia.c \
|
||||||
alias_util.c alias_old.c
|
alias_util.c alias_old.c
|
||||||
INCS= alias.h
|
INCS= alias.h
|
||||||
WARNS?= 2
|
WARNS?= 6
|
||||||
|
|
||||||
.include <bsd.lib.mk>
|
.include <bsd.lib.mk>
|
||||||
|
@ -162,43 +162,43 @@ static void TcpMonitorOut(struct ip *, struct alias_link *);
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
TcpMonitorIn(struct ip *pip, struct alias_link *link)
|
TcpMonitorIn(struct ip *pip, struct alias_link *lnk)
|
||||||
{
|
{
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
switch (GetStateIn(link)) {
|
switch (GetStateIn(lnk)) {
|
||||||
case ALIAS_TCP_STATE_NOT_CONNECTED:
|
case ALIAS_TCP_STATE_NOT_CONNECTED:
|
||||||
if (tc->th_flags & TH_RST)
|
if (tc->th_flags & TH_RST)
|
||||||
SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED);
|
SetStateIn(lnk, ALIAS_TCP_STATE_DISCONNECTED);
|
||||||
else if (tc->th_flags & TH_SYN)
|
else if (tc->th_flags & TH_SYN)
|
||||||
SetStateIn(link, ALIAS_TCP_STATE_CONNECTED);
|
SetStateIn(lnk, ALIAS_TCP_STATE_CONNECTED);
|
||||||
break;
|
break;
|
||||||
case ALIAS_TCP_STATE_CONNECTED:
|
case ALIAS_TCP_STATE_CONNECTED:
|
||||||
if (tc->th_flags & (TH_FIN | TH_RST))
|
if (tc->th_flags & (TH_FIN | TH_RST))
|
||||||
SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED);
|
SetStateIn(lnk, ALIAS_TCP_STATE_DISCONNECTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
TcpMonitorOut(struct ip *pip, struct alias_link *link)
|
TcpMonitorOut(struct ip *pip, struct alias_link *lnk)
|
||||||
{
|
{
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
switch (GetStateOut(link)) {
|
switch (GetStateOut(lnk)) {
|
||||||
case ALIAS_TCP_STATE_NOT_CONNECTED:
|
case ALIAS_TCP_STATE_NOT_CONNECTED:
|
||||||
if (tc->th_flags & TH_RST)
|
if (tc->th_flags & TH_RST)
|
||||||
SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED);
|
SetStateOut(lnk, ALIAS_TCP_STATE_DISCONNECTED);
|
||||||
else if (tc->th_flags & TH_SYN)
|
else if (tc->th_flags & TH_SYN)
|
||||||
SetStateOut(link, ALIAS_TCP_STATE_CONNECTED);
|
SetStateOut(lnk, ALIAS_TCP_STATE_CONNECTED);
|
||||||
break;
|
break;
|
||||||
case ALIAS_TCP_STATE_CONNECTED:
|
case ALIAS_TCP_STATE_CONNECTED:
|
||||||
if (tc->th_flags & (TH_FIN | TH_RST))
|
if (tc->th_flags & (TH_FIN | TH_RST))
|
||||||
SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED);
|
SetStateOut(lnk, ALIAS_TCP_STATE_DISCONNECTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,18 +273,18 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip)
|
|||||||
De-alias incoming echo and timestamp replies.
|
De-alias incoming echo and timestamp replies.
|
||||||
Alias incoming echo and timestamp requests.
|
Alias incoming echo and timestamp requests.
|
||||||
*/
|
*/
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
struct icmp *ic;
|
struct icmp *ic;
|
||||||
|
|
||||||
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
/* Get source address from ICMP data field and restore original data */
|
/* Get source address from ICMP data field and restore original data */
|
||||||
link = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
|
lnk = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
u_short original_id;
|
u_short original_id;
|
||||||
int accumulate;
|
int accumulate;
|
||||||
|
|
||||||
original_id = GetOriginalPort(link);
|
original_id = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = ic->icmp_id;
|
accumulate = ic->icmp_id;
|
||||||
@ -298,7 +298,7 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip)
|
|||||||
{
|
{
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
&original_address, &pip->ip_dst, 2);
|
&original_address, &pip->ip_dst, 2);
|
||||||
pip->ip_dst = original_address;
|
pip->ip_dst = original_address;
|
||||||
@ -320,7 +320,7 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip)
|
|||||||
struct icmp *ic, *ic2;
|
struct icmp *ic, *ic2;
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
||||||
ip = &ic->icmp_ip;
|
ip = &ic->icmp_ip;
|
||||||
@ -330,29 +330,29 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip)
|
|||||||
ic2 = (struct icmp *)ud;
|
ic2 = (struct icmp *)ud;
|
||||||
|
|
||||||
if (ip->ip_p == IPPROTO_UDP)
|
if (ip->ip_p == IPPROTO_UDP)
|
||||||
link = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src,
|
lnk = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src,
|
||||||
ud->uh_dport, ud->uh_sport,
|
ud->uh_dport, ud->uh_sport,
|
||||||
IPPROTO_UDP, 0);
|
IPPROTO_UDP, 0);
|
||||||
else if (ip->ip_p == IPPROTO_TCP)
|
else if (ip->ip_p == IPPROTO_TCP)
|
||||||
link = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src,
|
lnk = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src,
|
||||||
tc->th_dport, tc->th_sport,
|
tc->th_dport, tc->th_sport,
|
||||||
IPPROTO_TCP, 0);
|
IPPROTO_TCP, 0);
|
||||||
else if (ip->ip_p == IPPROTO_ICMP) {
|
else if (ip->ip_p == IPPROTO_ICMP) {
|
||||||
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
|
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
|
||||||
link = FindIcmpIn(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
|
lnk = FindIcmpIn(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
|
||||||
else
|
else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
} else
|
} else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
|
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
|
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
|
||||||
int accumulate, accumulate2;
|
int accumulate, accumulate2;
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short original_port;
|
u_short original_port;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
original_port = GetOriginalPort(link);
|
original_port = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&ip->ip_src);
|
accumulate = twowords(&ip->ip_src);
|
||||||
@ -379,8 +379,8 @@ fragment contained in ICMP data section */
|
|||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short original_id;
|
u_short original_id;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
original_id = GetOriginalPort(link);
|
original_id = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&ip->ip_src);
|
accumulate = twowords(&ip->ip_src);
|
||||||
@ -451,18 +451,18 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip)
|
|||||||
Alias outgoing echo and timestamp requests.
|
Alias outgoing echo and timestamp requests.
|
||||||
De-alias outgoing echo and timestamp replies.
|
De-alias outgoing echo and timestamp replies.
|
||||||
*/
|
*/
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
struct icmp *ic;
|
struct icmp *ic;
|
||||||
|
|
||||||
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
/* Save overwritten data for when echo packet returns */
|
/* Save overwritten data for when echo packet returns */
|
||||||
link = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
|
lnk = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
u_short alias_id;
|
u_short alias_id;
|
||||||
int accumulate;
|
int accumulate;
|
||||||
|
|
||||||
alias_id = GetAliasPort(link);
|
alias_id = GetAliasPort(lnk);
|
||||||
|
|
||||||
/* Since data field is being modified, adjust ICMP checksum */
|
/* Since data field is being modified, adjust ICMP checksum */
|
||||||
accumulate = ic->icmp_id;
|
accumulate = ic->icmp_id;
|
||||||
@ -476,7 +476,7 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip)
|
|||||||
{
|
{
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
&alias_address, &pip->ip_src, 2);
|
&alias_address, &pip->ip_src, 2);
|
||||||
pip->ip_src = alias_address;
|
pip->ip_src = alias_address;
|
||||||
@ -499,7 +499,7 @@ IcmpAliasOut2(struct libalias *la, struct ip *pip)
|
|||||||
struct icmp *ic, *ic2;
|
struct icmp *ic, *ic2;
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
||||||
ip = &ic->icmp_ip;
|
ip = &ic->icmp_ip;
|
||||||
@ -509,29 +509,29 @@ IcmpAliasOut2(struct libalias *la, struct ip *pip)
|
|||||||
ic2 = (struct icmp *)ud;
|
ic2 = (struct icmp *)ud;
|
||||||
|
|
||||||
if (ip->ip_p == IPPROTO_UDP)
|
if (ip->ip_p == IPPROTO_UDP)
|
||||||
link = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src,
|
lnk = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src,
|
||||||
ud->uh_dport, ud->uh_sport,
|
ud->uh_dport, ud->uh_sport,
|
||||||
IPPROTO_UDP, 0);
|
IPPROTO_UDP, 0);
|
||||||
else if (ip->ip_p == IPPROTO_TCP)
|
else if (ip->ip_p == IPPROTO_TCP)
|
||||||
link = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src,
|
lnk = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src,
|
||||||
tc->th_dport, tc->th_sport,
|
tc->th_dport, tc->th_sport,
|
||||||
IPPROTO_TCP, 0);
|
IPPROTO_TCP, 0);
|
||||||
else if (ip->ip_p == IPPROTO_ICMP) {
|
else if (ip->ip_p == IPPROTO_ICMP) {
|
||||||
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
|
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
|
||||||
link = FindIcmpOut(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
|
lnk = FindIcmpOut(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
|
||||||
else
|
else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
} else
|
} else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
|
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
|
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
|
||||||
int accumulate;
|
int accumulate;
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
u_short alias_port;
|
u_short alias_port;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
alias_port = GetAliasPort(link);
|
alias_port = GetAliasPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&ip->ip_dst);
|
accumulate = twowords(&ip->ip_dst);
|
||||||
@ -558,8 +558,8 @@ fragment contained in ICMP data section */
|
|||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
u_short alias_id;
|
u_short alias_id;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
alias_id = GetAliasPort(link);
|
alias_id = GetAliasPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&ip->ip_dst);
|
accumulate = twowords(&ip->ip_dst);
|
||||||
@ -594,6 +594,8 @@ IcmpAliasOut(struct libalias *la, struct ip *pip, int create)
|
|||||||
int iresult;
|
int iresult;
|
||||||
struct icmp *ic;
|
struct icmp *ic;
|
||||||
|
|
||||||
|
(void)create;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
return (PKT_ALIAS_OK);
|
return (PKT_ALIAS_OK);
|
||||||
@ -632,17 +634,17 @@ ProtoAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
the dest IP address of the packet to our inside
|
the dest IP address of the packet to our inside
|
||||||
machine.
|
machine.
|
||||||
*/
|
*/
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
return (PKT_ALIAS_OK);
|
return (PKT_ALIAS_OK);
|
||||||
|
|
||||||
link = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
|
lnk = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
|
|
||||||
/* Restore original IP address */
|
/* Restore original IP address */
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
@ -663,17 +665,19 @@ ProtoAliasOut(struct libalias *la, struct ip *pip, int create)
|
|||||||
only thing which is done in this case is to alias
|
only thing which is done in this case is to alias
|
||||||
the source IP address of the packet.
|
the source IP address of the packet.
|
||||||
*/
|
*/
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
|
(void)create;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
return (PKT_ALIAS_OK);
|
return (PKT_ALIAS_OK);
|
||||||
|
|
||||||
link = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
|
lnk = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
|
|
||||||
/* Change source address */
|
/* Change source address */
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
@ -690,7 +694,7 @@ static int
|
|||||||
UdpAliasIn(struct libalias *la, struct ip *pip)
|
UdpAliasIn(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
@ -698,20 +702,20 @@ UdpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
|
|
||||||
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
link = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
|
lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
|
||||||
ud->uh_sport, ud->uh_dport,
|
ud->uh_sport, ud->uh_dport,
|
||||||
IPPROTO_UDP, 1);
|
IPPROTO_UDP, 1);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short alias_port;
|
u_short alias_port;
|
||||||
int accumulate;
|
int accumulate;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
alias_port = ud->uh_dport;
|
alias_port = ud->uh_dport;
|
||||||
ud->uh_dport = GetOriginalPort(link);
|
ud->uh_dport = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Special processing for IP encoding protocols */
|
/* Special processing for IP encoding protocols */
|
||||||
if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
|
if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
|
||||||
@ -719,10 +723,10 @@ UdpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
|
/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
|
||||||
else if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
|
else if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
|
||||||
|| ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER)
|
|| ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER)
|
||||||
r = AliasHandleUdpNbt(la, pip, link, &original_address, ud->uh_dport);
|
r = AliasHandleUdpNbt(la, pip, lnk, &original_address, ud->uh_dport);
|
||||||
else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
|
else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
|
||||||
|| ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER)
|
|| ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER)
|
||||||
r = AliasHandleUdpNbtNS(la, pip, link, &alias_address, &alias_port,
|
r = AliasHandleUdpNbtNS(la, pip, lnk, &alias_address, &alias_port,
|
||||||
&original_address, &ud->uh_dport);
|
&original_address, &ud->uh_dport);
|
||||||
|
|
||||||
/* If UDP checksum is not zero, then adjust since destination port */
|
/* If UDP checksum is not zero, then adjust since destination port */
|
||||||
@ -754,7 +758,7 @@ static int
|
|||||||
UdpAliasOut(struct libalias *la, struct ip *pip, int create)
|
UdpAliasOut(struct libalias *la, struct ip *pip, int create)
|
||||||
{
|
{
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
@ -762,26 +766,26 @@ UdpAliasOut(struct libalias *la, struct ip *pip, int create)
|
|||||||
|
|
||||||
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
link = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
|
lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
|
||||||
ud->uh_sport, ud->uh_dport,
|
ud->uh_sport, ud->uh_dport,
|
||||||
IPPROTO_UDP, create);
|
IPPROTO_UDP, create);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
u_short alias_port;
|
u_short alias_port;
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
alias_port = GetAliasPort(link);
|
alias_port = GetAliasPort(lnk);
|
||||||
|
|
||||||
/* Special processing for IP encoding protocols */
|
/* Special processing for IP encoding protocols */
|
||||||
if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
|
if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
|
||||||
AliasHandleCUSeeMeOut(la, pip, link);
|
AliasHandleCUSeeMeOut(la, pip, lnk);
|
||||||
/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
|
/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
|
||||||
else if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
|
else if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
|
||||||
|| ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER)
|
|| ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER)
|
||||||
AliasHandleUdpNbt(la, pip, link, &alias_address, alias_port);
|
AliasHandleUdpNbt(la, pip, lnk, &alias_address, alias_port);
|
||||||
else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
|
else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
|
||||||
|| ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER)
|
|| ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER)
|
||||||
AliasHandleUdpNbtNS(la, pip, link, &pip->ip_src, &ud->uh_sport,
|
AliasHandleUdpNbtNS(la, pip, lnk, &pip->ip_src, &ud->uh_sport,
|
||||||
&alias_address, &alias_port);
|
&alias_address, &alias_port);
|
||||||
/*
|
/*
|
||||||
* We don't know in advance what TID the TFTP server will choose,
|
* We don't know in advance what TID the TFTP server will choose,
|
||||||
@ -822,15 +826,15 @@ static int
|
|||||||
TcpAliasIn(struct libalias *la, struct ip *pip)
|
TcpAliasIn(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
link = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
|
lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
|
||||||
tc->th_sport, tc->th_dport,
|
tc->th_sport, tc->th_dport,
|
||||||
IPPROTO_TCP,
|
IPPROTO_TCP,
|
||||||
!(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY));
|
!(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY));
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
struct in_addr proxy_address;
|
struct in_addr proxy_address;
|
||||||
@ -841,17 +845,17 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
/* Special processing for IP encoding protocols */
|
/* Special processing for IP encoding protocols */
|
||||||
if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER
|
if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER
|
||||||
|| ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER)
|
|| ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER)
|
||||||
AliasHandlePptpIn(la, pip, link);
|
AliasHandlePptpIn(la, pip, lnk);
|
||||||
else if (la->skinnyPort != 0 && (ntohs(tc->th_dport) == la->skinnyPort
|
else if (la->skinnyPort != 0 && (ntohs(tc->th_dport) == la->skinnyPort
|
||||||
|| ntohs(tc->th_sport) == la->skinnyPort))
|
|| ntohs(tc->th_sport) == la->skinnyPort))
|
||||||
AliasHandleSkinny(la, pip, link);
|
AliasHandleSkinny(la, pip, lnk);
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
proxy_address = GetProxyAddress(link);
|
proxy_address = GetProxyAddress(lnk);
|
||||||
alias_port = tc->th_dport;
|
alias_port = tc->th_dport;
|
||||||
tc->th_dport = GetOriginalPort(link);
|
tc->th_dport = GetOriginalPort(lnk);
|
||||||
proxy_port = GetProxyPort(link);
|
proxy_port = GetProxyPort(lnk);
|
||||||
|
|
||||||
/* Adjust TCP checksum since destination port is being unaliased */
|
/* Adjust TCP checksum since destination port is being unaliased */
|
||||||
/* and destination port is being altered. */
|
/* and destination port is being altered. */
|
||||||
@ -870,10 +874,10 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
accumulate -= twowords(&proxy_address);
|
accumulate -= twowords(&proxy_address);
|
||||||
}
|
}
|
||||||
/* See if ACK number needs to be modified */
|
/* See if ACK number needs to be modified */
|
||||||
if (GetAckModified(link) == 1) {
|
if (GetAckModified(lnk) == 1) {
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
delta = GetDeltaAckIn(pip, link);
|
delta = GetDeltaAckIn(pip, lnk);
|
||||||
if (delta != 0) {
|
if (delta != 0) {
|
||||||
accumulate += twowords(&tc->th_ack);
|
accumulate += twowords(&tc->th_ack);
|
||||||
tc->th_ack = htonl(ntohl(tc->th_ack) - delta);
|
tc->th_ack = htonl(ntohl(tc->th_ack) - delta);
|
||||||
@ -897,7 +901,7 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
||||||
|
|
||||||
/* Monitor TCP connection state */
|
/* Monitor TCP connection state */
|
||||||
TcpMonitorIn(pip, link);
|
TcpMonitorIn(pip, lnk);
|
||||||
|
|
||||||
return (PKT_ALIAS_OK);
|
return (PKT_ALIAS_OK);
|
||||||
}
|
}
|
||||||
@ -913,7 +917,7 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
|
|||||||
struct in_addr dest_address;
|
struct in_addr dest_address;
|
||||||
struct in_addr proxy_server_address;
|
struct in_addr proxy_server_address;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
@ -941,12 +945,12 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
|
|||||||
accumulate -= twowords(&pip->ip_dst);
|
accumulate -= twowords(&pip->ip_dst);
|
||||||
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
||||||
}
|
}
|
||||||
link = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
|
lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
|
||||||
tc->th_sport, tc->th_dport,
|
tc->th_sport, tc->th_dport,
|
||||||
IPPROTO_TCP, create);
|
IPPROTO_TCP, create);
|
||||||
if (link == NULL)
|
if (lnk == NULL)
|
||||||
return (PKT_ALIAS_IGNORED);
|
return (PKT_ALIAS_IGNORED);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
u_short alias_port;
|
u_short alias_port;
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
int accumulate;
|
int accumulate;
|
||||||
@ -955,36 +959,36 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
|
|||||||
Also modify packet to include destination encoding. This may
|
Also modify packet to include destination encoding. This may
|
||||||
change the size of IP header. */
|
change the size of IP header. */
|
||||||
if (proxy_type != 0) {
|
if (proxy_type != 0) {
|
||||||
SetProxyPort(link, dest_port);
|
SetProxyPort(lnk, dest_port);
|
||||||
SetProxyAddress(link, dest_address);
|
SetProxyAddress(lnk, dest_address);
|
||||||
ProxyModify(la, link, pip, maxpacketsize, proxy_type);
|
ProxyModify(la, lnk, pip, maxpacketsize, proxy_type);
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
}
|
}
|
||||||
/* Get alias address and port */
|
/* Get alias address and port */
|
||||||
alias_port = GetAliasPort(link);
|
alias_port = GetAliasPort(lnk);
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
|
|
||||||
/* Monitor TCP connection state */
|
/* Monitor TCP connection state */
|
||||||
TcpMonitorOut(pip, link);
|
TcpMonitorOut(pip, lnk);
|
||||||
|
|
||||||
/* Special processing for IP encoding protocols */
|
/* Special processing for IP encoding protocols */
|
||||||
if (ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER
|
if (ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER
|
||||||
|| ntohs(tc->th_sport) == FTP_CONTROL_PORT_NUMBER)
|
|| ntohs(tc->th_sport) == FTP_CONTROL_PORT_NUMBER)
|
||||||
AliasHandleFtpOut(la, pip, link, maxpacketsize);
|
AliasHandleFtpOut(la, pip, lnk, maxpacketsize);
|
||||||
else if (ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_1
|
else if (ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_1
|
||||||
|| ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_2)
|
|| ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_2)
|
||||||
AliasHandleIrcOut(la, pip, link, maxpacketsize);
|
AliasHandleIrcOut(la, pip, lnk, maxpacketsize);
|
||||||
else if (ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_1
|
else if (ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_1
|
||||||
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_1
|
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_1
|
||||||
|| ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_2
|
|| ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_2
|
||||||
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_2)
|
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_2)
|
||||||
AliasHandleRtspOut(la, pip, link, maxpacketsize);
|
AliasHandleRtspOut(la, pip, lnk, maxpacketsize);
|
||||||
else if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER
|
else if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER
|
||||||
|| ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER)
|
|| ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER)
|
||||||
AliasHandlePptpOut(la, pip, link);
|
AliasHandlePptpOut(la, pip, lnk);
|
||||||
else if (la->skinnyPort != 0 && (ntohs(tc->th_sport) == la->skinnyPort
|
else if (la->skinnyPort != 0 && (ntohs(tc->th_sport) == la->skinnyPort
|
||||||
|| ntohs(tc->th_dport) == la->skinnyPort))
|
|| ntohs(tc->th_dport) == la->skinnyPort))
|
||||||
AliasHandleSkinny(la, pip, link);
|
AliasHandleSkinny(la, pip, lnk);
|
||||||
|
|
||||||
/* Adjust TCP checksum since source port is being aliased */
|
/* Adjust TCP checksum since source port is being aliased */
|
||||||
/* and source address is being altered */
|
/* and source address is being altered */
|
||||||
@ -995,10 +999,10 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
|
|||||||
accumulate -= twowords(&alias_address);
|
accumulate -= twowords(&alias_address);
|
||||||
|
|
||||||
/* Modify sequence number if necessary */
|
/* Modify sequence number if necessary */
|
||||||
if (GetAckModified(link) == 1) {
|
if (GetAckModified(lnk) == 1) {
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
if (delta != 0) {
|
if (delta != 0) {
|
||||||
accumulate += twowords(&tc->th_seq);
|
accumulate += twowords(&tc->th_seq);
|
||||||
tc->th_seq = htonl(ntohl(tc->th_seq) + delta);
|
tc->th_seq = htonl(ntohl(tc->th_seq) + delta);
|
||||||
@ -1042,13 +1046,13 @@ static int FragmentOut(struct libalias *, struct ip *);
|
|||||||
static int
|
static int
|
||||||
FragmentIn(struct libalias *la, struct ip *pip)
|
FragmentIn(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
link = FindFragmentIn2(la, pip->ip_src, pip->ip_dst, pip->ip_id);
|
lnk = FindFragmentIn2(la, pip->ip_src, pip->ip_dst, pip->ip_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
|
|
||||||
GetFragmentAddr(link, &original_address);
|
GetFragmentAddr(lnk, &original_address);
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
&original_address, &pip->ip_dst, 2);
|
&original_address, &pip->ip_dst, 2);
|
||||||
pip->ip_dst = original_address;
|
pip->ip_dst = original_address;
|
||||||
@ -1094,14 +1098,14 @@ int
|
|||||||
LibAliasSaveFragment(struct libalias *la, char *ptr)
|
LibAliasSaveFragment(struct libalias *la, char *ptr)
|
||||||
{
|
{
|
||||||
int iresult;
|
int iresult;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
struct ip *pip;
|
struct ip *pip;
|
||||||
|
|
||||||
pip = (struct ip *)ptr;
|
pip = (struct ip *)ptr;
|
||||||
link = AddFragmentPtrLink(la, pip->ip_src, pip->ip_id);
|
lnk = AddFragmentPtrLink(la, pip->ip_src, pip->ip_id);
|
||||||
iresult = PKT_ALIAS_ERROR;
|
iresult = PKT_ALIAS_ERROR;
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
SetFragmentPtr(link, ptr);
|
SetFragmentPtr(lnk, ptr);
|
||||||
iresult = PKT_ALIAS_OK;
|
iresult = PKT_ALIAS_OK;
|
||||||
}
|
}
|
||||||
return (iresult);
|
return (iresult);
|
||||||
@ -1111,16 +1115,16 @@ LibAliasSaveFragment(struct libalias *la, char *ptr)
|
|||||||
char *
|
char *
|
||||||
LibAliasGetFragment(struct libalias *la, char *ptr)
|
LibAliasGetFragment(struct libalias *la, char *ptr)
|
||||||
{
|
{
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
char *fptr;
|
char *fptr;
|
||||||
struct ip *pip;
|
struct ip *pip;
|
||||||
|
|
||||||
pip = (struct ip *)ptr;
|
pip = (struct ip *)ptr;
|
||||||
link = FindFragmentPtr(la, pip->ip_src, pip->ip_id);
|
lnk = FindFragmentPtr(la, pip->ip_src, pip->ip_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
GetFragmentPtr(link, &fptr);
|
GetFragmentPtr(lnk, &fptr);
|
||||||
SetFragmentPtr(link, NULL);
|
SetFragmentPtr(lnk, NULL);
|
||||||
SetExpire(link, 0); /* Deletes link */
|
SetExpire(lnk, 0); /* Deletes link */
|
||||||
|
|
||||||
return (fptr);
|
return (fptr);
|
||||||
} else {
|
} else {
|
||||||
@ -1140,6 +1144,7 @@ LibAliasFragmentIn(struct libalias *la, char *ptr, /* Points to correctly
|
|||||||
struct ip *pip;
|
struct ip *pip;
|
||||||
struct ip *fpip;
|
struct ip *fpip;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
pip = (struct ip *)ptr;
|
pip = (struct ip *)ptr;
|
||||||
fpip = (struct ip *)ptr_fragment;
|
fpip = (struct ip *)ptr_fragment;
|
||||||
|
|
||||||
@ -1197,12 +1202,12 @@ LibAliasIn(struct libalias *la, char *ptr, int maxpacketsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ntohs(pip->ip_off) & IP_MF) {
|
if (ntohs(pip->ip_off) & IP_MF) {
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
link = FindFragmentIn1(la, pip->ip_src, alias_addr, pip->ip_id);
|
lnk = FindFragmentIn1(la, pip->ip_src, alias_addr, pip->ip_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
iresult = PKT_ALIAS_FOUND_HEADER_FRAGMENT;
|
iresult = PKT_ALIAS_FOUND_HEADER_FRAGMENT;
|
||||||
SetFragmentAddr(link, pip->ip_dst);
|
SetFragmentAddr(lnk, pip->ip_dst);
|
||||||
} else {
|
} else {
|
||||||
iresult = PKT_ALIAS_ERROR;
|
iresult = PKT_ALIAS_ERROR;
|
||||||
}
|
}
|
||||||
@ -1324,7 +1329,7 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
|
|||||||
struct icmp *ic;
|
struct icmp *ic;
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
int iresult = PKT_ALIAS_IGNORED;
|
int iresult = PKT_ALIAS_IGNORED;
|
||||||
|
|
||||||
pip = (struct ip *)ptr;
|
pip = (struct ip *)ptr;
|
||||||
@ -1340,27 +1345,27 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
|
|||||||
|
|
||||||
/* Find a link */
|
/* Find a link */
|
||||||
if (pip->ip_p == IPPROTO_UDP)
|
if (pip->ip_p == IPPROTO_UDP)
|
||||||
link = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src,
|
lnk = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src,
|
||||||
ud->uh_dport, ud->uh_sport,
|
ud->uh_dport, ud->uh_sport,
|
||||||
IPPROTO_UDP, 0);
|
IPPROTO_UDP, 0);
|
||||||
else if (pip->ip_p == IPPROTO_TCP)
|
else if (pip->ip_p == IPPROTO_TCP)
|
||||||
link = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src,
|
lnk = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src,
|
||||||
tc->th_dport, tc->th_sport,
|
tc->th_dport, tc->th_sport,
|
||||||
IPPROTO_TCP, 0);
|
IPPROTO_TCP, 0);
|
||||||
else if (pip->ip_p == IPPROTO_ICMP)
|
else if (pip->ip_p == IPPROTO_ICMP)
|
||||||
link = FindIcmpIn(la, pip->ip_dst, pip->ip_src, ic->icmp_id, 0);
|
lnk = FindIcmpIn(la, pip->ip_dst, pip->ip_src, ic->icmp_id, 0);
|
||||||
else
|
else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
|
|
||||||
/* Change it from an aliased packet to an unaliased packet */
|
/* Change it from an aliased packet to an unaliased packet */
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
if (pip->ip_p == IPPROTO_UDP || pip->ip_p == IPPROTO_TCP) {
|
if (pip->ip_p == IPPROTO_UDP || pip->ip_p == IPPROTO_TCP) {
|
||||||
int accumulate;
|
int accumulate;
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short original_port;
|
u_short original_port;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
original_port = GetOriginalPort(link);
|
original_port = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust TCP/UDP checksum */
|
/* Adjust TCP/UDP checksum */
|
||||||
accumulate = twowords(&pip->ip_src);
|
accumulate = twowords(&pip->ip_src);
|
||||||
@ -1395,8 +1400,8 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
|
|||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short original_id;
|
u_short original_id;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
original_id = GetOriginalPort(link);
|
original_id = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&pip->ip_src);
|
accumulate = twowords(&pip->ip_src);
|
||||||
|
@ -89,13 +89,13 @@ int PacketUnaliasOut(char *_ptr, int _maxpacketsize);
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
PacketAliasAddServer(struct alias_link *_link,
|
PacketAliasAddServer(struct alias_link *_lnk,
|
||||||
struct in_addr _addr, unsigned short _port);
|
struct in_addr _addr, unsigned short _port);
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
PacketAliasRedirectAddr(struct in_addr _src_addr,
|
PacketAliasRedirectAddr(struct in_addr _src_addr,
|
||||||
struct in_addr _alias_addr);
|
struct in_addr _alias_addr);
|
||||||
int PacketAliasRedirectDynamic(struct alias_link *_link);
|
int PacketAliasRedirectDynamic(struct alias_link *_lnk);
|
||||||
void PacketAliasRedirectDelete(struct alias_link *_link);
|
void PacketAliasRedirectDelete(struct alias_link *_lnk);
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
PacketAliasRedirectPort(struct in_addr _src_addr,
|
PacketAliasRedirectPort(struct in_addr _src_addr,
|
||||||
unsigned short _src_port, struct in_addr _dst_addr,
|
unsigned short _src_port, struct in_addr _dst_addr,
|
||||||
@ -140,13 +140,13 @@ int LibAliasUnaliasOut(struct libalias *, char *_ptr, int _maxpacketsize);
|
|||||||
/* Port and address redirection functions. */
|
/* Port and address redirection functions. */
|
||||||
|
|
||||||
int
|
int
|
||||||
LibAliasAddServer(struct libalias *, struct alias_link *_link,
|
LibAliasAddServer(struct libalias *, struct alias_link *_lnk,
|
||||||
struct in_addr _addr, unsigned short _port);
|
struct in_addr _addr, unsigned short _port);
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
LibAliasRedirectAddr(struct libalias *, struct in_addr _src_addr,
|
LibAliasRedirectAddr(struct libalias *, struct in_addr _src_addr,
|
||||||
struct in_addr _alias_addr);
|
struct in_addr _alias_addr);
|
||||||
int LibAliasRedirectDynamic(struct libalias *, struct alias_link *_link);
|
int LibAliasRedirectDynamic(struct libalias *, struct alias_link *_lnk);
|
||||||
void LibAliasRedirectDelete(struct libalias *, struct alias_link *_link);
|
void LibAliasRedirectDelete(struct libalias *, struct alias_link *_lnk);
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
LibAliasRedirectPort(struct libalias *, struct in_addr _src_addr,
|
LibAliasRedirectPort(struct libalias *, struct in_addr _src_addr,
|
||||||
unsigned short _src_port, struct in_addr _dst_addr,
|
unsigned short _src_port, struct in_addr _dst_addr,
|
||||||
|
@ -68,25 +68,25 @@ struct client_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip, struct alias_link *link)
|
AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip, struct alias_link *lnk)
|
||||||
{
|
{
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
|
|
||||||
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
if (ntohs(ud->uh_ulen) - sizeof(struct udphdr) >= sizeof(struct cu_header)) {
|
if (ntohs(ud->uh_ulen) - sizeof(struct udphdr) >= sizeof(struct cu_header)) {
|
||||||
struct cu_header *cu;
|
struct cu_header *cu;
|
||||||
struct alias_link *cu_link;
|
struct alias_link *cu_lnk;
|
||||||
|
|
||||||
cu = (struct cu_header *)(ud + 1);
|
cu = (struct cu_header *)(ud + 1);
|
||||||
if (cu->addr)
|
if (cu->addr)
|
||||||
cu->addr = (u_int32_t) GetAliasAddress(link).s_addr;
|
cu->addr = (u_int32_t) GetAliasAddress(lnk).s_addr;
|
||||||
|
|
||||||
cu_link = FindUdpTcpOut(la, pip->ip_src, GetDestAddress(link),
|
cu_lnk = FindUdpTcpOut(la, pip->ip_src, GetDestAddress(lnk),
|
||||||
ud->uh_dport, 0, IPPROTO_UDP, 1);
|
ud->uh_dport, 0, IPPROTO_UDP, 1);
|
||||||
|
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
if (cu_link)
|
if (cu_lnk)
|
||||||
PunchFWHole(cu_link);
|
PunchFWHole(cu_lnk);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,6 +102,7 @@ AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip, struct in_addr origina
|
|||||||
char *end;
|
char *end;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
alias_addr.s_addr = pip->ip_dst.s_addr;
|
alias_addr.s_addr = pip->ip_dst.s_addr;
|
||||||
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
cu = (struct cu_header *)(ud + 1);
|
cu = (struct cu_header *)(ud + 1);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -104,7 +104,7 @@ void
|
|||||||
AliasHandleFtpOut(
|
AliasHandleFtpOut(
|
||||||
struct libalias *la,
|
struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link, /* The link to go through (aliased port) */
|
struct alias_link *lnk, /* The link to go through (aliased port) */
|
||||||
int maxpacketsize /* The maximum size this packet can grow to
|
int maxpacketsize /* The maximum size this packet can grow to
|
||||||
(including headers) */ )
|
(including headers) */ )
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ AliasHandleFtpOut(
|
|||||||
* Check that data length is not too long and previous message was
|
* Check that data length is not too long and previous message was
|
||||||
* properly terminated with CRLF.
|
* properly terminated with CRLF.
|
||||||
*/
|
*/
|
||||||
pflags = GetProtocolFlags(link);
|
pflags = GetProtocolFlags(lnk);
|
||||||
if (dlen <= MAX_MESSAGE_SIZE && !(pflags & WAIT_CRLF)) {
|
if (dlen <= MAX_MESSAGE_SIZE && !(pflags & WAIT_CRLF)) {
|
||||||
ftp_message_type = FTP_UNKNOWN_MESSAGE;
|
ftp_message_type = FTP_UNKNOWN_MESSAGE;
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ AliasHandleFtpOut(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ftp_message_type != FTP_UNKNOWN_MESSAGE)
|
if (ftp_message_type != FTP_UNKNOWN_MESSAGE)
|
||||||
NewFtpMessage(la, pip, link, maxpacketsize, ftp_message_type);
|
NewFtpMessage(la, pip, lnk, maxpacketsize, ftp_message_type);
|
||||||
}
|
}
|
||||||
/* Track the msgs which are CRLF term'd for PORT/PASV FW breach */
|
/* Track the msgs which are CRLF term'd for PORT/PASV FW breach */
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ AliasHandleFtpOut(
|
|||||||
pflags &= ~WAIT_CRLF;
|
pflags &= ~WAIT_CRLF;
|
||||||
else
|
else
|
||||||
pflags |= WAIT_CRLF;
|
pflags |= WAIT_CRLF;
|
||||||
SetProtocolFlags(link, pflags);
|
SetProtocolFlags(lnk, pflags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,11 +551,11 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
NewFtpMessage(struct libalias *la, struct ip *pip,
|
NewFtpMessage(struct libalias *la, struct ip *pip,
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
int maxpacketsize,
|
int maxpacketsize,
|
||||||
int ftp_message_type)
|
int ftp_message_type)
|
||||||
{
|
{
|
||||||
struct alias_link *ftp_link;
|
struct alias_link *ftp_lnk;
|
||||||
|
|
||||||
/* Security checks. */
|
/* Security checks. */
|
||||||
if (pip->ip_src.s_addr != la->true_addr.s_addr)
|
if (pip->ip_src.s_addr != la->true_addr.s_addr)
|
||||||
@ -565,16 +565,16 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Establish link to address and port found in FTP control message. */
|
/* Establish link to address and port found in FTP control message. */
|
||||||
ftp_link = FindUdpTcpOut(la, la->true_addr, GetDestAddress(link),
|
ftp_lnk = FindUdpTcpOut(la, la->true_addr, GetDestAddress(lnk),
|
||||||
htons(la->true_port), 0, IPPROTO_TCP, 1);
|
htons(la->true_port), 0, IPPROTO_TCP, 1);
|
||||||
|
|
||||||
if (ftp_link != NULL) {
|
if (ftp_lnk != NULL) {
|
||||||
int slen, hlen, tlen, dlen;
|
int slen, hlen, tlen, dlen;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
|
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
/* Punch hole in firewall */
|
/* Punch hole in firewall */
|
||||||
PunchFWHole(ftp_link);
|
PunchFWHole(ftp_lnk);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Calculate data length of TCP packet */
|
/* Calculate data length of TCP packet */
|
||||||
@ -593,14 +593,14 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
|
|||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
|
|
||||||
/* Decompose alias address into quad format */
|
/* Decompose alias address into quad format */
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
ptr = (u_char *) & alias_address.s_addr;
|
ptr = (u_char *) & alias_address.s_addr;
|
||||||
a1 = *ptr++;
|
a1 = *ptr++;
|
||||||
a2 = *ptr++;
|
a2 = *ptr++;
|
||||||
a3 = *ptr++;
|
a3 = *ptr++;
|
||||||
a4 = *ptr;
|
a4 = *ptr;
|
||||||
|
|
||||||
alias_port = GetAliasPort(ftp_link);
|
alias_port = GetAliasPort(ftp_lnk);
|
||||||
|
|
||||||
switch (ftp_message_type) {
|
switch (ftp_message_type) {
|
||||||
case FTP_PORT_COMMAND:
|
case FTP_PORT_COMMAND:
|
||||||
@ -646,9 +646,9 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
|
|||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
SetAckModified(link);
|
SetAckModified(lnk);
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
AddSeq(pip, link, delta + slen - dlen);
|
AddSeq(pip, lnk, delta + slen - dlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Revise IP header */
|
/* Revise IP header */
|
||||||
|
@ -67,7 +67,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
void
|
void
|
||||||
AliasHandleIrcOut(struct libalias *la,
|
AliasHandleIrcOut(struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine */
|
struct ip *pip, /* IP packet to examine */
|
||||||
struct alias_link *link, /* Which link are we on? */
|
struct alias_link *lnk, /* Which link are we on? */
|
||||||
int maxsize /* Maximum size of IP packet including
|
int maxsize /* Maximum size of IP packet including
|
||||||
* headers */
|
* headers */
|
||||||
)
|
)
|
||||||
@ -89,7 +89,7 @@ AliasHandleIrcOut(struct libalias *la,
|
|||||||
* Return if data length is too short - assume an entire PRIVMSG in
|
* Return if data length is too short - assume an entire PRIVMSG in
|
||||||
* each packet.
|
* each packet.
|
||||||
*/
|
*/
|
||||||
if (dlen < sizeof(":A!a@n.n PRIVMSG A :aDCC 1 1a") - 1)
|
if (dlen < (int)sizeof(":A!a@n.n PRIVMSG A :aDCC 1 1a") - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Place string pointer at beginning of data */
|
/* Place string pointer at beginning of data */
|
||||||
@ -109,9 +109,9 @@ lFOUND_CTCP:
|
|||||||
{
|
{
|
||||||
char newpacket[65536]; /* Estimate of maximum packet size
|
char newpacket[65536]; /* Estimate of maximum packet size
|
||||||
* :) */
|
* :) */
|
||||||
int copyat = i; /* Same */
|
unsigned int copyat = i; /* Same */
|
||||||
int iCopy = 0; /* How much data have we written to
|
unsigned int iCopy = 0; /* How much data have we written to
|
||||||
* copy-back string? */
|
* copy-back string? */
|
||||||
unsigned long org_addr; /* Original IP address */
|
unsigned long org_addr; /* Original IP address */
|
||||||
unsigned short org_port; /* Original source port
|
unsigned short org_port; /* Original source port
|
||||||
* address */
|
* address */
|
||||||
@ -249,7 +249,7 @@ lCTCP_START:
|
|||||||
|
|
||||||
/* We've got the address and port - now alias it */
|
/* We've got the address and port - now alias it */
|
||||||
{
|
{
|
||||||
struct alias_link *dcc_link;
|
struct alias_link *dcc_lnk;
|
||||||
struct in_addr destaddr;
|
struct in_addr destaddr;
|
||||||
|
|
||||||
|
|
||||||
@ -268,11 +268,11 @@ lCTCP_START:
|
|||||||
* matter, and this would probably allow it through
|
* matter, and this would probably allow it through
|
||||||
* at least _some_ firewalls.
|
* at least _some_ firewalls.
|
||||||
*/
|
*/
|
||||||
dcc_link = FindUdpTcpOut(la, true_addr, destaddr,
|
dcc_lnk = FindUdpTcpOut(la, true_addr, destaddr,
|
||||||
true_port, 0,
|
true_port, 0,
|
||||||
IPPROTO_TCP, 1);
|
IPPROTO_TCP, 1);
|
||||||
DBprintf(("Got a DCC link\n"));
|
DBprintf(("Got a DCC link\n"));
|
||||||
if (dcc_link) {
|
if (dcc_lnk) {
|
||||||
struct in_addr alias_address; /* Address from aliasing */
|
struct in_addr alias_address; /* Address from aliasing */
|
||||||
u_short alias_port; /* Port given by
|
u_short alias_port; /* Port given by
|
||||||
* aliasing */
|
* aliasing */
|
||||||
@ -280,10 +280,10 @@ lCTCP_START:
|
|||||||
|
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
/* Generate firewall hole as appropriate */
|
/* Generate firewall hole as appropriate */
|
||||||
PunchFWHole(dcc_link);
|
PunchFWHole(dcc_lnk);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
n = snprintf(&newpacket[iCopy],
|
n = snprintf(&newpacket[iCopy],
|
||||||
sizeof(newpacket) - iCopy,
|
sizeof(newpacket) - iCopy,
|
||||||
"%lu ", (u_long) htonl(alias_address.s_addr));
|
"%lu ", (u_long) htonl(alias_address.s_addr));
|
||||||
@ -296,7 +296,7 @@ lCTCP_START:
|
|||||||
DBprintf(("DCC constructed packet overflow.\n"));
|
DBprintf(("DCC constructed packet overflow.\n"));
|
||||||
goto lBAD_CTCP;
|
goto lBAD_CTCP;
|
||||||
}
|
}
|
||||||
alias_port = GetAliasPort(dcc_link);
|
alias_port = GetAliasPort(dcc_lnk);
|
||||||
n = snprintf(&newpacket[iCopy],
|
n = snprintf(&newpacket[iCopy],
|
||||||
sizeof(newpacket) - iCopy,
|
sizeof(newpacket) - iCopy,
|
||||||
"%u", htons(alias_port));
|
"%u", htons(alias_port));
|
||||||
@ -342,9 +342,9 @@ lPACKET_DONE:
|
|||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
SetAckModified(link);
|
SetAckModified(lnk);
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
AddSeq(pip, link, delta + copyat + iCopy - dlen);
|
AddSeq(pip, lnk, delta + copyat + iCopy - dlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Revise IP header */
|
/* Revise IP header */
|
||||||
|
@ -227,43 +227,43 @@ int
|
|||||||
FindNewPortGroup(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr,
|
FindNewPortGroup(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||||
u_short _src_port, u_short _dst_port, u_short _port_count,
|
u_short _src_port, u_short _dst_port, u_short _port_count,
|
||||||
u_char _proto, u_char _align);
|
u_char _proto, u_char _align);
|
||||||
void GetFragmentAddr(struct alias_link *_link, struct in_addr *_src_addr);
|
void GetFragmentAddr(struct alias_link *_lnk, struct in_addr *_src_addr);
|
||||||
void SetFragmentAddr(struct alias_link *_link, struct in_addr _src_addr);
|
void SetFragmentAddr(struct alias_link *_lnk, struct in_addr _src_addr);
|
||||||
void GetFragmentPtr(struct alias_link *_link, char **_fptr);
|
void GetFragmentPtr(struct alias_link *_lnk, char **_fptr);
|
||||||
void SetFragmentPtr(struct alias_link *_link, char *fptr);
|
void SetFragmentPtr(struct alias_link *_lnk, char *fptr);
|
||||||
void SetStateIn(struct alias_link *_link, int _state);
|
void SetStateIn(struct alias_link *_lnk, int _state);
|
||||||
void SetStateOut(struct alias_link *_link, int _state);
|
void SetStateOut(struct alias_link *_lnk, int _state);
|
||||||
int GetStateIn (struct alias_link *_link);
|
int GetStateIn (struct alias_link *_lnk);
|
||||||
int GetStateOut(struct alias_link *_link);
|
int GetStateOut(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetOriginalAddress(struct alias_link *_link);
|
GetOriginalAddress(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetDestAddress(struct alias_link *_link);
|
GetDestAddress(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetAliasAddress(struct alias_link *_link);
|
GetAliasAddress(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetDefaultAliasAddress(struct libalias *la);
|
GetDefaultAliasAddress(struct libalias *la);
|
||||||
void SetDefaultAliasAddress(struct libalias *la, struct in_addr _alias_addr);
|
void SetDefaultAliasAddress(struct libalias *la, struct in_addr _alias_addr);
|
||||||
u_short GetOriginalPort(struct alias_link *_link);
|
u_short GetOriginalPort(struct alias_link *_lnk);
|
||||||
u_short GetAliasPort(struct alias_link *_link);
|
u_short GetAliasPort(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetProxyAddress(struct alias_link *_link);
|
GetProxyAddress(struct alias_link *_lnk);
|
||||||
void SetProxyAddress(struct alias_link *_link, struct in_addr _addr);
|
void SetProxyAddress(struct alias_link *_lnk, struct in_addr _addr);
|
||||||
u_short GetProxyPort(struct alias_link *_link);
|
u_short GetProxyPort(struct alias_link *_lnk);
|
||||||
void SetProxyPort(struct alias_link *_link, u_short _port);
|
void SetProxyPort(struct alias_link *_lnk, u_short _port);
|
||||||
void SetAckModified(struct alias_link *_link);
|
void SetAckModified(struct alias_link *_lnk);
|
||||||
int GetAckModified(struct alias_link *_link);
|
int GetAckModified(struct alias_link *_lnk);
|
||||||
int GetDeltaAckIn(struct ip *_pip, struct alias_link *_link);
|
int GetDeltaAckIn(struct ip *_pip, struct alias_link *_lnk);
|
||||||
int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_link);
|
int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_lnk);
|
||||||
void AddSeq (struct ip *_pip, struct alias_link *_link, int _delta);
|
void AddSeq (struct ip *_pip, struct alias_link *_lnk, int _delta);
|
||||||
void SetExpire (struct alias_link *_link, int _expire);
|
void SetExpire (struct alias_link *_lnk, int _expire);
|
||||||
void ClearCheckNewLink(struct libalias *la);
|
void ClearCheckNewLink(struct libalias *la);
|
||||||
void SetProtocolFlags(struct alias_link *_link, int _pflags);
|
void SetProtocolFlags(struct alias_link *_lnk, int _pflags);
|
||||||
int GetProtocolFlags(struct alias_link *_link);
|
int GetProtocolFlags(struct alias_link *_lnk);
|
||||||
void SetDestCallId(struct alias_link *_link, u_int16_t _cid);
|
void SetDestCallId(struct alias_link *_lnk, u_int16_t _cid);
|
||||||
|
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
void PunchFWHole(struct alias_link *_link);
|
void PunchFWHole(struct alias_link *_lnk);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -275,47 +275,47 @@ void HouseKeeping(struct libalias *);
|
|||||||
|
|
||||||
/* FTP routines */
|
/* FTP routines */
|
||||||
void
|
void
|
||||||
AliasHandleFtpOut(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleFtpOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
int _maxpacketsize);
|
int _maxpacketsize);
|
||||||
|
|
||||||
/* IRC routines */
|
/* IRC routines */
|
||||||
void
|
void
|
||||||
AliasHandleIrcOut(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleIrcOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
int _maxsize);
|
int _maxsize);
|
||||||
|
|
||||||
/* RTSP routines */
|
/* RTSP routines */
|
||||||
void
|
void
|
||||||
AliasHandleRtspOut(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleRtspOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
int _maxpacketsize);
|
int _maxpacketsize);
|
||||||
|
|
||||||
/* PPTP routines */
|
/* PPTP routines */
|
||||||
void AliasHandlePptpOut(struct libalias *la, struct ip *_pip, struct alias_link *_link);
|
void AliasHandlePptpOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk);
|
||||||
void AliasHandlePptpIn(struct libalias *la, struct ip *_pip, struct alias_link *_link);
|
void AliasHandlePptpIn(struct libalias *la, struct ip *_pip, struct alias_link *_lnk);
|
||||||
int AliasHandlePptpGreOut(struct libalias *la, struct ip *_pip);
|
int AliasHandlePptpGreOut(struct libalias *la, struct ip *_pip);
|
||||||
int AliasHandlePptpGreIn(struct libalias *la, struct ip *_pip);
|
int AliasHandlePptpGreIn(struct libalias *la, struct ip *_pip);
|
||||||
|
|
||||||
/* NetBIOS routines */
|
/* NetBIOS routines */
|
||||||
int
|
int
|
||||||
AliasHandleUdpNbt(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleUdpNbt(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
struct in_addr *_alias_address, u_short _alias_port);
|
struct in_addr *_alias_address, u_short _alias_port);
|
||||||
int
|
int
|
||||||
AliasHandleUdpNbtNS(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleUdpNbtNS(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
struct in_addr *_alias_address, u_short * _alias_port,
|
struct in_addr *_alias_address, u_short * _alias_port,
|
||||||
struct in_addr *_original_address, u_short * _original_port);
|
struct in_addr *_original_address, u_short * _original_port);
|
||||||
|
|
||||||
/* CUSeeMe routines */
|
/* CUSeeMe routines */
|
||||||
void AliasHandleCUSeeMeOut(struct libalias *la, struct ip *_pip, struct alias_link *_link);
|
void AliasHandleCUSeeMeOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk);
|
||||||
void AliasHandleCUSeeMeIn(struct libalias *la, struct ip *_pip, struct in_addr _original_addr);
|
void AliasHandleCUSeeMeIn(struct libalias *la, struct ip *_pip, struct in_addr _original_addr);
|
||||||
|
|
||||||
/* Skinny routines */
|
/* Skinny routines */
|
||||||
void AliasHandleSkinny(struct libalias *la, struct ip *_pip, struct alias_link *_link);
|
void AliasHandleSkinny(struct libalias *la, struct ip *_pip, struct alias_link *_lnk);
|
||||||
|
|
||||||
/* Transparent proxy routines */
|
/* Transparent proxy routines */
|
||||||
int
|
int
|
||||||
ProxyCheck(struct libalias *la, struct ip *_pip, struct in_addr *_proxy_server_addr,
|
ProxyCheck(struct libalias *la, struct ip *_pip, struct in_addr *_proxy_server_addr,
|
||||||
u_short * _proxy_server_port);
|
u_short * _proxy_server_port);
|
||||||
void
|
void
|
||||||
ProxyModify(struct libalias *la, struct alias_link *_link, struct ip *_pip,
|
ProxyModify(struct libalias *la, struct alias_link *_lnk, struct ip *_pip,
|
||||||
int _maxpacketsize, int _proxy_type);
|
int _maxpacketsize, int _proxy_type);
|
||||||
|
|
||||||
enum alias_tcp_state {
|
enum alias_tcp_state {
|
||||||
|
@ -204,7 +204,7 @@ int
|
|||||||
AliasHandleUdpNbt(
|
AliasHandleUdpNbt(
|
||||||
struct libalias *la,
|
struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
struct in_addr *alias_address,
|
struct in_addr *alias_address,
|
||||||
u_short alias_port
|
u_short alias_port
|
||||||
)
|
)
|
||||||
@ -214,6 +214,9 @@ AliasHandleUdpNbt(
|
|||||||
u_char *p = NULL;
|
u_char *p = NULL;
|
||||||
char *pmax;
|
char *pmax;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
|
(void)lnk;
|
||||||
|
|
||||||
/* Calculate data length of UDP packet */
|
/* Calculate data length of UDP packet */
|
||||||
uh = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
uh = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
pmax = (char *)uh + ntohs(uh->uh_ulen);
|
pmax = (char *)uh + ntohs(uh->uh_ulen);
|
||||||
@ -288,6 +291,8 @@ AliasHandleQuestion(
|
|||||||
NBTArguments * nbtarg)
|
NBTArguments * nbtarg)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
(void)nbtarg;
|
||||||
|
|
||||||
while (count != 0) {
|
while (count != 0) {
|
||||||
/* Name Filed */
|
/* Name Filed */
|
||||||
q = (NBTNsQuestion *) AliasHandleName((u_char *) q, pmax);
|
q = (NBTNsQuestion *) AliasHandleName((u_char *) q, pmax);
|
||||||
@ -468,6 +473,8 @@ AliasHandleResourceNULL(
|
|||||||
NBTNsResourceNULL *n;
|
NBTNsResourceNULL *n;
|
||||||
u_short bcount;
|
u_short bcount;
|
||||||
|
|
||||||
|
(void)nbtarg;
|
||||||
|
|
||||||
if (q == NULL || (char *)(q + 1) > pmax)
|
if (q == NULL || (char *)(q + 1) > pmax)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@ -501,6 +508,8 @@ AliasHandleResourceNS(
|
|||||||
NBTNsResourceNULL *n;
|
NBTNsResourceNULL *n;
|
||||||
u_short bcount;
|
u_short bcount;
|
||||||
|
|
||||||
|
(void)nbtarg;
|
||||||
|
|
||||||
if (q == NULL || (char *)(q + 1) > pmax)
|
if (q == NULL || (char *)(q + 1) > pmax)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@ -532,6 +541,8 @@ AliasHandleResourceNBSTAT(
|
|||||||
NBTNsResourceNBSTAT *n;
|
NBTNsResourceNBSTAT *n;
|
||||||
u_short bcount;
|
u_short bcount;
|
||||||
|
|
||||||
|
(void)nbtarg;
|
||||||
|
|
||||||
if (q == NULL || (char *)(q + 1) > pmax)
|
if (q == NULL || (char *)(q + 1) > pmax)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@ -621,7 +632,7 @@ int
|
|||||||
AliasHandleUdpNbtNS(
|
AliasHandleUdpNbtNS(
|
||||||
struct libalias *la,
|
struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
struct in_addr *alias_address,
|
struct in_addr *alias_address,
|
||||||
u_short * alias_port,
|
u_short * alias_port,
|
||||||
struct in_addr *original_address,
|
struct in_addr *original_address,
|
||||||
@ -633,6 +644,9 @@ AliasHandleUdpNbtNS(
|
|||||||
char *pmax;
|
char *pmax;
|
||||||
NBTArguments nbtarg;
|
NBTArguments nbtarg;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
|
(void)lnk;
|
||||||
|
|
||||||
/* Set up Common Parameter */
|
/* Set up Common Parameter */
|
||||||
nbtarg.oldaddr = *alias_address;
|
nbtarg.oldaddr = *alias_address;
|
||||||
nbtarg.oldport = *alias_port;
|
nbtarg.oldport = *alias_port;
|
||||||
|
@ -104,11 +104,11 @@ PacketUnaliasOut(char *_ptr, int _maxpacketsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PacketAliasAddServer(struct alias_link *_link,
|
PacketAliasAddServer(struct alias_link *_lnk,
|
||||||
struct in_addr _addr, unsigned short _port)
|
struct in_addr _addr, unsigned short _port)
|
||||||
{
|
{
|
||||||
|
|
||||||
return LibAliasAddServer(la, _link, _addr, _port);
|
return LibAliasAddServer(la, _lnk, _addr, _port);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
@ -121,17 +121,17 @@ PacketAliasRedirectAddr(struct in_addr _src_addr,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
PacketAliasRedirectDynamic(struct alias_link *_link)
|
PacketAliasRedirectDynamic(struct alias_link *_lnk)
|
||||||
{
|
{
|
||||||
|
|
||||||
return LibAliasRedirectDynamic(la, _link);
|
return LibAliasRedirectDynamic(la, _lnk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PacketAliasRedirectDelete(struct alias_link *_link)
|
PacketAliasRedirectDelete(struct alias_link *_lnk)
|
||||||
{
|
{
|
||||||
|
|
||||||
LibAliasRedirectDelete(la, _link);
|
LibAliasRedirectDelete(la, _lnk);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
|
@ -147,9 +147,9 @@ static PptpCallId AliasVerifyPptp(struct ip *, u_int16_t *);
|
|||||||
void
|
void
|
||||||
AliasHandlePptpOut(struct libalias *la,
|
AliasHandlePptpOut(struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link)
|
struct alias_link *lnk)
|
||||||
{ /* The PPTP control link */
|
{ /* The PPTP control link */
|
||||||
struct alias_link *pptp_link;
|
struct alias_link *pptp_lnk;
|
||||||
PptpCallId cptr;
|
PptpCallId cptr;
|
||||||
PptpCode codes;
|
PptpCode codes;
|
||||||
u_int16_t ctl_type; /* control message type */
|
u_int16_t ctl_type; /* control message type */
|
||||||
@ -169,8 +169,8 @@ AliasHandlePptpOut(struct libalias *la,
|
|||||||
* Establish PPTP link for address and Call ID found in
|
* Establish PPTP link for address and Call ID found in
|
||||||
* control message.
|
* control message.
|
||||||
*/
|
*/
|
||||||
pptp_link = AddPptp(la, GetOriginalAddress(link), GetDestAddress(link),
|
pptp_lnk = AddPptp(la, GetOriginalAddress(lnk), GetDestAddress(lnk),
|
||||||
GetAliasAddress(link), cptr->cid1);
|
GetAliasAddress(lnk), cptr->cid1);
|
||||||
break;
|
break;
|
||||||
case PPTP_CallClearRequest:
|
case PPTP_CallClearRequest:
|
||||||
case PPTP_CallDiscNotify:
|
case PPTP_CallDiscNotify:
|
||||||
@ -178,19 +178,19 @@ AliasHandlePptpOut(struct libalias *la,
|
|||||||
* Find PPTP link for address and Call ID found in control
|
* Find PPTP link for address and Call ID found in control
|
||||||
* message.
|
* message.
|
||||||
*/
|
*/
|
||||||
pptp_link = FindPptpOutByCallId(la, GetOriginalAddress(link),
|
pptp_lnk = FindPptpOutByCallId(la, GetOriginalAddress(lnk),
|
||||||
GetDestAddress(link),
|
GetDestAddress(lnk),
|
||||||
cptr->cid1);
|
cptr->cid1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pptp_link != NULL) {
|
if (pptp_lnk != NULL) {
|
||||||
int accumulate = cptr->cid1;
|
int accumulate = cptr->cid1;
|
||||||
|
|
||||||
/* alias the Call Id */
|
/* alias the Call Id */
|
||||||
cptr->cid1 = GetAliasPort(pptp_link);
|
cptr->cid1 = GetAliasPort(pptp_lnk);
|
||||||
|
|
||||||
/* Compute TCP checksum for revised packet */
|
/* Compute TCP checksum for revised packet */
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
@ -203,14 +203,14 @@ AliasHandlePptpOut(struct libalias *la,
|
|||||||
codes = (PptpCode) (cptr + 1);
|
codes = (PptpCode) (cptr + 1);
|
||||||
if (codes->resCode == 1) /* Connection
|
if (codes->resCode == 1) /* Connection
|
||||||
* established, */
|
* established, */
|
||||||
SetDestCallId(pptp_link, /* note the Peer's Call
|
SetDestCallId(pptp_lnk, /* note the Peer's Call
|
||||||
* ID. */
|
* ID. */
|
||||||
cptr->cid2);
|
cptr->cid2);
|
||||||
else
|
else
|
||||||
SetExpire(pptp_link, 0); /* Connection refused. */
|
SetExpire(pptp_lnk, 0); /* Connection refused. */
|
||||||
break;
|
break;
|
||||||
case PPTP_CallDiscNotify: /* Connection closed. */
|
case PPTP_CallDiscNotify: /* Connection closed. */
|
||||||
SetExpire(pptp_link, 0);
|
SetExpire(pptp_lnk, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,9 +219,9 @@ AliasHandlePptpOut(struct libalias *la,
|
|||||||
void
|
void
|
||||||
AliasHandlePptpIn(struct libalias *la,
|
AliasHandlePptpIn(struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link)
|
struct alias_link *lnk)
|
||||||
{ /* The PPTP control link */
|
{ /* The PPTP control link */
|
||||||
struct alias_link *pptp_link;
|
struct alias_link *pptp_lnk;
|
||||||
PptpCallId cptr;
|
PptpCallId cptr;
|
||||||
u_int16_t *pcall_id;
|
u_int16_t *pcall_id;
|
||||||
u_int16_t ctl_type; /* control message type */
|
u_int16_t ctl_type; /* control message type */
|
||||||
@ -243,26 +243,26 @@ AliasHandlePptpIn(struct libalias *la,
|
|||||||
pcall_id = &cptr->cid2;
|
pcall_id = &cptr->cid2;
|
||||||
break;
|
break;
|
||||||
case PPTP_CallDiscNotify: /* Connection closed. */
|
case PPTP_CallDiscNotify: /* Connection closed. */
|
||||||
pptp_link = FindPptpInByCallId(la, GetDestAddress(link),
|
pptp_lnk = FindPptpInByCallId(la, GetDestAddress(lnk),
|
||||||
GetAliasAddress(link),
|
GetAliasAddress(lnk),
|
||||||
cptr->cid1);
|
cptr->cid1);
|
||||||
if (pptp_link != NULL)
|
if (pptp_lnk != NULL)
|
||||||
SetExpire(pptp_link, 0);
|
SetExpire(pptp_lnk, 0);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find PPTP link for address and Call ID found in PPTP Control Msg */
|
/* Find PPTP link for address and Call ID found in PPTP Control Msg */
|
||||||
pptp_link = FindPptpInByPeerCallId(la, GetDestAddress(link),
|
pptp_lnk = FindPptpInByPeerCallId(la, GetDestAddress(lnk),
|
||||||
GetAliasAddress(link),
|
GetAliasAddress(lnk),
|
||||||
*pcall_id);
|
*pcall_id);
|
||||||
|
|
||||||
if (pptp_link != NULL) {
|
if (pptp_lnk != NULL) {
|
||||||
int accumulate = *pcall_id;
|
int accumulate = *pcall_id;
|
||||||
|
|
||||||
/* De-alias the Peer's Call Id. */
|
/* De-alias the Peer's Call Id. */
|
||||||
*pcall_id = GetOriginalPort(pptp_link);
|
*pcall_id = GetOriginalPort(pptp_lnk);
|
||||||
|
|
||||||
/* Compute TCP checksum for modified packet */
|
/* Compute TCP checksum for modified packet */
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
@ -274,10 +274,10 @@ AliasHandlePptpIn(struct libalias *la,
|
|||||||
|
|
||||||
if (codes->resCode == 1) /* Connection
|
if (codes->resCode == 1) /* Connection
|
||||||
* established, */
|
* established, */
|
||||||
SetDestCallId(pptp_link, /* note the Call ID. */
|
SetDestCallId(pptp_lnk, /* note the Call ID. */
|
||||||
cptr->cid1);
|
cptr->cid1);
|
||||||
else
|
else
|
||||||
SetExpire(pptp_link, 0); /* Connection refused. */
|
SetExpire(pptp_lnk, 0); /* Connection refused. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ AliasVerifyPptp(struct ip *pip, u_int16_t * ptype)
|
|||||||
dlen = tlen - hlen;
|
dlen = tlen - hlen;
|
||||||
|
|
||||||
/* Verify data length */
|
/* Verify data length */
|
||||||
if (dlen < (sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds)))
|
if (dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds)))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
/* Move up to PPTP message header */
|
/* Move up to PPTP message header */
|
||||||
@ -312,8 +312,8 @@ AliasVerifyPptp(struct ip *pip, u_int16_t * ptype)
|
|||||||
|
|
||||||
/* Verify data length. */
|
/* Verify data length. */
|
||||||
if ((*ptype == PPTP_OutCallReply || *ptype == PPTP_InCallReply) &&
|
if ((*ptype == PPTP_OutCallReply || *ptype == PPTP_InCallReply) &&
|
||||||
(dlen < sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) +
|
(dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) +
|
||||||
sizeof(struct pptpCodes)))
|
sizeof(struct pptpCodes))))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
else
|
else
|
||||||
return (PptpCallId) (hptr + 1);
|
return (PptpCallId) (hptr + 1);
|
||||||
@ -324,7 +324,7 @@ int
|
|||||||
AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
|
AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
GreHdr *gr;
|
GreHdr *gr;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
gr = (GreHdr *) ((char *)pip + (pip->ip_hl << 2));
|
gr = (GreHdr *) ((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
@ -332,9 +332,9 @@ AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
|
|||||||
if ((ntohl(*((u_int32_t *) gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
if ((ntohl(*((u_int32_t *) gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
link = FindPptpOutByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
lnk = FindPptpOutByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr alias_addr = GetAliasAddress(link);
|
struct in_addr alias_addr = GetAliasAddress(lnk);
|
||||||
|
|
||||||
/* Change source IP address. */
|
/* Change source IP address. */
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
@ -349,7 +349,7 @@ int
|
|||||||
AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
|
AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
GreHdr *gr;
|
GreHdr *gr;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
gr = (GreHdr *) ((char *)pip + (pip->ip_hl << 2));
|
gr = (GreHdr *) ((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
@ -357,12 +357,12 @@ AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
|
|||||||
if ((ntohl(*((u_int32_t *) gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
if ((ntohl(*((u_int32_t *) gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
link = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
lnk = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr src_addr = GetOriginalAddress(link);
|
struct in_addr src_addr = GetOriginalAddress(lnk);
|
||||||
|
|
||||||
/* De-alias the Peer's Call Id. */
|
/* De-alias the Peer's Call Id. */
|
||||||
gr->gh_call_id = GetOriginalPort(link);
|
gr->gh_call_id = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Restore original IP address. */
|
/* Restore original IP address. */
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
|
@ -274,7 +274,7 @@ RuleNumberDelete(struct libalias *la, int rule_index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ProxyEncodeTcpStream(struct alias_link *link,
|
ProxyEncodeTcpStream(struct alias_link *lnk,
|
||||||
struct ip *pip,
|
struct ip *pip,
|
||||||
int maxpacketsize)
|
int maxpacketsize)
|
||||||
{
|
{
|
||||||
@ -287,12 +287,12 @@ ProxyEncodeTcpStream(struct alias_link *link,
|
|||||||
|
|
||||||
/* Don't modify if once already modified */
|
/* Don't modify if once already modified */
|
||||||
|
|
||||||
if (GetAckModified(link))
|
if (GetAckModified(lnk))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Translate destination address and port to string form */
|
/* Translate destination address and port to string form */
|
||||||
snprintf(buffer, sizeof(buffer) - 2, "[DEST %s %d]",
|
snprintf(buffer, sizeof(buffer) - 2, "[DEST %s %d]",
|
||||||
inet_ntoa(GetProxyAddress(link)), (u_int) ntohs(GetProxyPort(link)));
|
inet_ntoa(GetProxyAddress(lnk)), (u_int) ntohs(GetProxyPort(lnk)));
|
||||||
|
|
||||||
/* Pad string out to a multiple of two in length */
|
/* Pad string out to a multiple of two in length */
|
||||||
slen = strlen(buffer);
|
slen = strlen(buffer);
|
||||||
@ -307,7 +307,7 @@ ProxyEncodeTcpStream(struct alias_link *link,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for packet overflow */
|
/* Check for packet overflow */
|
||||||
if ((ntohs(pip->ip_len) + strlen(buffer)) > maxpacketsize)
|
if ((int)(ntohs(pip->ip_len) + strlen(buffer)) > maxpacketsize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Shift existing TCP data and insert destination string */
|
/* Shift existing TCP data and insert destination string */
|
||||||
@ -335,9 +335,9 @@ ProxyEncodeTcpStream(struct alias_link *link,
|
|||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
SetAckModified(link);
|
SetAckModified(lnk);
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
AddSeq(pip, link, delta + slen);
|
AddSeq(pip, lnk, delta + slen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update IP header packet length and checksum */
|
/* Update IP header packet length and checksum */
|
||||||
@ -372,6 +372,8 @@ ProxyEncodeIpHeader(struct ip *pip,
|
|||||||
fprintf(stdout, "tcp cksum 1 = %x\n", (u_int) TcpChecksum(pip));
|
fprintf(stdout, "tcp cksum 1 = %x\n", (u_int) TcpChecksum(pip));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
(void)maxpacketsize;
|
||||||
|
|
||||||
/* Check to see that there is room to add an IP option */
|
/* Check to see that there is room to add an IP option */
|
||||||
if (pip->ip_hl > (0x0f - OPTION_LEN_INT32))
|
if (pip->ip_hl > (0x0f - OPTION_LEN_INT32))
|
||||||
return;
|
return;
|
||||||
@ -481,18 +483,21 @@ ProxyCheck(struct libalias *la, struct ip *pip,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ProxyModify(struct libalias *la, struct alias_link *link,
|
ProxyModify(struct libalias *la, struct alias_link *lnk,
|
||||||
struct ip *pip,
|
struct ip *pip,
|
||||||
int maxpacketsize,
|
int maxpacketsize,
|
||||||
int proxy_type)
|
int proxy_type)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
(void)la;
|
||||||
|
|
||||||
switch (proxy_type) {
|
switch (proxy_type) {
|
||||||
case PROXY_TYPE_ENCODE_IPHDR:
|
case PROXY_TYPE_ENCODE_IPHDR:
|
||||||
ProxyEncodeIpHeader(pip, maxpacketsize);
|
ProxyEncodeIpHeader(pip, maxpacketsize);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROXY_TYPE_ENCODE_TCPSTREAM:
|
case PROXY_TYPE_ENCODE_TCPSTREAM:
|
||||||
ProxyEncodeTcpStream(link, pip, maxpacketsize);
|
ProxyEncodeTcpStream(lnk, pip, maxpacketsize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -549,7 +554,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
|
|||||||
/* Copy command line into a buffer */
|
/* Copy command line into a buffer */
|
||||||
cmd += strspn(cmd, " \t");
|
cmd += strspn(cmd, " \t");
|
||||||
cmd_len = strlen(cmd);
|
cmd_len = strlen(cmd);
|
||||||
if (cmd_len > (sizeof(buffer) - 1))
|
if (cmd_len > (int)(sizeof(buffer) - 1))
|
||||||
return (-1);
|
return (-1);
|
||||||
strcpy(buffer, cmd);
|
strcpy(buffer, cmd);
|
||||||
|
|
||||||
|
@ -132,10 +132,12 @@ typedef enum {
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
|
alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
|
||||||
struct tcphdr *tc, struct alias_link *link,
|
struct tcphdr *tc, struct alias_link *lnk,
|
||||||
ConvDirection direction)
|
ConvDirection direction)
|
||||||
{
|
{
|
||||||
reg_msg->ipAddr = (u_int32_t) GetAliasAddress(link).s_addr;
|
(void)direction;
|
||||||
|
|
||||||
|
reg_msg->ipAddr = (u_int32_t) GetAliasAddress(lnk).s_addr;
|
||||||
|
|
||||||
tc->th_sum = 0;
|
tc->th_sum = 0;
|
||||||
tc->th_sum = TcpChecksum(pip);
|
tc->th_sum = TcpChecksum(pip);
|
||||||
@ -146,11 +148,16 @@ alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
|
|||||||
static int
|
static int
|
||||||
alias_skinny_startmedia(struct StartMediaTransmission *start_media,
|
alias_skinny_startmedia(struct StartMediaTransmission *start_media,
|
||||||
struct ip *pip, struct tcphdr *tc,
|
struct ip *pip, struct tcphdr *tc,
|
||||||
struct alias_link *link, u_int32_t localIpAddr,
|
struct alias_link *lnk, u_int32_t localIpAddr,
|
||||||
ConvDirection direction)
|
ConvDirection direction)
|
||||||
{
|
{
|
||||||
struct in_addr dst, src;
|
struct in_addr dst, src;
|
||||||
|
|
||||||
|
(void)pip;
|
||||||
|
(void)tc;
|
||||||
|
(void)lnk;
|
||||||
|
(void)direction;
|
||||||
|
|
||||||
dst.s_addr = start_media->remoteIpAddr;
|
dst.s_addr = start_media->remoteIpAddr;
|
||||||
src.s_addr = localIpAddr;
|
src.s_addr = localIpAddr;
|
||||||
|
|
||||||
@ -164,10 +171,12 @@ alias_skinny_startmedia(struct StartMediaTransmission *start_media,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
|
alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
|
||||||
struct tcphdr *tc, struct alias_link *link,
|
struct tcphdr *tc, struct alias_link *lnk,
|
||||||
ConvDirection direction)
|
ConvDirection direction)
|
||||||
{
|
{
|
||||||
port_msg->stationIpPort = (u_int32_t) ntohs(GetAliasPort(link));
|
(void)direction;
|
||||||
|
|
||||||
|
port_msg->stationIpPort = (u_int32_t) ntohs(GetAliasPort(lnk));
|
||||||
|
|
||||||
tc->th_sum = 0;
|
tc->th_sum = 0;
|
||||||
tc->th_sum = TcpChecksum(pip);
|
tc->th_sum = TcpChecksum(pip);
|
||||||
@ -178,22 +187,25 @@ alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
|
|||||||
static int
|
static int
|
||||||
alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opnrcvch_ack,
|
alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opnrcvch_ack,
|
||||||
struct ip *pip, struct tcphdr *tc,
|
struct ip *pip, struct tcphdr *tc,
|
||||||
struct alias_link *link, u_int32_t * localIpAddr,
|
struct alias_link *lnk, u_int32_t * localIpAddr,
|
||||||
ConvDirection direction)
|
ConvDirection direction)
|
||||||
{
|
{
|
||||||
struct in_addr null_addr;
|
struct in_addr null_addr;
|
||||||
struct alias_link *opnrcv_link;
|
struct alias_link *opnrcv_lnk;
|
||||||
u_int32_t localPort;
|
u_int32_t localPort;
|
||||||
|
|
||||||
|
(void)lnk;
|
||||||
|
(void)direction;
|
||||||
|
|
||||||
*localIpAddr = (u_int32_t) opnrcvch_ack->ipAddr;
|
*localIpAddr = (u_int32_t) opnrcvch_ack->ipAddr;
|
||||||
localPort = opnrcvch_ack->port;
|
localPort = opnrcvch_ack->port;
|
||||||
|
|
||||||
null_addr.s_addr = INADDR_ANY;
|
null_addr.s_addr = INADDR_ANY;
|
||||||
opnrcv_link = FindUdpTcpOut(la, pip->ip_src, null_addr,
|
opnrcv_lnk = FindUdpTcpOut(la, pip->ip_src, null_addr,
|
||||||
htons((u_short) opnrcvch_ack->port), 0,
|
htons((u_short) opnrcvch_ack->port), 0,
|
||||||
IPPROTO_UDP, 1);
|
IPPROTO_UDP, 1);
|
||||||
opnrcvch_ack->ipAddr = (u_int32_t) GetAliasAddress(opnrcv_link).s_addr;
|
opnrcvch_ack->ipAddr = (u_int32_t) GetAliasAddress(opnrcv_lnk).s_addr;
|
||||||
opnrcvch_ack->port = (u_int32_t) ntohs(GetAliasPort(opnrcv_link));
|
opnrcvch_ack->port = (u_int32_t) ntohs(GetAliasPort(opnrcv_lnk));
|
||||||
|
|
||||||
tc->th_sum = 0;
|
tc->th_sum = 0;
|
||||||
tc->th_sum = TcpChecksum(pip);
|
tc->th_sum = TcpChecksum(pip);
|
||||||
@ -202,11 +214,11 @@ alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opn
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *lnk)
|
||||||
{
|
{
|
||||||
int hlen, tlen, dlen;
|
int hlen, tlen, dlen;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
u_int32_t msgId, len, t, lip;
|
int32_t msgId, len, t, lip;
|
||||||
struct skinny_header *sd;
|
struct skinny_header *sd;
|
||||||
int orig_len, skinny_hdr_len = sizeof(struct skinny_header);
|
int orig_len, skinny_hdr_len = sizeof(struct skinny_header);
|
||||||
ConvDirection direction;
|
ConvDirection direction;
|
||||||
@ -248,7 +260,7 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
msgId = (sd->msgId);
|
msgId = (sd->msgId);
|
||||||
t = len;
|
t = len;
|
||||||
|
|
||||||
if (t < 0 || t > orig_len || t > dlen) {
|
if (t > orig_len || t > dlen) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet, invalid length \n");
|
"PacketAlias/Skinny: Not a skinny packet, invalid length \n");
|
||||||
@ -259,7 +271,7 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
case REG_MSG: {
|
case REG_MSG: {
|
||||||
struct RegisterMessage *reg_mesg;
|
struct RegisterMessage *reg_mesg;
|
||||||
|
|
||||||
if (len < sizeof(struct RegisterMessage)) {
|
if (len < (int)sizeof(struct RegisterMessage)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet, bad registration message\n");
|
"PacketAlias/Skinny: Not a skinny packet, bad registration message\n");
|
||||||
@ -271,13 +283,13 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Received a register message");
|
"PacketAlias/Skinny: Received a register message");
|
||||||
#endif
|
#endif
|
||||||
alias_skinny_reg_msg(reg_mesg, pip, tc, link, direction);
|
alias_skinny_reg_msg(reg_mesg, pip, tc, lnk, direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IP_PORT_MSG: {
|
case IP_PORT_MSG: {
|
||||||
struct IpPortMessage *port_mesg;
|
struct IpPortMessage *port_mesg;
|
||||||
|
|
||||||
if (len < sizeof(struct IpPortMessage)) {
|
if (len < (int)sizeof(struct IpPortMessage)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet, port message\n");
|
"PacketAlias/Skinny: Not a skinny packet, port message\n");
|
||||||
@ -289,13 +301,13 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
"PacketAlias/Skinny: Received ipport message\n");
|
"PacketAlias/Skinny: Received ipport message\n");
|
||||||
#endif
|
#endif
|
||||||
port_mesg = (struct IpPortMessage *)&sd->msgId;
|
port_mesg = (struct IpPortMessage *)&sd->msgId;
|
||||||
alias_skinny_port_msg(port_mesg, pip, tc, link, direction);
|
alias_skinny_port_msg(port_mesg, pip, tc, lnk, direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OPNRCVCH_ACK: {
|
case OPNRCVCH_ACK: {
|
||||||
struct OpenReceiveChannelAck *opnrcvchn_ack;
|
struct OpenReceiveChannelAck *opnrcvchn_ack;
|
||||||
|
|
||||||
if (len < sizeof(struct OpenReceiveChannelAck)) {
|
if (len < (int)sizeof(struct OpenReceiveChannelAck)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet, packet,OpnRcvChnAckMsg\n");
|
"PacketAlias/Skinny: Not a skinny packet, packet,OpnRcvChnAckMsg\n");
|
||||||
@ -307,13 +319,13 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
"PacketAlias/Skinny: Received open rcv channel msg\n");
|
"PacketAlias/Skinny: Received open rcv channel msg\n");
|
||||||
#endif
|
#endif
|
||||||
opnrcvchn_ack = (struct OpenReceiveChannelAck *)&sd->msgId;
|
opnrcvchn_ack = (struct OpenReceiveChannelAck *)&sd->msgId;
|
||||||
alias_skinny_opnrcvch_ack(la, opnrcvchn_ack, pip, tc, link, &lip, direction);
|
alias_skinny_opnrcvch_ack(la, opnrcvchn_ack, pip, tc, lnk, &lip, direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case START_MEDIATX: {
|
case START_MEDIATX: {
|
||||||
struct StartMediaTransmission *startmedia_tx;
|
struct StartMediaTransmission *startmedia_tx;
|
||||||
|
|
||||||
if (len < sizeof(struct StartMediaTransmission)) {
|
if (len < (int)sizeof(struct StartMediaTransmission)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet,StartMediaTx Message\n");
|
"PacketAlias/Skinny: Not a skinny packet,StartMediaTx Message\n");
|
||||||
@ -325,7 +337,7 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
"PacketAlias/Skinny: Received start media trans msg\n");
|
"PacketAlias/Skinny: Received start media trans msg\n");
|
||||||
#endif
|
#endif
|
||||||
startmedia_tx = (struct StartMediaTransmission *)&sd->msgId;
|
startmedia_tx = (struct StartMediaTransmission *)&sd->msgId;
|
||||||
alias_skinny_startmedia(startmedia_tx, pip, tc, link, lip, direction);
|
alias_skinny_startmedia(startmedia_tx, pip, tc, lnk, lip, direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -138,7 +138,7 @@ search_string(char *data, int dlen, const char *search_str)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
alias_rtsp_out(struct libalias *la, struct ip *pip,
|
alias_rtsp_out(struct libalias *la, struct ip *pip,
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
char *data,
|
char *data,
|
||||||
const char *port_str)
|
const char *port_str)
|
||||||
{
|
{
|
||||||
@ -151,7 +151,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
const char *transport_str = "transport:";
|
const char *transport_str = "transport:";
|
||||||
char newdata[2048], *port_data, *port_newdata, stemp[80];
|
char newdata[2048], *port_data, *port_newdata, stemp[80];
|
||||||
int links_created = 0, pkt_updated = 0;
|
int links_created = 0, pkt_updated = 0;
|
||||||
struct alias_link *rtsp_link = NULL;
|
struct alias_link *rtsp_lnk = NULL;
|
||||||
struct in_addr null_addr;
|
struct in_addr null_addr;
|
||||||
|
|
||||||
/* Calculate data length of TCP packet */
|
/* Calculate data length of TCP packet */
|
||||||
@ -171,7 +171,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
memcpy(newdata, data, pos);
|
memcpy(newdata, data, pos);
|
||||||
port_newdata = newdata + pos;
|
port_newdata = newdata + pos;
|
||||||
|
|
||||||
while (port_dlen > strlen(port_str)) {
|
while (port_dlen > (int)strlen(port_str)) {
|
||||||
/* Find keyword, appropriate port string */
|
/* Find keyword, appropriate port string */
|
||||||
pos = search_string(port_data, port_dlen, port_str);
|
pos = search_string(port_data, port_dlen, port_str);
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
@ -242,17 +242,17 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
* to port found in
|
* to port found in
|
||||||
* RTSP packet
|
* RTSP packet
|
||||||
*/
|
*/
|
||||||
rtsp_link = FindRtspOut(la, GetOriginalAddress(link), null_addr,
|
rtsp_lnk = FindRtspOut(la, GetOriginalAddress(lnk), null_addr,
|
||||||
htons(base_port + j), htons(base_alias + j),
|
htons(base_port + j), htons(base_alias + j),
|
||||||
IPPROTO_UDP);
|
IPPROTO_UDP);
|
||||||
if (rtsp_link != NULL) {
|
if (rtsp_lnk != NULL) {
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
/*
|
/*
|
||||||
* Punch
|
* Punch
|
||||||
* hole in
|
* hole in
|
||||||
* firewall
|
* firewall
|
||||||
*/
|
*/
|
||||||
PunchFWHole(rtsp_link);
|
PunchFWHole(rtsp_lnk);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -265,7 +265,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
}
|
}
|
||||||
ealias = htons(base_alias + (RTSP_PORT_GROUP - 1));
|
ealias = htons(base_alias + (RTSP_PORT_GROUP - 1));
|
||||||
}
|
}
|
||||||
if (salias && rtsp_link) {
|
if (salias && rtsp_lnk) {
|
||||||
|
|
||||||
pkt_updated = 1;
|
pkt_updated = 1;
|
||||||
|
|
||||||
@ -308,9 +308,9 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
new_dlen = port_newdata - newdata;
|
new_dlen = port_newdata - newdata;
|
||||||
memcpy(data, newdata, new_dlen);
|
memcpy(data, newdata, new_dlen);
|
||||||
|
|
||||||
SetAckModified(link);
|
SetAckModified(lnk);
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
AddSeq(pip, link, delta + new_dlen - dlen);
|
AddSeq(pip, lnk, delta + new_dlen - dlen);
|
||||||
|
|
||||||
new_len = htons(hlen + new_dlen);
|
new_len = htons(hlen + new_dlen);
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
@ -329,7 +329,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
alias_pna_out(struct libalias *la, struct ip *pip,
|
alias_pna_out(struct libalias *la, struct ip *pip,
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
char *data,
|
char *data,
|
||||||
int dlen)
|
int dlen)
|
||||||
{
|
{
|
||||||
@ -352,7 +352,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
|
|||||||
}
|
}
|
||||||
if ((ntohs(msg_id) == 1) || (ntohs(msg_id) == 7)) {
|
if ((ntohs(msg_id) == 1) || (ntohs(msg_id) == 7)) {
|
||||||
memcpy(&port, work, 2);
|
memcpy(&port, work, 2);
|
||||||
pna_links = FindUdpTcpOut(la, pip->ip_src, GetDestAddress(link),
|
pna_links = FindUdpTcpOut(la, pip->ip_src, GetDestAddress(lnk),
|
||||||
port, 0, IPPROTO_UDP, 1);
|
port, 0, IPPROTO_UDP, 1);
|
||||||
if (pna_links != NULL) {
|
if (pna_links != NULL) {
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
@ -375,7 +375,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link, int maxpacketsize)
|
AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *lnk, int maxpacketsize)
|
||||||
{
|
{
|
||||||
int hlen, tlen, dlen;
|
int hlen, tlen, dlen;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
@ -385,6 +385,8 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
|
|||||||
const char *server_port_str = "server_port";
|
const char *server_port_str = "server_port";
|
||||||
int i, parseOk;
|
int i, parseOk;
|
||||||
|
|
||||||
|
(void)maxpacketsize;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
hlen = (pip->ip_hl + tc->th_off) << 2;
|
hlen = (pip->ip_hl + tc->th_off) << 2;
|
||||||
tlen = ntohs(pip->ip_len);
|
tlen = ntohs(pip->ip_len);
|
||||||
@ -397,15 +399,15 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
|
|||||||
if ((ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_1) ||
|
if ((ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_1) ||
|
||||||
(ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_2)) {
|
(ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_2)) {
|
||||||
|
|
||||||
if (dlen >= strlen(setup)) {
|
if (dlen >= (int)strlen(setup)) {
|
||||||
if (memcmp(data, setup, strlen(setup)) == 0) {
|
if (memcmp(data, setup, strlen(setup)) == 0) {
|
||||||
alias_rtsp_out(la, pip, link, data, client_port_str);
|
alias_rtsp_out(la, pip, lnk, data, client_port_str);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dlen >= strlen(pna)) {
|
if (dlen >= (int)strlen(pna)) {
|
||||||
if (memcmp(data, pna, strlen(pna)) == 0) {
|
if (memcmp(data, pna, strlen(pna)) == 0) {
|
||||||
alias_pna_out(la, pip, link, data, dlen);
|
alias_pna_out(la, pip, lnk, data, dlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -415,10 +417,10 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
|
|||||||
* Accomodate varying number of blanks between 200 & OK
|
* Accomodate varying number of blanks between 200 & OK
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (dlen >= strlen(str200)) {
|
if (dlen >= (int)strlen(str200)) {
|
||||||
|
|
||||||
for (parseOk = 0, i = 0;
|
for (parseOk = 0, i = 0;
|
||||||
i <= dlen - strlen(str200);
|
i <= dlen - (int)strlen(str200);
|
||||||
i++) {
|
i++) {
|
||||||
if (memcmp(&data[i], str200, strlen(str200)) == 0) {
|
if (memcmp(&data[i], str200, strlen(str200)) == 0) {
|
||||||
parseOk = 1;
|
parseOk = 1;
|
||||||
@ -431,10 +433,10 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
|
|||||||
while (data[i] == ' ') /* skip blank(s) */
|
while (data[i] == ' ') /* skip blank(s) */
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if ((dlen - i) >= strlen(okstr)) {
|
if ((dlen - i) >= (int)strlen(okstr)) {
|
||||||
|
|
||||||
if (memcmp(&data[i], okstr, strlen(okstr)) == 0)
|
if (memcmp(&data[i], okstr, strlen(okstr)) == 0)
|
||||||
alias_rtsp_out(la, pip, link, data, server_port_str);
|
alias_rtsp_out(la, pip, lnk, data, server_port_str);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,8 @@ LibAliasInternetChecksum(struct libalias *la, u_short * ptr, int nbytes)
|
|||||||
{
|
{
|
||||||
int sum, oddbyte;
|
int sum, oddbyte;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
|
|
||||||
sum = 0;
|
sum = 0;
|
||||||
while (nbytes > 1) {
|
while (nbytes > 1) {
|
||||||
sum += *ptr++;
|
sum += *ptr++;
|
||||||
|
@ -8,6 +8,6 @@ SRCS= alias.c alias_cuseeme.c alias_db.c alias_ftp.c alias_irc.c \
|
|||||||
alias_nbt.c alias_pptp.c alias_proxy.c alias_skinny.c alias_smedia.c \
|
alias_nbt.c alias_pptp.c alias_proxy.c alias_skinny.c alias_smedia.c \
|
||||||
alias_util.c alias_old.c
|
alias_util.c alias_old.c
|
||||||
INCS= alias.h
|
INCS= alias.h
|
||||||
WARNS?= 2
|
WARNS?= 6
|
||||||
|
|
||||||
.include <bsd.lib.mk>
|
.include <bsd.lib.mk>
|
||||||
|
@ -162,43 +162,43 @@ static void TcpMonitorOut(struct ip *, struct alias_link *);
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
TcpMonitorIn(struct ip *pip, struct alias_link *link)
|
TcpMonitorIn(struct ip *pip, struct alias_link *lnk)
|
||||||
{
|
{
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
switch (GetStateIn(link)) {
|
switch (GetStateIn(lnk)) {
|
||||||
case ALIAS_TCP_STATE_NOT_CONNECTED:
|
case ALIAS_TCP_STATE_NOT_CONNECTED:
|
||||||
if (tc->th_flags & TH_RST)
|
if (tc->th_flags & TH_RST)
|
||||||
SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED);
|
SetStateIn(lnk, ALIAS_TCP_STATE_DISCONNECTED);
|
||||||
else if (tc->th_flags & TH_SYN)
|
else if (tc->th_flags & TH_SYN)
|
||||||
SetStateIn(link, ALIAS_TCP_STATE_CONNECTED);
|
SetStateIn(lnk, ALIAS_TCP_STATE_CONNECTED);
|
||||||
break;
|
break;
|
||||||
case ALIAS_TCP_STATE_CONNECTED:
|
case ALIAS_TCP_STATE_CONNECTED:
|
||||||
if (tc->th_flags & (TH_FIN | TH_RST))
|
if (tc->th_flags & (TH_FIN | TH_RST))
|
||||||
SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED);
|
SetStateIn(lnk, ALIAS_TCP_STATE_DISCONNECTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
TcpMonitorOut(struct ip *pip, struct alias_link *link)
|
TcpMonitorOut(struct ip *pip, struct alias_link *lnk)
|
||||||
{
|
{
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
switch (GetStateOut(link)) {
|
switch (GetStateOut(lnk)) {
|
||||||
case ALIAS_TCP_STATE_NOT_CONNECTED:
|
case ALIAS_TCP_STATE_NOT_CONNECTED:
|
||||||
if (tc->th_flags & TH_RST)
|
if (tc->th_flags & TH_RST)
|
||||||
SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED);
|
SetStateOut(lnk, ALIAS_TCP_STATE_DISCONNECTED);
|
||||||
else if (tc->th_flags & TH_SYN)
|
else if (tc->th_flags & TH_SYN)
|
||||||
SetStateOut(link, ALIAS_TCP_STATE_CONNECTED);
|
SetStateOut(lnk, ALIAS_TCP_STATE_CONNECTED);
|
||||||
break;
|
break;
|
||||||
case ALIAS_TCP_STATE_CONNECTED:
|
case ALIAS_TCP_STATE_CONNECTED:
|
||||||
if (tc->th_flags & (TH_FIN | TH_RST))
|
if (tc->th_flags & (TH_FIN | TH_RST))
|
||||||
SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED);
|
SetStateOut(lnk, ALIAS_TCP_STATE_DISCONNECTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,18 +273,18 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip)
|
|||||||
De-alias incoming echo and timestamp replies.
|
De-alias incoming echo and timestamp replies.
|
||||||
Alias incoming echo and timestamp requests.
|
Alias incoming echo and timestamp requests.
|
||||||
*/
|
*/
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
struct icmp *ic;
|
struct icmp *ic;
|
||||||
|
|
||||||
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
/* Get source address from ICMP data field and restore original data */
|
/* Get source address from ICMP data field and restore original data */
|
||||||
link = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
|
lnk = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
u_short original_id;
|
u_short original_id;
|
||||||
int accumulate;
|
int accumulate;
|
||||||
|
|
||||||
original_id = GetOriginalPort(link);
|
original_id = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = ic->icmp_id;
|
accumulate = ic->icmp_id;
|
||||||
@ -298,7 +298,7 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip)
|
|||||||
{
|
{
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
&original_address, &pip->ip_dst, 2);
|
&original_address, &pip->ip_dst, 2);
|
||||||
pip->ip_dst = original_address;
|
pip->ip_dst = original_address;
|
||||||
@ -320,7 +320,7 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip)
|
|||||||
struct icmp *ic, *ic2;
|
struct icmp *ic, *ic2;
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
||||||
ip = &ic->icmp_ip;
|
ip = &ic->icmp_ip;
|
||||||
@ -330,29 +330,29 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip)
|
|||||||
ic2 = (struct icmp *)ud;
|
ic2 = (struct icmp *)ud;
|
||||||
|
|
||||||
if (ip->ip_p == IPPROTO_UDP)
|
if (ip->ip_p == IPPROTO_UDP)
|
||||||
link = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src,
|
lnk = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src,
|
||||||
ud->uh_dport, ud->uh_sport,
|
ud->uh_dport, ud->uh_sport,
|
||||||
IPPROTO_UDP, 0);
|
IPPROTO_UDP, 0);
|
||||||
else if (ip->ip_p == IPPROTO_TCP)
|
else if (ip->ip_p == IPPROTO_TCP)
|
||||||
link = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src,
|
lnk = FindUdpTcpIn(la, ip->ip_dst, ip->ip_src,
|
||||||
tc->th_dport, tc->th_sport,
|
tc->th_dport, tc->th_sport,
|
||||||
IPPROTO_TCP, 0);
|
IPPROTO_TCP, 0);
|
||||||
else if (ip->ip_p == IPPROTO_ICMP) {
|
else if (ip->ip_p == IPPROTO_ICMP) {
|
||||||
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
|
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
|
||||||
link = FindIcmpIn(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
|
lnk = FindIcmpIn(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
|
||||||
else
|
else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
} else
|
} else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
|
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
|
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
|
||||||
int accumulate, accumulate2;
|
int accumulate, accumulate2;
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short original_port;
|
u_short original_port;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
original_port = GetOriginalPort(link);
|
original_port = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&ip->ip_src);
|
accumulate = twowords(&ip->ip_src);
|
||||||
@ -379,8 +379,8 @@ fragment contained in ICMP data section */
|
|||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short original_id;
|
u_short original_id;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
original_id = GetOriginalPort(link);
|
original_id = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&ip->ip_src);
|
accumulate = twowords(&ip->ip_src);
|
||||||
@ -451,18 +451,18 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip)
|
|||||||
Alias outgoing echo and timestamp requests.
|
Alias outgoing echo and timestamp requests.
|
||||||
De-alias outgoing echo and timestamp replies.
|
De-alias outgoing echo and timestamp replies.
|
||||||
*/
|
*/
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
struct icmp *ic;
|
struct icmp *ic;
|
||||||
|
|
||||||
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
/* Save overwritten data for when echo packet returns */
|
/* Save overwritten data for when echo packet returns */
|
||||||
link = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
|
lnk = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
u_short alias_id;
|
u_short alias_id;
|
||||||
int accumulate;
|
int accumulate;
|
||||||
|
|
||||||
alias_id = GetAliasPort(link);
|
alias_id = GetAliasPort(lnk);
|
||||||
|
|
||||||
/* Since data field is being modified, adjust ICMP checksum */
|
/* Since data field is being modified, adjust ICMP checksum */
|
||||||
accumulate = ic->icmp_id;
|
accumulate = ic->icmp_id;
|
||||||
@ -476,7 +476,7 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip)
|
|||||||
{
|
{
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
&alias_address, &pip->ip_src, 2);
|
&alias_address, &pip->ip_src, 2);
|
||||||
pip->ip_src = alias_address;
|
pip->ip_src = alias_address;
|
||||||
@ -499,7 +499,7 @@ IcmpAliasOut2(struct libalias *la, struct ip *pip)
|
|||||||
struct icmp *ic, *ic2;
|
struct icmp *ic, *ic2;
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
|
||||||
ip = &ic->icmp_ip;
|
ip = &ic->icmp_ip;
|
||||||
@ -509,29 +509,29 @@ IcmpAliasOut2(struct libalias *la, struct ip *pip)
|
|||||||
ic2 = (struct icmp *)ud;
|
ic2 = (struct icmp *)ud;
|
||||||
|
|
||||||
if (ip->ip_p == IPPROTO_UDP)
|
if (ip->ip_p == IPPROTO_UDP)
|
||||||
link = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src,
|
lnk = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src,
|
||||||
ud->uh_dport, ud->uh_sport,
|
ud->uh_dport, ud->uh_sport,
|
||||||
IPPROTO_UDP, 0);
|
IPPROTO_UDP, 0);
|
||||||
else if (ip->ip_p == IPPROTO_TCP)
|
else if (ip->ip_p == IPPROTO_TCP)
|
||||||
link = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src,
|
lnk = FindUdpTcpOut(la, ip->ip_dst, ip->ip_src,
|
||||||
tc->th_dport, tc->th_sport,
|
tc->th_dport, tc->th_sport,
|
||||||
IPPROTO_TCP, 0);
|
IPPROTO_TCP, 0);
|
||||||
else if (ip->ip_p == IPPROTO_ICMP) {
|
else if (ip->ip_p == IPPROTO_ICMP) {
|
||||||
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
|
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
|
||||||
link = FindIcmpOut(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
|
lnk = FindIcmpOut(la, ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
|
||||||
else
|
else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
} else
|
} else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
|
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
|
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
|
||||||
int accumulate;
|
int accumulate;
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
u_short alias_port;
|
u_short alias_port;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
alias_port = GetAliasPort(link);
|
alias_port = GetAliasPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&ip->ip_dst);
|
accumulate = twowords(&ip->ip_dst);
|
||||||
@ -558,8 +558,8 @@ fragment contained in ICMP data section */
|
|||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
u_short alias_id;
|
u_short alias_id;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
alias_id = GetAliasPort(link);
|
alias_id = GetAliasPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&ip->ip_dst);
|
accumulate = twowords(&ip->ip_dst);
|
||||||
@ -594,6 +594,8 @@ IcmpAliasOut(struct libalias *la, struct ip *pip, int create)
|
|||||||
int iresult;
|
int iresult;
|
||||||
struct icmp *ic;
|
struct icmp *ic;
|
||||||
|
|
||||||
|
(void)create;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
return (PKT_ALIAS_OK);
|
return (PKT_ALIAS_OK);
|
||||||
@ -632,17 +634,17 @@ ProtoAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
the dest IP address of the packet to our inside
|
the dest IP address of the packet to our inside
|
||||||
machine.
|
machine.
|
||||||
*/
|
*/
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
return (PKT_ALIAS_OK);
|
return (PKT_ALIAS_OK);
|
||||||
|
|
||||||
link = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
|
lnk = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
|
|
||||||
/* Restore original IP address */
|
/* Restore original IP address */
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
@ -663,17 +665,19 @@ ProtoAliasOut(struct libalias *la, struct ip *pip, int create)
|
|||||||
only thing which is done in this case is to alias
|
only thing which is done in this case is to alias
|
||||||
the source IP address of the packet.
|
the source IP address of the packet.
|
||||||
*/
|
*/
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
|
(void)create;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
return (PKT_ALIAS_OK);
|
return (PKT_ALIAS_OK);
|
||||||
|
|
||||||
link = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
|
lnk = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
|
|
||||||
/* Change source address */
|
/* Change source address */
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
@ -690,7 +694,7 @@ static int
|
|||||||
UdpAliasIn(struct libalias *la, struct ip *pip)
|
UdpAliasIn(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
@ -698,20 +702,20 @@ UdpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
|
|
||||||
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
link = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
|
lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
|
||||||
ud->uh_sport, ud->uh_dport,
|
ud->uh_sport, ud->uh_dport,
|
||||||
IPPROTO_UDP, 1);
|
IPPROTO_UDP, 1);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short alias_port;
|
u_short alias_port;
|
||||||
int accumulate;
|
int accumulate;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
alias_port = ud->uh_dport;
|
alias_port = ud->uh_dport;
|
||||||
ud->uh_dport = GetOriginalPort(link);
|
ud->uh_dport = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Special processing for IP encoding protocols */
|
/* Special processing for IP encoding protocols */
|
||||||
if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
|
if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
|
||||||
@ -719,10 +723,10 @@ UdpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
|
/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
|
||||||
else if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
|
else if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
|
||||||
|| ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER)
|
|| ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER)
|
||||||
r = AliasHandleUdpNbt(la, pip, link, &original_address, ud->uh_dport);
|
r = AliasHandleUdpNbt(la, pip, lnk, &original_address, ud->uh_dport);
|
||||||
else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
|
else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
|
||||||
|| ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER)
|
|| ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER)
|
||||||
r = AliasHandleUdpNbtNS(la, pip, link, &alias_address, &alias_port,
|
r = AliasHandleUdpNbtNS(la, pip, lnk, &alias_address, &alias_port,
|
||||||
&original_address, &ud->uh_dport);
|
&original_address, &ud->uh_dport);
|
||||||
|
|
||||||
/* If UDP checksum is not zero, then adjust since destination port */
|
/* If UDP checksum is not zero, then adjust since destination port */
|
||||||
@ -754,7 +758,7 @@ static int
|
|||||||
UdpAliasOut(struct libalias *la, struct ip *pip, int create)
|
UdpAliasOut(struct libalias *la, struct ip *pip, int create)
|
||||||
{
|
{
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
/* Return if proxy-only mode is enabled */
|
/* Return if proxy-only mode is enabled */
|
||||||
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
|
||||||
@ -762,26 +766,26 @@ UdpAliasOut(struct libalias *la, struct ip *pip, int create)
|
|||||||
|
|
||||||
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
link = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
|
lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
|
||||||
ud->uh_sport, ud->uh_dport,
|
ud->uh_sport, ud->uh_dport,
|
||||||
IPPROTO_UDP, create);
|
IPPROTO_UDP, create);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
u_short alias_port;
|
u_short alias_port;
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
alias_port = GetAliasPort(link);
|
alias_port = GetAliasPort(lnk);
|
||||||
|
|
||||||
/* Special processing for IP encoding protocols */
|
/* Special processing for IP encoding protocols */
|
||||||
if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
|
if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
|
||||||
AliasHandleCUSeeMeOut(la, pip, link);
|
AliasHandleCUSeeMeOut(la, pip, lnk);
|
||||||
/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
|
/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
|
||||||
else if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
|
else if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
|
||||||
|| ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER)
|
|| ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER)
|
||||||
AliasHandleUdpNbt(la, pip, link, &alias_address, alias_port);
|
AliasHandleUdpNbt(la, pip, lnk, &alias_address, alias_port);
|
||||||
else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
|
else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
|
||||||
|| ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER)
|
|| ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER)
|
||||||
AliasHandleUdpNbtNS(la, pip, link, &pip->ip_src, &ud->uh_sport,
|
AliasHandleUdpNbtNS(la, pip, lnk, &pip->ip_src, &ud->uh_sport,
|
||||||
&alias_address, &alias_port);
|
&alias_address, &alias_port);
|
||||||
/*
|
/*
|
||||||
* We don't know in advance what TID the TFTP server will choose,
|
* We don't know in advance what TID the TFTP server will choose,
|
||||||
@ -822,15 +826,15 @@ static int
|
|||||||
TcpAliasIn(struct libalias *la, struct ip *pip)
|
TcpAliasIn(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
link = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
|
lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
|
||||||
tc->th_sport, tc->th_dport,
|
tc->th_sport, tc->th_dport,
|
||||||
IPPROTO_TCP,
|
IPPROTO_TCP,
|
||||||
!(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY));
|
!(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY));
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
struct in_addr proxy_address;
|
struct in_addr proxy_address;
|
||||||
@ -841,17 +845,17 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
/* Special processing for IP encoding protocols */
|
/* Special processing for IP encoding protocols */
|
||||||
if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER
|
if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER
|
||||||
|| ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER)
|
|| ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER)
|
||||||
AliasHandlePptpIn(la, pip, link);
|
AliasHandlePptpIn(la, pip, lnk);
|
||||||
else if (la->skinnyPort != 0 && (ntohs(tc->th_dport) == la->skinnyPort
|
else if (la->skinnyPort != 0 && (ntohs(tc->th_dport) == la->skinnyPort
|
||||||
|| ntohs(tc->th_sport) == la->skinnyPort))
|
|| ntohs(tc->th_sport) == la->skinnyPort))
|
||||||
AliasHandleSkinny(la, pip, link);
|
AliasHandleSkinny(la, pip, lnk);
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
proxy_address = GetProxyAddress(link);
|
proxy_address = GetProxyAddress(lnk);
|
||||||
alias_port = tc->th_dport;
|
alias_port = tc->th_dport;
|
||||||
tc->th_dport = GetOriginalPort(link);
|
tc->th_dport = GetOriginalPort(lnk);
|
||||||
proxy_port = GetProxyPort(link);
|
proxy_port = GetProxyPort(lnk);
|
||||||
|
|
||||||
/* Adjust TCP checksum since destination port is being unaliased */
|
/* Adjust TCP checksum since destination port is being unaliased */
|
||||||
/* and destination port is being altered. */
|
/* and destination port is being altered. */
|
||||||
@ -870,10 +874,10 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
accumulate -= twowords(&proxy_address);
|
accumulate -= twowords(&proxy_address);
|
||||||
}
|
}
|
||||||
/* See if ACK number needs to be modified */
|
/* See if ACK number needs to be modified */
|
||||||
if (GetAckModified(link) == 1) {
|
if (GetAckModified(lnk) == 1) {
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
delta = GetDeltaAckIn(pip, link);
|
delta = GetDeltaAckIn(pip, lnk);
|
||||||
if (delta != 0) {
|
if (delta != 0) {
|
||||||
accumulate += twowords(&tc->th_ack);
|
accumulate += twowords(&tc->th_ack);
|
||||||
tc->th_ack = htonl(ntohl(tc->th_ack) - delta);
|
tc->th_ack = htonl(ntohl(tc->th_ack) - delta);
|
||||||
@ -897,7 +901,7 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
|
|||||||
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
||||||
|
|
||||||
/* Monitor TCP connection state */
|
/* Monitor TCP connection state */
|
||||||
TcpMonitorIn(pip, link);
|
TcpMonitorIn(pip, lnk);
|
||||||
|
|
||||||
return (PKT_ALIAS_OK);
|
return (PKT_ALIAS_OK);
|
||||||
}
|
}
|
||||||
@ -913,7 +917,7 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
|
|||||||
struct in_addr dest_address;
|
struct in_addr dest_address;
|
||||||
struct in_addr proxy_server_address;
|
struct in_addr proxy_server_address;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
@ -941,12 +945,12 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
|
|||||||
accumulate -= twowords(&pip->ip_dst);
|
accumulate -= twowords(&pip->ip_dst);
|
||||||
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
ADJUST_CHECKSUM(accumulate, pip->ip_sum);
|
||||||
}
|
}
|
||||||
link = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
|
lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
|
||||||
tc->th_sport, tc->th_dport,
|
tc->th_sport, tc->th_dport,
|
||||||
IPPROTO_TCP, create);
|
IPPROTO_TCP, create);
|
||||||
if (link == NULL)
|
if (lnk == NULL)
|
||||||
return (PKT_ALIAS_IGNORED);
|
return (PKT_ALIAS_IGNORED);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
u_short alias_port;
|
u_short alias_port;
|
||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
int accumulate;
|
int accumulate;
|
||||||
@ -955,36 +959,36 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
|
|||||||
Also modify packet to include destination encoding. This may
|
Also modify packet to include destination encoding. This may
|
||||||
change the size of IP header. */
|
change the size of IP header. */
|
||||||
if (proxy_type != 0) {
|
if (proxy_type != 0) {
|
||||||
SetProxyPort(link, dest_port);
|
SetProxyPort(lnk, dest_port);
|
||||||
SetProxyAddress(link, dest_address);
|
SetProxyAddress(lnk, dest_address);
|
||||||
ProxyModify(la, link, pip, maxpacketsize, proxy_type);
|
ProxyModify(la, lnk, pip, maxpacketsize, proxy_type);
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
}
|
}
|
||||||
/* Get alias address and port */
|
/* Get alias address and port */
|
||||||
alias_port = GetAliasPort(link);
|
alias_port = GetAliasPort(lnk);
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
|
|
||||||
/* Monitor TCP connection state */
|
/* Monitor TCP connection state */
|
||||||
TcpMonitorOut(pip, link);
|
TcpMonitorOut(pip, lnk);
|
||||||
|
|
||||||
/* Special processing for IP encoding protocols */
|
/* Special processing for IP encoding protocols */
|
||||||
if (ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER
|
if (ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER
|
||||||
|| ntohs(tc->th_sport) == FTP_CONTROL_PORT_NUMBER)
|
|| ntohs(tc->th_sport) == FTP_CONTROL_PORT_NUMBER)
|
||||||
AliasHandleFtpOut(la, pip, link, maxpacketsize);
|
AliasHandleFtpOut(la, pip, lnk, maxpacketsize);
|
||||||
else if (ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_1
|
else if (ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_1
|
||||||
|| ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_2)
|
|| ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_2)
|
||||||
AliasHandleIrcOut(la, pip, link, maxpacketsize);
|
AliasHandleIrcOut(la, pip, lnk, maxpacketsize);
|
||||||
else if (ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_1
|
else if (ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_1
|
||||||
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_1
|
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_1
|
||||||
|| ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_2
|
|| ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_2
|
||||||
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_2)
|
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_2)
|
||||||
AliasHandleRtspOut(la, pip, link, maxpacketsize);
|
AliasHandleRtspOut(la, pip, lnk, maxpacketsize);
|
||||||
else if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER
|
else if (ntohs(tc->th_dport) == PPTP_CONTROL_PORT_NUMBER
|
||||||
|| ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER)
|
|| ntohs(tc->th_sport) == PPTP_CONTROL_PORT_NUMBER)
|
||||||
AliasHandlePptpOut(la, pip, link);
|
AliasHandlePptpOut(la, pip, lnk);
|
||||||
else if (la->skinnyPort != 0 && (ntohs(tc->th_sport) == la->skinnyPort
|
else if (la->skinnyPort != 0 && (ntohs(tc->th_sport) == la->skinnyPort
|
||||||
|| ntohs(tc->th_dport) == la->skinnyPort))
|
|| ntohs(tc->th_dport) == la->skinnyPort))
|
||||||
AliasHandleSkinny(la, pip, link);
|
AliasHandleSkinny(la, pip, lnk);
|
||||||
|
|
||||||
/* Adjust TCP checksum since source port is being aliased */
|
/* Adjust TCP checksum since source port is being aliased */
|
||||||
/* and source address is being altered */
|
/* and source address is being altered */
|
||||||
@ -995,10 +999,10 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
|
|||||||
accumulate -= twowords(&alias_address);
|
accumulate -= twowords(&alias_address);
|
||||||
|
|
||||||
/* Modify sequence number if necessary */
|
/* Modify sequence number if necessary */
|
||||||
if (GetAckModified(link) == 1) {
|
if (GetAckModified(lnk) == 1) {
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
if (delta != 0) {
|
if (delta != 0) {
|
||||||
accumulate += twowords(&tc->th_seq);
|
accumulate += twowords(&tc->th_seq);
|
||||||
tc->th_seq = htonl(ntohl(tc->th_seq) + delta);
|
tc->th_seq = htonl(ntohl(tc->th_seq) + delta);
|
||||||
@ -1042,13 +1046,13 @@ static int FragmentOut(struct libalias *, struct ip *);
|
|||||||
static int
|
static int
|
||||||
FragmentIn(struct libalias *la, struct ip *pip)
|
FragmentIn(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
link = FindFragmentIn2(la, pip->ip_src, pip->ip_dst, pip->ip_id);
|
lnk = FindFragmentIn2(la, pip->ip_src, pip->ip_dst, pip->ip_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
|
|
||||||
GetFragmentAddr(link, &original_address);
|
GetFragmentAddr(lnk, &original_address);
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
&original_address, &pip->ip_dst, 2);
|
&original_address, &pip->ip_dst, 2);
|
||||||
pip->ip_dst = original_address;
|
pip->ip_dst = original_address;
|
||||||
@ -1094,14 +1098,14 @@ int
|
|||||||
LibAliasSaveFragment(struct libalias *la, char *ptr)
|
LibAliasSaveFragment(struct libalias *la, char *ptr)
|
||||||
{
|
{
|
||||||
int iresult;
|
int iresult;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
struct ip *pip;
|
struct ip *pip;
|
||||||
|
|
||||||
pip = (struct ip *)ptr;
|
pip = (struct ip *)ptr;
|
||||||
link = AddFragmentPtrLink(la, pip->ip_src, pip->ip_id);
|
lnk = AddFragmentPtrLink(la, pip->ip_src, pip->ip_id);
|
||||||
iresult = PKT_ALIAS_ERROR;
|
iresult = PKT_ALIAS_ERROR;
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
SetFragmentPtr(link, ptr);
|
SetFragmentPtr(lnk, ptr);
|
||||||
iresult = PKT_ALIAS_OK;
|
iresult = PKT_ALIAS_OK;
|
||||||
}
|
}
|
||||||
return (iresult);
|
return (iresult);
|
||||||
@ -1111,16 +1115,16 @@ LibAliasSaveFragment(struct libalias *la, char *ptr)
|
|||||||
char *
|
char *
|
||||||
LibAliasGetFragment(struct libalias *la, char *ptr)
|
LibAliasGetFragment(struct libalias *la, char *ptr)
|
||||||
{
|
{
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
char *fptr;
|
char *fptr;
|
||||||
struct ip *pip;
|
struct ip *pip;
|
||||||
|
|
||||||
pip = (struct ip *)ptr;
|
pip = (struct ip *)ptr;
|
||||||
link = FindFragmentPtr(la, pip->ip_src, pip->ip_id);
|
lnk = FindFragmentPtr(la, pip->ip_src, pip->ip_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
GetFragmentPtr(link, &fptr);
|
GetFragmentPtr(lnk, &fptr);
|
||||||
SetFragmentPtr(link, NULL);
|
SetFragmentPtr(lnk, NULL);
|
||||||
SetExpire(link, 0); /* Deletes link */
|
SetExpire(lnk, 0); /* Deletes link */
|
||||||
|
|
||||||
return (fptr);
|
return (fptr);
|
||||||
} else {
|
} else {
|
||||||
@ -1140,6 +1144,7 @@ LibAliasFragmentIn(struct libalias *la, char *ptr, /* Points to correctly
|
|||||||
struct ip *pip;
|
struct ip *pip;
|
||||||
struct ip *fpip;
|
struct ip *fpip;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
pip = (struct ip *)ptr;
|
pip = (struct ip *)ptr;
|
||||||
fpip = (struct ip *)ptr_fragment;
|
fpip = (struct ip *)ptr_fragment;
|
||||||
|
|
||||||
@ -1197,12 +1202,12 @@ LibAliasIn(struct libalias *la, char *ptr, int maxpacketsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ntohs(pip->ip_off) & IP_MF) {
|
if (ntohs(pip->ip_off) & IP_MF) {
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
link = FindFragmentIn1(la, pip->ip_src, alias_addr, pip->ip_id);
|
lnk = FindFragmentIn1(la, pip->ip_src, alias_addr, pip->ip_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
iresult = PKT_ALIAS_FOUND_HEADER_FRAGMENT;
|
iresult = PKT_ALIAS_FOUND_HEADER_FRAGMENT;
|
||||||
SetFragmentAddr(link, pip->ip_dst);
|
SetFragmentAddr(lnk, pip->ip_dst);
|
||||||
} else {
|
} else {
|
||||||
iresult = PKT_ALIAS_ERROR;
|
iresult = PKT_ALIAS_ERROR;
|
||||||
}
|
}
|
||||||
@ -1324,7 +1329,7 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
|
|||||||
struct icmp *ic;
|
struct icmp *ic;
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
int iresult = PKT_ALIAS_IGNORED;
|
int iresult = PKT_ALIAS_IGNORED;
|
||||||
|
|
||||||
pip = (struct ip *)ptr;
|
pip = (struct ip *)ptr;
|
||||||
@ -1340,27 +1345,27 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
|
|||||||
|
|
||||||
/* Find a link */
|
/* Find a link */
|
||||||
if (pip->ip_p == IPPROTO_UDP)
|
if (pip->ip_p == IPPROTO_UDP)
|
||||||
link = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src,
|
lnk = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src,
|
||||||
ud->uh_dport, ud->uh_sport,
|
ud->uh_dport, ud->uh_sport,
|
||||||
IPPROTO_UDP, 0);
|
IPPROTO_UDP, 0);
|
||||||
else if (pip->ip_p == IPPROTO_TCP)
|
else if (pip->ip_p == IPPROTO_TCP)
|
||||||
link = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src,
|
lnk = FindUdpTcpIn(la, pip->ip_dst, pip->ip_src,
|
||||||
tc->th_dport, tc->th_sport,
|
tc->th_dport, tc->th_sport,
|
||||||
IPPROTO_TCP, 0);
|
IPPROTO_TCP, 0);
|
||||||
else if (pip->ip_p == IPPROTO_ICMP)
|
else if (pip->ip_p == IPPROTO_ICMP)
|
||||||
link = FindIcmpIn(la, pip->ip_dst, pip->ip_src, ic->icmp_id, 0);
|
lnk = FindIcmpIn(la, pip->ip_dst, pip->ip_src, ic->icmp_id, 0);
|
||||||
else
|
else
|
||||||
link = NULL;
|
lnk = NULL;
|
||||||
|
|
||||||
/* Change it from an aliased packet to an unaliased packet */
|
/* Change it from an aliased packet to an unaliased packet */
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
if (pip->ip_p == IPPROTO_UDP || pip->ip_p == IPPROTO_TCP) {
|
if (pip->ip_p == IPPROTO_UDP || pip->ip_p == IPPROTO_TCP) {
|
||||||
int accumulate;
|
int accumulate;
|
||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short original_port;
|
u_short original_port;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
original_port = GetOriginalPort(link);
|
original_port = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust TCP/UDP checksum */
|
/* Adjust TCP/UDP checksum */
|
||||||
accumulate = twowords(&pip->ip_src);
|
accumulate = twowords(&pip->ip_src);
|
||||||
@ -1395,8 +1400,8 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
|
|||||||
struct in_addr original_address;
|
struct in_addr original_address;
|
||||||
u_short original_id;
|
u_short original_id;
|
||||||
|
|
||||||
original_address = GetOriginalAddress(link);
|
original_address = GetOriginalAddress(lnk);
|
||||||
original_id = GetOriginalPort(link);
|
original_id = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Adjust ICMP checksum */
|
/* Adjust ICMP checksum */
|
||||||
accumulate = twowords(&pip->ip_src);
|
accumulate = twowords(&pip->ip_src);
|
||||||
|
@ -89,13 +89,13 @@ int PacketUnaliasOut(char *_ptr, int _maxpacketsize);
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
PacketAliasAddServer(struct alias_link *_link,
|
PacketAliasAddServer(struct alias_link *_lnk,
|
||||||
struct in_addr _addr, unsigned short _port);
|
struct in_addr _addr, unsigned short _port);
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
PacketAliasRedirectAddr(struct in_addr _src_addr,
|
PacketAliasRedirectAddr(struct in_addr _src_addr,
|
||||||
struct in_addr _alias_addr);
|
struct in_addr _alias_addr);
|
||||||
int PacketAliasRedirectDynamic(struct alias_link *_link);
|
int PacketAliasRedirectDynamic(struct alias_link *_lnk);
|
||||||
void PacketAliasRedirectDelete(struct alias_link *_link);
|
void PacketAliasRedirectDelete(struct alias_link *_lnk);
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
PacketAliasRedirectPort(struct in_addr _src_addr,
|
PacketAliasRedirectPort(struct in_addr _src_addr,
|
||||||
unsigned short _src_port, struct in_addr _dst_addr,
|
unsigned short _src_port, struct in_addr _dst_addr,
|
||||||
@ -140,13 +140,13 @@ int LibAliasUnaliasOut(struct libalias *, char *_ptr, int _maxpacketsize);
|
|||||||
/* Port and address redirection functions. */
|
/* Port and address redirection functions. */
|
||||||
|
|
||||||
int
|
int
|
||||||
LibAliasAddServer(struct libalias *, struct alias_link *_link,
|
LibAliasAddServer(struct libalias *, struct alias_link *_lnk,
|
||||||
struct in_addr _addr, unsigned short _port);
|
struct in_addr _addr, unsigned short _port);
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
LibAliasRedirectAddr(struct libalias *, struct in_addr _src_addr,
|
LibAliasRedirectAddr(struct libalias *, struct in_addr _src_addr,
|
||||||
struct in_addr _alias_addr);
|
struct in_addr _alias_addr);
|
||||||
int LibAliasRedirectDynamic(struct libalias *, struct alias_link *_link);
|
int LibAliasRedirectDynamic(struct libalias *, struct alias_link *_lnk);
|
||||||
void LibAliasRedirectDelete(struct libalias *, struct alias_link *_link);
|
void LibAliasRedirectDelete(struct libalias *, struct alias_link *_lnk);
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
LibAliasRedirectPort(struct libalias *, struct in_addr _src_addr,
|
LibAliasRedirectPort(struct libalias *, struct in_addr _src_addr,
|
||||||
unsigned short _src_port, struct in_addr _dst_addr,
|
unsigned short _src_port, struct in_addr _dst_addr,
|
||||||
|
@ -68,25 +68,25 @@ struct client_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip, struct alias_link *link)
|
AliasHandleCUSeeMeOut(struct libalias *la, struct ip *pip, struct alias_link *lnk)
|
||||||
{
|
{
|
||||||
struct udphdr *ud;
|
struct udphdr *ud;
|
||||||
|
|
||||||
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
if (ntohs(ud->uh_ulen) - sizeof(struct udphdr) >= sizeof(struct cu_header)) {
|
if (ntohs(ud->uh_ulen) - sizeof(struct udphdr) >= sizeof(struct cu_header)) {
|
||||||
struct cu_header *cu;
|
struct cu_header *cu;
|
||||||
struct alias_link *cu_link;
|
struct alias_link *cu_lnk;
|
||||||
|
|
||||||
cu = (struct cu_header *)(ud + 1);
|
cu = (struct cu_header *)(ud + 1);
|
||||||
if (cu->addr)
|
if (cu->addr)
|
||||||
cu->addr = (u_int32_t) GetAliasAddress(link).s_addr;
|
cu->addr = (u_int32_t) GetAliasAddress(lnk).s_addr;
|
||||||
|
|
||||||
cu_link = FindUdpTcpOut(la, pip->ip_src, GetDestAddress(link),
|
cu_lnk = FindUdpTcpOut(la, pip->ip_src, GetDestAddress(lnk),
|
||||||
ud->uh_dport, 0, IPPROTO_UDP, 1);
|
ud->uh_dport, 0, IPPROTO_UDP, 1);
|
||||||
|
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
if (cu_link)
|
if (cu_lnk)
|
||||||
PunchFWHole(cu_link);
|
PunchFWHole(cu_lnk);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,6 +102,7 @@ AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip, struct in_addr origina
|
|||||||
char *end;
|
char *end;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
alias_addr.s_addr = pip->ip_dst.s_addr;
|
alias_addr.s_addr = pip->ip_dst.s_addr;
|
||||||
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
cu = (struct cu_header *)(ud + 1);
|
cu = (struct cu_header *)(ud + 1);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -104,7 +104,7 @@ void
|
|||||||
AliasHandleFtpOut(
|
AliasHandleFtpOut(
|
||||||
struct libalias *la,
|
struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link, /* The link to go through (aliased port) */
|
struct alias_link *lnk, /* The link to go through (aliased port) */
|
||||||
int maxpacketsize /* The maximum size this packet can grow to
|
int maxpacketsize /* The maximum size this packet can grow to
|
||||||
(including headers) */ )
|
(including headers) */ )
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ AliasHandleFtpOut(
|
|||||||
* Check that data length is not too long and previous message was
|
* Check that data length is not too long and previous message was
|
||||||
* properly terminated with CRLF.
|
* properly terminated with CRLF.
|
||||||
*/
|
*/
|
||||||
pflags = GetProtocolFlags(link);
|
pflags = GetProtocolFlags(lnk);
|
||||||
if (dlen <= MAX_MESSAGE_SIZE && !(pflags & WAIT_CRLF)) {
|
if (dlen <= MAX_MESSAGE_SIZE && !(pflags & WAIT_CRLF)) {
|
||||||
ftp_message_type = FTP_UNKNOWN_MESSAGE;
|
ftp_message_type = FTP_UNKNOWN_MESSAGE;
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ AliasHandleFtpOut(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ftp_message_type != FTP_UNKNOWN_MESSAGE)
|
if (ftp_message_type != FTP_UNKNOWN_MESSAGE)
|
||||||
NewFtpMessage(la, pip, link, maxpacketsize, ftp_message_type);
|
NewFtpMessage(la, pip, lnk, maxpacketsize, ftp_message_type);
|
||||||
}
|
}
|
||||||
/* Track the msgs which are CRLF term'd for PORT/PASV FW breach */
|
/* Track the msgs which are CRLF term'd for PORT/PASV FW breach */
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ AliasHandleFtpOut(
|
|||||||
pflags &= ~WAIT_CRLF;
|
pflags &= ~WAIT_CRLF;
|
||||||
else
|
else
|
||||||
pflags |= WAIT_CRLF;
|
pflags |= WAIT_CRLF;
|
||||||
SetProtocolFlags(link, pflags);
|
SetProtocolFlags(lnk, pflags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,11 +551,11 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
NewFtpMessage(struct libalias *la, struct ip *pip,
|
NewFtpMessage(struct libalias *la, struct ip *pip,
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
int maxpacketsize,
|
int maxpacketsize,
|
||||||
int ftp_message_type)
|
int ftp_message_type)
|
||||||
{
|
{
|
||||||
struct alias_link *ftp_link;
|
struct alias_link *ftp_lnk;
|
||||||
|
|
||||||
/* Security checks. */
|
/* Security checks. */
|
||||||
if (pip->ip_src.s_addr != la->true_addr.s_addr)
|
if (pip->ip_src.s_addr != la->true_addr.s_addr)
|
||||||
@ -565,16 +565,16 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Establish link to address and port found in FTP control message. */
|
/* Establish link to address and port found in FTP control message. */
|
||||||
ftp_link = FindUdpTcpOut(la, la->true_addr, GetDestAddress(link),
|
ftp_lnk = FindUdpTcpOut(la, la->true_addr, GetDestAddress(lnk),
|
||||||
htons(la->true_port), 0, IPPROTO_TCP, 1);
|
htons(la->true_port), 0, IPPROTO_TCP, 1);
|
||||||
|
|
||||||
if (ftp_link != NULL) {
|
if (ftp_lnk != NULL) {
|
||||||
int slen, hlen, tlen, dlen;
|
int slen, hlen, tlen, dlen;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
|
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
/* Punch hole in firewall */
|
/* Punch hole in firewall */
|
||||||
PunchFWHole(ftp_link);
|
PunchFWHole(ftp_lnk);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Calculate data length of TCP packet */
|
/* Calculate data length of TCP packet */
|
||||||
@ -593,14 +593,14 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
|
|||||||
struct in_addr alias_address;
|
struct in_addr alias_address;
|
||||||
|
|
||||||
/* Decompose alias address into quad format */
|
/* Decompose alias address into quad format */
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
ptr = (u_char *) & alias_address.s_addr;
|
ptr = (u_char *) & alias_address.s_addr;
|
||||||
a1 = *ptr++;
|
a1 = *ptr++;
|
||||||
a2 = *ptr++;
|
a2 = *ptr++;
|
||||||
a3 = *ptr++;
|
a3 = *ptr++;
|
||||||
a4 = *ptr;
|
a4 = *ptr;
|
||||||
|
|
||||||
alias_port = GetAliasPort(ftp_link);
|
alias_port = GetAliasPort(ftp_lnk);
|
||||||
|
|
||||||
switch (ftp_message_type) {
|
switch (ftp_message_type) {
|
||||||
case FTP_PORT_COMMAND:
|
case FTP_PORT_COMMAND:
|
||||||
@ -646,9 +646,9 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
|
|||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
SetAckModified(link);
|
SetAckModified(lnk);
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
AddSeq(pip, link, delta + slen - dlen);
|
AddSeq(pip, lnk, delta + slen - dlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Revise IP header */
|
/* Revise IP header */
|
||||||
|
@ -67,7 +67,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
void
|
void
|
||||||
AliasHandleIrcOut(struct libalias *la,
|
AliasHandleIrcOut(struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine */
|
struct ip *pip, /* IP packet to examine */
|
||||||
struct alias_link *link, /* Which link are we on? */
|
struct alias_link *lnk, /* Which link are we on? */
|
||||||
int maxsize /* Maximum size of IP packet including
|
int maxsize /* Maximum size of IP packet including
|
||||||
* headers */
|
* headers */
|
||||||
)
|
)
|
||||||
@ -89,7 +89,7 @@ AliasHandleIrcOut(struct libalias *la,
|
|||||||
* Return if data length is too short - assume an entire PRIVMSG in
|
* Return if data length is too short - assume an entire PRIVMSG in
|
||||||
* each packet.
|
* each packet.
|
||||||
*/
|
*/
|
||||||
if (dlen < sizeof(":A!a@n.n PRIVMSG A :aDCC 1 1a") - 1)
|
if (dlen < (int)sizeof(":A!a@n.n PRIVMSG A :aDCC 1 1a") - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Place string pointer at beginning of data */
|
/* Place string pointer at beginning of data */
|
||||||
@ -109,9 +109,9 @@ lFOUND_CTCP:
|
|||||||
{
|
{
|
||||||
char newpacket[65536]; /* Estimate of maximum packet size
|
char newpacket[65536]; /* Estimate of maximum packet size
|
||||||
* :) */
|
* :) */
|
||||||
int copyat = i; /* Same */
|
unsigned int copyat = i; /* Same */
|
||||||
int iCopy = 0; /* How much data have we written to
|
unsigned int iCopy = 0; /* How much data have we written to
|
||||||
* copy-back string? */
|
* copy-back string? */
|
||||||
unsigned long org_addr; /* Original IP address */
|
unsigned long org_addr; /* Original IP address */
|
||||||
unsigned short org_port; /* Original source port
|
unsigned short org_port; /* Original source port
|
||||||
* address */
|
* address */
|
||||||
@ -249,7 +249,7 @@ lCTCP_START:
|
|||||||
|
|
||||||
/* We've got the address and port - now alias it */
|
/* We've got the address and port - now alias it */
|
||||||
{
|
{
|
||||||
struct alias_link *dcc_link;
|
struct alias_link *dcc_lnk;
|
||||||
struct in_addr destaddr;
|
struct in_addr destaddr;
|
||||||
|
|
||||||
|
|
||||||
@ -268,11 +268,11 @@ lCTCP_START:
|
|||||||
* matter, and this would probably allow it through
|
* matter, and this would probably allow it through
|
||||||
* at least _some_ firewalls.
|
* at least _some_ firewalls.
|
||||||
*/
|
*/
|
||||||
dcc_link = FindUdpTcpOut(la, true_addr, destaddr,
|
dcc_lnk = FindUdpTcpOut(la, true_addr, destaddr,
|
||||||
true_port, 0,
|
true_port, 0,
|
||||||
IPPROTO_TCP, 1);
|
IPPROTO_TCP, 1);
|
||||||
DBprintf(("Got a DCC link\n"));
|
DBprintf(("Got a DCC link\n"));
|
||||||
if (dcc_link) {
|
if (dcc_lnk) {
|
||||||
struct in_addr alias_address; /* Address from aliasing */
|
struct in_addr alias_address; /* Address from aliasing */
|
||||||
u_short alias_port; /* Port given by
|
u_short alias_port; /* Port given by
|
||||||
* aliasing */
|
* aliasing */
|
||||||
@ -280,10 +280,10 @@ lCTCP_START:
|
|||||||
|
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
/* Generate firewall hole as appropriate */
|
/* Generate firewall hole as appropriate */
|
||||||
PunchFWHole(dcc_link);
|
PunchFWHole(dcc_lnk);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
alias_address = GetAliasAddress(link);
|
alias_address = GetAliasAddress(lnk);
|
||||||
n = snprintf(&newpacket[iCopy],
|
n = snprintf(&newpacket[iCopy],
|
||||||
sizeof(newpacket) - iCopy,
|
sizeof(newpacket) - iCopy,
|
||||||
"%lu ", (u_long) htonl(alias_address.s_addr));
|
"%lu ", (u_long) htonl(alias_address.s_addr));
|
||||||
@ -296,7 +296,7 @@ lCTCP_START:
|
|||||||
DBprintf(("DCC constructed packet overflow.\n"));
|
DBprintf(("DCC constructed packet overflow.\n"));
|
||||||
goto lBAD_CTCP;
|
goto lBAD_CTCP;
|
||||||
}
|
}
|
||||||
alias_port = GetAliasPort(dcc_link);
|
alias_port = GetAliasPort(dcc_lnk);
|
||||||
n = snprintf(&newpacket[iCopy],
|
n = snprintf(&newpacket[iCopy],
|
||||||
sizeof(newpacket) - iCopy,
|
sizeof(newpacket) - iCopy,
|
||||||
"%u", htons(alias_port));
|
"%u", htons(alias_port));
|
||||||
@ -342,9 +342,9 @@ lPACKET_DONE:
|
|||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
SetAckModified(link);
|
SetAckModified(lnk);
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
AddSeq(pip, link, delta + copyat + iCopy - dlen);
|
AddSeq(pip, lnk, delta + copyat + iCopy - dlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Revise IP header */
|
/* Revise IP header */
|
||||||
|
@ -227,43 +227,43 @@ int
|
|||||||
FindNewPortGroup(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr,
|
FindNewPortGroup(struct libalias *la, struct in_addr _dst_addr, struct in_addr _alias_addr,
|
||||||
u_short _src_port, u_short _dst_port, u_short _port_count,
|
u_short _src_port, u_short _dst_port, u_short _port_count,
|
||||||
u_char _proto, u_char _align);
|
u_char _proto, u_char _align);
|
||||||
void GetFragmentAddr(struct alias_link *_link, struct in_addr *_src_addr);
|
void GetFragmentAddr(struct alias_link *_lnk, struct in_addr *_src_addr);
|
||||||
void SetFragmentAddr(struct alias_link *_link, struct in_addr _src_addr);
|
void SetFragmentAddr(struct alias_link *_lnk, struct in_addr _src_addr);
|
||||||
void GetFragmentPtr(struct alias_link *_link, char **_fptr);
|
void GetFragmentPtr(struct alias_link *_lnk, char **_fptr);
|
||||||
void SetFragmentPtr(struct alias_link *_link, char *fptr);
|
void SetFragmentPtr(struct alias_link *_lnk, char *fptr);
|
||||||
void SetStateIn(struct alias_link *_link, int _state);
|
void SetStateIn(struct alias_link *_lnk, int _state);
|
||||||
void SetStateOut(struct alias_link *_link, int _state);
|
void SetStateOut(struct alias_link *_lnk, int _state);
|
||||||
int GetStateIn (struct alias_link *_link);
|
int GetStateIn (struct alias_link *_lnk);
|
||||||
int GetStateOut(struct alias_link *_link);
|
int GetStateOut(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetOriginalAddress(struct alias_link *_link);
|
GetOriginalAddress(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetDestAddress(struct alias_link *_link);
|
GetDestAddress(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetAliasAddress(struct alias_link *_link);
|
GetAliasAddress(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetDefaultAliasAddress(struct libalias *la);
|
GetDefaultAliasAddress(struct libalias *la);
|
||||||
void SetDefaultAliasAddress(struct libalias *la, struct in_addr _alias_addr);
|
void SetDefaultAliasAddress(struct libalias *la, struct in_addr _alias_addr);
|
||||||
u_short GetOriginalPort(struct alias_link *_link);
|
u_short GetOriginalPort(struct alias_link *_lnk);
|
||||||
u_short GetAliasPort(struct alias_link *_link);
|
u_short GetAliasPort(struct alias_link *_lnk);
|
||||||
struct in_addr
|
struct in_addr
|
||||||
GetProxyAddress(struct alias_link *_link);
|
GetProxyAddress(struct alias_link *_lnk);
|
||||||
void SetProxyAddress(struct alias_link *_link, struct in_addr _addr);
|
void SetProxyAddress(struct alias_link *_lnk, struct in_addr _addr);
|
||||||
u_short GetProxyPort(struct alias_link *_link);
|
u_short GetProxyPort(struct alias_link *_lnk);
|
||||||
void SetProxyPort(struct alias_link *_link, u_short _port);
|
void SetProxyPort(struct alias_link *_lnk, u_short _port);
|
||||||
void SetAckModified(struct alias_link *_link);
|
void SetAckModified(struct alias_link *_lnk);
|
||||||
int GetAckModified(struct alias_link *_link);
|
int GetAckModified(struct alias_link *_lnk);
|
||||||
int GetDeltaAckIn(struct ip *_pip, struct alias_link *_link);
|
int GetDeltaAckIn(struct ip *_pip, struct alias_link *_lnk);
|
||||||
int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_link);
|
int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_lnk);
|
||||||
void AddSeq (struct ip *_pip, struct alias_link *_link, int _delta);
|
void AddSeq (struct ip *_pip, struct alias_link *_lnk, int _delta);
|
||||||
void SetExpire (struct alias_link *_link, int _expire);
|
void SetExpire (struct alias_link *_lnk, int _expire);
|
||||||
void ClearCheckNewLink(struct libalias *la);
|
void ClearCheckNewLink(struct libalias *la);
|
||||||
void SetProtocolFlags(struct alias_link *_link, int _pflags);
|
void SetProtocolFlags(struct alias_link *_lnk, int _pflags);
|
||||||
int GetProtocolFlags(struct alias_link *_link);
|
int GetProtocolFlags(struct alias_link *_lnk);
|
||||||
void SetDestCallId(struct alias_link *_link, u_int16_t _cid);
|
void SetDestCallId(struct alias_link *_lnk, u_int16_t _cid);
|
||||||
|
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
void PunchFWHole(struct alias_link *_link);
|
void PunchFWHole(struct alias_link *_lnk);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -275,47 +275,47 @@ void HouseKeeping(struct libalias *);
|
|||||||
|
|
||||||
/* FTP routines */
|
/* FTP routines */
|
||||||
void
|
void
|
||||||
AliasHandleFtpOut(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleFtpOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
int _maxpacketsize);
|
int _maxpacketsize);
|
||||||
|
|
||||||
/* IRC routines */
|
/* IRC routines */
|
||||||
void
|
void
|
||||||
AliasHandleIrcOut(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleIrcOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
int _maxsize);
|
int _maxsize);
|
||||||
|
|
||||||
/* RTSP routines */
|
/* RTSP routines */
|
||||||
void
|
void
|
||||||
AliasHandleRtspOut(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleRtspOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
int _maxpacketsize);
|
int _maxpacketsize);
|
||||||
|
|
||||||
/* PPTP routines */
|
/* PPTP routines */
|
||||||
void AliasHandlePptpOut(struct libalias *la, struct ip *_pip, struct alias_link *_link);
|
void AliasHandlePptpOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk);
|
||||||
void AliasHandlePptpIn(struct libalias *la, struct ip *_pip, struct alias_link *_link);
|
void AliasHandlePptpIn(struct libalias *la, struct ip *_pip, struct alias_link *_lnk);
|
||||||
int AliasHandlePptpGreOut(struct libalias *la, struct ip *_pip);
|
int AliasHandlePptpGreOut(struct libalias *la, struct ip *_pip);
|
||||||
int AliasHandlePptpGreIn(struct libalias *la, struct ip *_pip);
|
int AliasHandlePptpGreIn(struct libalias *la, struct ip *_pip);
|
||||||
|
|
||||||
/* NetBIOS routines */
|
/* NetBIOS routines */
|
||||||
int
|
int
|
||||||
AliasHandleUdpNbt(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleUdpNbt(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
struct in_addr *_alias_address, u_short _alias_port);
|
struct in_addr *_alias_address, u_short _alias_port);
|
||||||
int
|
int
|
||||||
AliasHandleUdpNbtNS(struct libalias *la, struct ip *_pip, struct alias_link *_link,
|
AliasHandleUdpNbtNS(struct libalias *la, struct ip *_pip, struct alias_link *_lnk,
|
||||||
struct in_addr *_alias_address, u_short * _alias_port,
|
struct in_addr *_alias_address, u_short * _alias_port,
|
||||||
struct in_addr *_original_address, u_short * _original_port);
|
struct in_addr *_original_address, u_short * _original_port);
|
||||||
|
|
||||||
/* CUSeeMe routines */
|
/* CUSeeMe routines */
|
||||||
void AliasHandleCUSeeMeOut(struct libalias *la, struct ip *_pip, struct alias_link *_link);
|
void AliasHandleCUSeeMeOut(struct libalias *la, struct ip *_pip, struct alias_link *_lnk);
|
||||||
void AliasHandleCUSeeMeIn(struct libalias *la, struct ip *_pip, struct in_addr _original_addr);
|
void AliasHandleCUSeeMeIn(struct libalias *la, struct ip *_pip, struct in_addr _original_addr);
|
||||||
|
|
||||||
/* Skinny routines */
|
/* Skinny routines */
|
||||||
void AliasHandleSkinny(struct libalias *la, struct ip *_pip, struct alias_link *_link);
|
void AliasHandleSkinny(struct libalias *la, struct ip *_pip, struct alias_link *_lnk);
|
||||||
|
|
||||||
/* Transparent proxy routines */
|
/* Transparent proxy routines */
|
||||||
int
|
int
|
||||||
ProxyCheck(struct libalias *la, struct ip *_pip, struct in_addr *_proxy_server_addr,
|
ProxyCheck(struct libalias *la, struct ip *_pip, struct in_addr *_proxy_server_addr,
|
||||||
u_short * _proxy_server_port);
|
u_short * _proxy_server_port);
|
||||||
void
|
void
|
||||||
ProxyModify(struct libalias *la, struct alias_link *_link, struct ip *_pip,
|
ProxyModify(struct libalias *la, struct alias_link *_lnk, struct ip *_pip,
|
||||||
int _maxpacketsize, int _proxy_type);
|
int _maxpacketsize, int _proxy_type);
|
||||||
|
|
||||||
enum alias_tcp_state {
|
enum alias_tcp_state {
|
||||||
|
@ -204,7 +204,7 @@ int
|
|||||||
AliasHandleUdpNbt(
|
AliasHandleUdpNbt(
|
||||||
struct libalias *la,
|
struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
struct in_addr *alias_address,
|
struct in_addr *alias_address,
|
||||||
u_short alias_port
|
u_short alias_port
|
||||||
)
|
)
|
||||||
@ -214,6 +214,9 @@ AliasHandleUdpNbt(
|
|||||||
u_char *p = NULL;
|
u_char *p = NULL;
|
||||||
char *pmax;
|
char *pmax;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
|
(void)lnk;
|
||||||
|
|
||||||
/* Calculate data length of UDP packet */
|
/* Calculate data length of UDP packet */
|
||||||
uh = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
uh = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
pmax = (char *)uh + ntohs(uh->uh_ulen);
|
pmax = (char *)uh + ntohs(uh->uh_ulen);
|
||||||
@ -288,6 +291,8 @@ AliasHandleQuestion(
|
|||||||
NBTArguments * nbtarg)
|
NBTArguments * nbtarg)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
(void)nbtarg;
|
||||||
|
|
||||||
while (count != 0) {
|
while (count != 0) {
|
||||||
/* Name Filed */
|
/* Name Filed */
|
||||||
q = (NBTNsQuestion *) AliasHandleName((u_char *) q, pmax);
|
q = (NBTNsQuestion *) AliasHandleName((u_char *) q, pmax);
|
||||||
@ -468,6 +473,8 @@ AliasHandleResourceNULL(
|
|||||||
NBTNsResourceNULL *n;
|
NBTNsResourceNULL *n;
|
||||||
u_short bcount;
|
u_short bcount;
|
||||||
|
|
||||||
|
(void)nbtarg;
|
||||||
|
|
||||||
if (q == NULL || (char *)(q + 1) > pmax)
|
if (q == NULL || (char *)(q + 1) > pmax)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@ -501,6 +508,8 @@ AliasHandleResourceNS(
|
|||||||
NBTNsResourceNULL *n;
|
NBTNsResourceNULL *n;
|
||||||
u_short bcount;
|
u_short bcount;
|
||||||
|
|
||||||
|
(void)nbtarg;
|
||||||
|
|
||||||
if (q == NULL || (char *)(q + 1) > pmax)
|
if (q == NULL || (char *)(q + 1) > pmax)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@ -532,6 +541,8 @@ AliasHandleResourceNBSTAT(
|
|||||||
NBTNsResourceNBSTAT *n;
|
NBTNsResourceNBSTAT *n;
|
||||||
u_short bcount;
|
u_short bcount;
|
||||||
|
|
||||||
|
(void)nbtarg;
|
||||||
|
|
||||||
if (q == NULL || (char *)(q + 1) > pmax)
|
if (q == NULL || (char *)(q + 1) > pmax)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
@ -621,7 +632,7 @@ int
|
|||||||
AliasHandleUdpNbtNS(
|
AliasHandleUdpNbtNS(
|
||||||
struct libalias *la,
|
struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
struct in_addr *alias_address,
|
struct in_addr *alias_address,
|
||||||
u_short * alias_port,
|
u_short * alias_port,
|
||||||
struct in_addr *original_address,
|
struct in_addr *original_address,
|
||||||
@ -633,6 +644,9 @@ AliasHandleUdpNbtNS(
|
|||||||
char *pmax;
|
char *pmax;
|
||||||
NBTArguments nbtarg;
|
NBTArguments nbtarg;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
|
(void)lnk;
|
||||||
|
|
||||||
/* Set up Common Parameter */
|
/* Set up Common Parameter */
|
||||||
nbtarg.oldaddr = *alias_address;
|
nbtarg.oldaddr = *alias_address;
|
||||||
nbtarg.oldport = *alias_port;
|
nbtarg.oldport = *alias_port;
|
||||||
|
@ -104,11 +104,11 @@ PacketUnaliasOut(char *_ptr, int _maxpacketsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PacketAliasAddServer(struct alias_link *_link,
|
PacketAliasAddServer(struct alias_link *_lnk,
|
||||||
struct in_addr _addr, unsigned short _port)
|
struct in_addr _addr, unsigned short _port)
|
||||||
{
|
{
|
||||||
|
|
||||||
return LibAliasAddServer(la, _link, _addr, _port);
|
return LibAliasAddServer(la, _lnk, _addr, _port);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
@ -121,17 +121,17 @@ PacketAliasRedirectAddr(struct in_addr _src_addr,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
PacketAliasRedirectDynamic(struct alias_link *_link)
|
PacketAliasRedirectDynamic(struct alias_link *_lnk)
|
||||||
{
|
{
|
||||||
|
|
||||||
return LibAliasRedirectDynamic(la, _link);
|
return LibAliasRedirectDynamic(la, _lnk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PacketAliasRedirectDelete(struct alias_link *_link)
|
PacketAliasRedirectDelete(struct alias_link *_lnk)
|
||||||
{
|
{
|
||||||
|
|
||||||
LibAliasRedirectDelete(la, _link);
|
LibAliasRedirectDelete(la, _lnk);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct alias_link *
|
struct alias_link *
|
||||||
|
@ -147,9 +147,9 @@ static PptpCallId AliasVerifyPptp(struct ip *, u_int16_t *);
|
|||||||
void
|
void
|
||||||
AliasHandlePptpOut(struct libalias *la,
|
AliasHandlePptpOut(struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link)
|
struct alias_link *lnk)
|
||||||
{ /* The PPTP control link */
|
{ /* The PPTP control link */
|
||||||
struct alias_link *pptp_link;
|
struct alias_link *pptp_lnk;
|
||||||
PptpCallId cptr;
|
PptpCallId cptr;
|
||||||
PptpCode codes;
|
PptpCode codes;
|
||||||
u_int16_t ctl_type; /* control message type */
|
u_int16_t ctl_type; /* control message type */
|
||||||
@ -169,8 +169,8 @@ AliasHandlePptpOut(struct libalias *la,
|
|||||||
* Establish PPTP link for address and Call ID found in
|
* Establish PPTP link for address and Call ID found in
|
||||||
* control message.
|
* control message.
|
||||||
*/
|
*/
|
||||||
pptp_link = AddPptp(la, GetOriginalAddress(link), GetDestAddress(link),
|
pptp_lnk = AddPptp(la, GetOriginalAddress(lnk), GetDestAddress(lnk),
|
||||||
GetAliasAddress(link), cptr->cid1);
|
GetAliasAddress(lnk), cptr->cid1);
|
||||||
break;
|
break;
|
||||||
case PPTP_CallClearRequest:
|
case PPTP_CallClearRequest:
|
||||||
case PPTP_CallDiscNotify:
|
case PPTP_CallDiscNotify:
|
||||||
@ -178,19 +178,19 @@ AliasHandlePptpOut(struct libalias *la,
|
|||||||
* Find PPTP link for address and Call ID found in control
|
* Find PPTP link for address and Call ID found in control
|
||||||
* message.
|
* message.
|
||||||
*/
|
*/
|
||||||
pptp_link = FindPptpOutByCallId(la, GetOriginalAddress(link),
|
pptp_lnk = FindPptpOutByCallId(la, GetOriginalAddress(lnk),
|
||||||
GetDestAddress(link),
|
GetDestAddress(lnk),
|
||||||
cptr->cid1);
|
cptr->cid1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pptp_link != NULL) {
|
if (pptp_lnk != NULL) {
|
||||||
int accumulate = cptr->cid1;
|
int accumulate = cptr->cid1;
|
||||||
|
|
||||||
/* alias the Call Id */
|
/* alias the Call Id */
|
||||||
cptr->cid1 = GetAliasPort(pptp_link);
|
cptr->cid1 = GetAliasPort(pptp_lnk);
|
||||||
|
|
||||||
/* Compute TCP checksum for revised packet */
|
/* Compute TCP checksum for revised packet */
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
@ -203,14 +203,14 @@ AliasHandlePptpOut(struct libalias *la,
|
|||||||
codes = (PptpCode) (cptr + 1);
|
codes = (PptpCode) (cptr + 1);
|
||||||
if (codes->resCode == 1) /* Connection
|
if (codes->resCode == 1) /* Connection
|
||||||
* established, */
|
* established, */
|
||||||
SetDestCallId(pptp_link, /* note the Peer's Call
|
SetDestCallId(pptp_lnk, /* note the Peer's Call
|
||||||
* ID. */
|
* ID. */
|
||||||
cptr->cid2);
|
cptr->cid2);
|
||||||
else
|
else
|
||||||
SetExpire(pptp_link, 0); /* Connection refused. */
|
SetExpire(pptp_lnk, 0); /* Connection refused. */
|
||||||
break;
|
break;
|
||||||
case PPTP_CallDiscNotify: /* Connection closed. */
|
case PPTP_CallDiscNotify: /* Connection closed. */
|
||||||
SetExpire(pptp_link, 0);
|
SetExpire(pptp_lnk, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,9 +219,9 @@ AliasHandlePptpOut(struct libalias *la,
|
|||||||
void
|
void
|
||||||
AliasHandlePptpIn(struct libalias *la,
|
AliasHandlePptpIn(struct libalias *la,
|
||||||
struct ip *pip, /* IP packet to examine/patch */
|
struct ip *pip, /* IP packet to examine/patch */
|
||||||
struct alias_link *link)
|
struct alias_link *lnk)
|
||||||
{ /* The PPTP control link */
|
{ /* The PPTP control link */
|
||||||
struct alias_link *pptp_link;
|
struct alias_link *pptp_lnk;
|
||||||
PptpCallId cptr;
|
PptpCallId cptr;
|
||||||
u_int16_t *pcall_id;
|
u_int16_t *pcall_id;
|
||||||
u_int16_t ctl_type; /* control message type */
|
u_int16_t ctl_type; /* control message type */
|
||||||
@ -243,26 +243,26 @@ AliasHandlePptpIn(struct libalias *la,
|
|||||||
pcall_id = &cptr->cid2;
|
pcall_id = &cptr->cid2;
|
||||||
break;
|
break;
|
||||||
case PPTP_CallDiscNotify: /* Connection closed. */
|
case PPTP_CallDiscNotify: /* Connection closed. */
|
||||||
pptp_link = FindPptpInByCallId(la, GetDestAddress(link),
|
pptp_lnk = FindPptpInByCallId(la, GetDestAddress(lnk),
|
||||||
GetAliasAddress(link),
|
GetAliasAddress(lnk),
|
||||||
cptr->cid1);
|
cptr->cid1);
|
||||||
if (pptp_link != NULL)
|
if (pptp_lnk != NULL)
|
||||||
SetExpire(pptp_link, 0);
|
SetExpire(pptp_lnk, 0);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find PPTP link for address and Call ID found in PPTP Control Msg */
|
/* Find PPTP link for address and Call ID found in PPTP Control Msg */
|
||||||
pptp_link = FindPptpInByPeerCallId(la, GetDestAddress(link),
|
pptp_lnk = FindPptpInByPeerCallId(la, GetDestAddress(lnk),
|
||||||
GetAliasAddress(link),
|
GetAliasAddress(lnk),
|
||||||
*pcall_id);
|
*pcall_id);
|
||||||
|
|
||||||
if (pptp_link != NULL) {
|
if (pptp_lnk != NULL) {
|
||||||
int accumulate = *pcall_id;
|
int accumulate = *pcall_id;
|
||||||
|
|
||||||
/* De-alias the Peer's Call Id. */
|
/* De-alias the Peer's Call Id. */
|
||||||
*pcall_id = GetOriginalPort(pptp_link);
|
*pcall_id = GetOriginalPort(pptp_lnk);
|
||||||
|
|
||||||
/* Compute TCP checksum for modified packet */
|
/* Compute TCP checksum for modified packet */
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
@ -274,10 +274,10 @@ AliasHandlePptpIn(struct libalias *la,
|
|||||||
|
|
||||||
if (codes->resCode == 1) /* Connection
|
if (codes->resCode == 1) /* Connection
|
||||||
* established, */
|
* established, */
|
||||||
SetDestCallId(pptp_link, /* note the Call ID. */
|
SetDestCallId(pptp_lnk, /* note the Call ID. */
|
||||||
cptr->cid1);
|
cptr->cid1);
|
||||||
else
|
else
|
||||||
SetExpire(pptp_link, 0); /* Connection refused. */
|
SetExpire(pptp_lnk, 0); /* Connection refused. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ AliasVerifyPptp(struct ip *pip, u_int16_t * ptype)
|
|||||||
dlen = tlen - hlen;
|
dlen = tlen - hlen;
|
||||||
|
|
||||||
/* Verify data length */
|
/* Verify data length */
|
||||||
if (dlen < (sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds)))
|
if (dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds)))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
/* Move up to PPTP message header */
|
/* Move up to PPTP message header */
|
||||||
@ -312,8 +312,8 @@ AliasVerifyPptp(struct ip *pip, u_int16_t * ptype)
|
|||||||
|
|
||||||
/* Verify data length. */
|
/* Verify data length. */
|
||||||
if ((*ptype == PPTP_OutCallReply || *ptype == PPTP_InCallReply) &&
|
if ((*ptype == PPTP_OutCallReply || *ptype == PPTP_InCallReply) &&
|
||||||
(dlen < sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) +
|
(dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) +
|
||||||
sizeof(struct pptpCodes)))
|
sizeof(struct pptpCodes))))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
else
|
else
|
||||||
return (PptpCallId) (hptr + 1);
|
return (PptpCallId) (hptr + 1);
|
||||||
@ -324,7 +324,7 @@ int
|
|||||||
AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
|
AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
GreHdr *gr;
|
GreHdr *gr;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
gr = (GreHdr *) ((char *)pip + (pip->ip_hl << 2));
|
gr = (GreHdr *) ((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
@ -332,9 +332,9 @@ AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
|
|||||||
if ((ntohl(*((u_int32_t *) gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
if ((ntohl(*((u_int32_t *) gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
link = FindPptpOutByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
lnk = FindPptpOutByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr alias_addr = GetAliasAddress(link);
|
struct in_addr alias_addr = GetAliasAddress(lnk);
|
||||||
|
|
||||||
/* Change source IP address. */
|
/* Change source IP address. */
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
@ -349,7 +349,7 @@ int
|
|||||||
AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
|
AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
|
||||||
{
|
{
|
||||||
GreHdr *gr;
|
GreHdr *gr;
|
||||||
struct alias_link *link;
|
struct alias_link *lnk;
|
||||||
|
|
||||||
gr = (GreHdr *) ((char *)pip + (pip->ip_hl << 2));
|
gr = (GreHdr *) ((char *)pip + (pip->ip_hl << 2));
|
||||||
|
|
||||||
@ -357,12 +357,12 @@ AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
|
|||||||
if ((ntohl(*((u_int32_t *) gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
if ((ntohl(*((u_int32_t *) gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
link = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
lnk = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
||||||
if (link != NULL) {
|
if (lnk != NULL) {
|
||||||
struct in_addr src_addr = GetOriginalAddress(link);
|
struct in_addr src_addr = GetOriginalAddress(lnk);
|
||||||
|
|
||||||
/* De-alias the Peer's Call Id. */
|
/* De-alias the Peer's Call Id. */
|
||||||
gr->gh_call_id = GetOriginalPort(link);
|
gr->gh_call_id = GetOriginalPort(lnk);
|
||||||
|
|
||||||
/* Restore original IP address. */
|
/* Restore original IP address. */
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
|
@ -274,7 +274,7 @@ RuleNumberDelete(struct libalias *la, int rule_index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ProxyEncodeTcpStream(struct alias_link *link,
|
ProxyEncodeTcpStream(struct alias_link *lnk,
|
||||||
struct ip *pip,
|
struct ip *pip,
|
||||||
int maxpacketsize)
|
int maxpacketsize)
|
||||||
{
|
{
|
||||||
@ -287,12 +287,12 @@ ProxyEncodeTcpStream(struct alias_link *link,
|
|||||||
|
|
||||||
/* Don't modify if once already modified */
|
/* Don't modify if once already modified */
|
||||||
|
|
||||||
if (GetAckModified(link))
|
if (GetAckModified(lnk))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Translate destination address and port to string form */
|
/* Translate destination address and port to string form */
|
||||||
snprintf(buffer, sizeof(buffer) - 2, "[DEST %s %d]",
|
snprintf(buffer, sizeof(buffer) - 2, "[DEST %s %d]",
|
||||||
inet_ntoa(GetProxyAddress(link)), (u_int) ntohs(GetProxyPort(link)));
|
inet_ntoa(GetProxyAddress(lnk)), (u_int) ntohs(GetProxyPort(lnk)));
|
||||||
|
|
||||||
/* Pad string out to a multiple of two in length */
|
/* Pad string out to a multiple of two in length */
|
||||||
slen = strlen(buffer);
|
slen = strlen(buffer);
|
||||||
@ -307,7 +307,7 @@ ProxyEncodeTcpStream(struct alias_link *link,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for packet overflow */
|
/* Check for packet overflow */
|
||||||
if ((ntohs(pip->ip_len) + strlen(buffer)) > maxpacketsize)
|
if ((int)(ntohs(pip->ip_len) + strlen(buffer)) > maxpacketsize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Shift existing TCP data and insert destination string */
|
/* Shift existing TCP data and insert destination string */
|
||||||
@ -335,9 +335,9 @@ ProxyEncodeTcpStream(struct alias_link *link,
|
|||||||
{
|
{
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
SetAckModified(link);
|
SetAckModified(lnk);
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
AddSeq(pip, link, delta + slen);
|
AddSeq(pip, lnk, delta + slen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update IP header packet length and checksum */
|
/* Update IP header packet length and checksum */
|
||||||
@ -372,6 +372,8 @@ ProxyEncodeIpHeader(struct ip *pip,
|
|||||||
fprintf(stdout, "tcp cksum 1 = %x\n", (u_int) TcpChecksum(pip));
|
fprintf(stdout, "tcp cksum 1 = %x\n", (u_int) TcpChecksum(pip));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
(void)maxpacketsize;
|
||||||
|
|
||||||
/* Check to see that there is room to add an IP option */
|
/* Check to see that there is room to add an IP option */
|
||||||
if (pip->ip_hl > (0x0f - OPTION_LEN_INT32))
|
if (pip->ip_hl > (0x0f - OPTION_LEN_INT32))
|
||||||
return;
|
return;
|
||||||
@ -481,18 +483,21 @@ ProxyCheck(struct libalias *la, struct ip *pip,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ProxyModify(struct libalias *la, struct alias_link *link,
|
ProxyModify(struct libalias *la, struct alias_link *lnk,
|
||||||
struct ip *pip,
|
struct ip *pip,
|
||||||
int maxpacketsize,
|
int maxpacketsize,
|
||||||
int proxy_type)
|
int proxy_type)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
(void)la;
|
||||||
|
|
||||||
switch (proxy_type) {
|
switch (proxy_type) {
|
||||||
case PROXY_TYPE_ENCODE_IPHDR:
|
case PROXY_TYPE_ENCODE_IPHDR:
|
||||||
ProxyEncodeIpHeader(pip, maxpacketsize);
|
ProxyEncodeIpHeader(pip, maxpacketsize);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROXY_TYPE_ENCODE_TCPSTREAM:
|
case PROXY_TYPE_ENCODE_TCPSTREAM:
|
||||||
ProxyEncodeTcpStream(link, pip, maxpacketsize);
|
ProxyEncodeTcpStream(lnk, pip, maxpacketsize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -549,7 +554,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
|
|||||||
/* Copy command line into a buffer */
|
/* Copy command line into a buffer */
|
||||||
cmd += strspn(cmd, " \t");
|
cmd += strspn(cmd, " \t");
|
||||||
cmd_len = strlen(cmd);
|
cmd_len = strlen(cmd);
|
||||||
if (cmd_len > (sizeof(buffer) - 1))
|
if (cmd_len > (int)(sizeof(buffer) - 1))
|
||||||
return (-1);
|
return (-1);
|
||||||
strcpy(buffer, cmd);
|
strcpy(buffer, cmd);
|
||||||
|
|
||||||
|
@ -132,10 +132,12 @@ typedef enum {
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
|
alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
|
||||||
struct tcphdr *tc, struct alias_link *link,
|
struct tcphdr *tc, struct alias_link *lnk,
|
||||||
ConvDirection direction)
|
ConvDirection direction)
|
||||||
{
|
{
|
||||||
reg_msg->ipAddr = (u_int32_t) GetAliasAddress(link).s_addr;
|
(void)direction;
|
||||||
|
|
||||||
|
reg_msg->ipAddr = (u_int32_t) GetAliasAddress(lnk).s_addr;
|
||||||
|
|
||||||
tc->th_sum = 0;
|
tc->th_sum = 0;
|
||||||
tc->th_sum = TcpChecksum(pip);
|
tc->th_sum = TcpChecksum(pip);
|
||||||
@ -146,11 +148,16 @@ alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
|
|||||||
static int
|
static int
|
||||||
alias_skinny_startmedia(struct StartMediaTransmission *start_media,
|
alias_skinny_startmedia(struct StartMediaTransmission *start_media,
|
||||||
struct ip *pip, struct tcphdr *tc,
|
struct ip *pip, struct tcphdr *tc,
|
||||||
struct alias_link *link, u_int32_t localIpAddr,
|
struct alias_link *lnk, u_int32_t localIpAddr,
|
||||||
ConvDirection direction)
|
ConvDirection direction)
|
||||||
{
|
{
|
||||||
struct in_addr dst, src;
|
struct in_addr dst, src;
|
||||||
|
|
||||||
|
(void)pip;
|
||||||
|
(void)tc;
|
||||||
|
(void)lnk;
|
||||||
|
(void)direction;
|
||||||
|
|
||||||
dst.s_addr = start_media->remoteIpAddr;
|
dst.s_addr = start_media->remoteIpAddr;
|
||||||
src.s_addr = localIpAddr;
|
src.s_addr = localIpAddr;
|
||||||
|
|
||||||
@ -164,10 +171,12 @@ alias_skinny_startmedia(struct StartMediaTransmission *start_media,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
|
alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
|
||||||
struct tcphdr *tc, struct alias_link *link,
|
struct tcphdr *tc, struct alias_link *lnk,
|
||||||
ConvDirection direction)
|
ConvDirection direction)
|
||||||
{
|
{
|
||||||
port_msg->stationIpPort = (u_int32_t) ntohs(GetAliasPort(link));
|
(void)direction;
|
||||||
|
|
||||||
|
port_msg->stationIpPort = (u_int32_t) ntohs(GetAliasPort(lnk));
|
||||||
|
|
||||||
tc->th_sum = 0;
|
tc->th_sum = 0;
|
||||||
tc->th_sum = TcpChecksum(pip);
|
tc->th_sum = TcpChecksum(pip);
|
||||||
@ -178,22 +187,25 @@ alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
|
|||||||
static int
|
static int
|
||||||
alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opnrcvch_ack,
|
alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opnrcvch_ack,
|
||||||
struct ip *pip, struct tcphdr *tc,
|
struct ip *pip, struct tcphdr *tc,
|
||||||
struct alias_link *link, u_int32_t * localIpAddr,
|
struct alias_link *lnk, u_int32_t * localIpAddr,
|
||||||
ConvDirection direction)
|
ConvDirection direction)
|
||||||
{
|
{
|
||||||
struct in_addr null_addr;
|
struct in_addr null_addr;
|
||||||
struct alias_link *opnrcv_link;
|
struct alias_link *opnrcv_lnk;
|
||||||
u_int32_t localPort;
|
u_int32_t localPort;
|
||||||
|
|
||||||
|
(void)lnk;
|
||||||
|
(void)direction;
|
||||||
|
|
||||||
*localIpAddr = (u_int32_t) opnrcvch_ack->ipAddr;
|
*localIpAddr = (u_int32_t) opnrcvch_ack->ipAddr;
|
||||||
localPort = opnrcvch_ack->port;
|
localPort = opnrcvch_ack->port;
|
||||||
|
|
||||||
null_addr.s_addr = INADDR_ANY;
|
null_addr.s_addr = INADDR_ANY;
|
||||||
opnrcv_link = FindUdpTcpOut(la, pip->ip_src, null_addr,
|
opnrcv_lnk = FindUdpTcpOut(la, pip->ip_src, null_addr,
|
||||||
htons((u_short) opnrcvch_ack->port), 0,
|
htons((u_short) opnrcvch_ack->port), 0,
|
||||||
IPPROTO_UDP, 1);
|
IPPROTO_UDP, 1);
|
||||||
opnrcvch_ack->ipAddr = (u_int32_t) GetAliasAddress(opnrcv_link).s_addr;
|
opnrcvch_ack->ipAddr = (u_int32_t) GetAliasAddress(opnrcv_lnk).s_addr;
|
||||||
opnrcvch_ack->port = (u_int32_t) ntohs(GetAliasPort(opnrcv_link));
|
opnrcvch_ack->port = (u_int32_t) ntohs(GetAliasPort(opnrcv_lnk));
|
||||||
|
|
||||||
tc->th_sum = 0;
|
tc->th_sum = 0;
|
||||||
tc->th_sum = TcpChecksum(pip);
|
tc->th_sum = TcpChecksum(pip);
|
||||||
@ -202,11 +214,11 @@ alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opn
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *lnk)
|
||||||
{
|
{
|
||||||
int hlen, tlen, dlen;
|
int hlen, tlen, dlen;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
u_int32_t msgId, len, t, lip;
|
int32_t msgId, len, t, lip;
|
||||||
struct skinny_header *sd;
|
struct skinny_header *sd;
|
||||||
int orig_len, skinny_hdr_len = sizeof(struct skinny_header);
|
int orig_len, skinny_hdr_len = sizeof(struct skinny_header);
|
||||||
ConvDirection direction;
|
ConvDirection direction;
|
||||||
@ -248,7 +260,7 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
msgId = (sd->msgId);
|
msgId = (sd->msgId);
|
||||||
t = len;
|
t = len;
|
||||||
|
|
||||||
if (t < 0 || t > orig_len || t > dlen) {
|
if (t > orig_len || t > dlen) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet, invalid length \n");
|
"PacketAlias/Skinny: Not a skinny packet, invalid length \n");
|
||||||
@ -259,7 +271,7 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
case REG_MSG: {
|
case REG_MSG: {
|
||||||
struct RegisterMessage *reg_mesg;
|
struct RegisterMessage *reg_mesg;
|
||||||
|
|
||||||
if (len < sizeof(struct RegisterMessage)) {
|
if (len < (int)sizeof(struct RegisterMessage)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet, bad registration message\n");
|
"PacketAlias/Skinny: Not a skinny packet, bad registration message\n");
|
||||||
@ -271,13 +283,13 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Received a register message");
|
"PacketAlias/Skinny: Received a register message");
|
||||||
#endif
|
#endif
|
||||||
alias_skinny_reg_msg(reg_mesg, pip, tc, link, direction);
|
alias_skinny_reg_msg(reg_mesg, pip, tc, lnk, direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IP_PORT_MSG: {
|
case IP_PORT_MSG: {
|
||||||
struct IpPortMessage *port_mesg;
|
struct IpPortMessage *port_mesg;
|
||||||
|
|
||||||
if (len < sizeof(struct IpPortMessage)) {
|
if (len < (int)sizeof(struct IpPortMessage)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet, port message\n");
|
"PacketAlias/Skinny: Not a skinny packet, port message\n");
|
||||||
@ -289,13 +301,13 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
"PacketAlias/Skinny: Received ipport message\n");
|
"PacketAlias/Skinny: Received ipport message\n");
|
||||||
#endif
|
#endif
|
||||||
port_mesg = (struct IpPortMessage *)&sd->msgId;
|
port_mesg = (struct IpPortMessage *)&sd->msgId;
|
||||||
alias_skinny_port_msg(port_mesg, pip, tc, link, direction);
|
alias_skinny_port_msg(port_mesg, pip, tc, lnk, direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OPNRCVCH_ACK: {
|
case OPNRCVCH_ACK: {
|
||||||
struct OpenReceiveChannelAck *opnrcvchn_ack;
|
struct OpenReceiveChannelAck *opnrcvchn_ack;
|
||||||
|
|
||||||
if (len < sizeof(struct OpenReceiveChannelAck)) {
|
if (len < (int)sizeof(struct OpenReceiveChannelAck)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet, packet,OpnRcvChnAckMsg\n");
|
"PacketAlias/Skinny: Not a skinny packet, packet,OpnRcvChnAckMsg\n");
|
||||||
@ -307,13 +319,13 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
"PacketAlias/Skinny: Received open rcv channel msg\n");
|
"PacketAlias/Skinny: Received open rcv channel msg\n");
|
||||||
#endif
|
#endif
|
||||||
opnrcvchn_ack = (struct OpenReceiveChannelAck *)&sd->msgId;
|
opnrcvchn_ack = (struct OpenReceiveChannelAck *)&sd->msgId;
|
||||||
alias_skinny_opnrcvch_ack(la, opnrcvchn_ack, pip, tc, link, &lip, direction);
|
alias_skinny_opnrcvch_ack(la, opnrcvchn_ack, pip, tc, lnk, &lip, direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case START_MEDIATX: {
|
case START_MEDIATX: {
|
||||||
struct StartMediaTransmission *startmedia_tx;
|
struct StartMediaTransmission *startmedia_tx;
|
||||||
|
|
||||||
if (len < sizeof(struct StartMediaTransmission)) {
|
if (len < (int)sizeof(struct StartMediaTransmission)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"PacketAlias/Skinny: Not a skinny packet,StartMediaTx Message\n");
|
"PacketAlias/Skinny: Not a skinny packet,StartMediaTx Message\n");
|
||||||
@ -325,7 +337,7 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
|
|||||||
"PacketAlias/Skinny: Received start media trans msg\n");
|
"PacketAlias/Skinny: Received start media trans msg\n");
|
||||||
#endif
|
#endif
|
||||||
startmedia_tx = (struct StartMediaTransmission *)&sd->msgId;
|
startmedia_tx = (struct StartMediaTransmission *)&sd->msgId;
|
||||||
alias_skinny_startmedia(startmedia_tx, pip, tc, link, lip, direction);
|
alias_skinny_startmedia(startmedia_tx, pip, tc, lnk, lip, direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -138,7 +138,7 @@ search_string(char *data, int dlen, const char *search_str)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
alias_rtsp_out(struct libalias *la, struct ip *pip,
|
alias_rtsp_out(struct libalias *la, struct ip *pip,
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
char *data,
|
char *data,
|
||||||
const char *port_str)
|
const char *port_str)
|
||||||
{
|
{
|
||||||
@ -151,7 +151,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
const char *transport_str = "transport:";
|
const char *transport_str = "transport:";
|
||||||
char newdata[2048], *port_data, *port_newdata, stemp[80];
|
char newdata[2048], *port_data, *port_newdata, stemp[80];
|
||||||
int links_created = 0, pkt_updated = 0;
|
int links_created = 0, pkt_updated = 0;
|
||||||
struct alias_link *rtsp_link = NULL;
|
struct alias_link *rtsp_lnk = NULL;
|
||||||
struct in_addr null_addr;
|
struct in_addr null_addr;
|
||||||
|
|
||||||
/* Calculate data length of TCP packet */
|
/* Calculate data length of TCP packet */
|
||||||
@ -171,7 +171,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
memcpy(newdata, data, pos);
|
memcpy(newdata, data, pos);
|
||||||
port_newdata = newdata + pos;
|
port_newdata = newdata + pos;
|
||||||
|
|
||||||
while (port_dlen > strlen(port_str)) {
|
while (port_dlen > (int)strlen(port_str)) {
|
||||||
/* Find keyword, appropriate port string */
|
/* Find keyword, appropriate port string */
|
||||||
pos = search_string(port_data, port_dlen, port_str);
|
pos = search_string(port_data, port_dlen, port_str);
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
@ -242,17 +242,17 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
* to port found in
|
* to port found in
|
||||||
* RTSP packet
|
* RTSP packet
|
||||||
*/
|
*/
|
||||||
rtsp_link = FindRtspOut(la, GetOriginalAddress(link), null_addr,
|
rtsp_lnk = FindRtspOut(la, GetOriginalAddress(lnk), null_addr,
|
||||||
htons(base_port + j), htons(base_alias + j),
|
htons(base_port + j), htons(base_alias + j),
|
||||||
IPPROTO_UDP);
|
IPPROTO_UDP);
|
||||||
if (rtsp_link != NULL) {
|
if (rtsp_lnk != NULL) {
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
/*
|
/*
|
||||||
* Punch
|
* Punch
|
||||||
* hole in
|
* hole in
|
||||||
* firewall
|
* firewall
|
||||||
*/
|
*/
|
||||||
PunchFWHole(rtsp_link);
|
PunchFWHole(rtsp_lnk);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -265,7 +265,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
}
|
}
|
||||||
ealias = htons(base_alias + (RTSP_PORT_GROUP - 1));
|
ealias = htons(base_alias + (RTSP_PORT_GROUP - 1));
|
||||||
}
|
}
|
||||||
if (salias && rtsp_link) {
|
if (salias && rtsp_lnk) {
|
||||||
|
|
||||||
pkt_updated = 1;
|
pkt_updated = 1;
|
||||||
|
|
||||||
@ -308,9 +308,9 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
new_dlen = port_newdata - newdata;
|
new_dlen = port_newdata - newdata;
|
||||||
memcpy(data, newdata, new_dlen);
|
memcpy(data, newdata, new_dlen);
|
||||||
|
|
||||||
SetAckModified(link);
|
SetAckModified(lnk);
|
||||||
delta = GetDeltaSeqOut(pip, link);
|
delta = GetDeltaSeqOut(pip, lnk);
|
||||||
AddSeq(pip, link, delta + new_dlen - dlen);
|
AddSeq(pip, lnk, delta + new_dlen - dlen);
|
||||||
|
|
||||||
new_len = htons(hlen + new_dlen);
|
new_len = htons(hlen + new_dlen);
|
||||||
DifferentialChecksum(&pip->ip_sum,
|
DifferentialChecksum(&pip->ip_sum,
|
||||||
@ -329,7 +329,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
alias_pna_out(struct libalias *la, struct ip *pip,
|
alias_pna_out(struct libalias *la, struct ip *pip,
|
||||||
struct alias_link *link,
|
struct alias_link *lnk,
|
||||||
char *data,
|
char *data,
|
||||||
int dlen)
|
int dlen)
|
||||||
{
|
{
|
||||||
@ -352,7 +352,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
|
|||||||
}
|
}
|
||||||
if ((ntohs(msg_id) == 1) || (ntohs(msg_id) == 7)) {
|
if ((ntohs(msg_id) == 1) || (ntohs(msg_id) == 7)) {
|
||||||
memcpy(&port, work, 2);
|
memcpy(&port, work, 2);
|
||||||
pna_links = FindUdpTcpOut(la, pip->ip_src, GetDestAddress(link),
|
pna_links = FindUdpTcpOut(la, pip->ip_src, GetDestAddress(lnk),
|
||||||
port, 0, IPPROTO_UDP, 1);
|
port, 0, IPPROTO_UDP, 1);
|
||||||
if (pna_links != NULL) {
|
if (pna_links != NULL) {
|
||||||
#ifndef NO_FW_PUNCH
|
#ifndef NO_FW_PUNCH
|
||||||
@ -375,7 +375,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link, int maxpacketsize)
|
AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *lnk, int maxpacketsize)
|
||||||
{
|
{
|
||||||
int hlen, tlen, dlen;
|
int hlen, tlen, dlen;
|
||||||
struct tcphdr *tc;
|
struct tcphdr *tc;
|
||||||
@ -385,6 +385,8 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
|
|||||||
const char *server_port_str = "server_port";
|
const char *server_port_str = "server_port";
|
||||||
int i, parseOk;
|
int i, parseOk;
|
||||||
|
|
||||||
|
(void)maxpacketsize;
|
||||||
|
|
||||||
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
|
||||||
hlen = (pip->ip_hl + tc->th_off) << 2;
|
hlen = (pip->ip_hl + tc->th_off) << 2;
|
||||||
tlen = ntohs(pip->ip_len);
|
tlen = ntohs(pip->ip_len);
|
||||||
@ -397,15 +399,15 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
|
|||||||
if ((ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_1) ||
|
if ((ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_1) ||
|
||||||
(ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_2)) {
|
(ntohs(tc->th_dport) == RTSP_CONTROL_PORT_NUMBER_2)) {
|
||||||
|
|
||||||
if (dlen >= strlen(setup)) {
|
if (dlen >= (int)strlen(setup)) {
|
||||||
if (memcmp(data, setup, strlen(setup)) == 0) {
|
if (memcmp(data, setup, strlen(setup)) == 0) {
|
||||||
alias_rtsp_out(la, pip, link, data, client_port_str);
|
alias_rtsp_out(la, pip, lnk, data, client_port_str);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dlen >= strlen(pna)) {
|
if (dlen >= (int)strlen(pna)) {
|
||||||
if (memcmp(data, pna, strlen(pna)) == 0) {
|
if (memcmp(data, pna, strlen(pna)) == 0) {
|
||||||
alias_pna_out(la, pip, link, data, dlen);
|
alias_pna_out(la, pip, lnk, data, dlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -415,10 +417,10 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
|
|||||||
* Accomodate varying number of blanks between 200 & OK
|
* Accomodate varying number of blanks between 200 & OK
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (dlen >= strlen(str200)) {
|
if (dlen >= (int)strlen(str200)) {
|
||||||
|
|
||||||
for (parseOk = 0, i = 0;
|
for (parseOk = 0, i = 0;
|
||||||
i <= dlen - strlen(str200);
|
i <= dlen - (int)strlen(str200);
|
||||||
i++) {
|
i++) {
|
||||||
if (memcmp(&data[i], str200, strlen(str200)) == 0) {
|
if (memcmp(&data[i], str200, strlen(str200)) == 0) {
|
||||||
parseOk = 1;
|
parseOk = 1;
|
||||||
@ -431,10 +433,10 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
|
|||||||
while (data[i] == ' ') /* skip blank(s) */
|
while (data[i] == ' ') /* skip blank(s) */
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if ((dlen - i) >= strlen(okstr)) {
|
if ((dlen - i) >= (int)strlen(okstr)) {
|
||||||
|
|
||||||
if (memcmp(&data[i], okstr, strlen(okstr)) == 0)
|
if (memcmp(&data[i], okstr, strlen(okstr)) == 0)
|
||||||
alias_rtsp_out(la, pip, link, data, server_port_str);
|
alias_rtsp_out(la, pip, lnk, data, server_port_str);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,8 @@ LibAliasInternetChecksum(struct libalias *la, u_short * ptr, int nbytes)
|
|||||||
{
|
{
|
||||||
int sum, oddbyte;
|
int sum, oddbyte;
|
||||||
|
|
||||||
|
(void)la;
|
||||||
|
|
||||||
sum = 0;
|
sum = 0;
|
||||||
while (nbytes > 1) {
|
while (nbytes > 1) {
|
||||||
sum += *ptr++;
|
sum += *ptr++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user