From 75b8ca22865b39326d190287e3fba668f2bc9c69 Mon Sep 17 00:00:00 2001 From: des Date: Mon, 5 Jul 2004 11:10:57 +0000 Subject: [PATCH] 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. --- lib/libalias/Makefile | 2 +- lib/libalias/alias.c | 253 ++++----- lib/libalias/alias.h | 12 +- lib/libalias/alias_cuseeme.c | 13 +- lib/libalias/alias_db.c | 762 ++++++++++++++------------- lib/libalias/alias_ftp.c | 28 +- lib/libalias/alias_irc.c | 28 +- lib/libalias/alias_local.h | 74 +-- lib/libalias/alias_nbt.c | 18 +- lib/libalias/alias_old.c | 12 +- lib/libalias/alias_pptp.c | 70 +-- lib/libalias/alias_proxy.c | 25 +- lib/libalias/alias_skinny.c | 54 +- lib/libalias/alias_smedia.c | 44 +- lib/libalias/alias_util.c | 2 + sys/netinet/libalias/Makefile | 2 +- sys/netinet/libalias/alias.c | 253 ++++----- sys/netinet/libalias/alias.h | 12 +- sys/netinet/libalias/alias_cuseeme.c | 13 +- sys/netinet/libalias/alias_db.c | 762 ++++++++++++++------------- sys/netinet/libalias/alias_ftp.c | 28 +- sys/netinet/libalias/alias_irc.c | 28 +- sys/netinet/libalias/alias_local.h | 74 +-- sys/netinet/libalias/alias_nbt.c | 18 +- sys/netinet/libalias/alias_old.c | 12 +- sys/netinet/libalias/alias_pptp.c | 70 +-- sys/netinet/libalias/alias_proxy.c | 25 +- sys/netinet/libalias/alias_skinny.c | 54 +- sys/netinet/libalias/alias_smedia.c | 44 +- sys/netinet/libalias/alias_util.c | 2 + 30 files changed, 1442 insertions(+), 1352 deletions(-) diff --git a/lib/libalias/Makefile b/lib/libalias/Makefile index 334d02f57239..f077b559d117 100644 --- a/lib/libalias/Makefile +++ b/lib/libalias/Makefile @@ -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 diff --git a/lib/libalias/alias.c b/lib/libalias/alias.c index c456c66f04ea..832190057160 100644 --- a/lib/libalias/alias.c +++ b/lib/libalias/alias.c @@ -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); diff --git a/lib/libalias/alias.h b/lib/libalias/alias.h index cf681a42e71b..1deec9f08315 100644 --- a/lib/libalias/alias.h +++ b/lib/libalias/alias.h @@ -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, diff --git a/lib/libalias/alias_cuseeme.c b/lib/libalias/alias_cuseeme.c index 4b0f5a5ddc10..bca6b3b28154 100644 --- a/lib/libalias/alias_cuseeme.c +++ b/lib/libalias/alias_cuseeme.c @@ -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); diff --git a/lib/libalias/alias_db.c b/lib/libalias/alias_db.c index 9f3693c8b2a7..e41106600356 100644 --- a/lib/libalias/alias_db.c +++ b/lib/libalias/alias_db.c @@ -354,15 +354,15 @@ static void ShowAliasStats(struct libalias *); #ifndef NO_FW_PUNCH /* Firewall control */ -static void InitPunchFW(struct libalias *la); -static void UninitPunchFW(struct libalias *la); -static void ClearFWHole(struct alias_link *link); +static void InitPunchFW(struct libalias *); +static void UninitPunchFW(struct libalias *); +static void ClearFWHole(struct alias_link *); #endif /* Log file control */ -static void InitPacketAliasLog(struct libalias *la); -static void UninitPacketAliasLog(struct libalias *la); +static void InitPacketAliasLog(struct libalias *); +static void UninitPacketAliasLog(struct libalias *); static u_int StartPointIn(struct in_addr alias_addr, @@ -508,7 +508,7 @@ static struct alias_link * unused triplets: (dest addr, dest port, alias port). */ static int -GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) +GetNewPort(struct libalias *la, struct alias_link *lnk, int alias_port_param) { int i; int max_trials; @@ -539,7 +539,7 @@ GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) * this is already in use, the remainder of the * trials will be random. */ - port_net = link->src_port; + port_net = lnk->src_port; port_sys = ntohs(port_net); } else { /* First trial and all subsequent are random. */ @@ -548,7 +548,7 @@ GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) port_net = htons(port_sys); } } else if (alias_port_param >= 0 && alias_port_param < 0x10000) { - link->alias_port = (u_short) alias_port_param; + lnk->alias_port = (u_short) alias_port_param; return (0); } else { #ifdef DEBUG @@ -564,13 +564,13 @@ GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) int go_ahead; struct alias_link *search_result; - search_result = FindLinkIn(la, link->dst_addr, link->alias_addr, - link->dst_port, port_net, - link->link_type, 0); + search_result = FindLinkIn(la, lnk->dst_addr, lnk->alias_addr, + lnk->dst_port, port_net, + lnk->link_type, 0); if (search_result == NULL) go_ahead = 1; - else if (!(link->flags & LINK_PARTIALLY_SPECIFIED) + else if (!(lnk->flags & LINK_PARTIALLY_SPECIFIED) && (search_result->flags & LINK_PARTIALLY_SPECIFIED)) go_ahead = 1; else @@ -578,15 +578,15 @@ GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) if (go_ahead) { if ((la->packetAliasMode & PKT_ALIAS_USE_SOCKETS) - && (link->flags & LINK_PARTIALLY_SPECIFIED) - && ((link->link_type == LINK_TCP) || - (link->link_type == LINK_UDP))) { - if (GetSocket(la, port_net, &link->sockfd, link->link_type)) { - link->alias_port = port_net; + && (lnk->flags & LINK_PARTIALLY_SPECIFIED) + && ((lnk->link_type == LINK_TCP) || + (lnk->link_type == LINK_UDP))) { + if (GetSocket(la, port_net, &lnk->sockfd, lnk->link_type)) { + lnk->alias_port = port_net; return (0); } } else { - link->alias_port = port_net; + lnk->alias_port = port_net; return (0); } } @@ -745,19 +745,19 @@ FindNewPortGroup(struct libalias *la, static void CleanupAliasData(struct libalias *la) { - struct alias_link *link; + struct alias_link *lnk; int i, icount; icount = 0; for (i = 0; i < LINK_TABLE_OUT_SIZE; i++) { - link = LIST_FIRST(&la->linkTableOut[i]); - while (link != NULL) { + lnk = LIST_FIRST(&la->linkTableOut[i]); + while (lnk != NULL) { struct alias_link *link_next; - link_next = LIST_NEXT(link, list_out); + link_next = LIST_NEXT(lnk, list_out); icount++; - DeleteLink(link); - link = link_next; + DeleteLink(lnk); + lnk = link_next; } } @@ -769,37 +769,37 @@ static void IncrementalCleanup(struct libalias *la) { int icount; - struct alias_link *link; + struct alias_link *lnk; icount = 0; - link = LIST_FIRST(&la->linkTableOut[la->cleanupIndex++]); - while (link != NULL) { + lnk = LIST_FIRST(&la->linkTableOut[la->cleanupIndex++]); + while (lnk != NULL) { int idelta; struct alias_link *link_next; - link_next = LIST_NEXT(link, list_out); - idelta = la->timeStamp - link->timestamp; - switch (link->link_type) { + link_next = LIST_NEXT(lnk, list_out); + idelta = la->timeStamp - lnk->timestamp; + switch (lnk->link_type) { case LINK_TCP: - if (idelta > link->expire_time) { + if (idelta > lnk->expire_time) { struct tcp_dat *tcp_aux; - tcp_aux = link->data.tcp; + tcp_aux = lnk->data.tcp; if (tcp_aux->state.in != ALIAS_TCP_STATE_CONNECTED || tcp_aux->state.out != ALIAS_TCP_STATE_CONNECTED) { - DeleteLink(link); + DeleteLink(lnk); icount++; } } break; default: - if (idelta > link->expire_time) { - DeleteLink(link); + if (idelta > lnk->expire_time) { + DeleteLink(lnk); icount++; } break; } - link = link_next; + lnk = link_next; } if (la->cleanupIndex == LINK_TABLE_OUT_SIZE) @@ -807,42 +807,42 @@ IncrementalCleanup(struct libalias *la) } static void -DeleteLink(struct alias_link *link) +DeleteLink(struct alias_link *lnk) { - struct libalias *la = link->la; + struct libalias *la = lnk->la; /* Don't do anything if the link is marked permanent */ - if (la->deleteAllLinks == 0 && link->flags & LINK_PERMANENT) + if (la->deleteAllLinks == 0 && lnk->flags & LINK_PERMANENT) return; #ifndef NO_FW_PUNCH /* Delete associated firewall hole, if any */ - ClearFWHole(link); + ClearFWHole(lnk); #endif /* Free memory allocated for LSNAT server pool */ - if (link->server != NULL) { + if (lnk->server != NULL) { struct server *head, *curr, *next; - head = curr = link->server; + head = curr = lnk->server; do { next = curr->next; free(curr); } while ((curr = next) != head); } /* Adjust output table pointers */ - LIST_REMOVE(link, list_out); + LIST_REMOVE(lnk, list_out); /* Adjust input table pointers */ - LIST_REMOVE(link, list_in); + LIST_REMOVE(lnk, list_in); /* Close socket, if one has been allocated */ - if (link->sockfd != -1) { + if (lnk->sockfd != -1) { la->sockCount--; - close(link->sockfd); + close(lnk->sockfd); } /* Link-type dependent cleanup */ - switch (link->link_type) { + switch (lnk->link_type) { case LINK_ICMP: la->icmpLinkCount--; break; @@ -851,7 +851,7 @@ DeleteLink(struct alias_link *link) break; case LINK_TCP: la->tcpLinkCount--; - free(link->data.tcp); + free(lnk->data.tcp); break; case LINK_PPTP: la->pptpLinkCount--; @@ -861,8 +861,8 @@ DeleteLink(struct alias_link *link) break; case LINK_FRAGMENT_PTR: la->fragmentPtrLinkCount--; - if (link->data.frag_ptr != NULL) - free(link->data.frag_ptr); + if (lnk->data.frag_ptr != NULL) + free(lnk->data.frag_ptr); break; case LINK_ADDR: break; @@ -872,7 +872,7 @@ DeleteLink(struct alias_link *link) } /* Free memory */ - free(link); + free(lnk); /* Write statistics, if logging enabled */ if (la->packetAliasMode & PKT_ALIAS_LOG) { @@ -892,62 +892,62 @@ AddLink(struct libalias *la, struct in_addr src_addr, { /* port will be automatically *//* chosen. * If greater than */ u_int start_point; /* zero, equal to alias port */ - struct alias_link *link; + struct alias_link *lnk; - link = malloc(sizeof(struct alias_link)); - if (link != NULL) { + lnk = malloc(sizeof(struct alias_link)); + if (lnk != NULL) { /* Basic initialization */ - link->la = la; - link->src_addr = src_addr; - link->dst_addr = dst_addr; - link->alias_addr = alias_addr; - link->proxy_addr.s_addr = INADDR_ANY; - link->src_port = src_port; - link->dst_port = dst_port; - link->proxy_port = 0; - link->server = NULL; - link->link_type = link_type; - link->sockfd = -1; - link->flags = 0; - link->pflags = 0; - link->timestamp = la->timeStamp; + lnk->la = la; + lnk->src_addr = src_addr; + lnk->dst_addr = dst_addr; + lnk->alias_addr = alias_addr; + lnk->proxy_addr.s_addr = INADDR_ANY; + lnk->src_port = src_port; + lnk->dst_port = dst_port; + lnk->proxy_port = 0; + lnk->server = NULL; + lnk->link_type = link_type; + lnk->sockfd = -1; + lnk->flags = 0; + lnk->pflags = 0; + lnk->timestamp = la->timeStamp; /* Expiration time */ switch (link_type) { case LINK_ICMP: - link->expire_time = ICMP_EXPIRE_TIME; + lnk->expire_time = ICMP_EXPIRE_TIME; break; case LINK_UDP: - link->expire_time = UDP_EXPIRE_TIME; + lnk->expire_time = UDP_EXPIRE_TIME; break; case LINK_TCP: - link->expire_time = TCP_EXPIRE_INITIAL; + lnk->expire_time = TCP_EXPIRE_INITIAL; break; case LINK_PPTP: - link->flags |= LINK_PERMANENT; /* no timeout. */ + lnk->flags |= LINK_PERMANENT; /* no timeout. */ break; case LINK_FRAGMENT_ID: - link->expire_time = FRAGMENT_ID_EXPIRE_TIME; + lnk->expire_time = FRAGMENT_ID_EXPIRE_TIME; break; case LINK_FRAGMENT_PTR: - link->expire_time = FRAGMENT_PTR_EXPIRE_TIME; + lnk->expire_time = FRAGMENT_PTR_EXPIRE_TIME; break; case LINK_ADDR: break; default: - link->expire_time = PROTO_EXPIRE_TIME; + lnk->expire_time = PROTO_EXPIRE_TIME; break; } /* Determine alias flags */ if (dst_addr.s_addr == INADDR_ANY) - link->flags |= LINK_UNKNOWN_DEST_ADDR; + lnk->flags |= LINK_UNKNOWN_DEST_ADDR; if (dst_port == 0) - link->flags |= LINK_UNKNOWN_DEST_PORT; + lnk->flags |= LINK_UNKNOWN_DEST_PORT; /* Determine alias port */ - if (GetNewPort(la, link, alias_port_param) != 0) { - free(link); + if (GetNewPort(la, lnk, alias_port_param) != 0) { + free(lnk); return (NULL); } /* Link-type dependent initialization */ @@ -973,13 +973,13 @@ AddLink(struct libalias *la, struct in_addr src_addr, for (i = 0; i < N_LINK_TCP_DATA; i++) aux_tcp->ack[i].active = 0; aux_tcp->fwhole = -1; - link->data.tcp = aux_tcp; + lnk->data.tcp = aux_tcp; } else { #ifdef DEBUG fprintf(stderr, "PacketAlias/AddLink: "); fprintf(stderr, " cannot allocate auxiliary TCP data\n"); #endif - free(link); + free(lnk); return (NULL); } break; @@ -1002,11 +1002,11 @@ AddLink(struct libalias *la, struct in_addr src_addr, /* Set up pointers for output lookup table */ start_point = StartPointOut(src_addr, dst_addr, src_port, dst_port, link_type); - LIST_INSERT_HEAD(&la->linkTableOut[start_point], link, list_out); + LIST_INSERT_HEAD(&la->linkTableOut[start_point], lnk, list_out); /* Set up pointers for input lookup table */ - start_point = StartPointIn(alias_addr, link->alias_port, link_type); - LIST_INSERT_HEAD(&la->linkTableIn[start_point], link, list_in); + start_point = StartPointIn(alias_addr, lnk->alias_port, link_type); + LIST_INSERT_HEAD(&la->linkTableIn[start_point], lnk, list_in); } else { #ifdef DEBUG fprintf(stderr, "PacketAlias/AddLink(): "); @@ -1017,11 +1017,11 @@ AddLink(struct libalias *la, struct in_addr src_addr, if (la->packetAliasMode & PKT_ALIAS_LOG) { ShowAliasStats(la); } - return (link); + return (lnk); } static struct alias_link * -ReLink(struct alias_link *old_link, +ReLink(struct alias_link *old_lnk, struct in_addr src_addr, struct in_addr dst_addr, struct in_addr alias_addr, @@ -1031,21 +1031,21 @@ ReLink(struct alias_link *old_link, int link_type) { /* port will be automatically *//* chosen. * If greater than */ - struct alias_link *new_link; /* zero, equal to alias port */ - struct libalias *la = old_link->la; + struct alias_link *new_lnk; /* zero, equal to alias port */ + struct libalias *la = old_lnk->la; - new_link = AddLink(la, src_addr, dst_addr, alias_addr, + new_lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_port, dst_port, alias_port_param, link_type); #ifndef NO_FW_PUNCH - if (new_link != NULL && - old_link->link_type == LINK_TCP && - old_link->data.tcp->fwhole > 0) { - PunchFWHole(new_link); + if (new_lnk != NULL && + old_lnk->link_type == LINK_TCP && + old_lnk->data.tcp->fwhole > 0) { + PunchFWHole(new_lnk); } #endif - DeleteLink(old_link); - return (new_link); + DeleteLink(old_lnk); + return (new_lnk); } static struct alias_link * @@ -1057,43 +1057,43 @@ _FindLinkOut(struct libalias *la, struct in_addr src_addr, int replace_partial_links) { u_int i; - struct alias_link *link; + struct alias_link *lnk; i = StartPointOut(src_addr, dst_addr, src_port, dst_port, link_type); - LIST_FOREACH(link, &la->linkTableOut[i], list_out) { - if (link->src_addr.s_addr == src_addr.s_addr - && link->server == NULL - && link->dst_addr.s_addr == dst_addr.s_addr - && link->dst_port == dst_port - && link->src_port == src_port - && link->link_type == link_type) { - link->timestamp = la->timeStamp; + LIST_FOREACH(lnk, &la->linkTableOut[i], list_out) { + if (lnk->src_addr.s_addr == src_addr.s_addr + && lnk->server == NULL + && lnk->dst_addr.s_addr == dst_addr.s_addr + && lnk->dst_port == dst_port + && lnk->src_port == src_port + && lnk->link_type == link_type) { + lnk->timestamp = la->timeStamp; break; } } /* Search for partially specified links. */ - if (link == NULL && replace_partial_links) { + if (lnk == NULL && replace_partial_links) { if (dst_port != 0 && dst_addr.s_addr != INADDR_ANY) { - link = _FindLinkOut(la, src_addr, dst_addr, src_port, 0, + lnk = _FindLinkOut(la, src_addr, dst_addr, src_port, 0, link_type, 0); - if (link == NULL) - link = _FindLinkOut(la, src_addr, la->nullAddress, src_port, + if (lnk == NULL) + lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, dst_port, link_type, 0); } - if (link == NULL && + if (lnk == NULL && (dst_port != 0 || dst_addr.s_addr != INADDR_ANY)) { - link = _FindLinkOut(la, src_addr, la->nullAddress, src_port, 0, + lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, 0, link_type, 0); } - if (link != NULL) { - link = ReLink(link, - src_addr, dst_addr, link->alias_addr, - src_port, dst_port, link->alias_port, + if (lnk != NULL) { + lnk = ReLink(lnk, + src_addr, dst_addr, lnk->alias_addr, + src_port, dst_port, lnk->alias_port, link_type); } } - return (link); + return (lnk); } static struct alias_link * @@ -1104,12 +1104,12 @@ FindLinkOut(struct libalias *la, struct in_addr src_addr, int link_type, int replace_partial_links) { - struct alias_link *link; + struct alias_link *lnk; - link = _FindLinkOut(la, src_addr, dst_addr, src_port, dst_port, + lnk = _FindLinkOut(la, src_addr, dst_addr, src_port, dst_port, link_type, replace_partial_links); - if (link == NULL) { + if (lnk == NULL) { /* * The following allows permanent links to be specified as * using the default source address (i.e. device interface @@ -1118,11 +1118,11 @@ FindLinkOut(struct libalias *la, struct in_addr src_addr, */ if (la->aliasAddress.s_addr != INADDR_ANY && src_addr.s_addr == la->aliasAddress.s_addr) { - link = _FindLinkOut(la, la->nullAddress, dst_addr, src_port, dst_port, + lnk = _FindLinkOut(la, la->nullAddress, dst_addr, src_port, dst_port, link_type, replace_partial_links); } } - return (link); + return (lnk); } @@ -1136,17 +1136,17 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr, { int flags_in; u_int start_point; - struct alias_link *link; - struct alias_link *link_fully_specified; - struct alias_link *link_unknown_all; - struct alias_link *link_unknown_dst_addr; - struct alias_link *link_unknown_dst_port; + struct alias_link *lnk; + struct alias_link *lnk_fully_specified; + struct alias_link *lnk_unknown_all; + struct alias_link *lnk_unknown_dst_addr; + struct alias_link *lnk_unknown_dst_port; /* Initialize pointers */ - link_fully_specified = NULL; - link_unknown_all = NULL; - link_unknown_dst_addr = NULL; - link_unknown_dst_port = NULL; + lnk_fully_specified = NULL; + lnk_unknown_all = NULL; + lnk_unknown_dst_addr = NULL; + lnk_unknown_dst_port = NULL; /* If either the dest addr or port is unknown, the search loop will have to know about this. */ @@ -1159,80 +1159,80 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr, /* Search loop */ start_point = StartPointIn(alias_addr, alias_port, link_type); - LIST_FOREACH(link, &la->linkTableIn[start_point], list_in) { + LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) { int flags; - flags = flags_in | link->flags; + flags = flags_in | lnk->flags; if (!(flags & LINK_PARTIALLY_SPECIFIED)) { - if (link->alias_addr.s_addr == alias_addr.s_addr - && link->alias_port == alias_port - && link->dst_addr.s_addr == dst_addr.s_addr - && link->dst_port == dst_port - && link->link_type == link_type) { - link_fully_specified = link; + if (lnk->alias_addr.s_addr == alias_addr.s_addr + && lnk->alias_port == alias_port + && lnk->dst_addr.s_addr == dst_addr.s_addr + && lnk->dst_port == dst_port + && lnk->link_type == link_type) { + lnk_fully_specified = lnk; break; } } else if ((flags & LINK_UNKNOWN_DEST_ADDR) && (flags & LINK_UNKNOWN_DEST_PORT)) { - if (link->alias_addr.s_addr == alias_addr.s_addr - && link->alias_port == alias_port - && link->link_type == link_type) { - if (link_unknown_all == NULL) - link_unknown_all = link; + if (lnk->alias_addr.s_addr == alias_addr.s_addr + && lnk->alias_port == alias_port + && lnk->link_type == link_type) { + if (lnk_unknown_all == NULL) + lnk_unknown_all = lnk; } } else if (flags & LINK_UNKNOWN_DEST_ADDR) { - if (link->alias_addr.s_addr == alias_addr.s_addr - && link->alias_port == alias_port - && link->link_type == link_type - && link->dst_port == dst_port) { - if (link_unknown_dst_addr == NULL) - link_unknown_dst_addr = link; + if (lnk->alias_addr.s_addr == alias_addr.s_addr + && lnk->alias_port == alias_port + && lnk->link_type == link_type + && lnk->dst_port == dst_port) { + if (lnk_unknown_dst_addr == NULL) + lnk_unknown_dst_addr = lnk; } } else if (flags & LINK_UNKNOWN_DEST_PORT) { - if (link->alias_addr.s_addr == alias_addr.s_addr - && link->alias_port == alias_port - && link->link_type == link_type - && link->dst_addr.s_addr == dst_addr.s_addr) { - if (link_unknown_dst_port == NULL) - link_unknown_dst_port = link; + if (lnk->alias_addr.s_addr == alias_addr.s_addr + && lnk->alias_port == alias_port + && lnk->link_type == link_type + && lnk->dst_addr.s_addr == dst_addr.s_addr) { + if (lnk_unknown_dst_port == NULL) + lnk_unknown_dst_port = lnk; } } } - if (link_fully_specified != NULL) { - link_fully_specified->timestamp = la->timeStamp; - link = link_fully_specified; - } else if (link_unknown_dst_port != NULL) - link = link_unknown_dst_port; - else if (link_unknown_dst_addr != NULL) - link = link_unknown_dst_addr; - else if (link_unknown_all != NULL) - link = link_unknown_all; + if (lnk_fully_specified != NULL) { + lnk_fully_specified->timestamp = la->timeStamp; + lnk = lnk_fully_specified; + } else if (lnk_unknown_dst_port != NULL) + lnk = lnk_unknown_dst_port; + else if (lnk_unknown_dst_addr != NULL) + lnk = lnk_unknown_dst_addr; + else if (lnk_unknown_all != NULL) + lnk = lnk_unknown_all; else return (NULL); if (replace_partial_links && - (link->flags & LINK_PARTIALLY_SPECIFIED || link->server != NULL)) { + (lnk->flags & LINK_PARTIALLY_SPECIFIED || lnk->server != NULL)) { struct in_addr src_addr; u_short src_port; - if (link->server != NULL) { /* LSNAT link */ - src_addr = link->server->addr; - src_port = link->server->port; - link->server = link->server->next; + if (lnk->server != NULL) { /* LSNAT link */ + src_addr = lnk->server->addr; + src_port = lnk->server->port; + lnk->server = lnk->server->next; } else { - src_addr = link->src_addr; - src_port = link->src_port; + src_addr = lnk->src_addr; + src_port = lnk->src_port; } - link = ReLink(link, + lnk = ReLink(lnk, src_addr, dst_addr, alias_addr, src_port, dst_port, alias_port, link_type); } - return (link); + return (lnk); } static struct alias_link * @@ -1243,12 +1243,12 @@ FindLinkIn(struct libalias *la, struct in_addr dst_addr, int link_type, int replace_partial_links) { - struct alias_link *link; + struct alias_link *lnk; - link = _FindLinkIn(la, dst_addr, alias_addr, dst_port, alias_port, + lnk = _FindLinkIn(la, dst_addr, alias_addr, dst_port, alias_port, link_type, replace_partial_links); - if (link == NULL) { + if (lnk == NULL) { /* * The following allows permanent links to be specified as * using the default aliasing address (i.e. device @@ -1257,11 +1257,11 @@ FindLinkIn(struct libalias *la, struct in_addr dst_addr, */ if (la->aliasAddress.s_addr != INADDR_ANY && alias_addr.s_addr == la->aliasAddress.s_addr) { - link = _FindLinkIn(la, dst_addr, la->nullAddress, dst_port, alias_port, + lnk = _FindLinkIn(la, dst_addr, la->nullAddress, dst_port, alias_port, link_type, replace_partial_links); } } - return (link); + return (lnk); } @@ -1290,20 +1290,20 @@ FindIcmpIn(struct libalias *la, struct in_addr dst_addr, u_short id_alias, int create) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, NO_DEST_PORT, id_alias, LINK_ICMP, 0); - if (link == NULL && create && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { + if (lnk == NULL && create && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { struct in_addr target_addr; target_addr = FindOriginalAddress(la, alias_addr); - link = AddLink(la, target_addr, dst_addr, alias_addr, + lnk = AddLink(la, target_addr, dst_addr, alias_addr, id_alias, NO_DEST_PORT, id_alias, LINK_ICMP); } - return (link); + return (lnk); } @@ -1313,20 +1313,20 @@ FindIcmpOut(struct libalias *la, struct in_addr src_addr, u_short id, int create) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkOut(la, src_addr, dst_addr, + lnk = FindLinkOut(la, src_addr, dst_addr, id, NO_DEST_PORT, LINK_ICMP, 0); - if (link == NULL && create) { + if (lnk == NULL && create) { struct in_addr alias_addr; alias_addr = FindAliasAddress(la, src_addr); - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, id, NO_DEST_PORT, GET_ALIAS_ID, LINK_ICMP); } - return (link); + return (lnk); } @@ -1335,18 +1335,18 @@ FindFragmentIn1(struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_short ip_id) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, NO_DEST_PORT, ip_id, LINK_FRAGMENT_ID, 0); - if (link == NULL) { - link = AddLink(la, la->nullAddress, dst_addr, alias_addr, + if (lnk == NULL) { + lnk = AddLink(la, la->nullAddress, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, ip_id, LINK_FRAGMENT_ID); } - return (link); + return (lnk); } @@ -1387,21 +1387,21 @@ FindProtoIn(struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_char proto) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, NO_DEST_PORT, 0, proto, 1); - if (link == NULL && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { + if (lnk == NULL && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { struct in_addr target_addr; target_addr = FindOriginalAddress(la, alias_addr); - link = AddLink(la, target_addr, dst_addr, alias_addr, + lnk = AddLink(la, target_addr, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, 0, proto); } - return (link); + return (lnk); } @@ -1410,21 +1410,21 @@ FindProtoOut(struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, u_char proto) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkOut(la, src_addr, dst_addr, + lnk = FindLinkOut(la, src_addr, dst_addr, NO_SRC_PORT, NO_DEST_PORT, proto, 1); - if (link == NULL) { + if (lnk == NULL) { struct in_addr alias_addr; alias_addr = FindAliasAddress(la, src_addr); - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, 0, proto); } - return (link); + return (lnk); } @@ -1437,7 +1437,7 @@ FindUdpTcpIn(struct libalias *la, struct in_addr dst_addr, int create) { int link_type; - struct alias_link *link; + struct alias_link *lnk; switch (proto) { case IPPROTO_UDP: @@ -1451,19 +1451,19 @@ FindUdpTcpIn(struct libalias *la, struct in_addr dst_addr, break; } - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, dst_port, alias_port, link_type, create); - if (link == NULL && create && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { + if (lnk == NULL && create && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { struct in_addr target_addr; target_addr = FindOriginalAddress(la, alias_addr); - link = AddLink(la, target_addr, dst_addr, alias_addr, + lnk = AddLink(la, target_addr, dst_addr, alias_addr, alias_port, dst_port, alias_port, link_type); } - return (link); + return (lnk); } @@ -1476,7 +1476,7 @@ FindUdpTcpOut(struct libalias *la, struct in_addr src_addr, int create) { int link_type; - struct alias_link *link; + struct alias_link *lnk; switch (proto) { case IPPROTO_UDP: @@ -1490,17 +1490,17 @@ FindUdpTcpOut(struct libalias *la, struct in_addr src_addr, break; } - link = FindLinkOut(la, src_addr, dst_addr, src_port, dst_port, link_type, create); + lnk = FindLinkOut(la, src_addr, dst_addr, src_port, dst_port, link_type, create); - if (link == NULL && create) { + if (lnk == NULL && create) { struct in_addr alias_addr; alias_addr = FindAliasAddress(la, src_addr); - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_port, dst_port, GET_ALIAS_PORT, link_type); } - return (link); + return (lnk); } @@ -1510,13 +1510,13 @@ AddPptp(struct libalias *la, struct in_addr src_addr, struct in_addr alias_addr, u_int16_t src_call_id) { - struct alias_link *link; + struct alias_link *lnk; - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_call_id, 0, GET_ALIAS_PORT, LINK_PPTP); - return (link); + return (lnk); } @@ -1526,17 +1526,17 @@ FindPptpOutByCallId(struct libalias *la, struct in_addr src_addr, u_int16_t src_call_id) { u_int i; - struct alias_link *link; + struct alias_link *lnk; i = StartPointOut(src_addr, dst_addr, 0, 0, LINK_PPTP); - LIST_FOREACH(link, &la->linkTableOut[i], list_out) - if (link->link_type == LINK_PPTP && - link->src_addr.s_addr == src_addr.s_addr && - link->dst_addr.s_addr == dst_addr.s_addr && - link->src_port == src_call_id) + LIST_FOREACH(lnk, &la->linkTableOut[i], list_out) + if (lnk->link_type == LINK_PPTP && + lnk->src_addr.s_addr == src_addr.s_addr && + lnk->dst_addr.s_addr == dst_addr.s_addr && + lnk->src_port == src_call_id) break; - return (link); + return (lnk); } @@ -1546,17 +1546,17 @@ FindPptpOutByPeerCallId(struct libalias *la, struct in_addr src_addr, u_int16_t dst_call_id) { u_int i; - struct alias_link *link; + struct alias_link *lnk; i = StartPointOut(src_addr, dst_addr, 0, 0, LINK_PPTP); - LIST_FOREACH(link, &la->linkTableOut[i], list_out) - if (link->link_type == LINK_PPTP && - link->src_addr.s_addr == src_addr.s_addr && - link->dst_addr.s_addr == dst_addr.s_addr && - link->dst_port == dst_call_id) + LIST_FOREACH(lnk, &la->linkTableOut[i], list_out) + if (lnk->link_type == LINK_PPTP && + lnk->src_addr.s_addr == src_addr.s_addr && + lnk->dst_addr.s_addr == dst_addr.s_addr && + lnk->dst_port == dst_call_id) break; - return (link); + return (lnk); } @@ -1566,17 +1566,17 @@ FindPptpInByCallId(struct libalias *la, struct in_addr dst_addr, u_int16_t dst_call_id) { u_int i; - struct alias_link *link; + struct alias_link *lnk; i = StartPointIn(alias_addr, 0, LINK_PPTP); - LIST_FOREACH(link, &la->linkTableIn[i], list_in) - if (link->link_type == LINK_PPTP && - link->dst_addr.s_addr == dst_addr.s_addr && - link->alias_addr.s_addr == alias_addr.s_addr && - link->dst_port == dst_call_id) + LIST_FOREACH(lnk, &la->linkTableIn[i], list_in) + if (lnk->link_type == LINK_PPTP && + lnk->dst_addr.s_addr == dst_addr.s_addr && + lnk->alias_addr.s_addr == alias_addr.s_addr && + lnk->dst_port == dst_call_id) break; - return (link); + return (lnk); } @@ -1585,14 +1585,14 @@ FindPptpInByPeerCallId(struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_int16_t alias_call_id) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, 0 /* any */ , alias_call_id, LINK_PPTP, 0); - return (link); + return (lnk); } @@ -1604,7 +1604,7 @@ FindRtspOut(struct libalias *la, struct in_addr src_addr, u_char proto) { int link_type; - struct alias_link *link; + struct alias_link *lnk; switch (proto) { case IPPROTO_UDP: @@ -1618,28 +1618,28 @@ FindRtspOut(struct libalias *la, struct in_addr src_addr, break; } - link = FindLinkOut(la, src_addr, dst_addr, src_port, 0, link_type, 1); + lnk = FindLinkOut(la, src_addr, dst_addr, src_port, 0, link_type, 1); - if (link == NULL) { + if (lnk == NULL) { struct in_addr alias_addr; alias_addr = FindAliasAddress(la, src_addr); - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_port, 0, alias_port, link_type); } - return (link); + return (lnk); } struct in_addr FindOriginalAddress(struct libalias *la, struct in_addr alias_addr) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, la->nullAddress, alias_addr, + lnk = FindLinkIn(la, la->nullAddress, alias_addr, 0, 0, LINK_ADDR, 0); - if (link == NULL) { + if (lnk == NULL) { la->newDefaultLink = 1; if (la->targetAddress.s_addr == INADDR_ANY) return (alias_addr); @@ -1649,17 +1649,17 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr) else return (la->targetAddress); } else { - if (link->server != NULL) { /* LSNAT link */ + if (lnk->server != NULL) { /* LSNAT link */ struct in_addr src_addr; - src_addr = link->server->addr; - link->server = link->server->next; + src_addr = lnk->server->addr; + lnk->server = lnk->server->next; return (src_addr); - } else if (link->src_addr.s_addr == INADDR_ANY) + } else if (lnk->src_addr.s_addr == INADDR_ANY) return (la->aliasAddress.s_addr != INADDR_ANY) ? la->aliasAddress : alias_addr; else - return (link->src_addr); + return (lnk->src_addr); } } @@ -1667,19 +1667,19 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr) struct in_addr FindAliasAddress(struct libalias *la, struct in_addr original_addr) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkOut(la, original_addr, la->nullAddress, + lnk = FindLinkOut(la, original_addr, la->nullAddress, 0, 0, LINK_ADDR, 0); - if (link == NULL) { + if (lnk == NULL) { return (la->aliasAddress.s_addr != INADDR_ANY) ? la->aliasAddress : original_addr; } else { - if (link->alias_addr.s_addr == INADDR_ANY) + if (lnk->alias_addr.s_addr == INADDR_ANY) return (la->aliasAddress.s_addr != INADDR_ANY) ? la->aliasAddress : original_addr; else - return (link->alias_addr); + return (lnk->alias_addr); } } @@ -1700,117 +1700,117 @@ FindAliasAddress(struct libalias *la, struct in_addr original_addr) void -SetFragmentAddr(struct alias_link *link, struct in_addr src_addr) +SetFragmentAddr(struct alias_link *lnk, struct in_addr src_addr) { - link->data.frag_addr = src_addr; + lnk->data.frag_addr = src_addr; } void -GetFragmentAddr(struct alias_link *link, struct in_addr *src_addr) +GetFragmentAddr(struct alias_link *lnk, struct in_addr *src_addr) { - *src_addr = link->data.frag_addr; + *src_addr = lnk->data.frag_addr; } void -SetFragmentPtr(struct alias_link *link, char *fptr) +SetFragmentPtr(struct alias_link *lnk, char *fptr) { - link->data.frag_ptr = fptr; + lnk->data.frag_ptr = fptr; } void -GetFragmentPtr(struct alias_link *link, char **fptr) +GetFragmentPtr(struct alias_link *lnk, char **fptr) { - *fptr = link->data.frag_ptr; + *fptr = lnk->data.frag_ptr; } void -SetStateIn(struct alias_link *link, int state) +SetStateIn(struct alias_link *lnk, int state) { /* TCP input state */ switch (state) { case ALIAS_TCP_STATE_DISCONNECTED: - if (link->data.tcp->state.out != ALIAS_TCP_STATE_CONNECTED) - link->expire_time = TCP_EXPIRE_DEAD; + if (lnk->data.tcp->state.out != ALIAS_TCP_STATE_CONNECTED) + lnk->expire_time = TCP_EXPIRE_DEAD; else - link->expire_time = TCP_EXPIRE_SINGLEDEAD; + lnk->expire_time = TCP_EXPIRE_SINGLEDEAD; break; case ALIAS_TCP_STATE_CONNECTED: - if (link->data.tcp->state.out == ALIAS_TCP_STATE_CONNECTED) - link->expire_time = TCP_EXPIRE_CONNECTED; + if (lnk->data.tcp->state.out == ALIAS_TCP_STATE_CONNECTED) + lnk->expire_time = TCP_EXPIRE_CONNECTED; break; default: abort(); } - link->data.tcp->state.in = state; + lnk->data.tcp->state.in = state; } void -SetStateOut(struct alias_link *link, int state) +SetStateOut(struct alias_link *lnk, int state) { /* TCP output state */ switch (state) { case ALIAS_TCP_STATE_DISCONNECTED: - if (link->data.tcp->state.in != ALIAS_TCP_STATE_CONNECTED) - link->expire_time = TCP_EXPIRE_DEAD; + if (lnk->data.tcp->state.in != ALIAS_TCP_STATE_CONNECTED) + lnk->expire_time = TCP_EXPIRE_DEAD; else - link->expire_time = TCP_EXPIRE_SINGLEDEAD; + lnk->expire_time = TCP_EXPIRE_SINGLEDEAD; break; case ALIAS_TCP_STATE_CONNECTED: - if (link->data.tcp->state.in == ALIAS_TCP_STATE_CONNECTED) - link->expire_time = TCP_EXPIRE_CONNECTED; + if (lnk->data.tcp->state.in == ALIAS_TCP_STATE_CONNECTED) + lnk->expire_time = TCP_EXPIRE_CONNECTED; break; default: abort(); } - link->data.tcp->state.out = state; + lnk->data.tcp->state.out = state; } int -GetStateIn(struct alias_link *link) +GetStateIn(struct alias_link *lnk) { /* TCP input state */ - return (link->data.tcp->state.in); + return (lnk->data.tcp->state.in); } int -GetStateOut(struct alias_link *link) +GetStateOut(struct alias_link *lnk) { /* TCP output state */ - return (link->data.tcp->state.out); + return (lnk->data.tcp->state.out); } struct in_addr -GetOriginalAddress(struct alias_link *link) +GetOriginalAddress(struct alias_link *lnk) { - if (link->src_addr.s_addr == INADDR_ANY) - return (link->la->aliasAddress); + if (lnk->src_addr.s_addr == INADDR_ANY) + return (lnk->la->aliasAddress); else - return (link->src_addr); + return (lnk->src_addr); } struct in_addr -GetDestAddress(struct alias_link *link) +GetDestAddress(struct alias_link *lnk) { - return (link->dst_addr); + return (lnk->dst_addr); } struct in_addr -GetAliasAddress(struct alias_link *link) +GetAliasAddress(struct alias_link *lnk) { - if (link->alias_addr.s_addr == INADDR_ANY) - return (link->la->aliasAddress); + if (lnk->alias_addr.s_addr == INADDR_ANY) + return (lnk->la->aliasAddress); else - return (link->alias_addr); + return (lnk->alias_addr); } @@ -1829,73 +1829,73 @@ SetDefaultAliasAddress(struct libalias *la, struct in_addr alias_addr) u_short -GetOriginalPort(struct alias_link *link) +GetOriginalPort(struct alias_link *lnk) { - return (link->src_port); + return (lnk->src_port); } u_short -GetAliasPort(struct alias_link *link) +GetAliasPort(struct alias_link *lnk) { - return (link->alias_port); + return (lnk->alias_port); } #ifndef NO_FW_PUNCH static u_short -GetDestPort(struct alias_link *link) +GetDestPort(struct alias_link *lnk) { - return (link->dst_port); + return (lnk->dst_port); } #endif void -SetAckModified(struct alias_link *link) +SetAckModified(struct alias_link *lnk) { /* Indicate that ACK numbers have been modified in a TCP connection */ - link->data.tcp->state.ack_modified = 1; + lnk->data.tcp->state.ack_modified = 1; } struct in_addr -GetProxyAddress(struct alias_link *link) +GetProxyAddress(struct alias_link *lnk) { - return (link->proxy_addr); + return (lnk->proxy_addr); } void -SetProxyAddress(struct alias_link *link, struct in_addr addr) +SetProxyAddress(struct alias_link *lnk, struct in_addr addr) { - link->proxy_addr = addr; + lnk->proxy_addr = addr; } u_short -GetProxyPort(struct alias_link *link) +GetProxyPort(struct alias_link *lnk) { - return (link->proxy_port); + return (lnk->proxy_port); } void -SetProxyPort(struct alias_link *link, u_short port) +SetProxyPort(struct alias_link *lnk, u_short port) { - link->proxy_port = port; + lnk->proxy_port = port; } int -GetAckModified(struct alias_link *link) +GetAckModified(struct alias_link *lnk) { /* See if ACK numbers have been modified */ - return (link->data.tcp->state.ack_modified); + return (lnk->data.tcp->state.ack_modified); } int -GetDeltaAckIn(struct ip *pip, struct alias_link *link) +GetDeltaAckIn(struct ip *pip, struct alias_link *lnk) { /* Find out how much the ACK number has been altered for an incoming @@ -1916,7 +1916,7 @@ packet size was altered is searched. for (i = 0; i < N_LINK_TCP_DATA; i++) { struct ack_data_record x; - x = link->data.tcp->ack[i]; + x = lnk->data.tcp->ack[i]; if (x.active == 1) { int ack_diff; @@ -1939,7 +1939,7 @@ packet size was altered is searched. int -GetDeltaSeqOut(struct ip *pip, struct alias_link *link) +GetDeltaSeqOut(struct ip *pip, struct alias_link *lnk) { /* Find out how much the sequence number has been altered for an outgoing @@ -1960,7 +1960,7 @@ packet size was altered is searched. for (i = 0; i < N_LINK_TCP_DATA; i++) { struct ack_data_record x; - x = link->data.tcp->ack[i]; + x = lnk->data.tcp->ack[i]; if (x.active == 1) { int seq_diff; @@ -1983,7 +1983,7 @@ packet size was altered is searched. void -AddSeq(struct ip *pip, struct alias_link *link, int delta) +AddSeq(struct ip *pip, struct alias_link *lnk, int delta) { /* When a TCP packet has been altered in length, save this @@ -2007,26 +2007,26 @@ been altered, then this list will begin to overwrite itself. x.delta = delta; x.active = 1; - i = link->data.tcp->state.index; - link->data.tcp->ack[i] = x; + i = lnk->data.tcp->state.index; + lnk->data.tcp->ack[i] = x; i++; if (i == N_LINK_TCP_DATA) - link->data.tcp->state.index = 0; + lnk->data.tcp->state.index = 0; else - link->data.tcp->state.index = i; + lnk->data.tcp->state.index = i; } void -SetExpire(struct alias_link *link, int expire) +SetExpire(struct alias_link *lnk, int expire) { if (expire == 0) { - link->flags &= ~LINK_PERMANENT; - DeleteLink(link); + lnk->flags &= ~LINK_PERMANENT; + DeleteLink(lnk); } else if (expire == -1) { - link->flags |= LINK_PERMANENT; + lnk->flags |= LINK_PERMANENT; } else if (expire > 0) { - link->expire_time = expire; + lnk->expire_time = expire; } else { #ifdef DEBUG fprintf(stderr, "PacketAlias/SetExpire(): "); @@ -2042,27 +2042,27 @@ ClearCheckNewLink(struct libalias *la) } void -SetProtocolFlags(struct alias_link *link, int pflags) +SetProtocolFlags(struct alias_link *lnk, int pflags) { - link->pflags = pflags;; + lnk->pflags = pflags;; } int -GetProtocolFlags(struct alias_link *link) +GetProtocolFlags(struct alias_link *lnk) { - return (link->pflags); + return (lnk->pflags); } void -SetDestCallId(struct alias_link *link, u_int16_t cid) +SetDestCallId(struct alias_link *lnk, u_int16_t cid) { - struct libalias *la = link->la; + struct libalias *la = lnk->la; la->deleteAllLinks = 1; - link = ReLink(link, link->src_addr, link->dst_addr, link->alias_addr, - link->src_port, cid, link->alias_port, link->link_type); + lnk = ReLink(lnk, lnk->src_addr, lnk->dst_addr, lnk->alias_addr, + lnk->src_port, cid, lnk->alias_port, lnk->link_type); la->deleteAllLinks = 0; } @@ -2186,7 +2186,7 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p u_char proto) { int link_type; - struct alias_link *link; + struct alias_link *lnk; switch (proto) { case IPPROTO_UDP: @@ -2203,12 +2203,12 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p return (NULL); } - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_port, dst_port, alias_port, link_type); - if (link != NULL) { - link->flags |= LINK_PERMANENT; + if (lnk != NULL) { + lnk->flags |= LINK_PERMANENT; } #ifdef DEBUG else { @@ -2217,15 +2217,17 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p } #endif - return (link); + return (lnk); } /* Add server to the pool of servers */ int -LibAliasAddServer(struct libalias *la, struct alias_link *link, struct in_addr addr, u_short port) +LibAliasAddServer(struct libalias *la, struct alias_link *lnk, struct in_addr addr, u_short port) { struct server *server; + (void)la; + server = malloc(sizeof(struct server)); if (server != NULL) { @@ -2234,7 +2236,7 @@ LibAliasAddServer(struct libalias *la, struct alias_link *link, struct in_addr a server->addr = addr; server->port = port; - head = link->server; + head = lnk->server; if (head == NULL) server->next = server; else { @@ -2244,7 +2246,7 @@ LibAliasAddServer(struct libalias *la, struct alias_link *link, struct in_addr a s->next = server; server->next = head; } - link->server = server; + lnk->server = server; return (0); } else return (-1); @@ -2258,14 +2260,14 @@ LibAliasRedirectProto(struct libalias *la, struct in_addr src_addr, struct in_addr alias_addr, u_char proto) { - struct alias_link *link; + struct alias_link *lnk; - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, 0, proto); - if (link != NULL) { - link->flags |= LINK_PERMANENT; + if (lnk != NULL) { + lnk->flags |= LINK_PERMANENT; } #ifdef DEBUG else { @@ -2274,7 +2276,7 @@ LibAliasRedirectProto(struct libalias *la, struct in_addr src_addr, } #endif - return (link); + return (lnk); } /* Static address translation */ @@ -2282,14 +2284,14 @@ struct alias_link * LibAliasRedirectAddr(struct libalias *la, struct in_addr src_addr, struct in_addr alias_addr) { - struct alias_link *link; + struct alias_link *lnk; - link = AddLink(la, src_addr, la->nullAddress, alias_addr, + lnk = AddLink(la, src_addr, la->nullAddress, alias_addr, 0, 0, 0, LINK_ADDR); - if (link != NULL) { - link->flags |= LINK_PERMANENT; + if (lnk != NULL) { + lnk->flags |= LINK_PERMANENT; } #ifdef DEBUG else { @@ -2298,32 +2300,34 @@ LibAliasRedirectAddr(struct libalias *la, struct in_addr src_addr, } #endif - return (link); + return (lnk); } /* Mark the aliasing link dynamic */ int -LibAliasRedirectDynamic(struct libalias *la, struct alias_link *link) +LibAliasRedirectDynamic(struct libalias *la, struct alias_link *lnk) { - if (link->flags & LINK_PARTIALLY_SPECIFIED) + (void)la; + + if (lnk->flags & LINK_PARTIALLY_SPECIFIED) return (-1); else { - link->flags &= ~LINK_PERMANENT; + lnk->flags &= ~LINK_PERMANENT; return (0); } } void -LibAliasRedirectDelete(struct libalias *la, struct alias_link *link) +LibAliasRedirectDelete(struct libalias *la, struct alias_link *lnk) { /* This is a dangerous function to put in the API, because an invalid pointer can crash the program. */ la->deleteAllLinks = 1; - DeleteLink(link); + DeleteLink(lnk); la->deleteAllLinks = 0; } @@ -2597,19 +2601,19 @@ UninitPunchFW(struct libalias *la) /* Make a certain link go through the firewall */ void -PunchFWHole(struct alias_link *link) +PunchFWHole(struct alias_link *lnk) { struct libalias *la; int r; /* Result code */ struct ip_fw rule; /* On-the-fly built rule */ int fwhole; /* Where to punch hole */ - la = link->la; + la = lnk->la; /* Don't do anything unless we are asked to */ if (!(la->packetAliasMode & PKT_ALIAS_PUNCH_FW) || la->fireWallFD < 0 || - link->link_type != LINK_TCP) + lnk->link_type != LINK_TCP) return; memset(&rule, 0, sizeof rule); @@ -2645,22 +2649,22 @@ PunchFWHole(struct alias_link *link) * accept tcp from DAddr DPort to OAddr OPort */ #if IPFW2 - if (GetOriginalPort(link) != 0 && GetDestPort(link) != 0) { + if (GetOriginalPort(lnk) != 0 && GetDestPort(lnk) != 0) { u_int32_t rulebuf[255]; int i; i = fill_rule(rulebuf, sizeof(rulebuf), fwhole, O_ACCEPT, IPPROTO_TCP, - GetOriginalAddress(link), ntohs(GetOriginalPort(link)), - GetDestAddress(link), ntohs(GetDestPort(link))); + GetOriginalAddress(lnk), ntohs(GetOriginalPort(lnk)), + GetDestAddress(lnk), ntohs(GetDestPort(lnk))); r = setsockopt(la->fireWallFD, IPPROTO_IP, IP_FW_ADD, rulebuf, i); if (r) err(1, "alias punch inbound(1) setsockopt(IP_FW_ADD)"); i = fill_rule(rulebuf, sizeof(rulebuf), fwhole, O_ACCEPT, IPPROTO_TCP, - GetDestAddress(link), ntohs(GetDestPort(link)), - GetOriginalAddress(link), ntohs(GetOriginalPort(link))); + GetDestAddress(lnk), ntohs(GetDestPort(lnk)), + GetOriginalAddress(lnk), ntohs(GetOriginalPort(lnk))); r = setsockopt(la->fireWallFD, IPPROTO_IP, IP_FW_ADD, rulebuf, i); if (r) err(1, "alias punch inbound(2) setsockopt(IP_FW_ADD)"); @@ -2677,10 +2681,10 @@ PunchFWHole(struct alias_link *link) rule.fw_dmsk.s_addr = INADDR_BROADCAST; /* Build and apply specific part of the rules */ - rule.fw_src = GetOriginalAddress(link); - rule.fw_dst = GetDestAddress(link); - rule.fw_uar.fw_pts[0] = ntohs(GetOriginalPort(link)); - rule.fw_uar.fw_pts[1] = ntohs(GetDestPort(link)); + rule.fw_src = GetOriginalAddress(lnk); + rule.fw_dst = GetDestAddress(lnk); + rule.fw_uar.fw_pts[0] = ntohs(GetOriginalPort(lnk)); + rule.fw_uar.fw_pts[1] = ntohs(GetDestPort(lnk)); /* * Skip non-bound links - XXX should not be strictly necessary, but @@ -2694,10 +2698,10 @@ PunchFWHole(struct alias_link *link) if (r) err(1, "alias punch inbound(1) setsockopt(IP_FW_ADD)"); #endif - rule.fw_src = GetDestAddress(link); - rule.fw_dst = GetOriginalAddress(link); - rule.fw_uar.fw_pts[0] = ntohs(GetDestPort(link)); - rule.fw_uar.fw_pts[1] = ntohs(GetOriginalPort(link)); + rule.fw_src = GetDestAddress(lnk); + rule.fw_dst = GetOriginalAddress(lnk); + rule.fw_uar.fw_pts[0] = ntohs(GetDestPort(lnk)); + rule.fw_uar.fw_pts[1] = ntohs(GetOriginalPort(lnk)); r = setsockopt(fireWallFD, IPPROTO_IP, IP_FW_ADD, &rule, sizeof rule); #ifdef DEBUG if (r) @@ -2706,21 +2710,21 @@ PunchFWHole(struct alias_link *link) } #endif /* !IPFW2 */ /* Indicate hole applied */ - link->data.tcp->fwhole = fwhole; + lnk->data.tcp->fwhole = fwhole; fw_setfield(la, la->fireWallField, fwhole); } /* Remove a hole in a firewall associated with a particular alias - link. Calling this too often is harmless. */ + lnk. Calling this too often is harmless. */ static void -ClearFWHole(struct alias_link *link) +ClearFWHole(struct alias_link *lnk) { struct libalias *la; - la = link->la; - if (link->link_type == LINK_TCP) { - int fwhole = link->data.tcp->fwhole; /* Where is the firewall + la = lnk->la; + if (lnk->link_type == LINK_TCP) { + int fwhole = lnk->data.tcp->fwhole; /* Where is the firewall * hole? */ struct ip_fw rule; @@ -2737,7 +2741,7 @@ ClearFWHole(struct alias_link *link) &rule, sizeof rule)); #endif /* !IPFW2 */ fw_clrfield(la, la->fireWallField, fwhole); - link->data.tcp->fwhole = -1; + lnk->data.tcp->fwhole = -1; } } diff --git a/lib/libalias/alias_ftp.c b/lib/libalias/alias_ftp.c index 2b678c6a47c3..79938db218ed 100644 --- a/lib/libalias/alias_ftp.c +++ b/lib/libalias/alias_ftp.c @@ -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 */ diff --git a/lib/libalias/alias_irc.c b/lib/libalias/alias_irc.c index 7b3d030d1a39..06abab0501eb 100644 --- a/lib/libalias/alias_irc.c +++ b/lib/libalias/alias_irc.c @@ -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 */ diff --git a/lib/libalias/alias_local.h b/lib/libalias/alias_local.h index b70fee6673f1..bf923a29aad2 100644 --- a/lib/libalias/alias_local.h +++ b/lib/libalias/alias_local.h @@ -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 { diff --git a/lib/libalias/alias_nbt.c b/lib/libalias/alias_nbt.c index fc5fa8422f9b..151bc9d934d1 100644 --- a/lib/libalias/alias_nbt.c +++ b/lib/libalias/alias_nbt.c @@ -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; diff --git a/lib/libalias/alias_old.c b/lib/libalias/alias_old.c index 5e9be07cc849..120c1428882d 100644 --- a/lib/libalias/alias_old.c +++ b/lib/libalias/alias_old.c @@ -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 * diff --git a/lib/libalias/alias_pptp.c b/lib/libalias/alias_pptp.c index 24bce3e6237a..499b5fe2fea6 100644 --- a/lib/libalias/alias_pptp.c +++ b/lib/libalias/alias_pptp.c @@ -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, diff --git a/lib/libalias/alias_proxy.c b/lib/libalias/alias_proxy.c index 70e0a159fecd..24d8bfee73b0 100644 --- a/lib/libalias/alias_proxy.c +++ b/lib/libalias/alias_proxy.c @@ -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); diff --git a/lib/libalias/alias_skinny.c b/lib/libalias/alias_skinny.c index fbd3e68f3a39..6a64063cdd99 100644 --- a/lib/libalias/alias_skinny.c +++ b/lib/libalias/alias_skinny.c @@ -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: diff --git a/lib/libalias/alias_smedia.c b/lib/libalias/alias_smedia.c index b96a9fac565d..ef19bea95203 100644 --- a/lib/libalias/alias_smedia.c +++ b/lib/libalias/alias_smedia.c @@ -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); } } diff --git a/lib/libalias/alias_util.c b/lib/libalias/alias_util.c index 574d4ed7d091..14df53d97768 100644 --- a/lib/libalias/alias_util.c +++ b/lib/libalias/alias_util.c @@ -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++; diff --git a/sys/netinet/libalias/Makefile b/sys/netinet/libalias/Makefile index 334d02f57239..f077b559d117 100644 --- a/sys/netinet/libalias/Makefile +++ b/sys/netinet/libalias/Makefile @@ -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 diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c index c456c66f04ea..832190057160 100644 --- a/sys/netinet/libalias/alias.c +++ b/sys/netinet/libalias/alias.c @@ -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); diff --git a/sys/netinet/libalias/alias.h b/sys/netinet/libalias/alias.h index cf681a42e71b..1deec9f08315 100644 --- a/sys/netinet/libalias/alias.h +++ b/sys/netinet/libalias/alias.h @@ -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, diff --git a/sys/netinet/libalias/alias_cuseeme.c b/sys/netinet/libalias/alias_cuseeme.c index 4b0f5a5ddc10..bca6b3b28154 100644 --- a/sys/netinet/libalias/alias_cuseeme.c +++ b/sys/netinet/libalias/alias_cuseeme.c @@ -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); diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c index 9f3693c8b2a7..e41106600356 100644 --- a/sys/netinet/libalias/alias_db.c +++ b/sys/netinet/libalias/alias_db.c @@ -354,15 +354,15 @@ static void ShowAliasStats(struct libalias *); #ifndef NO_FW_PUNCH /* Firewall control */ -static void InitPunchFW(struct libalias *la); -static void UninitPunchFW(struct libalias *la); -static void ClearFWHole(struct alias_link *link); +static void InitPunchFW(struct libalias *); +static void UninitPunchFW(struct libalias *); +static void ClearFWHole(struct alias_link *); #endif /* Log file control */ -static void InitPacketAliasLog(struct libalias *la); -static void UninitPacketAliasLog(struct libalias *la); +static void InitPacketAliasLog(struct libalias *); +static void UninitPacketAliasLog(struct libalias *); static u_int StartPointIn(struct in_addr alias_addr, @@ -508,7 +508,7 @@ static struct alias_link * unused triplets: (dest addr, dest port, alias port). */ static int -GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) +GetNewPort(struct libalias *la, struct alias_link *lnk, int alias_port_param) { int i; int max_trials; @@ -539,7 +539,7 @@ GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) * this is already in use, the remainder of the * trials will be random. */ - port_net = link->src_port; + port_net = lnk->src_port; port_sys = ntohs(port_net); } else { /* First trial and all subsequent are random. */ @@ -548,7 +548,7 @@ GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) port_net = htons(port_sys); } } else if (alias_port_param >= 0 && alias_port_param < 0x10000) { - link->alias_port = (u_short) alias_port_param; + lnk->alias_port = (u_short) alias_port_param; return (0); } else { #ifdef DEBUG @@ -564,13 +564,13 @@ GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) int go_ahead; struct alias_link *search_result; - search_result = FindLinkIn(la, link->dst_addr, link->alias_addr, - link->dst_port, port_net, - link->link_type, 0); + search_result = FindLinkIn(la, lnk->dst_addr, lnk->alias_addr, + lnk->dst_port, port_net, + lnk->link_type, 0); if (search_result == NULL) go_ahead = 1; - else if (!(link->flags & LINK_PARTIALLY_SPECIFIED) + else if (!(lnk->flags & LINK_PARTIALLY_SPECIFIED) && (search_result->flags & LINK_PARTIALLY_SPECIFIED)) go_ahead = 1; else @@ -578,15 +578,15 @@ GetNewPort(struct libalias *la, struct alias_link *link, int alias_port_param) if (go_ahead) { if ((la->packetAliasMode & PKT_ALIAS_USE_SOCKETS) - && (link->flags & LINK_PARTIALLY_SPECIFIED) - && ((link->link_type == LINK_TCP) || - (link->link_type == LINK_UDP))) { - if (GetSocket(la, port_net, &link->sockfd, link->link_type)) { - link->alias_port = port_net; + && (lnk->flags & LINK_PARTIALLY_SPECIFIED) + && ((lnk->link_type == LINK_TCP) || + (lnk->link_type == LINK_UDP))) { + if (GetSocket(la, port_net, &lnk->sockfd, lnk->link_type)) { + lnk->alias_port = port_net; return (0); } } else { - link->alias_port = port_net; + lnk->alias_port = port_net; return (0); } } @@ -745,19 +745,19 @@ FindNewPortGroup(struct libalias *la, static void CleanupAliasData(struct libalias *la) { - struct alias_link *link; + struct alias_link *lnk; int i, icount; icount = 0; for (i = 0; i < LINK_TABLE_OUT_SIZE; i++) { - link = LIST_FIRST(&la->linkTableOut[i]); - while (link != NULL) { + lnk = LIST_FIRST(&la->linkTableOut[i]); + while (lnk != NULL) { struct alias_link *link_next; - link_next = LIST_NEXT(link, list_out); + link_next = LIST_NEXT(lnk, list_out); icount++; - DeleteLink(link); - link = link_next; + DeleteLink(lnk); + lnk = link_next; } } @@ -769,37 +769,37 @@ static void IncrementalCleanup(struct libalias *la) { int icount; - struct alias_link *link; + struct alias_link *lnk; icount = 0; - link = LIST_FIRST(&la->linkTableOut[la->cleanupIndex++]); - while (link != NULL) { + lnk = LIST_FIRST(&la->linkTableOut[la->cleanupIndex++]); + while (lnk != NULL) { int idelta; struct alias_link *link_next; - link_next = LIST_NEXT(link, list_out); - idelta = la->timeStamp - link->timestamp; - switch (link->link_type) { + link_next = LIST_NEXT(lnk, list_out); + idelta = la->timeStamp - lnk->timestamp; + switch (lnk->link_type) { case LINK_TCP: - if (idelta > link->expire_time) { + if (idelta > lnk->expire_time) { struct tcp_dat *tcp_aux; - tcp_aux = link->data.tcp; + tcp_aux = lnk->data.tcp; if (tcp_aux->state.in != ALIAS_TCP_STATE_CONNECTED || tcp_aux->state.out != ALIAS_TCP_STATE_CONNECTED) { - DeleteLink(link); + DeleteLink(lnk); icount++; } } break; default: - if (idelta > link->expire_time) { - DeleteLink(link); + if (idelta > lnk->expire_time) { + DeleteLink(lnk); icount++; } break; } - link = link_next; + lnk = link_next; } if (la->cleanupIndex == LINK_TABLE_OUT_SIZE) @@ -807,42 +807,42 @@ IncrementalCleanup(struct libalias *la) } static void -DeleteLink(struct alias_link *link) +DeleteLink(struct alias_link *lnk) { - struct libalias *la = link->la; + struct libalias *la = lnk->la; /* Don't do anything if the link is marked permanent */ - if (la->deleteAllLinks == 0 && link->flags & LINK_PERMANENT) + if (la->deleteAllLinks == 0 && lnk->flags & LINK_PERMANENT) return; #ifndef NO_FW_PUNCH /* Delete associated firewall hole, if any */ - ClearFWHole(link); + ClearFWHole(lnk); #endif /* Free memory allocated for LSNAT server pool */ - if (link->server != NULL) { + if (lnk->server != NULL) { struct server *head, *curr, *next; - head = curr = link->server; + head = curr = lnk->server; do { next = curr->next; free(curr); } while ((curr = next) != head); } /* Adjust output table pointers */ - LIST_REMOVE(link, list_out); + LIST_REMOVE(lnk, list_out); /* Adjust input table pointers */ - LIST_REMOVE(link, list_in); + LIST_REMOVE(lnk, list_in); /* Close socket, if one has been allocated */ - if (link->sockfd != -1) { + if (lnk->sockfd != -1) { la->sockCount--; - close(link->sockfd); + close(lnk->sockfd); } /* Link-type dependent cleanup */ - switch (link->link_type) { + switch (lnk->link_type) { case LINK_ICMP: la->icmpLinkCount--; break; @@ -851,7 +851,7 @@ DeleteLink(struct alias_link *link) break; case LINK_TCP: la->tcpLinkCount--; - free(link->data.tcp); + free(lnk->data.tcp); break; case LINK_PPTP: la->pptpLinkCount--; @@ -861,8 +861,8 @@ DeleteLink(struct alias_link *link) break; case LINK_FRAGMENT_PTR: la->fragmentPtrLinkCount--; - if (link->data.frag_ptr != NULL) - free(link->data.frag_ptr); + if (lnk->data.frag_ptr != NULL) + free(lnk->data.frag_ptr); break; case LINK_ADDR: break; @@ -872,7 +872,7 @@ DeleteLink(struct alias_link *link) } /* Free memory */ - free(link); + free(lnk); /* Write statistics, if logging enabled */ if (la->packetAliasMode & PKT_ALIAS_LOG) { @@ -892,62 +892,62 @@ AddLink(struct libalias *la, struct in_addr src_addr, { /* port will be automatically *//* chosen. * If greater than */ u_int start_point; /* zero, equal to alias port */ - struct alias_link *link; + struct alias_link *lnk; - link = malloc(sizeof(struct alias_link)); - if (link != NULL) { + lnk = malloc(sizeof(struct alias_link)); + if (lnk != NULL) { /* Basic initialization */ - link->la = la; - link->src_addr = src_addr; - link->dst_addr = dst_addr; - link->alias_addr = alias_addr; - link->proxy_addr.s_addr = INADDR_ANY; - link->src_port = src_port; - link->dst_port = dst_port; - link->proxy_port = 0; - link->server = NULL; - link->link_type = link_type; - link->sockfd = -1; - link->flags = 0; - link->pflags = 0; - link->timestamp = la->timeStamp; + lnk->la = la; + lnk->src_addr = src_addr; + lnk->dst_addr = dst_addr; + lnk->alias_addr = alias_addr; + lnk->proxy_addr.s_addr = INADDR_ANY; + lnk->src_port = src_port; + lnk->dst_port = dst_port; + lnk->proxy_port = 0; + lnk->server = NULL; + lnk->link_type = link_type; + lnk->sockfd = -1; + lnk->flags = 0; + lnk->pflags = 0; + lnk->timestamp = la->timeStamp; /* Expiration time */ switch (link_type) { case LINK_ICMP: - link->expire_time = ICMP_EXPIRE_TIME; + lnk->expire_time = ICMP_EXPIRE_TIME; break; case LINK_UDP: - link->expire_time = UDP_EXPIRE_TIME; + lnk->expire_time = UDP_EXPIRE_TIME; break; case LINK_TCP: - link->expire_time = TCP_EXPIRE_INITIAL; + lnk->expire_time = TCP_EXPIRE_INITIAL; break; case LINK_PPTP: - link->flags |= LINK_PERMANENT; /* no timeout. */ + lnk->flags |= LINK_PERMANENT; /* no timeout. */ break; case LINK_FRAGMENT_ID: - link->expire_time = FRAGMENT_ID_EXPIRE_TIME; + lnk->expire_time = FRAGMENT_ID_EXPIRE_TIME; break; case LINK_FRAGMENT_PTR: - link->expire_time = FRAGMENT_PTR_EXPIRE_TIME; + lnk->expire_time = FRAGMENT_PTR_EXPIRE_TIME; break; case LINK_ADDR: break; default: - link->expire_time = PROTO_EXPIRE_TIME; + lnk->expire_time = PROTO_EXPIRE_TIME; break; } /* Determine alias flags */ if (dst_addr.s_addr == INADDR_ANY) - link->flags |= LINK_UNKNOWN_DEST_ADDR; + lnk->flags |= LINK_UNKNOWN_DEST_ADDR; if (dst_port == 0) - link->flags |= LINK_UNKNOWN_DEST_PORT; + lnk->flags |= LINK_UNKNOWN_DEST_PORT; /* Determine alias port */ - if (GetNewPort(la, link, alias_port_param) != 0) { - free(link); + if (GetNewPort(la, lnk, alias_port_param) != 0) { + free(lnk); return (NULL); } /* Link-type dependent initialization */ @@ -973,13 +973,13 @@ AddLink(struct libalias *la, struct in_addr src_addr, for (i = 0; i < N_LINK_TCP_DATA; i++) aux_tcp->ack[i].active = 0; aux_tcp->fwhole = -1; - link->data.tcp = aux_tcp; + lnk->data.tcp = aux_tcp; } else { #ifdef DEBUG fprintf(stderr, "PacketAlias/AddLink: "); fprintf(stderr, " cannot allocate auxiliary TCP data\n"); #endif - free(link); + free(lnk); return (NULL); } break; @@ -1002,11 +1002,11 @@ AddLink(struct libalias *la, struct in_addr src_addr, /* Set up pointers for output lookup table */ start_point = StartPointOut(src_addr, dst_addr, src_port, dst_port, link_type); - LIST_INSERT_HEAD(&la->linkTableOut[start_point], link, list_out); + LIST_INSERT_HEAD(&la->linkTableOut[start_point], lnk, list_out); /* Set up pointers for input lookup table */ - start_point = StartPointIn(alias_addr, link->alias_port, link_type); - LIST_INSERT_HEAD(&la->linkTableIn[start_point], link, list_in); + start_point = StartPointIn(alias_addr, lnk->alias_port, link_type); + LIST_INSERT_HEAD(&la->linkTableIn[start_point], lnk, list_in); } else { #ifdef DEBUG fprintf(stderr, "PacketAlias/AddLink(): "); @@ -1017,11 +1017,11 @@ AddLink(struct libalias *la, struct in_addr src_addr, if (la->packetAliasMode & PKT_ALIAS_LOG) { ShowAliasStats(la); } - return (link); + return (lnk); } static struct alias_link * -ReLink(struct alias_link *old_link, +ReLink(struct alias_link *old_lnk, struct in_addr src_addr, struct in_addr dst_addr, struct in_addr alias_addr, @@ -1031,21 +1031,21 @@ ReLink(struct alias_link *old_link, int link_type) { /* port will be automatically *//* chosen. * If greater than */ - struct alias_link *new_link; /* zero, equal to alias port */ - struct libalias *la = old_link->la; + struct alias_link *new_lnk; /* zero, equal to alias port */ + struct libalias *la = old_lnk->la; - new_link = AddLink(la, src_addr, dst_addr, alias_addr, + new_lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_port, dst_port, alias_port_param, link_type); #ifndef NO_FW_PUNCH - if (new_link != NULL && - old_link->link_type == LINK_TCP && - old_link->data.tcp->fwhole > 0) { - PunchFWHole(new_link); + if (new_lnk != NULL && + old_lnk->link_type == LINK_TCP && + old_lnk->data.tcp->fwhole > 0) { + PunchFWHole(new_lnk); } #endif - DeleteLink(old_link); - return (new_link); + DeleteLink(old_lnk); + return (new_lnk); } static struct alias_link * @@ -1057,43 +1057,43 @@ _FindLinkOut(struct libalias *la, struct in_addr src_addr, int replace_partial_links) { u_int i; - struct alias_link *link; + struct alias_link *lnk; i = StartPointOut(src_addr, dst_addr, src_port, dst_port, link_type); - LIST_FOREACH(link, &la->linkTableOut[i], list_out) { - if (link->src_addr.s_addr == src_addr.s_addr - && link->server == NULL - && link->dst_addr.s_addr == dst_addr.s_addr - && link->dst_port == dst_port - && link->src_port == src_port - && link->link_type == link_type) { - link->timestamp = la->timeStamp; + LIST_FOREACH(lnk, &la->linkTableOut[i], list_out) { + if (lnk->src_addr.s_addr == src_addr.s_addr + && lnk->server == NULL + && lnk->dst_addr.s_addr == dst_addr.s_addr + && lnk->dst_port == dst_port + && lnk->src_port == src_port + && lnk->link_type == link_type) { + lnk->timestamp = la->timeStamp; break; } } /* Search for partially specified links. */ - if (link == NULL && replace_partial_links) { + if (lnk == NULL && replace_partial_links) { if (dst_port != 0 && dst_addr.s_addr != INADDR_ANY) { - link = _FindLinkOut(la, src_addr, dst_addr, src_port, 0, + lnk = _FindLinkOut(la, src_addr, dst_addr, src_port, 0, link_type, 0); - if (link == NULL) - link = _FindLinkOut(la, src_addr, la->nullAddress, src_port, + if (lnk == NULL) + lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, dst_port, link_type, 0); } - if (link == NULL && + if (lnk == NULL && (dst_port != 0 || dst_addr.s_addr != INADDR_ANY)) { - link = _FindLinkOut(la, src_addr, la->nullAddress, src_port, 0, + lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, 0, link_type, 0); } - if (link != NULL) { - link = ReLink(link, - src_addr, dst_addr, link->alias_addr, - src_port, dst_port, link->alias_port, + if (lnk != NULL) { + lnk = ReLink(lnk, + src_addr, dst_addr, lnk->alias_addr, + src_port, dst_port, lnk->alias_port, link_type); } } - return (link); + return (lnk); } static struct alias_link * @@ -1104,12 +1104,12 @@ FindLinkOut(struct libalias *la, struct in_addr src_addr, int link_type, int replace_partial_links) { - struct alias_link *link; + struct alias_link *lnk; - link = _FindLinkOut(la, src_addr, dst_addr, src_port, dst_port, + lnk = _FindLinkOut(la, src_addr, dst_addr, src_port, dst_port, link_type, replace_partial_links); - if (link == NULL) { + if (lnk == NULL) { /* * The following allows permanent links to be specified as * using the default source address (i.e. device interface @@ -1118,11 +1118,11 @@ FindLinkOut(struct libalias *la, struct in_addr src_addr, */ if (la->aliasAddress.s_addr != INADDR_ANY && src_addr.s_addr == la->aliasAddress.s_addr) { - link = _FindLinkOut(la, la->nullAddress, dst_addr, src_port, dst_port, + lnk = _FindLinkOut(la, la->nullAddress, dst_addr, src_port, dst_port, link_type, replace_partial_links); } } - return (link); + return (lnk); } @@ -1136,17 +1136,17 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr, { int flags_in; u_int start_point; - struct alias_link *link; - struct alias_link *link_fully_specified; - struct alias_link *link_unknown_all; - struct alias_link *link_unknown_dst_addr; - struct alias_link *link_unknown_dst_port; + struct alias_link *lnk; + struct alias_link *lnk_fully_specified; + struct alias_link *lnk_unknown_all; + struct alias_link *lnk_unknown_dst_addr; + struct alias_link *lnk_unknown_dst_port; /* Initialize pointers */ - link_fully_specified = NULL; - link_unknown_all = NULL; - link_unknown_dst_addr = NULL; - link_unknown_dst_port = NULL; + lnk_fully_specified = NULL; + lnk_unknown_all = NULL; + lnk_unknown_dst_addr = NULL; + lnk_unknown_dst_port = NULL; /* If either the dest addr or port is unknown, the search loop will have to know about this. */ @@ -1159,80 +1159,80 @@ _FindLinkIn(struct libalias *la, struct in_addr dst_addr, /* Search loop */ start_point = StartPointIn(alias_addr, alias_port, link_type); - LIST_FOREACH(link, &la->linkTableIn[start_point], list_in) { + LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) { int flags; - flags = flags_in | link->flags; + flags = flags_in | lnk->flags; if (!(flags & LINK_PARTIALLY_SPECIFIED)) { - if (link->alias_addr.s_addr == alias_addr.s_addr - && link->alias_port == alias_port - && link->dst_addr.s_addr == dst_addr.s_addr - && link->dst_port == dst_port - && link->link_type == link_type) { - link_fully_specified = link; + if (lnk->alias_addr.s_addr == alias_addr.s_addr + && lnk->alias_port == alias_port + && lnk->dst_addr.s_addr == dst_addr.s_addr + && lnk->dst_port == dst_port + && lnk->link_type == link_type) { + lnk_fully_specified = lnk; break; } } else if ((flags & LINK_UNKNOWN_DEST_ADDR) && (flags & LINK_UNKNOWN_DEST_PORT)) { - if (link->alias_addr.s_addr == alias_addr.s_addr - && link->alias_port == alias_port - && link->link_type == link_type) { - if (link_unknown_all == NULL) - link_unknown_all = link; + if (lnk->alias_addr.s_addr == alias_addr.s_addr + && lnk->alias_port == alias_port + && lnk->link_type == link_type) { + if (lnk_unknown_all == NULL) + lnk_unknown_all = lnk; } } else if (flags & LINK_UNKNOWN_DEST_ADDR) { - if (link->alias_addr.s_addr == alias_addr.s_addr - && link->alias_port == alias_port - && link->link_type == link_type - && link->dst_port == dst_port) { - if (link_unknown_dst_addr == NULL) - link_unknown_dst_addr = link; + if (lnk->alias_addr.s_addr == alias_addr.s_addr + && lnk->alias_port == alias_port + && lnk->link_type == link_type + && lnk->dst_port == dst_port) { + if (lnk_unknown_dst_addr == NULL) + lnk_unknown_dst_addr = lnk; } } else if (flags & LINK_UNKNOWN_DEST_PORT) { - if (link->alias_addr.s_addr == alias_addr.s_addr - && link->alias_port == alias_port - && link->link_type == link_type - && link->dst_addr.s_addr == dst_addr.s_addr) { - if (link_unknown_dst_port == NULL) - link_unknown_dst_port = link; + if (lnk->alias_addr.s_addr == alias_addr.s_addr + && lnk->alias_port == alias_port + && lnk->link_type == link_type + && lnk->dst_addr.s_addr == dst_addr.s_addr) { + if (lnk_unknown_dst_port == NULL) + lnk_unknown_dst_port = lnk; } } } - if (link_fully_specified != NULL) { - link_fully_specified->timestamp = la->timeStamp; - link = link_fully_specified; - } else if (link_unknown_dst_port != NULL) - link = link_unknown_dst_port; - else if (link_unknown_dst_addr != NULL) - link = link_unknown_dst_addr; - else if (link_unknown_all != NULL) - link = link_unknown_all; + if (lnk_fully_specified != NULL) { + lnk_fully_specified->timestamp = la->timeStamp; + lnk = lnk_fully_specified; + } else if (lnk_unknown_dst_port != NULL) + lnk = lnk_unknown_dst_port; + else if (lnk_unknown_dst_addr != NULL) + lnk = lnk_unknown_dst_addr; + else if (lnk_unknown_all != NULL) + lnk = lnk_unknown_all; else return (NULL); if (replace_partial_links && - (link->flags & LINK_PARTIALLY_SPECIFIED || link->server != NULL)) { + (lnk->flags & LINK_PARTIALLY_SPECIFIED || lnk->server != NULL)) { struct in_addr src_addr; u_short src_port; - if (link->server != NULL) { /* LSNAT link */ - src_addr = link->server->addr; - src_port = link->server->port; - link->server = link->server->next; + if (lnk->server != NULL) { /* LSNAT link */ + src_addr = lnk->server->addr; + src_port = lnk->server->port; + lnk->server = lnk->server->next; } else { - src_addr = link->src_addr; - src_port = link->src_port; + src_addr = lnk->src_addr; + src_port = lnk->src_port; } - link = ReLink(link, + lnk = ReLink(lnk, src_addr, dst_addr, alias_addr, src_port, dst_port, alias_port, link_type); } - return (link); + return (lnk); } static struct alias_link * @@ -1243,12 +1243,12 @@ FindLinkIn(struct libalias *la, struct in_addr dst_addr, int link_type, int replace_partial_links) { - struct alias_link *link; + struct alias_link *lnk; - link = _FindLinkIn(la, dst_addr, alias_addr, dst_port, alias_port, + lnk = _FindLinkIn(la, dst_addr, alias_addr, dst_port, alias_port, link_type, replace_partial_links); - if (link == NULL) { + if (lnk == NULL) { /* * The following allows permanent links to be specified as * using the default aliasing address (i.e. device @@ -1257,11 +1257,11 @@ FindLinkIn(struct libalias *la, struct in_addr dst_addr, */ if (la->aliasAddress.s_addr != INADDR_ANY && alias_addr.s_addr == la->aliasAddress.s_addr) { - link = _FindLinkIn(la, dst_addr, la->nullAddress, dst_port, alias_port, + lnk = _FindLinkIn(la, dst_addr, la->nullAddress, dst_port, alias_port, link_type, replace_partial_links); } } - return (link); + return (lnk); } @@ -1290,20 +1290,20 @@ FindIcmpIn(struct libalias *la, struct in_addr dst_addr, u_short id_alias, int create) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, NO_DEST_PORT, id_alias, LINK_ICMP, 0); - if (link == NULL && create && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { + if (lnk == NULL && create && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { struct in_addr target_addr; target_addr = FindOriginalAddress(la, alias_addr); - link = AddLink(la, target_addr, dst_addr, alias_addr, + lnk = AddLink(la, target_addr, dst_addr, alias_addr, id_alias, NO_DEST_PORT, id_alias, LINK_ICMP); } - return (link); + return (lnk); } @@ -1313,20 +1313,20 @@ FindIcmpOut(struct libalias *la, struct in_addr src_addr, u_short id, int create) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkOut(la, src_addr, dst_addr, + lnk = FindLinkOut(la, src_addr, dst_addr, id, NO_DEST_PORT, LINK_ICMP, 0); - if (link == NULL && create) { + if (lnk == NULL && create) { struct in_addr alias_addr; alias_addr = FindAliasAddress(la, src_addr); - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, id, NO_DEST_PORT, GET_ALIAS_ID, LINK_ICMP); } - return (link); + return (lnk); } @@ -1335,18 +1335,18 @@ FindFragmentIn1(struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_short ip_id) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, NO_DEST_PORT, ip_id, LINK_FRAGMENT_ID, 0); - if (link == NULL) { - link = AddLink(la, la->nullAddress, dst_addr, alias_addr, + if (lnk == NULL) { + lnk = AddLink(la, la->nullAddress, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, ip_id, LINK_FRAGMENT_ID); } - return (link); + return (lnk); } @@ -1387,21 +1387,21 @@ FindProtoIn(struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_char proto) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, NO_DEST_PORT, 0, proto, 1); - if (link == NULL && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { + if (lnk == NULL && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { struct in_addr target_addr; target_addr = FindOriginalAddress(la, alias_addr); - link = AddLink(la, target_addr, dst_addr, alias_addr, + lnk = AddLink(la, target_addr, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, 0, proto); } - return (link); + return (lnk); } @@ -1410,21 +1410,21 @@ FindProtoOut(struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, u_char proto) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkOut(la, src_addr, dst_addr, + lnk = FindLinkOut(la, src_addr, dst_addr, NO_SRC_PORT, NO_DEST_PORT, proto, 1); - if (link == NULL) { + if (lnk == NULL) { struct in_addr alias_addr; alias_addr = FindAliasAddress(la, src_addr); - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, 0, proto); } - return (link); + return (lnk); } @@ -1437,7 +1437,7 @@ FindUdpTcpIn(struct libalias *la, struct in_addr dst_addr, int create) { int link_type; - struct alias_link *link; + struct alias_link *lnk; switch (proto) { case IPPROTO_UDP: @@ -1451,19 +1451,19 @@ FindUdpTcpIn(struct libalias *la, struct in_addr dst_addr, break; } - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, dst_port, alias_port, link_type, create); - if (link == NULL && create && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { + if (lnk == NULL && create && !(la->packetAliasMode & PKT_ALIAS_DENY_INCOMING)) { struct in_addr target_addr; target_addr = FindOriginalAddress(la, alias_addr); - link = AddLink(la, target_addr, dst_addr, alias_addr, + lnk = AddLink(la, target_addr, dst_addr, alias_addr, alias_port, dst_port, alias_port, link_type); } - return (link); + return (lnk); } @@ -1476,7 +1476,7 @@ FindUdpTcpOut(struct libalias *la, struct in_addr src_addr, int create) { int link_type; - struct alias_link *link; + struct alias_link *lnk; switch (proto) { case IPPROTO_UDP: @@ -1490,17 +1490,17 @@ FindUdpTcpOut(struct libalias *la, struct in_addr src_addr, break; } - link = FindLinkOut(la, src_addr, dst_addr, src_port, dst_port, link_type, create); + lnk = FindLinkOut(la, src_addr, dst_addr, src_port, dst_port, link_type, create); - if (link == NULL && create) { + if (lnk == NULL && create) { struct in_addr alias_addr; alias_addr = FindAliasAddress(la, src_addr); - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_port, dst_port, GET_ALIAS_PORT, link_type); } - return (link); + return (lnk); } @@ -1510,13 +1510,13 @@ AddPptp(struct libalias *la, struct in_addr src_addr, struct in_addr alias_addr, u_int16_t src_call_id) { - struct alias_link *link; + struct alias_link *lnk; - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_call_id, 0, GET_ALIAS_PORT, LINK_PPTP); - return (link); + return (lnk); } @@ -1526,17 +1526,17 @@ FindPptpOutByCallId(struct libalias *la, struct in_addr src_addr, u_int16_t src_call_id) { u_int i; - struct alias_link *link; + struct alias_link *lnk; i = StartPointOut(src_addr, dst_addr, 0, 0, LINK_PPTP); - LIST_FOREACH(link, &la->linkTableOut[i], list_out) - if (link->link_type == LINK_PPTP && - link->src_addr.s_addr == src_addr.s_addr && - link->dst_addr.s_addr == dst_addr.s_addr && - link->src_port == src_call_id) + LIST_FOREACH(lnk, &la->linkTableOut[i], list_out) + if (lnk->link_type == LINK_PPTP && + lnk->src_addr.s_addr == src_addr.s_addr && + lnk->dst_addr.s_addr == dst_addr.s_addr && + lnk->src_port == src_call_id) break; - return (link); + return (lnk); } @@ -1546,17 +1546,17 @@ FindPptpOutByPeerCallId(struct libalias *la, struct in_addr src_addr, u_int16_t dst_call_id) { u_int i; - struct alias_link *link; + struct alias_link *lnk; i = StartPointOut(src_addr, dst_addr, 0, 0, LINK_PPTP); - LIST_FOREACH(link, &la->linkTableOut[i], list_out) - if (link->link_type == LINK_PPTP && - link->src_addr.s_addr == src_addr.s_addr && - link->dst_addr.s_addr == dst_addr.s_addr && - link->dst_port == dst_call_id) + LIST_FOREACH(lnk, &la->linkTableOut[i], list_out) + if (lnk->link_type == LINK_PPTP && + lnk->src_addr.s_addr == src_addr.s_addr && + lnk->dst_addr.s_addr == dst_addr.s_addr && + lnk->dst_port == dst_call_id) break; - return (link); + return (lnk); } @@ -1566,17 +1566,17 @@ FindPptpInByCallId(struct libalias *la, struct in_addr dst_addr, u_int16_t dst_call_id) { u_int i; - struct alias_link *link; + struct alias_link *lnk; i = StartPointIn(alias_addr, 0, LINK_PPTP); - LIST_FOREACH(link, &la->linkTableIn[i], list_in) - if (link->link_type == LINK_PPTP && - link->dst_addr.s_addr == dst_addr.s_addr && - link->alias_addr.s_addr == alias_addr.s_addr && - link->dst_port == dst_call_id) + LIST_FOREACH(lnk, &la->linkTableIn[i], list_in) + if (lnk->link_type == LINK_PPTP && + lnk->dst_addr.s_addr == dst_addr.s_addr && + lnk->alias_addr.s_addr == alias_addr.s_addr && + lnk->dst_port == dst_call_id) break; - return (link); + return (lnk); } @@ -1585,14 +1585,14 @@ FindPptpInByPeerCallId(struct libalias *la, struct in_addr dst_addr, struct in_addr alias_addr, u_int16_t alias_call_id) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, dst_addr, alias_addr, + lnk = FindLinkIn(la, dst_addr, alias_addr, 0 /* any */ , alias_call_id, LINK_PPTP, 0); - return (link); + return (lnk); } @@ -1604,7 +1604,7 @@ FindRtspOut(struct libalias *la, struct in_addr src_addr, u_char proto) { int link_type; - struct alias_link *link; + struct alias_link *lnk; switch (proto) { case IPPROTO_UDP: @@ -1618,28 +1618,28 @@ FindRtspOut(struct libalias *la, struct in_addr src_addr, break; } - link = FindLinkOut(la, src_addr, dst_addr, src_port, 0, link_type, 1); + lnk = FindLinkOut(la, src_addr, dst_addr, src_port, 0, link_type, 1); - if (link == NULL) { + if (lnk == NULL) { struct in_addr alias_addr; alias_addr = FindAliasAddress(la, src_addr); - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_port, 0, alias_port, link_type); } - return (link); + return (lnk); } struct in_addr FindOriginalAddress(struct libalias *la, struct in_addr alias_addr) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkIn(la, la->nullAddress, alias_addr, + lnk = FindLinkIn(la, la->nullAddress, alias_addr, 0, 0, LINK_ADDR, 0); - if (link == NULL) { + if (lnk == NULL) { la->newDefaultLink = 1; if (la->targetAddress.s_addr == INADDR_ANY) return (alias_addr); @@ -1649,17 +1649,17 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr) else return (la->targetAddress); } else { - if (link->server != NULL) { /* LSNAT link */ + if (lnk->server != NULL) { /* LSNAT link */ struct in_addr src_addr; - src_addr = link->server->addr; - link->server = link->server->next; + src_addr = lnk->server->addr; + lnk->server = lnk->server->next; return (src_addr); - } else if (link->src_addr.s_addr == INADDR_ANY) + } else if (lnk->src_addr.s_addr == INADDR_ANY) return (la->aliasAddress.s_addr != INADDR_ANY) ? la->aliasAddress : alias_addr; else - return (link->src_addr); + return (lnk->src_addr); } } @@ -1667,19 +1667,19 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr) struct in_addr FindAliasAddress(struct libalias *la, struct in_addr original_addr) { - struct alias_link *link; + struct alias_link *lnk; - link = FindLinkOut(la, original_addr, la->nullAddress, + lnk = FindLinkOut(la, original_addr, la->nullAddress, 0, 0, LINK_ADDR, 0); - if (link == NULL) { + if (lnk == NULL) { return (la->aliasAddress.s_addr != INADDR_ANY) ? la->aliasAddress : original_addr; } else { - if (link->alias_addr.s_addr == INADDR_ANY) + if (lnk->alias_addr.s_addr == INADDR_ANY) return (la->aliasAddress.s_addr != INADDR_ANY) ? la->aliasAddress : original_addr; else - return (link->alias_addr); + return (lnk->alias_addr); } } @@ -1700,117 +1700,117 @@ FindAliasAddress(struct libalias *la, struct in_addr original_addr) void -SetFragmentAddr(struct alias_link *link, struct in_addr src_addr) +SetFragmentAddr(struct alias_link *lnk, struct in_addr src_addr) { - link->data.frag_addr = src_addr; + lnk->data.frag_addr = src_addr; } void -GetFragmentAddr(struct alias_link *link, struct in_addr *src_addr) +GetFragmentAddr(struct alias_link *lnk, struct in_addr *src_addr) { - *src_addr = link->data.frag_addr; + *src_addr = lnk->data.frag_addr; } void -SetFragmentPtr(struct alias_link *link, char *fptr) +SetFragmentPtr(struct alias_link *lnk, char *fptr) { - link->data.frag_ptr = fptr; + lnk->data.frag_ptr = fptr; } void -GetFragmentPtr(struct alias_link *link, char **fptr) +GetFragmentPtr(struct alias_link *lnk, char **fptr) { - *fptr = link->data.frag_ptr; + *fptr = lnk->data.frag_ptr; } void -SetStateIn(struct alias_link *link, int state) +SetStateIn(struct alias_link *lnk, int state) { /* TCP input state */ switch (state) { case ALIAS_TCP_STATE_DISCONNECTED: - if (link->data.tcp->state.out != ALIAS_TCP_STATE_CONNECTED) - link->expire_time = TCP_EXPIRE_DEAD; + if (lnk->data.tcp->state.out != ALIAS_TCP_STATE_CONNECTED) + lnk->expire_time = TCP_EXPIRE_DEAD; else - link->expire_time = TCP_EXPIRE_SINGLEDEAD; + lnk->expire_time = TCP_EXPIRE_SINGLEDEAD; break; case ALIAS_TCP_STATE_CONNECTED: - if (link->data.tcp->state.out == ALIAS_TCP_STATE_CONNECTED) - link->expire_time = TCP_EXPIRE_CONNECTED; + if (lnk->data.tcp->state.out == ALIAS_TCP_STATE_CONNECTED) + lnk->expire_time = TCP_EXPIRE_CONNECTED; break; default: abort(); } - link->data.tcp->state.in = state; + lnk->data.tcp->state.in = state; } void -SetStateOut(struct alias_link *link, int state) +SetStateOut(struct alias_link *lnk, int state) { /* TCP output state */ switch (state) { case ALIAS_TCP_STATE_DISCONNECTED: - if (link->data.tcp->state.in != ALIAS_TCP_STATE_CONNECTED) - link->expire_time = TCP_EXPIRE_DEAD; + if (lnk->data.tcp->state.in != ALIAS_TCP_STATE_CONNECTED) + lnk->expire_time = TCP_EXPIRE_DEAD; else - link->expire_time = TCP_EXPIRE_SINGLEDEAD; + lnk->expire_time = TCP_EXPIRE_SINGLEDEAD; break; case ALIAS_TCP_STATE_CONNECTED: - if (link->data.tcp->state.in == ALIAS_TCP_STATE_CONNECTED) - link->expire_time = TCP_EXPIRE_CONNECTED; + if (lnk->data.tcp->state.in == ALIAS_TCP_STATE_CONNECTED) + lnk->expire_time = TCP_EXPIRE_CONNECTED; break; default: abort(); } - link->data.tcp->state.out = state; + lnk->data.tcp->state.out = state; } int -GetStateIn(struct alias_link *link) +GetStateIn(struct alias_link *lnk) { /* TCP input state */ - return (link->data.tcp->state.in); + return (lnk->data.tcp->state.in); } int -GetStateOut(struct alias_link *link) +GetStateOut(struct alias_link *lnk) { /* TCP output state */ - return (link->data.tcp->state.out); + return (lnk->data.tcp->state.out); } struct in_addr -GetOriginalAddress(struct alias_link *link) +GetOriginalAddress(struct alias_link *lnk) { - if (link->src_addr.s_addr == INADDR_ANY) - return (link->la->aliasAddress); + if (lnk->src_addr.s_addr == INADDR_ANY) + return (lnk->la->aliasAddress); else - return (link->src_addr); + return (lnk->src_addr); } struct in_addr -GetDestAddress(struct alias_link *link) +GetDestAddress(struct alias_link *lnk) { - return (link->dst_addr); + return (lnk->dst_addr); } struct in_addr -GetAliasAddress(struct alias_link *link) +GetAliasAddress(struct alias_link *lnk) { - if (link->alias_addr.s_addr == INADDR_ANY) - return (link->la->aliasAddress); + if (lnk->alias_addr.s_addr == INADDR_ANY) + return (lnk->la->aliasAddress); else - return (link->alias_addr); + return (lnk->alias_addr); } @@ -1829,73 +1829,73 @@ SetDefaultAliasAddress(struct libalias *la, struct in_addr alias_addr) u_short -GetOriginalPort(struct alias_link *link) +GetOriginalPort(struct alias_link *lnk) { - return (link->src_port); + return (lnk->src_port); } u_short -GetAliasPort(struct alias_link *link) +GetAliasPort(struct alias_link *lnk) { - return (link->alias_port); + return (lnk->alias_port); } #ifndef NO_FW_PUNCH static u_short -GetDestPort(struct alias_link *link) +GetDestPort(struct alias_link *lnk) { - return (link->dst_port); + return (lnk->dst_port); } #endif void -SetAckModified(struct alias_link *link) +SetAckModified(struct alias_link *lnk) { /* Indicate that ACK numbers have been modified in a TCP connection */ - link->data.tcp->state.ack_modified = 1; + lnk->data.tcp->state.ack_modified = 1; } struct in_addr -GetProxyAddress(struct alias_link *link) +GetProxyAddress(struct alias_link *lnk) { - return (link->proxy_addr); + return (lnk->proxy_addr); } void -SetProxyAddress(struct alias_link *link, struct in_addr addr) +SetProxyAddress(struct alias_link *lnk, struct in_addr addr) { - link->proxy_addr = addr; + lnk->proxy_addr = addr; } u_short -GetProxyPort(struct alias_link *link) +GetProxyPort(struct alias_link *lnk) { - return (link->proxy_port); + return (lnk->proxy_port); } void -SetProxyPort(struct alias_link *link, u_short port) +SetProxyPort(struct alias_link *lnk, u_short port) { - link->proxy_port = port; + lnk->proxy_port = port; } int -GetAckModified(struct alias_link *link) +GetAckModified(struct alias_link *lnk) { /* See if ACK numbers have been modified */ - return (link->data.tcp->state.ack_modified); + return (lnk->data.tcp->state.ack_modified); } int -GetDeltaAckIn(struct ip *pip, struct alias_link *link) +GetDeltaAckIn(struct ip *pip, struct alias_link *lnk) { /* Find out how much the ACK number has been altered for an incoming @@ -1916,7 +1916,7 @@ packet size was altered is searched. for (i = 0; i < N_LINK_TCP_DATA; i++) { struct ack_data_record x; - x = link->data.tcp->ack[i]; + x = lnk->data.tcp->ack[i]; if (x.active == 1) { int ack_diff; @@ -1939,7 +1939,7 @@ packet size was altered is searched. int -GetDeltaSeqOut(struct ip *pip, struct alias_link *link) +GetDeltaSeqOut(struct ip *pip, struct alias_link *lnk) { /* Find out how much the sequence number has been altered for an outgoing @@ -1960,7 +1960,7 @@ packet size was altered is searched. for (i = 0; i < N_LINK_TCP_DATA; i++) { struct ack_data_record x; - x = link->data.tcp->ack[i]; + x = lnk->data.tcp->ack[i]; if (x.active == 1) { int seq_diff; @@ -1983,7 +1983,7 @@ packet size was altered is searched. void -AddSeq(struct ip *pip, struct alias_link *link, int delta) +AddSeq(struct ip *pip, struct alias_link *lnk, int delta) { /* When a TCP packet has been altered in length, save this @@ -2007,26 +2007,26 @@ been altered, then this list will begin to overwrite itself. x.delta = delta; x.active = 1; - i = link->data.tcp->state.index; - link->data.tcp->ack[i] = x; + i = lnk->data.tcp->state.index; + lnk->data.tcp->ack[i] = x; i++; if (i == N_LINK_TCP_DATA) - link->data.tcp->state.index = 0; + lnk->data.tcp->state.index = 0; else - link->data.tcp->state.index = i; + lnk->data.tcp->state.index = i; } void -SetExpire(struct alias_link *link, int expire) +SetExpire(struct alias_link *lnk, int expire) { if (expire == 0) { - link->flags &= ~LINK_PERMANENT; - DeleteLink(link); + lnk->flags &= ~LINK_PERMANENT; + DeleteLink(lnk); } else if (expire == -1) { - link->flags |= LINK_PERMANENT; + lnk->flags |= LINK_PERMANENT; } else if (expire > 0) { - link->expire_time = expire; + lnk->expire_time = expire; } else { #ifdef DEBUG fprintf(stderr, "PacketAlias/SetExpire(): "); @@ -2042,27 +2042,27 @@ ClearCheckNewLink(struct libalias *la) } void -SetProtocolFlags(struct alias_link *link, int pflags) +SetProtocolFlags(struct alias_link *lnk, int pflags) { - link->pflags = pflags;; + lnk->pflags = pflags;; } int -GetProtocolFlags(struct alias_link *link) +GetProtocolFlags(struct alias_link *lnk) { - return (link->pflags); + return (lnk->pflags); } void -SetDestCallId(struct alias_link *link, u_int16_t cid) +SetDestCallId(struct alias_link *lnk, u_int16_t cid) { - struct libalias *la = link->la; + struct libalias *la = lnk->la; la->deleteAllLinks = 1; - link = ReLink(link, link->src_addr, link->dst_addr, link->alias_addr, - link->src_port, cid, link->alias_port, link->link_type); + lnk = ReLink(lnk, lnk->src_addr, lnk->dst_addr, lnk->alias_addr, + lnk->src_port, cid, lnk->alias_port, lnk->link_type); la->deleteAllLinks = 0; } @@ -2186,7 +2186,7 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p u_char proto) { int link_type; - struct alias_link *link; + struct alias_link *lnk; switch (proto) { case IPPROTO_UDP: @@ -2203,12 +2203,12 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p return (NULL); } - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, src_port, dst_port, alias_port, link_type); - if (link != NULL) { - link->flags |= LINK_PERMANENT; + if (lnk != NULL) { + lnk->flags |= LINK_PERMANENT; } #ifdef DEBUG else { @@ -2217,15 +2217,17 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p } #endif - return (link); + return (lnk); } /* Add server to the pool of servers */ int -LibAliasAddServer(struct libalias *la, struct alias_link *link, struct in_addr addr, u_short port) +LibAliasAddServer(struct libalias *la, struct alias_link *lnk, struct in_addr addr, u_short port) { struct server *server; + (void)la; + server = malloc(sizeof(struct server)); if (server != NULL) { @@ -2234,7 +2236,7 @@ LibAliasAddServer(struct libalias *la, struct alias_link *link, struct in_addr a server->addr = addr; server->port = port; - head = link->server; + head = lnk->server; if (head == NULL) server->next = server; else { @@ -2244,7 +2246,7 @@ LibAliasAddServer(struct libalias *la, struct alias_link *link, struct in_addr a s->next = server; server->next = head; } - link->server = server; + lnk->server = server; return (0); } else return (-1); @@ -2258,14 +2260,14 @@ LibAliasRedirectProto(struct libalias *la, struct in_addr src_addr, struct in_addr alias_addr, u_char proto) { - struct alias_link *link; + struct alias_link *lnk; - link = AddLink(la, src_addr, dst_addr, alias_addr, + lnk = AddLink(la, src_addr, dst_addr, alias_addr, NO_SRC_PORT, NO_DEST_PORT, 0, proto); - if (link != NULL) { - link->flags |= LINK_PERMANENT; + if (lnk != NULL) { + lnk->flags |= LINK_PERMANENT; } #ifdef DEBUG else { @@ -2274,7 +2276,7 @@ LibAliasRedirectProto(struct libalias *la, struct in_addr src_addr, } #endif - return (link); + return (lnk); } /* Static address translation */ @@ -2282,14 +2284,14 @@ struct alias_link * LibAliasRedirectAddr(struct libalias *la, struct in_addr src_addr, struct in_addr alias_addr) { - struct alias_link *link; + struct alias_link *lnk; - link = AddLink(la, src_addr, la->nullAddress, alias_addr, + lnk = AddLink(la, src_addr, la->nullAddress, alias_addr, 0, 0, 0, LINK_ADDR); - if (link != NULL) { - link->flags |= LINK_PERMANENT; + if (lnk != NULL) { + lnk->flags |= LINK_PERMANENT; } #ifdef DEBUG else { @@ -2298,32 +2300,34 @@ LibAliasRedirectAddr(struct libalias *la, struct in_addr src_addr, } #endif - return (link); + return (lnk); } /* Mark the aliasing link dynamic */ int -LibAliasRedirectDynamic(struct libalias *la, struct alias_link *link) +LibAliasRedirectDynamic(struct libalias *la, struct alias_link *lnk) { - if (link->flags & LINK_PARTIALLY_SPECIFIED) + (void)la; + + if (lnk->flags & LINK_PARTIALLY_SPECIFIED) return (-1); else { - link->flags &= ~LINK_PERMANENT; + lnk->flags &= ~LINK_PERMANENT; return (0); } } void -LibAliasRedirectDelete(struct libalias *la, struct alias_link *link) +LibAliasRedirectDelete(struct libalias *la, struct alias_link *lnk) { /* This is a dangerous function to put in the API, because an invalid pointer can crash the program. */ la->deleteAllLinks = 1; - DeleteLink(link); + DeleteLink(lnk); la->deleteAllLinks = 0; } @@ -2597,19 +2601,19 @@ UninitPunchFW(struct libalias *la) /* Make a certain link go through the firewall */ void -PunchFWHole(struct alias_link *link) +PunchFWHole(struct alias_link *lnk) { struct libalias *la; int r; /* Result code */ struct ip_fw rule; /* On-the-fly built rule */ int fwhole; /* Where to punch hole */ - la = link->la; + la = lnk->la; /* Don't do anything unless we are asked to */ if (!(la->packetAliasMode & PKT_ALIAS_PUNCH_FW) || la->fireWallFD < 0 || - link->link_type != LINK_TCP) + lnk->link_type != LINK_TCP) return; memset(&rule, 0, sizeof rule); @@ -2645,22 +2649,22 @@ PunchFWHole(struct alias_link *link) * accept tcp from DAddr DPort to OAddr OPort */ #if IPFW2 - if (GetOriginalPort(link) != 0 && GetDestPort(link) != 0) { + if (GetOriginalPort(lnk) != 0 && GetDestPort(lnk) != 0) { u_int32_t rulebuf[255]; int i; i = fill_rule(rulebuf, sizeof(rulebuf), fwhole, O_ACCEPT, IPPROTO_TCP, - GetOriginalAddress(link), ntohs(GetOriginalPort(link)), - GetDestAddress(link), ntohs(GetDestPort(link))); + GetOriginalAddress(lnk), ntohs(GetOriginalPort(lnk)), + GetDestAddress(lnk), ntohs(GetDestPort(lnk))); r = setsockopt(la->fireWallFD, IPPROTO_IP, IP_FW_ADD, rulebuf, i); if (r) err(1, "alias punch inbound(1) setsockopt(IP_FW_ADD)"); i = fill_rule(rulebuf, sizeof(rulebuf), fwhole, O_ACCEPT, IPPROTO_TCP, - GetDestAddress(link), ntohs(GetDestPort(link)), - GetOriginalAddress(link), ntohs(GetOriginalPort(link))); + GetDestAddress(lnk), ntohs(GetDestPort(lnk)), + GetOriginalAddress(lnk), ntohs(GetOriginalPort(lnk))); r = setsockopt(la->fireWallFD, IPPROTO_IP, IP_FW_ADD, rulebuf, i); if (r) err(1, "alias punch inbound(2) setsockopt(IP_FW_ADD)"); @@ -2677,10 +2681,10 @@ PunchFWHole(struct alias_link *link) rule.fw_dmsk.s_addr = INADDR_BROADCAST; /* Build and apply specific part of the rules */ - rule.fw_src = GetOriginalAddress(link); - rule.fw_dst = GetDestAddress(link); - rule.fw_uar.fw_pts[0] = ntohs(GetOriginalPort(link)); - rule.fw_uar.fw_pts[1] = ntohs(GetDestPort(link)); + rule.fw_src = GetOriginalAddress(lnk); + rule.fw_dst = GetDestAddress(lnk); + rule.fw_uar.fw_pts[0] = ntohs(GetOriginalPort(lnk)); + rule.fw_uar.fw_pts[1] = ntohs(GetDestPort(lnk)); /* * Skip non-bound links - XXX should not be strictly necessary, but @@ -2694,10 +2698,10 @@ PunchFWHole(struct alias_link *link) if (r) err(1, "alias punch inbound(1) setsockopt(IP_FW_ADD)"); #endif - rule.fw_src = GetDestAddress(link); - rule.fw_dst = GetOriginalAddress(link); - rule.fw_uar.fw_pts[0] = ntohs(GetDestPort(link)); - rule.fw_uar.fw_pts[1] = ntohs(GetOriginalPort(link)); + rule.fw_src = GetDestAddress(lnk); + rule.fw_dst = GetOriginalAddress(lnk); + rule.fw_uar.fw_pts[0] = ntohs(GetDestPort(lnk)); + rule.fw_uar.fw_pts[1] = ntohs(GetOriginalPort(lnk)); r = setsockopt(fireWallFD, IPPROTO_IP, IP_FW_ADD, &rule, sizeof rule); #ifdef DEBUG if (r) @@ -2706,21 +2710,21 @@ PunchFWHole(struct alias_link *link) } #endif /* !IPFW2 */ /* Indicate hole applied */ - link->data.tcp->fwhole = fwhole; + lnk->data.tcp->fwhole = fwhole; fw_setfield(la, la->fireWallField, fwhole); } /* Remove a hole in a firewall associated with a particular alias - link. Calling this too often is harmless. */ + lnk. Calling this too often is harmless. */ static void -ClearFWHole(struct alias_link *link) +ClearFWHole(struct alias_link *lnk) { struct libalias *la; - la = link->la; - if (link->link_type == LINK_TCP) { - int fwhole = link->data.tcp->fwhole; /* Where is the firewall + la = lnk->la; + if (lnk->link_type == LINK_TCP) { + int fwhole = lnk->data.tcp->fwhole; /* Where is the firewall * hole? */ struct ip_fw rule; @@ -2737,7 +2741,7 @@ ClearFWHole(struct alias_link *link) &rule, sizeof rule)); #endif /* !IPFW2 */ fw_clrfield(la, la->fireWallField, fwhole); - link->data.tcp->fwhole = -1; + lnk->data.tcp->fwhole = -1; } } diff --git a/sys/netinet/libalias/alias_ftp.c b/sys/netinet/libalias/alias_ftp.c index 2b678c6a47c3..79938db218ed 100644 --- a/sys/netinet/libalias/alias_ftp.c +++ b/sys/netinet/libalias/alias_ftp.c @@ -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 */ diff --git a/sys/netinet/libalias/alias_irc.c b/sys/netinet/libalias/alias_irc.c index 7b3d030d1a39..06abab0501eb 100644 --- a/sys/netinet/libalias/alias_irc.c +++ b/sys/netinet/libalias/alias_irc.c @@ -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 */ diff --git a/sys/netinet/libalias/alias_local.h b/sys/netinet/libalias/alias_local.h index b70fee6673f1..bf923a29aad2 100644 --- a/sys/netinet/libalias/alias_local.h +++ b/sys/netinet/libalias/alias_local.h @@ -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 { diff --git a/sys/netinet/libalias/alias_nbt.c b/sys/netinet/libalias/alias_nbt.c index fc5fa8422f9b..151bc9d934d1 100644 --- a/sys/netinet/libalias/alias_nbt.c +++ b/sys/netinet/libalias/alias_nbt.c @@ -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; diff --git a/sys/netinet/libalias/alias_old.c b/sys/netinet/libalias/alias_old.c index 5e9be07cc849..120c1428882d 100644 --- a/sys/netinet/libalias/alias_old.c +++ b/sys/netinet/libalias/alias_old.c @@ -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 * diff --git a/sys/netinet/libalias/alias_pptp.c b/sys/netinet/libalias/alias_pptp.c index 24bce3e6237a..499b5fe2fea6 100644 --- a/sys/netinet/libalias/alias_pptp.c +++ b/sys/netinet/libalias/alias_pptp.c @@ -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, diff --git a/sys/netinet/libalias/alias_proxy.c b/sys/netinet/libalias/alias_proxy.c index 70e0a159fecd..24d8bfee73b0 100644 --- a/sys/netinet/libalias/alias_proxy.c +++ b/sys/netinet/libalias/alias_proxy.c @@ -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); diff --git a/sys/netinet/libalias/alias_skinny.c b/sys/netinet/libalias/alias_skinny.c index fbd3e68f3a39..6a64063cdd99 100644 --- a/sys/netinet/libalias/alias_skinny.c +++ b/sys/netinet/libalias/alias_skinny.c @@ -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: diff --git a/sys/netinet/libalias/alias_smedia.c b/sys/netinet/libalias/alias_smedia.c index b96a9fac565d..ef19bea95203 100644 --- a/sys/netinet/libalias/alias_smedia.c +++ b/sys/netinet/libalias/alias_smedia.c @@ -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); } } diff --git a/sys/netinet/libalias/alias_util.c b/sys/netinet/libalias/alias_util.c index 574d4ed7d091..14df53d97768 100644 --- a/sys/netinet/libalias/alias_util.c +++ b/sys/netinet/libalias/alias_util.c @@ -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++;