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:
des 2004-07-05 11:10:57 +00:00
parent 831b8f89db
commit 75b8ca2286
30 changed files with 1442 additions and 1352 deletions

View File

@ -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_util.c alias_old.c
INCS= alias.h
WARNS?= 2
WARNS?= 6
.include <bsd.lib.mk>

View File

@ -162,43 +162,43 @@ static void TcpMonitorOut(struct ip *, struct alias_link *);
static void
TcpMonitorIn(struct ip *pip, struct alias_link *link)
TcpMonitorIn(struct ip *pip, struct alias_link *lnk)
{
struct tcphdr *tc;
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
switch (GetStateIn(link)) {
switch (GetStateIn(lnk)) {
case ALIAS_TCP_STATE_NOT_CONNECTED:
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)
SetStateIn(link, ALIAS_TCP_STATE_CONNECTED);
SetStateIn(lnk, ALIAS_TCP_STATE_CONNECTED);
break;
case ALIAS_TCP_STATE_CONNECTED:
if (tc->th_flags & (TH_FIN | TH_RST))
SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED);
SetStateIn(lnk, ALIAS_TCP_STATE_DISCONNECTED);
break;
}
}
static void
TcpMonitorOut(struct ip *pip, struct alias_link *link)
TcpMonitorOut(struct ip *pip, struct alias_link *lnk)
{
struct tcphdr *tc;
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
switch (GetStateOut(link)) {
switch (GetStateOut(lnk)) {
case ALIAS_TCP_STATE_NOT_CONNECTED:
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)
SetStateOut(link, ALIAS_TCP_STATE_CONNECTED);
SetStateOut(lnk, ALIAS_TCP_STATE_CONNECTED);
break;
case ALIAS_TCP_STATE_CONNECTED:
if (tc->th_flags & (TH_FIN | TH_RST))
SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED);
SetStateOut(lnk, ALIAS_TCP_STATE_DISCONNECTED);
break;
}
}
@ -273,18 +273,18 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip)
De-alias incoming echo and timestamp replies.
Alias incoming echo and timestamp requests.
*/
struct alias_link *link;
struct alias_link *lnk;
struct icmp *ic;
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
/* Get source address from ICMP data field and restore original data */
link = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (link != NULL) {
lnk = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (lnk != NULL) {
u_short original_id;
int accumulate;
original_id = GetOriginalPort(link);
original_id = GetOriginalPort(lnk);
/* Adjust ICMP checksum */
accumulate = ic->icmp_id;
@ -298,7 +298,7 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip)
{
struct in_addr original_address;
original_address = GetOriginalAddress(link);
original_address = GetOriginalAddress(lnk);
DifferentialChecksum(&pip->ip_sum,
&original_address, &pip->ip_dst, 2);
pip->ip_dst = original_address;
@ -320,7 +320,7 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip)
struct icmp *ic, *ic2;
struct udphdr *ud;
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
ip = &ic->icmp_ip;
@ -330,29 +330,29 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip)
ic2 = (struct icmp *)ud;
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,
IPPROTO_UDP, 0);
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,
IPPROTO_TCP, 0);
else if (ip->ip_p == IPPROTO_ICMP) {
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
link = NULL;
lnk = NULL;
} else
link = NULL;
lnk = NULL;
if (link != NULL) {
if (lnk != NULL) {
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
int accumulate, accumulate2;
struct in_addr original_address;
u_short original_port;
original_address = GetOriginalAddress(link);
original_port = GetOriginalPort(link);
original_address = GetOriginalAddress(lnk);
original_port = GetOriginalPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&ip->ip_src);
@ -379,8 +379,8 @@ fragment contained in ICMP data section */
struct in_addr original_address;
u_short original_id;
original_address = GetOriginalAddress(link);
original_id = GetOriginalPort(link);
original_address = GetOriginalAddress(lnk);
original_id = GetOriginalPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&ip->ip_src);
@ -451,18 +451,18 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip)
Alias outgoing echo and timestamp requests.
De-alias outgoing echo and timestamp replies.
*/
struct alias_link *link;
struct alias_link *lnk;
struct icmp *ic;
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
/* Save overwritten data for when echo packet returns */
link = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (link != NULL) {
lnk = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (lnk != NULL) {
u_short alias_id;
int accumulate;
alias_id = GetAliasPort(link);
alias_id = GetAliasPort(lnk);
/* Since data field is being modified, adjust ICMP checksum */
accumulate = ic->icmp_id;
@ -476,7 +476,7 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip)
{
struct in_addr alias_address;
alias_address = GetAliasAddress(link);
alias_address = GetAliasAddress(lnk);
DifferentialChecksum(&pip->ip_sum,
&alias_address, &pip->ip_src, 2);
pip->ip_src = alias_address;
@ -499,7 +499,7 @@ IcmpAliasOut2(struct libalias *la, struct ip *pip)
struct icmp *ic, *ic2;
struct udphdr *ud;
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
ip = &ic->icmp_ip;
@ -509,29 +509,29 @@ IcmpAliasOut2(struct libalias *la, struct ip *pip)
ic2 = (struct icmp *)ud;
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,
IPPROTO_UDP, 0);
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,
IPPROTO_TCP, 0);
else if (ip->ip_p == IPPROTO_ICMP) {
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
link = NULL;
lnk = NULL;
} else
link = NULL;
lnk = NULL;
if (link != NULL) {
if (lnk != NULL) {
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
int accumulate;
struct in_addr alias_address;
u_short alias_port;
alias_address = GetAliasAddress(link);
alias_port = GetAliasPort(link);
alias_address = GetAliasAddress(lnk);
alias_port = GetAliasPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&ip->ip_dst);
@ -558,8 +558,8 @@ fragment contained in ICMP data section */
struct in_addr alias_address;
u_short alias_id;
alias_address = GetAliasAddress(link);
alias_id = GetAliasPort(link);
alias_address = GetAliasAddress(lnk);
alias_id = GetAliasPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&ip->ip_dst);
@ -594,6 +594,8 @@ IcmpAliasOut(struct libalias *la, struct ip *pip, int create)
int iresult;
struct icmp *ic;
(void)create;
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
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
machine.
*/
struct alias_link *link;
struct alias_link *lnk;
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return (PKT_ALIAS_OK);
link = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (link != NULL) {
lnk = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (lnk != NULL) {
struct in_addr original_address;
original_address = GetOriginalAddress(link);
original_address = GetOriginalAddress(lnk);
/* Restore original IP address */
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
the source IP address of the packet.
*/
struct alias_link *link;
struct alias_link *lnk;
(void)create;
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return (PKT_ALIAS_OK);
link = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (link != NULL) {
lnk = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (lnk != NULL) {
struct in_addr alias_address;
alias_address = GetAliasAddress(link);
alias_address = GetAliasAddress(lnk);
/* Change source address */
DifferentialChecksum(&pip->ip_sum,
@ -690,7 +694,7 @@ static int
UdpAliasIn(struct libalias *la, struct ip *pip)
{
struct udphdr *ud;
struct alias_link *link;
struct alias_link *lnk;
/* Return if proxy-only mode is enabled */
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));
link = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
ud->uh_sport, ud->uh_dport,
IPPROTO_UDP, 1);
if (link != NULL) {
if (lnk != NULL) {
struct in_addr alias_address;
struct in_addr original_address;
u_short alias_port;
int accumulate;
int r = 0;
alias_address = GetAliasAddress(link);
original_address = GetOriginalAddress(link);
alias_address = GetAliasAddress(lnk);
original_address = GetOriginalAddress(lnk);
alias_port = ud->uh_dport;
ud->uh_dport = GetOriginalPort(link);
ud->uh_dport = GetOriginalPort(lnk);
/* Special processing for IP encoding protocols */
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 */
else if (ntohs(ud->uh_dport) == 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
|| 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);
/* 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)
{
struct udphdr *ud;
struct alias_link *link;
struct alias_link *lnk;
/* Return if proxy-only mode is enabled */
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));
link = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
ud->uh_sport, ud->uh_dport,
IPPROTO_UDP, create);
if (link != NULL) {
if (lnk != NULL) {
u_short alias_port;
struct in_addr alias_address;
alias_address = GetAliasAddress(link);
alias_port = GetAliasPort(link);
alias_address = GetAliasAddress(lnk);
alias_port = GetAliasPort(lnk);
/* Special processing for IP encoding protocols */
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 */
else if (ntohs(ud->uh_dport) == 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
|| 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);
/*
* 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)
{
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
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,
IPPROTO_TCP,
!(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY));
if (link != NULL) {
if (lnk != NULL) {
struct in_addr alias_address;
struct in_addr original_address;
struct in_addr proxy_address;
@ -841,17 +845,17 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
/* Special processing for IP encoding protocols */
if (ntohs(tc->th_dport) == 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
|| ntohs(tc->th_sport) == la->skinnyPort))
AliasHandleSkinny(la, pip, link);
AliasHandleSkinny(la, pip, lnk);
alias_address = GetAliasAddress(link);
original_address = GetOriginalAddress(link);
proxy_address = GetProxyAddress(link);
alias_address = GetAliasAddress(lnk);
original_address = GetOriginalAddress(lnk);
proxy_address = GetProxyAddress(lnk);
alias_port = tc->th_dport;
tc->th_dport = GetOriginalPort(link);
proxy_port = GetProxyPort(link);
tc->th_dport = GetOriginalPort(lnk);
proxy_port = GetProxyPort(lnk);
/* Adjust TCP checksum since destination port is being unaliased */
/* and destination port is being altered. */
@ -870,10 +874,10 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
accumulate -= twowords(&proxy_address);
}
/* See if ACK number needs to be modified */
if (GetAckModified(link) == 1) {
if (GetAckModified(lnk) == 1) {
int delta;
delta = GetDeltaAckIn(pip, link);
delta = GetDeltaAckIn(pip, lnk);
if (delta != 0) {
accumulate += twowords(&tc->th_ack);
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);
/* Monitor TCP connection state */
TcpMonitorIn(pip, link);
TcpMonitorIn(pip, lnk);
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 proxy_server_address;
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
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);
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,
IPPROTO_TCP, create);
if (link == NULL)
if (lnk == NULL)
return (PKT_ALIAS_IGNORED);
if (link != NULL) {
if (lnk != NULL) {
u_short alias_port;
struct in_addr alias_address;
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
change the size of IP header. */
if (proxy_type != 0) {
SetProxyPort(link, dest_port);
SetProxyAddress(link, dest_address);
ProxyModify(la, link, pip, maxpacketsize, proxy_type);
SetProxyPort(lnk, dest_port);
SetProxyAddress(lnk, dest_address);
ProxyModify(la, lnk, pip, maxpacketsize, proxy_type);
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
}
/* Get alias address and port */
alias_port = GetAliasPort(link);
alias_address = GetAliasAddress(link);
alias_port = GetAliasPort(lnk);
alias_address = GetAliasAddress(lnk);
/* Monitor TCP connection state */
TcpMonitorOut(pip, link);
TcpMonitorOut(pip, lnk);
/* Special processing for IP encoding protocols */
if (ntohs(tc->th_dport) == 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
|| 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
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_1
|| ntohs(tc->th_dport) == 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
|| 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
|| ntohs(tc->th_dport) == la->skinnyPort))
AliasHandleSkinny(la, pip, link);
AliasHandleSkinny(la, pip, lnk);
/* Adjust TCP checksum since source port is being aliased */
/* 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);
/* Modify sequence number if necessary */
if (GetAckModified(link) == 1) {
if (GetAckModified(lnk) == 1) {
int delta;
delta = GetDeltaSeqOut(pip, link);
delta = GetDeltaSeqOut(pip, lnk);
if (delta != 0) {
accumulate += twowords(&tc->th_seq);
tc->th_seq = htonl(ntohl(tc->th_seq) + delta);
@ -1042,13 +1046,13 @@ static int FragmentOut(struct libalias *, struct ip *);
static int
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);
if (link != NULL) {
lnk = FindFragmentIn2(la, pip->ip_src, pip->ip_dst, pip->ip_id);
if (lnk != NULL) {
struct in_addr original_address;
GetFragmentAddr(link, &original_address);
GetFragmentAddr(lnk, &original_address);
DifferentialChecksum(&pip->ip_sum,
&original_address, &pip->ip_dst, 2);
pip->ip_dst = original_address;
@ -1094,14 +1098,14 @@ int
LibAliasSaveFragment(struct libalias *la, char *ptr)
{
int iresult;
struct alias_link *link;
struct alias_link *lnk;
struct ip *pip;
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;
if (link != NULL) {
SetFragmentPtr(link, ptr);
if (lnk != NULL) {
SetFragmentPtr(lnk, ptr);
iresult = PKT_ALIAS_OK;
}
return (iresult);
@ -1111,16 +1115,16 @@ LibAliasSaveFragment(struct libalias *la, char *ptr)
char *
LibAliasGetFragment(struct libalias *la, char *ptr)
{
struct alias_link *link;
struct alias_link *lnk;
char *fptr;
struct ip *pip;
pip = (struct ip *)ptr;
link = FindFragmentPtr(la, pip->ip_src, pip->ip_id);
if (link != NULL) {
GetFragmentPtr(link, &fptr);
SetFragmentPtr(link, NULL);
SetExpire(link, 0); /* Deletes link */
lnk = FindFragmentPtr(la, pip->ip_src, pip->ip_id);
if (lnk != NULL) {
GetFragmentPtr(lnk, &fptr);
SetFragmentPtr(lnk, NULL);
SetExpire(lnk, 0); /* Deletes link */
return (fptr);
} else {
@ -1140,6 +1144,7 @@ LibAliasFragmentIn(struct libalias *la, char *ptr, /* Points to correctly
struct ip *pip;
struct ip *fpip;
(void)la;
pip = (struct ip *)ptr;
fpip = (struct ip *)ptr_fragment;
@ -1197,12 +1202,12 @@ LibAliasIn(struct libalias *la, char *ptr, int maxpacketsize)
}
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);
if (link != NULL) {
lnk = FindFragmentIn1(la, pip->ip_src, alias_addr, pip->ip_id);
if (lnk != NULL) {
iresult = PKT_ALIAS_FOUND_HEADER_FRAGMENT;
SetFragmentAddr(link, pip->ip_dst);
SetFragmentAddr(lnk, pip->ip_dst);
} else {
iresult = PKT_ALIAS_ERROR;
}
@ -1324,7 +1329,7 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
struct icmp *ic;
struct udphdr *ud;
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
int iresult = PKT_ALIAS_IGNORED;
pip = (struct ip *)ptr;
@ -1340,27 +1345,27 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
/* Find a link */
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,
IPPROTO_UDP, 0);
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,
IPPROTO_TCP, 0);
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
link = NULL;
lnk = NULL;
/* 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) {
int accumulate;
struct in_addr original_address;
u_short original_port;
original_address = GetOriginalAddress(link);
original_port = GetOriginalPort(link);
original_address = GetOriginalAddress(lnk);
original_port = GetOriginalPort(lnk);
/* Adjust TCP/UDP checksum */
accumulate = twowords(&pip->ip_src);
@ -1395,8 +1400,8 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
struct in_addr original_address;
u_short original_id;
original_address = GetOriginalAddress(link);
original_id = GetOriginalPort(link);
original_address = GetOriginalAddress(lnk);
original_id = GetOriginalPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&pip->ip_src);

View File

@ -89,13 +89,13 @@ int PacketUnaliasOut(char *_ptr, int _maxpacketsize);
int
PacketAliasAddServer(struct alias_link *_link,
PacketAliasAddServer(struct alias_link *_lnk,
struct in_addr _addr, unsigned short _port);
struct alias_link *
PacketAliasRedirectAddr(struct in_addr _src_addr,
struct in_addr _alias_addr);
int PacketAliasRedirectDynamic(struct alias_link *_link);
void PacketAliasRedirectDelete(struct alias_link *_link);
int PacketAliasRedirectDynamic(struct alias_link *_lnk);
void PacketAliasRedirectDelete(struct alias_link *_lnk);
struct alias_link *
PacketAliasRedirectPort(struct in_addr _src_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. */
int
LibAliasAddServer(struct libalias *, struct alias_link *_link,
LibAliasAddServer(struct libalias *, struct alias_link *_lnk,
struct in_addr _addr, unsigned short _port);
struct alias_link *
LibAliasRedirectAddr(struct libalias *, struct in_addr _src_addr,
struct in_addr _alias_addr);
int LibAliasRedirectDynamic(struct libalias *, struct alias_link *_link);
void LibAliasRedirectDelete(struct libalias *, struct alias_link *_link);
int LibAliasRedirectDynamic(struct libalias *, struct alias_link *_lnk);
void LibAliasRedirectDelete(struct libalias *, struct alias_link *_lnk);
struct alias_link *
LibAliasRedirectPort(struct libalias *, struct in_addr _src_addr,
unsigned short _src_port, struct in_addr _dst_addr,

View File

@ -68,25 +68,25 @@ struct client_info {
};
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;
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
if (ntohs(ud->uh_ulen) - sizeof(struct udphdr) >= sizeof(struct cu_header)) {
struct cu_header *cu;
struct alias_link *cu_link;
struct alias_link *cu_lnk;
cu = (struct cu_header *)(ud + 1);
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);
#ifndef NO_FW_PUNCH
if (cu_link)
PunchFWHole(cu_link);
if (cu_lnk)
PunchFWHole(cu_lnk);
#endif
}
}
@ -102,6 +102,7 @@ AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip, struct in_addr origina
char *end;
int i;
(void)la;
alias_addr.s_addr = pip->ip_dst.s_addr;
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
cu = (struct cu_header *)(ud + 1);

File diff suppressed because it is too large Load Diff

View File

@ -104,7 +104,7 @@ void
AliasHandleFtpOut(
struct libalias *la,
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
(including headers) */ )
{
@ -127,7 +127,7 @@ AliasHandleFtpOut(
* Check that data length is not too long and previous message was
* properly terminated with CRLF.
*/
pflags = GetProtocolFlags(link);
pflags = GetProtocolFlags(lnk);
if (dlen <= MAX_MESSAGE_SIZE && !(pflags & WAIT_CRLF)) {
ftp_message_type = FTP_UNKNOWN_MESSAGE;
@ -152,7 +152,7 @@ AliasHandleFtpOut(
}
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 */
@ -164,7 +164,7 @@ AliasHandleFtpOut(
pflags &= ~WAIT_CRLF;
else
pflags |= WAIT_CRLF;
SetProtocolFlags(link, pflags);
SetProtocolFlags(lnk, pflags);
}
}
@ -551,11 +551,11 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
static void
NewFtpMessage(struct libalias *la, struct ip *pip,
struct alias_link *link,
struct alias_link *lnk,
int maxpacketsize,
int ftp_message_type)
{
struct alias_link *ftp_link;
struct alias_link *ftp_lnk;
/* Security checks. */
if (pip->ip_src.s_addr != la->true_addr.s_addr)
@ -565,16 +565,16 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
return;
/* 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);
if (ftp_link != NULL) {
if (ftp_lnk != NULL) {
int slen, hlen, tlen, dlen;
struct tcphdr *tc;
#ifndef NO_FW_PUNCH
/* Punch hole in firewall */
PunchFWHole(ftp_link);
PunchFWHole(ftp_lnk);
#endif
/* Calculate data length of TCP packet */
@ -593,14 +593,14 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
struct in_addr alias_address;
/* Decompose alias address into quad format */
alias_address = GetAliasAddress(link);
alias_address = GetAliasAddress(lnk);
ptr = (u_char *) & alias_address.s_addr;
a1 = *ptr++;
a2 = *ptr++;
a3 = *ptr++;
a4 = *ptr;
alias_port = GetAliasPort(ftp_link);
alias_port = GetAliasPort(ftp_lnk);
switch (ftp_message_type) {
case FTP_PORT_COMMAND:
@ -646,9 +646,9 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
{
int delta;
SetAckModified(link);
delta = GetDeltaSeqOut(pip, link);
AddSeq(pip, link, delta + slen - dlen);
SetAckModified(lnk);
delta = GetDeltaSeqOut(pip, lnk);
AddSeq(pip, lnk, delta + slen - dlen);
}
/* Revise IP header */

View File

@ -67,7 +67,7 @@ __FBSDID("$FreeBSD$");
void
AliasHandleIrcOut(struct libalias *la,
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
* headers */
)
@ -89,7 +89,7 @@ AliasHandleIrcOut(struct libalias *la,
* Return if data length is too short - assume an entire PRIVMSG in
* 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;
/* Place string pointer at beginning of data */
@ -109,9 +109,9 @@ AliasHandleIrcOut(struct libalias *la,
{
char newpacket[65536]; /* Estimate of maximum packet size
* :) */
int copyat = i; /* Same */
int iCopy = 0; /* How much data have we written to
* copy-back string? */
unsigned int copyat = i; /* Same */
unsigned int iCopy = 0; /* How much data have we written to
* copy-back string? */
unsigned long org_addr; /* Original IP address */
unsigned short org_port; /* Original source port
* address */
@ -249,7 +249,7 @@ AliasHandleIrcOut(struct libalias *la,
/* We've got the address and port - now alias it */
{
struct alias_link *dcc_link;
struct alias_link *dcc_lnk;
struct in_addr destaddr;
@ -268,11 +268,11 @@ AliasHandleIrcOut(struct libalias *la,
* matter, and this would probably allow it through
* at least _some_ firewalls.
*/
dcc_link = FindUdpTcpOut(la, true_addr, destaddr,
dcc_lnk = FindUdpTcpOut(la, true_addr, destaddr,
true_port, 0,
IPPROTO_TCP, 1);
DBprintf(("Got a DCC link\n"));
if (dcc_link) {
if (dcc_lnk) {
struct in_addr alias_address; /* Address from aliasing */
u_short alias_port; /* Port given by
* aliasing */
@ -280,10 +280,10 @@ AliasHandleIrcOut(struct libalias *la,
#ifndef NO_FW_PUNCH
/* Generate firewall hole as appropriate */
PunchFWHole(dcc_link);
PunchFWHole(dcc_lnk);
#endif
alias_address = GetAliasAddress(link);
alias_address = GetAliasAddress(lnk);
n = snprintf(&newpacket[iCopy],
sizeof(newpacket) - iCopy,
"%lu ", (u_long) htonl(alias_address.s_addr));
@ -296,7 +296,7 @@ AliasHandleIrcOut(struct libalias *la,
DBprintf(("DCC constructed packet overflow.\n"));
goto lBAD_CTCP;
}
alias_port = GetAliasPort(dcc_link);
alias_port = GetAliasPort(dcc_lnk);
n = snprintf(&newpacket[iCopy],
sizeof(newpacket) - iCopy,
"%u", htons(alias_port));
@ -342,9 +342,9 @@ AliasHandleIrcOut(struct libalias *la,
{
int delta;
SetAckModified(link);
delta = GetDeltaSeqOut(pip, link);
AddSeq(pip, link, delta + copyat + iCopy - dlen);
SetAckModified(lnk);
delta = GetDeltaSeqOut(pip, lnk);
AddSeq(pip, lnk, delta + copyat + iCopy - dlen);
}
/* Revise IP header */

View File

@ -227,43 +227,43 @@ int
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_char _proto, u_char _align);
void GetFragmentAddr(struct alias_link *_link, struct in_addr *_src_addr);
void SetFragmentAddr(struct alias_link *_link, struct in_addr _src_addr);
void GetFragmentPtr(struct alias_link *_link, char **_fptr);
void SetFragmentPtr(struct alias_link *_link, char *fptr);
void SetStateIn(struct alias_link *_link, int _state);
void SetStateOut(struct alias_link *_link, int _state);
int GetStateIn (struct alias_link *_link);
int GetStateOut(struct alias_link *_link);
void GetFragmentAddr(struct alias_link *_lnk, struct in_addr *_src_addr);
void SetFragmentAddr(struct alias_link *_lnk, struct in_addr _src_addr);
void GetFragmentPtr(struct alias_link *_lnk, char **_fptr);
void SetFragmentPtr(struct alias_link *_lnk, char *fptr);
void SetStateIn(struct alias_link *_lnk, int _state);
void SetStateOut(struct alias_link *_lnk, int _state);
int GetStateIn (struct alias_link *_lnk);
int GetStateOut(struct alias_link *_lnk);
struct in_addr
GetOriginalAddress(struct alias_link *_link);
GetOriginalAddress(struct alias_link *_lnk);
struct in_addr
GetDestAddress(struct alias_link *_link);
GetDestAddress(struct alias_link *_lnk);
struct in_addr
GetAliasAddress(struct alias_link *_link);
GetAliasAddress(struct alias_link *_lnk);
struct in_addr
GetDefaultAliasAddress(struct libalias *la);
void SetDefaultAliasAddress(struct libalias *la, struct in_addr _alias_addr);
u_short GetOriginalPort(struct alias_link *_link);
u_short GetAliasPort(struct alias_link *_link);
u_short GetOriginalPort(struct alias_link *_lnk);
u_short GetAliasPort(struct alias_link *_lnk);
struct in_addr
GetProxyAddress(struct alias_link *_link);
void SetProxyAddress(struct alias_link *_link, struct in_addr _addr);
u_short GetProxyPort(struct alias_link *_link);
void SetProxyPort(struct alias_link *_link, u_short _port);
void SetAckModified(struct alias_link *_link);
int GetAckModified(struct alias_link *_link);
int GetDeltaAckIn(struct ip *_pip, struct alias_link *_link);
int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_link);
void AddSeq (struct ip *_pip, struct alias_link *_link, int _delta);
void SetExpire (struct alias_link *_link, int _expire);
GetProxyAddress(struct alias_link *_lnk);
void SetProxyAddress(struct alias_link *_lnk, struct in_addr _addr);
u_short GetProxyPort(struct alias_link *_lnk);
void SetProxyPort(struct alias_link *_lnk, u_short _port);
void SetAckModified(struct alias_link *_lnk);
int GetAckModified(struct alias_link *_lnk);
int GetDeltaAckIn(struct ip *_pip, struct alias_link *_lnk);
int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_lnk);
void AddSeq (struct ip *_pip, struct alias_link *_lnk, int _delta);
void SetExpire (struct alias_link *_lnk, int _expire);
void ClearCheckNewLink(struct libalias *la);
void SetProtocolFlags(struct alias_link *_link, int _pflags);
int GetProtocolFlags(struct alias_link *_link);
void SetDestCallId(struct alias_link *_link, u_int16_t _cid);
void SetProtocolFlags(struct alias_link *_lnk, int _pflags);
int GetProtocolFlags(struct alias_link *_lnk);
void SetDestCallId(struct alias_link *_lnk, u_int16_t _cid);
#ifndef NO_FW_PUNCH
void PunchFWHole(struct alias_link *_link);
void PunchFWHole(struct alias_link *_lnk);
#endif
@ -275,47 +275,47 @@ void HouseKeeping(struct libalias *);
/* FTP routines */
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);
/* IRC routines */
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);
/* RTSP routines */
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);
/* PPTP routines */
void AliasHandlePptpOut(struct libalias *la, struct ip *_pip, struct alias_link *_link);
void AliasHandlePptpIn(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 *_lnk);
int AliasHandlePptpGreOut(struct libalias *la, struct ip *_pip);
int AliasHandlePptpGreIn(struct libalias *la, struct ip *_pip);
/* NetBIOS routines */
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);
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 *_original_address, u_short * _original_port);
/* 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);
/* 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 */
int
ProxyCheck(struct libalias *la, struct ip *_pip, struct in_addr *_proxy_server_addr,
u_short * _proxy_server_port);
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);
enum alias_tcp_state {

View File

@ -204,7 +204,7 @@ int
AliasHandleUdpNbt(
struct libalias *la,
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link,
struct alias_link *lnk,
struct in_addr *alias_address,
u_short alias_port
)
@ -214,6 +214,9 @@ AliasHandleUdpNbt(
u_char *p = NULL;
char *pmax;
(void)la;
(void)lnk;
/* Calculate data length of UDP packet */
uh = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
pmax = (char *)uh + ntohs(uh->uh_ulen);
@ -288,6 +291,8 @@ AliasHandleQuestion(
NBTArguments * nbtarg)
{
(void)nbtarg;
while (count != 0) {
/* Name Filed */
q = (NBTNsQuestion *) AliasHandleName((u_char *) q, pmax);
@ -468,6 +473,8 @@ AliasHandleResourceNULL(
NBTNsResourceNULL *n;
u_short bcount;
(void)nbtarg;
if (q == NULL || (char *)(q + 1) > pmax)
return (NULL);
@ -501,6 +508,8 @@ AliasHandleResourceNS(
NBTNsResourceNULL *n;
u_short bcount;
(void)nbtarg;
if (q == NULL || (char *)(q + 1) > pmax)
return (NULL);
@ -532,6 +541,8 @@ AliasHandleResourceNBSTAT(
NBTNsResourceNBSTAT *n;
u_short bcount;
(void)nbtarg;
if (q == NULL || (char *)(q + 1) > pmax)
return (NULL);
@ -621,7 +632,7 @@ int
AliasHandleUdpNbtNS(
struct libalias *la,
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link,
struct alias_link *lnk,
struct in_addr *alias_address,
u_short * alias_port,
struct in_addr *original_address,
@ -633,6 +644,9 @@ AliasHandleUdpNbtNS(
char *pmax;
NBTArguments nbtarg;
(void)la;
(void)lnk;
/* Set up Common Parameter */
nbtarg.oldaddr = *alias_address;
nbtarg.oldport = *alias_port;

View File

@ -104,11 +104,11 @@ PacketUnaliasOut(char *_ptr, int _maxpacketsize)
}
int
PacketAliasAddServer(struct alias_link *_link,
PacketAliasAddServer(struct alias_link *_lnk,
struct in_addr _addr, unsigned short _port)
{
return LibAliasAddServer(la, _link, _addr, _port);
return LibAliasAddServer(la, _lnk, _addr, _port);
}
struct alias_link *
@ -121,17 +121,17 @@ PacketAliasRedirectAddr(struct in_addr _src_addr,
int
PacketAliasRedirectDynamic(struct alias_link *_link)
PacketAliasRedirectDynamic(struct alias_link *_lnk)
{
return LibAliasRedirectDynamic(la, _link);
return LibAliasRedirectDynamic(la, _lnk);
}
void
PacketAliasRedirectDelete(struct alias_link *_link)
PacketAliasRedirectDelete(struct alias_link *_lnk)
{
LibAliasRedirectDelete(la, _link);
LibAliasRedirectDelete(la, _lnk);
}
struct alias_link *

View File

@ -147,9 +147,9 @@ static PptpCallId AliasVerifyPptp(struct ip *, u_int16_t *);
void
AliasHandlePptpOut(struct libalias *la,
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link)
struct alias_link *lnk)
{ /* The PPTP control link */
struct alias_link *pptp_link;
struct alias_link *pptp_lnk;
PptpCallId cptr;
PptpCode codes;
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
* control message.
*/
pptp_link = AddPptp(la, GetOriginalAddress(link), GetDestAddress(link),
GetAliasAddress(link), cptr->cid1);
pptp_lnk = AddPptp(la, GetOriginalAddress(lnk), GetDestAddress(lnk),
GetAliasAddress(lnk), cptr->cid1);
break;
case PPTP_CallClearRequest:
case PPTP_CallDiscNotify:
@ -178,19 +178,19 @@ AliasHandlePptpOut(struct libalias *la,
* Find PPTP link for address and Call ID found in control
* message.
*/
pptp_link = FindPptpOutByCallId(la, GetOriginalAddress(link),
GetDestAddress(link),
pptp_lnk = FindPptpOutByCallId(la, GetOriginalAddress(lnk),
GetDestAddress(lnk),
cptr->cid1);
break;
default:
return;
}
if (pptp_link != NULL) {
if (pptp_lnk != NULL) {
int accumulate = cptr->cid1;
/* alias the Call Id */
cptr->cid1 = GetAliasPort(pptp_link);
cptr->cid1 = GetAliasPort(pptp_lnk);
/* Compute TCP checksum for revised packet */
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
@ -203,14 +203,14 @@ AliasHandlePptpOut(struct libalias *la,
codes = (PptpCode) (cptr + 1);
if (codes->resCode == 1) /* Connection
* established, */
SetDestCallId(pptp_link, /* note the Peer's Call
SetDestCallId(pptp_lnk, /* note the Peer's Call
* ID. */
cptr->cid2);
else
SetExpire(pptp_link, 0); /* Connection refused. */
SetExpire(pptp_lnk, 0); /* Connection refused. */
break;
case PPTP_CallDiscNotify: /* Connection closed. */
SetExpire(pptp_link, 0);
SetExpire(pptp_lnk, 0);
break;
}
}
@ -219,9 +219,9 @@ AliasHandlePptpOut(struct libalias *la,
void
AliasHandlePptpIn(struct libalias *la,
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link)
struct alias_link *lnk)
{ /* The PPTP control link */
struct alias_link *pptp_link;
struct alias_link *pptp_lnk;
PptpCallId cptr;
u_int16_t *pcall_id;
u_int16_t ctl_type; /* control message type */
@ -243,26 +243,26 @@ AliasHandlePptpIn(struct libalias *la,
pcall_id = &cptr->cid2;
break;
case PPTP_CallDiscNotify: /* Connection closed. */
pptp_link = FindPptpInByCallId(la, GetDestAddress(link),
GetAliasAddress(link),
pptp_lnk = FindPptpInByCallId(la, GetDestAddress(lnk),
GetAliasAddress(lnk),
cptr->cid1);
if (pptp_link != NULL)
SetExpire(pptp_link, 0);
if (pptp_lnk != NULL)
SetExpire(pptp_lnk, 0);
return;
default:
return;
}
/* Find PPTP link for address and Call ID found in PPTP Control Msg */
pptp_link = FindPptpInByPeerCallId(la, GetDestAddress(link),
GetAliasAddress(link),
pptp_lnk = FindPptpInByPeerCallId(la, GetDestAddress(lnk),
GetAliasAddress(lnk),
*pcall_id);
if (pptp_link != NULL) {
if (pptp_lnk != NULL) {
int accumulate = *pcall_id;
/* De-alias the Peer's Call Id. */
*pcall_id = GetOriginalPort(pptp_link);
*pcall_id = GetOriginalPort(pptp_lnk);
/* Compute TCP checksum for modified packet */
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
@ -274,10 +274,10 @@ AliasHandlePptpIn(struct libalias *la,
if (codes->resCode == 1) /* Connection
* established, */
SetDestCallId(pptp_link, /* note the Call ID. */
SetDestCallId(pptp_lnk, /* note the Call ID. */
cptr->cid1);
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;
/* Verify data length */
if (dlen < (sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds)))
if (dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds)))
return (NULL);
/* Move up to PPTP message header */
@ -312,8 +312,8 @@ AliasVerifyPptp(struct ip *pip, u_int16_t * ptype)
/* Verify data length. */
if ((*ptype == PPTP_OutCallReply || *ptype == PPTP_InCallReply) &&
(dlen < sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) +
sizeof(struct pptpCodes)))
(dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) +
sizeof(struct pptpCodes))))
return (NULL);
else
return (PptpCallId) (hptr + 1);
@ -324,7 +324,7 @@ int
AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
{
GreHdr *gr;
struct alias_link *link;
struct alias_link *lnk;
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)
return (-1);
link = FindPptpOutByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
if (link != NULL) {
struct in_addr alias_addr = GetAliasAddress(link);
lnk = FindPptpOutByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
if (lnk != NULL) {
struct in_addr alias_addr = GetAliasAddress(lnk);
/* Change source IP address. */
DifferentialChecksum(&pip->ip_sum,
@ -349,7 +349,7 @@ int
AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
{
GreHdr *gr;
struct alias_link *link;
struct alias_link *lnk;
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)
return (-1);
link = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
if (link != NULL) {
struct in_addr src_addr = GetOriginalAddress(link);
lnk = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
if (lnk != NULL) {
struct in_addr src_addr = GetOriginalAddress(lnk);
/* De-alias the Peer's Call Id. */
gr->gh_call_id = GetOriginalPort(link);
gr->gh_call_id = GetOriginalPort(lnk);
/* Restore original IP address. */
DifferentialChecksum(&pip->ip_sum,

View File

@ -274,7 +274,7 @@ RuleNumberDelete(struct libalias *la, int rule_index)
}
static void
ProxyEncodeTcpStream(struct alias_link *link,
ProxyEncodeTcpStream(struct alias_link *lnk,
struct ip *pip,
int maxpacketsize)
{
@ -287,12 +287,12 @@ ProxyEncodeTcpStream(struct alias_link *link,
/* Don't modify if once already modified */
if (GetAckModified(link))
if (GetAckModified(lnk))
return;
/* Translate destination address and port to string form */
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 */
slen = strlen(buffer);
@ -307,7 +307,7 @@ ProxyEncodeTcpStream(struct alias_link *link,
}
/* Check for packet overflow */
if ((ntohs(pip->ip_len) + strlen(buffer)) > maxpacketsize)
if ((int)(ntohs(pip->ip_len) + strlen(buffer)) > maxpacketsize)
return;
/* Shift existing TCP data and insert destination string */
@ -335,9 +335,9 @@ ProxyEncodeTcpStream(struct alias_link *link,
{
int delta;
SetAckModified(link);
delta = GetDeltaSeqOut(pip, link);
AddSeq(pip, link, delta + slen);
SetAckModified(lnk);
delta = GetDeltaSeqOut(pip, lnk);
AddSeq(pip, lnk, delta + slen);
}
/* 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));
#endif
(void)maxpacketsize;
/* Check to see that there is room to add an IP option */
if (pip->ip_hl > (0x0f - OPTION_LEN_INT32))
return;
@ -481,18 +483,21 @@ ProxyCheck(struct libalias *la, struct ip *pip,
}
void
ProxyModify(struct libalias *la, struct alias_link *link,
ProxyModify(struct libalias *la, struct alias_link *lnk,
struct ip *pip,
int maxpacketsize,
int proxy_type)
{
(void)la;
switch (proxy_type) {
case PROXY_TYPE_ENCODE_IPHDR:
ProxyEncodeIpHeader(pip, maxpacketsize);
break;
case PROXY_TYPE_ENCODE_TCPSTREAM:
ProxyEncodeTcpStream(link, pip, maxpacketsize);
ProxyEncodeTcpStream(lnk, pip, maxpacketsize);
break;
}
}
@ -549,7 +554,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
/* Copy command line into a buffer */
cmd += strspn(cmd, " \t");
cmd_len = strlen(cmd);
if (cmd_len > (sizeof(buffer) - 1))
if (cmd_len > (int)(sizeof(buffer) - 1))
return (-1);
strcpy(buffer, cmd);

View File

@ -132,10 +132,12 @@ typedef enum {
static int
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)
{
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 = TcpChecksum(pip);
@ -146,11 +148,16 @@ alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
static int
alias_skinny_startmedia(struct StartMediaTransmission *start_media,
struct ip *pip, struct tcphdr *tc,
struct alias_link *link, u_int32_t localIpAddr,
struct alias_link *lnk, u_int32_t localIpAddr,
ConvDirection direction)
{
struct in_addr dst, src;
(void)pip;
(void)tc;
(void)lnk;
(void)direction;
dst.s_addr = start_media->remoteIpAddr;
src.s_addr = localIpAddr;
@ -164,10 +171,12 @@ alias_skinny_startmedia(struct StartMediaTransmission *start_media,
static int
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)
{
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 = TcpChecksum(pip);
@ -178,22 +187,25 @@ alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
static int
alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opnrcvch_ack,
struct ip *pip, struct tcphdr *tc,
struct alias_link *link, u_int32_t * localIpAddr,
struct alias_link *lnk, u_int32_t * localIpAddr,
ConvDirection direction)
{
struct in_addr null_addr;
struct alias_link *opnrcv_link;
struct alias_link *opnrcv_lnk;
u_int32_t localPort;
(void)lnk;
(void)direction;
*localIpAddr = (u_int32_t) opnrcvch_ack->ipAddr;
localPort = opnrcvch_ack->port;
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,
IPPROTO_UDP, 1);
opnrcvch_ack->ipAddr = (u_int32_t) GetAliasAddress(opnrcv_link).s_addr;
opnrcvch_ack->port = (u_int32_t) ntohs(GetAliasPort(opnrcv_link));
opnrcvch_ack->ipAddr = (u_int32_t) GetAliasAddress(opnrcv_lnk).s_addr;
opnrcvch_ack->port = (u_int32_t) ntohs(GetAliasPort(opnrcv_lnk));
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
@ -202,11 +214,11 @@ alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opn
}
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;
struct tcphdr *tc;
u_int32_t msgId, len, t, lip;
int32_t msgId, len, t, lip;
struct skinny_header *sd;
int orig_len, skinny_hdr_len = sizeof(struct skinny_header);
ConvDirection direction;
@ -248,7 +260,7 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
msgId = (sd->msgId);
t = len;
if (t < 0 || t > orig_len || t > dlen) {
if (t > orig_len || t > dlen) {
#ifdef DEBUG
fprintf(stderr,
"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: {
struct RegisterMessage *reg_mesg;
if (len < sizeof(struct RegisterMessage)) {
if (len < (int)sizeof(struct RegisterMessage)) {
#ifdef DEBUG
fprintf(stderr,
"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,
"PacketAlias/Skinny: Received a register message");
#endif
alias_skinny_reg_msg(reg_mesg, pip, tc, link, direction);
alias_skinny_reg_msg(reg_mesg, pip, tc, lnk, direction);
break;
}
case IP_PORT_MSG: {
struct IpPortMessage *port_mesg;
if (len < sizeof(struct IpPortMessage)) {
if (len < (int)sizeof(struct IpPortMessage)) {
#ifdef DEBUG
fprintf(stderr,
"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");
#endif
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;
}
case OPNRCVCH_ACK: {
struct OpenReceiveChannelAck *opnrcvchn_ack;
if (len < sizeof(struct OpenReceiveChannelAck)) {
if (len < (int)sizeof(struct OpenReceiveChannelAck)) {
#ifdef DEBUG
fprintf(stderr,
"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");
#endif
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;
}
case START_MEDIATX: {
struct StartMediaTransmission *startmedia_tx;
if (len < sizeof(struct StartMediaTransmission)) {
if (len < (int)sizeof(struct StartMediaTransmission)) {
#ifdef DEBUG
fprintf(stderr,
"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");
#endif
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;
}
default:

View File

@ -138,7 +138,7 @@ search_string(char *data, int dlen, const char *search_str)
static int
alias_rtsp_out(struct libalias *la, struct ip *pip,
struct alias_link *link,
struct alias_link *lnk,
char *data,
const char *port_str)
{
@ -151,7 +151,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
const char *transport_str = "transport:";
char newdata[2048], *port_data, *port_newdata, stemp[80];
int links_created = 0, pkt_updated = 0;
struct alias_link *rtsp_link = NULL;
struct alias_link *rtsp_lnk = NULL;
struct in_addr null_addr;
/* Calculate data length of TCP packet */
@ -171,7 +171,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
memcpy(newdata, data, pos);
port_newdata = newdata + pos;
while (port_dlen > strlen(port_str)) {
while (port_dlen > (int)strlen(port_str)) {
/* Find keyword, appropriate port string */
pos = search_string(port_data, port_dlen, port_str);
if (pos < 0) {
@ -242,17 +242,17 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
* to port found in
* 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),
IPPROTO_UDP);
if (rtsp_link != NULL) {
if (rtsp_lnk != NULL) {
#ifndef NO_FW_PUNCH
/*
* Punch
* hole in
* firewall
*/
PunchFWHole(rtsp_link);
PunchFWHole(rtsp_lnk);
#endif
} else {
#ifdef DEBUG
@ -265,7 +265,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
}
ealias = htons(base_alias + (RTSP_PORT_GROUP - 1));
}
if (salias && rtsp_link) {
if (salias && rtsp_lnk) {
pkt_updated = 1;
@ -308,9 +308,9 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
new_dlen = port_newdata - newdata;
memcpy(data, newdata, new_dlen);
SetAckModified(link);
delta = GetDeltaSeqOut(pip, link);
AddSeq(pip, link, delta + new_dlen - dlen);
SetAckModified(lnk);
delta = GetDeltaSeqOut(pip, lnk);
AddSeq(pip, lnk, delta + new_dlen - dlen);
new_len = htons(hlen + new_dlen);
DifferentialChecksum(&pip->ip_sum,
@ -329,7 +329,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
static int
alias_pna_out(struct libalias *la, struct ip *pip,
struct alias_link *link,
struct alias_link *lnk,
char *data,
int dlen)
{
@ -352,7 +352,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
}
if ((ntohs(msg_id) == 1) || (ntohs(msg_id) == 7)) {
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);
if (pna_links != NULL) {
#ifndef NO_FW_PUNCH
@ -375,7 +375,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
}
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;
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";
int i, parseOk;
(void)maxpacketsize;
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
hlen = (pip->ip_hl + tc->th_off) << 2;
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) ||
(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) {
alias_rtsp_out(la, pip, link, data, client_port_str);
alias_rtsp_out(la, pip, lnk, data, client_port_str);
return;
}
}
if (dlen >= strlen(pna)) {
if (dlen >= (int)strlen(pna)) {
if (memcmp(data, pna, strlen(pna)) == 0) {
alias_pna_out(la, pip, link, data, dlen);
alias_pna_out(la, pip, lnk, data, dlen);
}
}
} else {
@ -415,10 +417,10 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
* Accomodate varying number of blanks between 200 & OK
*/
if (dlen >= strlen(str200)) {
if (dlen >= (int)strlen(str200)) {
for (parseOk = 0, i = 0;
i <= dlen - strlen(str200);
i <= dlen - (int)strlen(str200);
i++) {
if (memcmp(&data[i], str200, strlen(str200)) == 0) {
parseOk = 1;
@ -431,10 +433,10 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
while (data[i] == ' ') /* skip blank(s) */
i++;
if ((dlen - i) >= strlen(okstr)) {
if ((dlen - i) >= (int)strlen(okstr)) {
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);
}
}

View File

@ -65,6 +65,8 @@ LibAliasInternetChecksum(struct libalias *la, u_short * ptr, int nbytes)
{
int sum, oddbyte;
(void)la;
sum = 0;
while (nbytes > 1) {
sum += *ptr++;

View File

@ -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_util.c alias_old.c
INCS= alias.h
WARNS?= 2
WARNS?= 6
.include <bsd.lib.mk>

View File

@ -162,43 +162,43 @@ static void TcpMonitorOut(struct ip *, struct alias_link *);
static void
TcpMonitorIn(struct ip *pip, struct alias_link *link)
TcpMonitorIn(struct ip *pip, struct alias_link *lnk)
{
struct tcphdr *tc;
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
switch (GetStateIn(link)) {
switch (GetStateIn(lnk)) {
case ALIAS_TCP_STATE_NOT_CONNECTED:
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)
SetStateIn(link, ALIAS_TCP_STATE_CONNECTED);
SetStateIn(lnk, ALIAS_TCP_STATE_CONNECTED);
break;
case ALIAS_TCP_STATE_CONNECTED:
if (tc->th_flags & (TH_FIN | TH_RST))
SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED);
SetStateIn(lnk, ALIAS_TCP_STATE_DISCONNECTED);
break;
}
}
static void
TcpMonitorOut(struct ip *pip, struct alias_link *link)
TcpMonitorOut(struct ip *pip, struct alias_link *lnk)
{
struct tcphdr *tc;
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
switch (GetStateOut(link)) {
switch (GetStateOut(lnk)) {
case ALIAS_TCP_STATE_NOT_CONNECTED:
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)
SetStateOut(link, ALIAS_TCP_STATE_CONNECTED);
SetStateOut(lnk, ALIAS_TCP_STATE_CONNECTED);
break;
case ALIAS_TCP_STATE_CONNECTED:
if (tc->th_flags & (TH_FIN | TH_RST))
SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED);
SetStateOut(lnk, ALIAS_TCP_STATE_DISCONNECTED);
break;
}
}
@ -273,18 +273,18 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip)
De-alias incoming echo and timestamp replies.
Alias incoming echo and timestamp requests.
*/
struct alias_link *link;
struct alias_link *lnk;
struct icmp *ic;
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
/* Get source address from ICMP data field and restore original data */
link = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (link != NULL) {
lnk = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (lnk != NULL) {
u_short original_id;
int accumulate;
original_id = GetOriginalPort(link);
original_id = GetOriginalPort(lnk);
/* Adjust ICMP checksum */
accumulate = ic->icmp_id;
@ -298,7 +298,7 @@ IcmpAliasIn1(struct libalias *la, struct ip *pip)
{
struct in_addr original_address;
original_address = GetOriginalAddress(link);
original_address = GetOriginalAddress(lnk);
DifferentialChecksum(&pip->ip_sum,
&original_address, &pip->ip_dst, 2);
pip->ip_dst = original_address;
@ -320,7 +320,7 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip)
struct icmp *ic, *ic2;
struct udphdr *ud;
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
ip = &ic->icmp_ip;
@ -330,29 +330,29 @@ IcmpAliasIn2(struct libalias *la, struct ip *pip)
ic2 = (struct icmp *)ud;
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,
IPPROTO_UDP, 0);
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,
IPPROTO_TCP, 0);
else if (ip->ip_p == IPPROTO_ICMP) {
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
link = NULL;
lnk = NULL;
} else
link = NULL;
lnk = NULL;
if (link != NULL) {
if (lnk != NULL) {
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
int accumulate, accumulate2;
struct in_addr original_address;
u_short original_port;
original_address = GetOriginalAddress(link);
original_port = GetOriginalPort(link);
original_address = GetOriginalAddress(lnk);
original_port = GetOriginalPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&ip->ip_src);
@ -379,8 +379,8 @@ fragment contained in ICMP data section */
struct in_addr original_address;
u_short original_id;
original_address = GetOriginalAddress(link);
original_id = GetOriginalPort(link);
original_address = GetOriginalAddress(lnk);
original_id = GetOriginalPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&ip->ip_src);
@ -451,18 +451,18 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip)
Alias outgoing echo and timestamp requests.
De-alias outgoing echo and timestamp replies.
*/
struct alias_link *link;
struct alias_link *lnk;
struct icmp *ic;
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
/* Save overwritten data for when echo packet returns */
link = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (link != NULL) {
lnk = FindIcmpOut(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (lnk != NULL) {
u_short alias_id;
int accumulate;
alias_id = GetAliasPort(link);
alias_id = GetAliasPort(lnk);
/* Since data field is being modified, adjust ICMP checksum */
accumulate = ic->icmp_id;
@ -476,7 +476,7 @@ IcmpAliasOut1(struct libalias *la, struct ip *pip)
{
struct in_addr alias_address;
alias_address = GetAliasAddress(link);
alias_address = GetAliasAddress(lnk);
DifferentialChecksum(&pip->ip_sum,
&alias_address, &pip->ip_src, 2);
pip->ip_src = alias_address;
@ -499,7 +499,7 @@ IcmpAliasOut2(struct libalias *la, struct ip *pip)
struct icmp *ic, *ic2;
struct udphdr *ud;
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
ip = &ic->icmp_ip;
@ -509,29 +509,29 @@ IcmpAliasOut2(struct libalias *la, struct ip *pip)
ic2 = (struct icmp *)ud;
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,
IPPROTO_UDP, 0);
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,
IPPROTO_TCP, 0);
else if (ip->ip_p == IPPROTO_ICMP) {
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
link = NULL;
lnk = NULL;
} else
link = NULL;
lnk = NULL;
if (link != NULL) {
if (lnk != NULL) {
if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP) {
int accumulate;
struct in_addr alias_address;
u_short alias_port;
alias_address = GetAliasAddress(link);
alias_port = GetAliasPort(link);
alias_address = GetAliasAddress(lnk);
alias_port = GetAliasPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&ip->ip_dst);
@ -558,8 +558,8 @@ fragment contained in ICMP data section */
struct in_addr alias_address;
u_short alias_id;
alias_address = GetAliasAddress(link);
alias_id = GetAliasPort(link);
alias_address = GetAliasAddress(lnk);
alias_id = GetAliasPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&ip->ip_dst);
@ -594,6 +594,8 @@ IcmpAliasOut(struct libalias *la, struct ip *pip, int create)
int iresult;
struct icmp *ic;
(void)create;
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
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
machine.
*/
struct alias_link *link;
struct alias_link *lnk;
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return (PKT_ALIAS_OK);
link = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (link != NULL) {
lnk = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (lnk != NULL) {
struct in_addr original_address;
original_address = GetOriginalAddress(link);
original_address = GetOriginalAddress(lnk);
/* Restore original IP address */
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
the source IP address of the packet.
*/
struct alias_link *link;
struct alias_link *lnk;
(void)create;
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return (PKT_ALIAS_OK);
link = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (link != NULL) {
lnk = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (lnk != NULL) {
struct in_addr alias_address;
alias_address = GetAliasAddress(link);
alias_address = GetAliasAddress(lnk);
/* Change source address */
DifferentialChecksum(&pip->ip_sum,
@ -690,7 +694,7 @@ static int
UdpAliasIn(struct libalias *la, struct ip *pip)
{
struct udphdr *ud;
struct alias_link *link;
struct alias_link *lnk;
/* Return if proxy-only mode is enabled */
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));
link = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
lnk = FindUdpTcpIn(la, pip->ip_src, pip->ip_dst,
ud->uh_sport, ud->uh_dport,
IPPROTO_UDP, 1);
if (link != NULL) {
if (lnk != NULL) {
struct in_addr alias_address;
struct in_addr original_address;
u_short alias_port;
int accumulate;
int r = 0;
alias_address = GetAliasAddress(link);
original_address = GetOriginalAddress(link);
alias_address = GetAliasAddress(lnk);
original_address = GetOriginalAddress(lnk);
alias_port = ud->uh_dport;
ud->uh_dport = GetOriginalPort(link);
ud->uh_dport = GetOriginalPort(lnk);
/* Special processing for IP encoding protocols */
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 */
else if (ntohs(ud->uh_dport) == 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
|| 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);
/* 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)
{
struct udphdr *ud;
struct alias_link *link;
struct alias_link *lnk;
/* Return if proxy-only mode is enabled */
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));
link = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
lnk = FindUdpTcpOut(la, pip->ip_src, pip->ip_dst,
ud->uh_sport, ud->uh_dport,
IPPROTO_UDP, create);
if (link != NULL) {
if (lnk != NULL) {
u_short alias_port;
struct in_addr alias_address;
alias_address = GetAliasAddress(link);
alias_port = GetAliasPort(link);
alias_address = GetAliasAddress(lnk);
alias_port = GetAliasPort(lnk);
/* Special processing for IP encoding protocols */
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 */
else if (ntohs(ud->uh_dport) == 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
|| 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);
/*
* 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)
{
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
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,
IPPROTO_TCP,
!(la->packetAliasMode & PKT_ALIAS_PROXY_ONLY));
if (link != NULL) {
if (lnk != NULL) {
struct in_addr alias_address;
struct in_addr original_address;
struct in_addr proxy_address;
@ -841,17 +845,17 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
/* Special processing for IP encoding protocols */
if (ntohs(tc->th_dport) == 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
|| ntohs(tc->th_sport) == la->skinnyPort))
AliasHandleSkinny(la, pip, link);
AliasHandleSkinny(la, pip, lnk);
alias_address = GetAliasAddress(link);
original_address = GetOriginalAddress(link);
proxy_address = GetProxyAddress(link);
alias_address = GetAliasAddress(lnk);
original_address = GetOriginalAddress(lnk);
proxy_address = GetProxyAddress(lnk);
alias_port = tc->th_dport;
tc->th_dport = GetOriginalPort(link);
proxy_port = GetProxyPort(link);
tc->th_dport = GetOriginalPort(lnk);
proxy_port = GetProxyPort(lnk);
/* Adjust TCP checksum since destination port is being unaliased */
/* and destination port is being altered. */
@ -870,10 +874,10 @@ TcpAliasIn(struct libalias *la, struct ip *pip)
accumulate -= twowords(&proxy_address);
}
/* See if ACK number needs to be modified */
if (GetAckModified(link) == 1) {
if (GetAckModified(lnk) == 1) {
int delta;
delta = GetDeltaAckIn(pip, link);
delta = GetDeltaAckIn(pip, lnk);
if (delta != 0) {
accumulate += twowords(&tc->th_ack);
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);
/* Monitor TCP connection state */
TcpMonitorIn(pip, link);
TcpMonitorIn(pip, lnk);
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 proxy_server_address;
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
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);
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,
IPPROTO_TCP, create);
if (link == NULL)
if (lnk == NULL)
return (PKT_ALIAS_IGNORED);
if (link != NULL) {
if (lnk != NULL) {
u_short alias_port;
struct in_addr alias_address;
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
change the size of IP header. */
if (proxy_type != 0) {
SetProxyPort(link, dest_port);
SetProxyAddress(link, dest_address);
ProxyModify(la, link, pip, maxpacketsize, proxy_type);
SetProxyPort(lnk, dest_port);
SetProxyAddress(lnk, dest_address);
ProxyModify(la, lnk, pip, maxpacketsize, proxy_type);
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
}
/* Get alias address and port */
alias_port = GetAliasPort(link);
alias_address = GetAliasAddress(link);
alias_port = GetAliasPort(lnk);
alias_address = GetAliasAddress(lnk);
/* Monitor TCP connection state */
TcpMonitorOut(pip, link);
TcpMonitorOut(pip, lnk);
/* Special processing for IP encoding protocols */
if (ntohs(tc->th_dport) == 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
|| 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
|| ntohs(tc->th_sport) == RTSP_CONTROL_PORT_NUMBER_1
|| ntohs(tc->th_dport) == 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
|| 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
|| ntohs(tc->th_dport) == la->skinnyPort))
AliasHandleSkinny(la, pip, link);
AliasHandleSkinny(la, pip, lnk);
/* Adjust TCP checksum since source port is being aliased */
/* 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);
/* Modify sequence number if necessary */
if (GetAckModified(link) == 1) {
if (GetAckModified(lnk) == 1) {
int delta;
delta = GetDeltaSeqOut(pip, link);
delta = GetDeltaSeqOut(pip, lnk);
if (delta != 0) {
accumulate += twowords(&tc->th_seq);
tc->th_seq = htonl(ntohl(tc->th_seq) + delta);
@ -1042,13 +1046,13 @@ static int FragmentOut(struct libalias *, struct ip *);
static int
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);
if (link != NULL) {
lnk = FindFragmentIn2(la, pip->ip_src, pip->ip_dst, pip->ip_id);
if (lnk != NULL) {
struct in_addr original_address;
GetFragmentAddr(link, &original_address);
GetFragmentAddr(lnk, &original_address);
DifferentialChecksum(&pip->ip_sum,
&original_address, &pip->ip_dst, 2);
pip->ip_dst = original_address;
@ -1094,14 +1098,14 @@ int
LibAliasSaveFragment(struct libalias *la, char *ptr)
{
int iresult;
struct alias_link *link;
struct alias_link *lnk;
struct ip *pip;
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;
if (link != NULL) {
SetFragmentPtr(link, ptr);
if (lnk != NULL) {
SetFragmentPtr(lnk, ptr);
iresult = PKT_ALIAS_OK;
}
return (iresult);
@ -1111,16 +1115,16 @@ LibAliasSaveFragment(struct libalias *la, char *ptr)
char *
LibAliasGetFragment(struct libalias *la, char *ptr)
{
struct alias_link *link;
struct alias_link *lnk;
char *fptr;
struct ip *pip;
pip = (struct ip *)ptr;
link = FindFragmentPtr(la, pip->ip_src, pip->ip_id);
if (link != NULL) {
GetFragmentPtr(link, &fptr);
SetFragmentPtr(link, NULL);
SetExpire(link, 0); /* Deletes link */
lnk = FindFragmentPtr(la, pip->ip_src, pip->ip_id);
if (lnk != NULL) {
GetFragmentPtr(lnk, &fptr);
SetFragmentPtr(lnk, NULL);
SetExpire(lnk, 0); /* Deletes link */
return (fptr);
} else {
@ -1140,6 +1144,7 @@ LibAliasFragmentIn(struct libalias *la, char *ptr, /* Points to correctly
struct ip *pip;
struct ip *fpip;
(void)la;
pip = (struct ip *)ptr;
fpip = (struct ip *)ptr_fragment;
@ -1197,12 +1202,12 @@ LibAliasIn(struct libalias *la, char *ptr, int maxpacketsize)
}
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);
if (link != NULL) {
lnk = FindFragmentIn1(la, pip->ip_src, alias_addr, pip->ip_id);
if (lnk != NULL) {
iresult = PKT_ALIAS_FOUND_HEADER_FRAGMENT;
SetFragmentAddr(link, pip->ip_dst);
SetFragmentAddr(lnk, pip->ip_dst);
} else {
iresult = PKT_ALIAS_ERROR;
}
@ -1324,7 +1329,7 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
struct icmp *ic;
struct udphdr *ud;
struct tcphdr *tc;
struct alias_link *link;
struct alias_link *lnk;
int iresult = PKT_ALIAS_IGNORED;
pip = (struct ip *)ptr;
@ -1340,27 +1345,27 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
/* Find a link */
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,
IPPROTO_UDP, 0);
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,
IPPROTO_TCP, 0);
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
link = NULL;
lnk = NULL;
/* 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) {
int accumulate;
struct in_addr original_address;
u_short original_port;
original_address = GetOriginalAddress(link);
original_port = GetOriginalPort(link);
original_address = GetOriginalAddress(lnk);
original_port = GetOriginalPort(lnk);
/* Adjust TCP/UDP checksum */
accumulate = twowords(&pip->ip_src);
@ -1395,8 +1400,8 @@ LibAliasUnaliasOut(struct libalias *la, char *ptr, /* valid IP packet */
struct in_addr original_address;
u_short original_id;
original_address = GetOriginalAddress(link);
original_id = GetOriginalPort(link);
original_address = GetOriginalAddress(lnk);
original_id = GetOriginalPort(lnk);
/* Adjust ICMP checksum */
accumulate = twowords(&pip->ip_src);

View File

@ -89,13 +89,13 @@ int PacketUnaliasOut(char *_ptr, int _maxpacketsize);
int
PacketAliasAddServer(struct alias_link *_link,
PacketAliasAddServer(struct alias_link *_lnk,
struct in_addr _addr, unsigned short _port);
struct alias_link *
PacketAliasRedirectAddr(struct in_addr _src_addr,
struct in_addr _alias_addr);
int PacketAliasRedirectDynamic(struct alias_link *_link);
void PacketAliasRedirectDelete(struct alias_link *_link);
int PacketAliasRedirectDynamic(struct alias_link *_lnk);
void PacketAliasRedirectDelete(struct alias_link *_lnk);
struct alias_link *
PacketAliasRedirectPort(struct in_addr _src_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. */
int
LibAliasAddServer(struct libalias *, struct alias_link *_link,
LibAliasAddServer(struct libalias *, struct alias_link *_lnk,
struct in_addr _addr, unsigned short _port);
struct alias_link *
LibAliasRedirectAddr(struct libalias *, struct in_addr _src_addr,
struct in_addr _alias_addr);
int LibAliasRedirectDynamic(struct libalias *, struct alias_link *_link);
void LibAliasRedirectDelete(struct libalias *, struct alias_link *_link);
int LibAliasRedirectDynamic(struct libalias *, struct alias_link *_lnk);
void LibAliasRedirectDelete(struct libalias *, struct alias_link *_lnk);
struct alias_link *
LibAliasRedirectPort(struct libalias *, struct in_addr _src_addr,
unsigned short _src_port, struct in_addr _dst_addr,

View File

@ -68,25 +68,25 @@ struct client_info {
};
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;
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
if (ntohs(ud->uh_ulen) - sizeof(struct udphdr) >= sizeof(struct cu_header)) {
struct cu_header *cu;
struct alias_link *cu_link;
struct alias_link *cu_lnk;
cu = (struct cu_header *)(ud + 1);
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);
#ifndef NO_FW_PUNCH
if (cu_link)
PunchFWHole(cu_link);
if (cu_lnk)
PunchFWHole(cu_lnk);
#endif
}
}
@ -102,6 +102,7 @@ AliasHandleCUSeeMeIn(struct libalias *la, struct ip *pip, struct in_addr origina
char *end;
int i;
(void)la;
alias_addr.s_addr = pip->ip_dst.s_addr;
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
cu = (struct cu_header *)(ud + 1);

File diff suppressed because it is too large Load Diff

View File

@ -104,7 +104,7 @@ void
AliasHandleFtpOut(
struct libalias *la,
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
(including headers) */ )
{
@ -127,7 +127,7 @@ AliasHandleFtpOut(
* Check that data length is not too long and previous message was
* properly terminated with CRLF.
*/
pflags = GetProtocolFlags(link);
pflags = GetProtocolFlags(lnk);
if (dlen <= MAX_MESSAGE_SIZE && !(pflags & WAIT_CRLF)) {
ftp_message_type = FTP_UNKNOWN_MESSAGE;
@ -152,7 +152,7 @@ AliasHandleFtpOut(
}
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 */
@ -164,7 +164,7 @@ AliasHandleFtpOut(
pflags &= ~WAIT_CRLF;
else
pflags |= WAIT_CRLF;
SetProtocolFlags(link, pflags);
SetProtocolFlags(lnk, pflags);
}
}
@ -551,11 +551,11 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
static void
NewFtpMessage(struct libalias *la, struct ip *pip,
struct alias_link *link,
struct alias_link *lnk,
int maxpacketsize,
int ftp_message_type)
{
struct alias_link *ftp_link;
struct alias_link *ftp_lnk;
/* Security checks. */
if (pip->ip_src.s_addr != la->true_addr.s_addr)
@ -565,16 +565,16 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
return;
/* 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);
if (ftp_link != NULL) {
if (ftp_lnk != NULL) {
int slen, hlen, tlen, dlen;
struct tcphdr *tc;
#ifndef NO_FW_PUNCH
/* Punch hole in firewall */
PunchFWHole(ftp_link);
PunchFWHole(ftp_lnk);
#endif
/* Calculate data length of TCP packet */
@ -593,14 +593,14 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
struct in_addr alias_address;
/* Decompose alias address into quad format */
alias_address = GetAliasAddress(link);
alias_address = GetAliasAddress(lnk);
ptr = (u_char *) & alias_address.s_addr;
a1 = *ptr++;
a2 = *ptr++;
a3 = *ptr++;
a4 = *ptr;
alias_port = GetAliasPort(ftp_link);
alias_port = GetAliasPort(ftp_lnk);
switch (ftp_message_type) {
case FTP_PORT_COMMAND:
@ -646,9 +646,9 @@ NewFtpMessage(struct libalias *la, struct ip *pip,
{
int delta;
SetAckModified(link);
delta = GetDeltaSeqOut(pip, link);
AddSeq(pip, link, delta + slen - dlen);
SetAckModified(lnk);
delta = GetDeltaSeqOut(pip, lnk);
AddSeq(pip, lnk, delta + slen - dlen);
}
/* Revise IP header */

View File

@ -67,7 +67,7 @@ __FBSDID("$FreeBSD$");
void
AliasHandleIrcOut(struct libalias *la,
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
* headers */
)
@ -89,7 +89,7 @@ AliasHandleIrcOut(struct libalias *la,
* Return if data length is too short - assume an entire PRIVMSG in
* 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;
/* Place string pointer at beginning of data */
@ -109,9 +109,9 @@ AliasHandleIrcOut(struct libalias *la,
{
char newpacket[65536]; /* Estimate of maximum packet size
* :) */
int copyat = i; /* Same */
int iCopy = 0; /* How much data have we written to
* copy-back string? */
unsigned int copyat = i; /* Same */
unsigned int iCopy = 0; /* How much data have we written to
* copy-back string? */
unsigned long org_addr; /* Original IP address */
unsigned short org_port; /* Original source port
* address */
@ -249,7 +249,7 @@ AliasHandleIrcOut(struct libalias *la,
/* We've got the address and port - now alias it */
{
struct alias_link *dcc_link;
struct alias_link *dcc_lnk;
struct in_addr destaddr;
@ -268,11 +268,11 @@ AliasHandleIrcOut(struct libalias *la,
* matter, and this would probably allow it through
* at least _some_ firewalls.
*/
dcc_link = FindUdpTcpOut(la, true_addr, destaddr,
dcc_lnk = FindUdpTcpOut(la, true_addr, destaddr,
true_port, 0,
IPPROTO_TCP, 1);
DBprintf(("Got a DCC link\n"));
if (dcc_link) {
if (dcc_lnk) {
struct in_addr alias_address; /* Address from aliasing */
u_short alias_port; /* Port given by
* aliasing */
@ -280,10 +280,10 @@ AliasHandleIrcOut(struct libalias *la,
#ifndef NO_FW_PUNCH
/* Generate firewall hole as appropriate */
PunchFWHole(dcc_link);
PunchFWHole(dcc_lnk);
#endif
alias_address = GetAliasAddress(link);
alias_address = GetAliasAddress(lnk);
n = snprintf(&newpacket[iCopy],
sizeof(newpacket) - iCopy,
"%lu ", (u_long) htonl(alias_address.s_addr));
@ -296,7 +296,7 @@ AliasHandleIrcOut(struct libalias *la,
DBprintf(("DCC constructed packet overflow.\n"));
goto lBAD_CTCP;
}
alias_port = GetAliasPort(dcc_link);
alias_port = GetAliasPort(dcc_lnk);
n = snprintf(&newpacket[iCopy],
sizeof(newpacket) - iCopy,
"%u", htons(alias_port));
@ -342,9 +342,9 @@ AliasHandleIrcOut(struct libalias *la,
{
int delta;
SetAckModified(link);
delta = GetDeltaSeqOut(pip, link);
AddSeq(pip, link, delta + copyat + iCopy - dlen);
SetAckModified(lnk);
delta = GetDeltaSeqOut(pip, lnk);
AddSeq(pip, lnk, delta + copyat + iCopy - dlen);
}
/* Revise IP header */

View File

@ -227,43 +227,43 @@ int
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_char _proto, u_char _align);
void GetFragmentAddr(struct alias_link *_link, struct in_addr *_src_addr);
void SetFragmentAddr(struct alias_link *_link, struct in_addr _src_addr);
void GetFragmentPtr(struct alias_link *_link, char **_fptr);
void SetFragmentPtr(struct alias_link *_link, char *fptr);
void SetStateIn(struct alias_link *_link, int _state);
void SetStateOut(struct alias_link *_link, int _state);
int GetStateIn (struct alias_link *_link);
int GetStateOut(struct alias_link *_link);
void GetFragmentAddr(struct alias_link *_lnk, struct in_addr *_src_addr);
void SetFragmentAddr(struct alias_link *_lnk, struct in_addr _src_addr);
void GetFragmentPtr(struct alias_link *_lnk, char **_fptr);
void SetFragmentPtr(struct alias_link *_lnk, char *fptr);
void SetStateIn(struct alias_link *_lnk, int _state);
void SetStateOut(struct alias_link *_lnk, int _state);
int GetStateIn (struct alias_link *_lnk);
int GetStateOut(struct alias_link *_lnk);
struct in_addr
GetOriginalAddress(struct alias_link *_link);
GetOriginalAddress(struct alias_link *_lnk);
struct in_addr
GetDestAddress(struct alias_link *_link);
GetDestAddress(struct alias_link *_lnk);
struct in_addr
GetAliasAddress(struct alias_link *_link);
GetAliasAddress(struct alias_link *_lnk);
struct in_addr
GetDefaultAliasAddress(struct libalias *la);
void SetDefaultAliasAddress(struct libalias *la, struct in_addr _alias_addr);
u_short GetOriginalPort(struct alias_link *_link);
u_short GetAliasPort(struct alias_link *_link);
u_short GetOriginalPort(struct alias_link *_lnk);
u_short GetAliasPort(struct alias_link *_lnk);
struct in_addr
GetProxyAddress(struct alias_link *_link);
void SetProxyAddress(struct alias_link *_link, struct in_addr _addr);
u_short GetProxyPort(struct alias_link *_link);
void SetProxyPort(struct alias_link *_link, u_short _port);
void SetAckModified(struct alias_link *_link);
int GetAckModified(struct alias_link *_link);
int GetDeltaAckIn(struct ip *_pip, struct alias_link *_link);
int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_link);
void AddSeq (struct ip *_pip, struct alias_link *_link, int _delta);
void SetExpire (struct alias_link *_link, int _expire);
GetProxyAddress(struct alias_link *_lnk);
void SetProxyAddress(struct alias_link *_lnk, struct in_addr _addr);
u_short GetProxyPort(struct alias_link *_lnk);
void SetProxyPort(struct alias_link *_lnk, u_short _port);
void SetAckModified(struct alias_link *_lnk);
int GetAckModified(struct alias_link *_lnk);
int GetDeltaAckIn(struct ip *_pip, struct alias_link *_lnk);
int GetDeltaSeqOut(struct ip *_pip, struct alias_link *_lnk);
void AddSeq (struct ip *_pip, struct alias_link *_lnk, int _delta);
void SetExpire (struct alias_link *_lnk, int _expire);
void ClearCheckNewLink(struct libalias *la);
void SetProtocolFlags(struct alias_link *_link, int _pflags);
int GetProtocolFlags(struct alias_link *_link);
void SetDestCallId(struct alias_link *_link, u_int16_t _cid);
void SetProtocolFlags(struct alias_link *_lnk, int _pflags);
int GetProtocolFlags(struct alias_link *_lnk);
void SetDestCallId(struct alias_link *_lnk, u_int16_t _cid);
#ifndef NO_FW_PUNCH
void PunchFWHole(struct alias_link *_link);
void PunchFWHole(struct alias_link *_lnk);
#endif
@ -275,47 +275,47 @@ void HouseKeeping(struct libalias *);
/* FTP routines */
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);
/* IRC routines */
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);
/* RTSP routines */
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);
/* PPTP routines */
void AliasHandlePptpOut(struct libalias *la, struct ip *_pip, struct alias_link *_link);
void AliasHandlePptpIn(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 *_lnk);
int AliasHandlePptpGreOut(struct libalias *la, struct ip *_pip);
int AliasHandlePptpGreIn(struct libalias *la, struct ip *_pip);
/* NetBIOS routines */
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);
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 *_original_address, u_short * _original_port);
/* 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);
/* 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 */
int
ProxyCheck(struct libalias *la, struct ip *_pip, struct in_addr *_proxy_server_addr,
u_short * _proxy_server_port);
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);
enum alias_tcp_state {

View File

@ -204,7 +204,7 @@ int
AliasHandleUdpNbt(
struct libalias *la,
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link,
struct alias_link *lnk,
struct in_addr *alias_address,
u_short alias_port
)
@ -214,6 +214,9 @@ AliasHandleUdpNbt(
u_char *p = NULL;
char *pmax;
(void)la;
(void)lnk;
/* Calculate data length of UDP packet */
uh = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
pmax = (char *)uh + ntohs(uh->uh_ulen);
@ -288,6 +291,8 @@ AliasHandleQuestion(
NBTArguments * nbtarg)
{
(void)nbtarg;
while (count != 0) {
/* Name Filed */
q = (NBTNsQuestion *) AliasHandleName((u_char *) q, pmax);
@ -468,6 +473,8 @@ AliasHandleResourceNULL(
NBTNsResourceNULL *n;
u_short bcount;
(void)nbtarg;
if (q == NULL || (char *)(q + 1) > pmax)
return (NULL);
@ -501,6 +508,8 @@ AliasHandleResourceNS(
NBTNsResourceNULL *n;
u_short bcount;
(void)nbtarg;
if (q == NULL || (char *)(q + 1) > pmax)
return (NULL);
@ -532,6 +541,8 @@ AliasHandleResourceNBSTAT(
NBTNsResourceNBSTAT *n;
u_short bcount;
(void)nbtarg;
if (q == NULL || (char *)(q + 1) > pmax)
return (NULL);
@ -621,7 +632,7 @@ int
AliasHandleUdpNbtNS(
struct libalias *la,
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link,
struct alias_link *lnk,
struct in_addr *alias_address,
u_short * alias_port,
struct in_addr *original_address,
@ -633,6 +644,9 @@ AliasHandleUdpNbtNS(
char *pmax;
NBTArguments nbtarg;
(void)la;
(void)lnk;
/* Set up Common Parameter */
nbtarg.oldaddr = *alias_address;
nbtarg.oldport = *alias_port;

View File

@ -104,11 +104,11 @@ PacketUnaliasOut(char *_ptr, int _maxpacketsize)
}
int
PacketAliasAddServer(struct alias_link *_link,
PacketAliasAddServer(struct alias_link *_lnk,
struct in_addr _addr, unsigned short _port)
{
return LibAliasAddServer(la, _link, _addr, _port);
return LibAliasAddServer(la, _lnk, _addr, _port);
}
struct alias_link *
@ -121,17 +121,17 @@ PacketAliasRedirectAddr(struct in_addr _src_addr,
int
PacketAliasRedirectDynamic(struct alias_link *_link)
PacketAliasRedirectDynamic(struct alias_link *_lnk)
{
return LibAliasRedirectDynamic(la, _link);
return LibAliasRedirectDynamic(la, _lnk);
}
void
PacketAliasRedirectDelete(struct alias_link *_link)
PacketAliasRedirectDelete(struct alias_link *_lnk)
{
LibAliasRedirectDelete(la, _link);
LibAliasRedirectDelete(la, _lnk);
}
struct alias_link *

View File

@ -147,9 +147,9 @@ static PptpCallId AliasVerifyPptp(struct ip *, u_int16_t *);
void
AliasHandlePptpOut(struct libalias *la,
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link)
struct alias_link *lnk)
{ /* The PPTP control link */
struct alias_link *pptp_link;
struct alias_link *pptp_lnk;
PptpCallId cptr;
PptpCode codes;
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
* control message.
*/
pptp_link = AddPptp(la, GetOriginalAddress(link), GetDestAddress(link),
GetAliasAddress(link), cptr->cid1);
pptp_lnk = AddPptp(la, GetOriginalAddress(lnk), GetDestAddress(lnk),
GetAliasAddress(lnk), cptr->cid1);
break;
case PPTP_CallClearRequest:
case PPTP_CallDiscNotify:
@ -178,19 +178,19 @@ AliasHandlePptpOut(struct libalias *la,
* Find PPTP link for address and Call ID found in control
* message.
*/
pptp_link = FindPptpOutByCallId(la, GetOriginalAddress(link),
GetDestAddress(link),
pptp_lnk = FindPptpOutByCallId(la, GetOriginalAddress(lnk),
GetDestAddress(lnk),
cptr->cid1);
break;
default:
return;
}
if (pptp_link != NULL) {
if (pptp_lnk != NULL) {
int accumulate = cptr->cid1;
/* alias the Call Id */
cptr->cid1 = GetAliasPort(pptp_link);
cptr->cid1 = GetAliasPort(pptp_lnk);
/* Compute TCP checksum for revised packet */
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
@ -203,14 +203,14 @@ AliasHandlePptpOut(struct libalias *la,
codes = (PptpCode) (cptr + 1);
if (codes->resCode == 1) /* Connection
* established, */
SetDestCallId(pptp_link, /* note the Peer's Call
SetDestCallId(pptp_lnk, /* note the Peer's Call
* ID. */
cptr->cid2);
else
SetExpire(pptp_link, 0); /* Connection refused. */
SetExpire(pptp_lnk, 0); /* Connection refused. */
break;
case PPTP_CallDiscNotify: /* Connection closed. */
SetExpire(pptp_link, 0);
SetExpire(pptp_lnk, 0);
break;
}
}
@ -219,9 +219,9 @@ AliasHandlePptpOut(struct libalias *la,
void
AliasHandlePptpIn(struct libalias *la,
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link)
struct alias_link *lnk)
{ /* The PPTP control link */
struct alias_link *pptp_link;
struct alias_link *pptp_lnk;
PptpCallId cptr;
u_int16_t *pcall_id;
u_int16_t ctl_type; /* control message type */
@ -243,26 +243,26 @@ AliasHandlePptpIn(struct libalias *la,
pcall_id = &cptr->cid2;
break;
case PPTP_CallDiscNotify: /* Connection closed. */
pptp_link = FindPptpInByCallId(la, GetDestAddress(link),
GetAliasAddress(link),
pptp_lnk = FindPptpInByCallId(la, GetDestAddress(lnk),
GetAliasAddress(lnk),
cptr->cid1);
if (pptp_link != NULL)
SetExpire(pptp_link, 0);
if (pptp_lnk != NULL)
SetExpire(pptp_lnk, 0);
return;
default:
return;
}
/* Find PPTP link for address and Call ID found in PPTP Control Msg */
pptp_link = FindPptpInByPeerCallId(la, GetDestAddress(link),
GetAliasAddress(link),
pptp_lnk = FindPptpInByPeerCallId(la, GetDestAddress(lnk),
GetAliasAddress(lnk),
*pcall_id);
if (pptp_link != NULL) {
if (pptp_lnk != NULL) {
int accumulate = *pcall_id;
/* De-alias the Peer's Call Id. */
*pcall_id = GetOriginalPort(pptp_link);
*pcall_id = GetOriginalPort(pptp_lnk);
/* Compute TCP checksum for modified packet */
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
@ -274,10 +274,10 @@ AliasHandlePptpIn(struct libalias *la,
if (codes->resCode == 1) /* Connection
* established, */
SetDestCallId(pptp_link, /* note the Call ID. */
SetDestCallId(pptp_lnk, /* note the Call ID. */
cptr->cid1);
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;
/* Verify data length */
if (dlen < (sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds)))
if (dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds)))
return (NULL);
/* Move up to PPTP message header */
@ -312,8 +312,8 @@ AliasVerifyPptp(struct ip *pip, u_int16_t * ptype)
/* Verify data length. */
if ((*ptype == PPTP_OutCallReply || *ptype == PPTP_InCallReply) &&
(dlen < sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) +
sizeof(struct pptpCodes)))
(dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) +
sizeof(struct pptpCodes))))
return (NULL);
else
return (PptpCallId) (hptr + 1);
@ -324,7 +324,7 @@ int
AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
{
GreHdr *gr;
struct alias_link *link;
struct alias_link *lnk;
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)
return (-1);
link = FindPptpOutByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
if (link != NULL) {
struct in_addr alias_addr = GetAliasAddress(link);
lnk = FindPptpOutByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
if (lnk != NULL) {
struct in_addr alias_addr = GetAliasAddress(lnk);
/* Change source IP address. */
DifferentialChecksum(&pip->ip_sum,
@ -349,7 +349,7 @@ int
AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
{
GreHdr *gr;
struct alias_link *link;
struct alias_link *lnk;
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)
return (-1);
link = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
if (link != NULL) {
struct in_addr src_addr = GetOriginalAddress(link);
lnk = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
if (lnk != NULL) {
struct in_addr src_addr = GetOriginalAddress(lnk);
/* De-alias the Peer's Call Id. */
gr->gh_call_id = GetOriginalPort(link);
gr->gh_call_id = GetOriginalPort(lnk);
/* Restore original IP address. */
DifferentialChecksum(&pip->ip_sum,

View File

@ -274,7 +274,7 @@ RuleNumberDelete(struct libalias *la, int rule_index)
}
static void
ProxyEncodeTcpStream(struct alias_link *link,
ProxyEncodeTcpStream(struct alias_link *lnk,
struct ip *pip,
int maxpacketsize)
{
@ -287,12 +287,12 @@ ProxyEncodeTcpStream(struct alias_link *link,
/* Don't modify if once already modified */
if (GetAckModified(link))
if (GetAckModified(lnk))
return;
/* Translate destination address and port to string form */
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 */
slen = strlen(buffer);
@ -307,7 +307,7 @@ ProxyEncodeTcpStream(struct alias_link *link,
}
/* Check for packet overflow */
if ((ntohs(pip->ip_len) + strlen(buffer)) > maxpacketsize)
if ((int)(ntohs(pip->ip_len) + strlen(buffer)) > maxpacketsize)
return;
/* Shift existing TCP data and insert destination string */
@ -335,9 +335,9 @@ ProxyEncodeTcpStream(struct alias_link *link,
{
int delta;
SetAckModified(link);
delta = GetDeltaSeqOut(pip, link);
AddSeq(pip, link, delta + slen);
SetAckModified(lnk);
delta = GetDeltaSeqOut(pip, lnk);
AddSeq(pip, lnk, delta + slen);
}
/* 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));
#endif
(void)maxpacketsize;
/* Check to see that there is room to add an IP option */
if (pip->ip_hl > (0x0f - OPTION_LEN_INT32))
return;
@ -481,18 +483,21 @@ ProxyCheck(struct libalias *la, struct ip *pip,
}
void
ProxyModify(struct libalias *la, struct alias_link *link,
ProxyModify(struct libalias *la, struct alias_link *lnk,
struct ip *pip,
int maxpacketsize,
int proxy_type)
{
(void)la;
switch (proxy_type) {
case PROXY_TYPE_ENCODE_IPHDR:
ProxyEncodeIpHeader(pip, maxpacketsize);
break;
case PROXY_TYPE_ENCODE_TCPSTREAM:
ProxyEncodeTcpStream(link, pip, maxpacketsize);
ProxyEncodeTcpStream(lnk, pip, maxpacketsize);
break;
}
}
@ -549,7 +554,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
/* Copy command line into a buffer */
cmd += strspn(cmd, " \t");
cmd_len = strlen(cmd);
if (cmd_len > (sizeof(buffer) - 1))
if (cmd_len > (int)(sizeof(buffer) - 1))
return (-1);
strcpy(buffer, cmd);

View File

@ -132,10 +132,12 @@ typedef enum {
static int
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)
{
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 = TcpChecksum(pip);
@ -146,11 +148,16 @@ alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
static int
alias_skinny_startmedia(struct StartMediaTransmission *start_media,
struct ip *pip, struct tcphdr *tc,
struct alias_link *link, u_int32_t localIpAddr,
struct alias_link *lnk, u_int32_t localIpAddr,
ConvDirection direction)
{
struct in_addr dst, src;
(void)pip;
(void)tc;
(void)lnk;
(void)direction;
dst.s_addr = start_media->remoteIpAddr;
src.s_addr = localIpAddr;
@ -164,10 +171,12 @@ alias_skinny_startmedia(struct StartMediaTransmission *start_media,
static int
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)
{
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 = TcpChecksum(pip);
@ -178,22 +187,25 @@ alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
static int
alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opnrcvch_ack,
struct ip *pip, struct tcphdr *tc,
struct alias_link *link, u_int32_t * localIpAddr,
struct alias_link *lnk, u_int32_t * localIpAddr,
ConvDirection direction)
{
struct in_addr null_addr;
struct alias_link *opnrcv_link;
struct alias_link *opnrcv_lnk;
u_int32_t localPort;
(void)lnk;
(void)direction;
*localIpAddr = (u_int32_t) opnrcvch_ack->ipAddr;
localPort = opnrcvch_ack->port;
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,
IPPROTO_UDP, 1);
opnrcvch_ack->ipAddr = (u_int32_t) GetAliasAddress(opnrcv_link).s_addr;
opnrcvch_ack->port = (u_int32_t) ntohs(GetAliasPort(opnrcv_link));
opnrcvch_ack->ipAddr = (u_int32_t) GetAliasAddress(opnrcv_lnk).s_addr;
opnrcvch_ack->port = (u_int32_t) ntohs(GetAliasPort(opnrcv_lnk));
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
@ -202,11 +214,11 @@ alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opn
}
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;
struct tcphdr *tc;
u_int32_t msgId, len, t, lip;
int32_t msgId, len, t, lip;
struct skinny_header *sd;
int orig_len, skinny_hdr_len = sizeof(struct skinny_header);
ConvDirection direction;
@ -248,7 +260,7 @@ AliasHandleSkinny(struct libalias *la, struct ip *pip, struct alias_link *link)
msgId = (sd->msgId);
t = len;
if (t < 0 || t > orig_len || t > dlen) {
if (t > orig_len || t > dlen) {
#ifdef DEBUG
fprintf(stderr,
"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: {
struct RegisterMessage *reg_mesg;
if (len < sizeof(struct RegisterMessage)) {
if (len < (int)sizeof(struct RegisterMessage)) {
#ifdef DEBUG
fprintf(stderr,
"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,
"PacketAlias/Skinny: Received a register message");
#endif
alias_skinny_reg_msg(reg_mesg, pip, tc, link, direction);
alias_skinny_reg_msg(reg_mesg, pip, tc, lnk, direction);
break;
}
case IP_PORT_MSG: {
struct IpPortMessage *port_mesg;
if (len < sizeof(struct IpPortMessage)) {
if (len < (int)sizeof(struct IpPortMessage)) {
#ifdef DEBUG
fprintf(stderr,
"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");
#endif
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;
}
case OPNRCVCH_ACK: {
struct OpenReceiveChannelAck *opnrcvchn_ack;
if (len < sizeof(struct OpenReceiveChannelAck)) {
if (len < (int)sizeof(struct OpenReceiveChannelAck)) {
#ifdef DEBUG
fprintf(stderr,
"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");
#endif
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;
}
case START_MEDIATX: {
struct StartMediaTransmission *startmedia_tx;
if (len < sizeof(struct StartMediaTransmission)) {
if (len < (int)sizeof(struct StartMediaTransmission)) {
#ifdef DEBUG
fprintf(stderr,
"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");
#endif
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;
}
default:

View File

@ -138,7 +138,7 @@ search_string(char *data, int dlen, const char *search_str)
static int
alias_rtsp_out(struct libalias *la, struct ip *pip,
struct alias_link *link,
struct alias_link *lnk,
char *data,
const char *port_str)
{
@ -151,7 +151,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
const char *transport_str = "transport:";
char newdata[2048], *port_data, *port_newdata, stemp[80];
int links_created = 0, pkt_updated = 0;
struct alias_link *rtsp_link = NULL;
struct alias_link *rtsp_lnk = NULL;
struct in_addr null_addr;
/* Calculate data length of TCP packet */
@ -171,7 +171,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
memcpy(newdata, data, pos);
port_newdata = newdata + pos;
while (port_dlen > strlen(port_str)) {
while (port_dlen > (int)strlen(port_str)) {
/* Find keyword, appropriate port string */
pos = search_string(port_data, port_dlen, port_str);
if (pos < 0) {
@ -242,17 +242,17 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
* to port found in
* 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),
IPPROTO_UDP);
if (rtsp_link != NULL) {
if (rtsp_lnk != NULL) {
#ifndef NO_FW_PUNCH
/*
* Punch
* hole in
* firewall
*/
PunchFWHole(rtsp_link);
PunchFWHole(rtsp_lnk);
#endif
} else {
#ifdef DEBUG
@ -265,7 +265,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
}
ealias = htons(base_alias + (RTSP_PORT_GROUP - 1));
}
if (salias && rtsp_link) {
if (salias && rtsp_lnk) {
pkt_updated = 1;
@ -308,9 +308,9 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
new_dlen = port_newdata - newdata;
memcpy(data, newdata, new_dlen);
SetAckModified(link);
delta = GetDeltaSeqOut(pip, link);
AddSeq(pip, link, delta + new_dlen - dlen);
SetAckModified(lnk);
delta = GetDeltaSeqOut(pip, lnk);
AddSeq(pip, lnk, delta + new_dlen - dlen);
new_len = htons(hlen + new_dlen);
DifferentialChecksum(&pip->ip_sum,
@ -329,7 +329,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
static int
alias_pna_out(struct libalias *la, struct ip *pip,
struct alias_link *link,
struct alias_link *lnk,
char *data,
int dlen)
{
@ -352,7 +352,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
}
if ((ntohs(msg_id) == 1) || (ntohs(msg_id) == 7)) {
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);
if (pna_links != NULL) {
#ifndef NO_FW_PUNCH
@ -375,7 +375,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
}
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;
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";
int i, parseOk;
(void)maxpacketsize;
tc = (struct tcphdr *)((char *)pip + (pip->ip_hl << 2));
hlen = (pip->ip_hl + tc->th_off) << 2;
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) ||
(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) {
alias_rtsp_out(la, pip, link, data, client_port_str);
alias_rtsp_out(la, pip, lnk, data, client_port_str);
return;
}
}
if (dlen >= strlen(pna)) {
if (dlen >= (int)strlen(pna)) {
if (memcmp(data, pna, strlen(pna)) == 0) {
alias_pna_out(la, pip, link, data, dlen);
alias_pna_out(la, pip, lnk, data, dlen);
}
}
} else {
@ -415,10 +417,10 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
* Accomodate varying number of blanks between 200 & OK
*/
if (dlen >= strlen(str200)) {
if (dlen >= (int)strlen(str200)) {
for (parseOk = 0, i = 0;
i <= dlen - strlen(str200);
i <= dlen - (int)strlen(str200);
i++) {
if (memcmp(&data[i], str200, strlen(str200)) == 0) {
parseOk = 1;
@ -431,10 +433,10 @@ AliasHandleRtspOut(struct libalias *la, struct ip *pip, struct alias_link *link,
while (data[i] == ' ') /* skip blank(s) */
i++;
if ((dlen - i) >= strlen(okstr)) {
if ((dlen - i) >= (int)strlen(okstr)) {
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);
}
}

View File

@ -65,6 +65,8 @@ LibAliasInternetChecksum(struct libalias *la, u_short * ptr, int nbytes)
{
int sum, oddbyte;
(void)la;
sum = 0;
while (nbytes > 1) {
sum += *ptr++;