Parenthesize return values.

This commit is contained in:
Dag-Erling Smørgrav 2004-07-05 10:55:23 +00:00
parent f311ebb4ec
commit ffcb611a9d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=131613
12 changed files with 240 additions and 240 deletions

View File

@ -417,7 +417,7 @@ IcmpAliasIn(struct libalias *la, struct ip *pip)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
@ -596,7 +596,7 @@ IcmpAliasOut(struct libalias *la, struct ip *pip, int create)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
@ -636,7 +636,7 @@ ProtoAliasIn(struct libalias *la, struct ip *pip)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
link = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (link != NULL) {
@ -667,7 +667,7 @@ ProtoAliasOut(struct libalias *la, struct ip *pip, int create)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
link = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (link != NULL) {
@ -694,7 +694,7 @@ UdpAliasIn(struct libalias *la, struct ip *pip)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
@ -758,7 +758,7 @@ UdpAliasOut(struct libalias *la, struct ip *pip, int create)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
@ -920,7 +920,7 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
proxy_type = ProxyCheck(la, pip, &proxy_server_address, &proxy_server_port);
if (proxy_type == 0 && (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY))
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
/* If this is a transparent proxy, save original destination,
then alter the destination and adjust checksums */
@ -1160,7 +1160,7 @@ LibAliasIn(struct libalias *la, char *ptr, int maxpacketsize)
la->packetAliasMode &= ~PKT_ALIAS_REVERSE;
iresult = PacketAliasOut(ptr, maxpacketsize);
la->packetAliasMode |= PKT_ALIAS_REVERSE;
return iresult;
return (iresult);
}
HouseKeeping(la);
ClearCheckNewLink(la);
@ -1170,7 +1170,7 @@ LibAliasIn(struct libalias *la, char *ptr, int maxpacketsize)
/* Defense against mangled packets */
if (ntohs(pip->ip_len) > maxpacketsize
|| (pip->ip_hl << 2) > maxpacketsize)
return PKT_ALIAS_IGNORED;
return (PKT_ALIAS_IGNORED);
iresult = PKT_ALIAS_IGNORED;
if ((ntohs(pip->ip_off) & IP_OFFMASK) == 0) {
@ -1254,7 +1254,7 @@ LibAliasOutTry(struct libalias *la, char *ptr, /* valid IP packet */
la->packetAliasMode &= ~PKT_ALIAS_REVERSE;
iresult = PacketAliasIn(ptr, maxpacketsize);
la->packetAliasMode |= PKT_ALIAS_REVERSE;
return iresult;
return (iresult);
}
HouseKeeping(la);
ClearCheckNewLink(la);
@ -1263,7 +1263,7 @@ LibAliasOutTry(struct libalias *la, char *ptr, /* valid IP packet */
/* Defense against mangled packets */
if (ntohs(pip->ip_len) > maxpacketsize
|| (pip->ip_hl << 2) > maxpacketsize)
return PKT_ALIAS_IGNORED;
return (PKT_ALIAS_IGNORED);
addr_save = GetDefaultAliasAddress(la);
if (la->packetAliasMode & PKT_ALIAS_UNREGISTERED_ONLY) {

View File

@ -1045,7 +1045,7 @@ ReLink(struct alias_link *old_link,
}
#endif
DeleteLink(old_link);
return new_link;
return (new_link);
}
static struct alias_link *
@ -1447,7 +1447,7 @@ FindUdpTcpIn(struct libalias *la, struct in_addr dst_addr,
link_type = LINK_TCP;
break;
default:
return NULL;
return (NULL);
break;
}
@ -1486,7 +1486,7 @@ FindUdpTcpOut(struct libalias *la, struct in_addr src_addr,
link_type = LINK_TCP;
break;
default:
return NULL;
return (NULL);
break;
}
@ -1614,7 +1614,7 @@ FindRtspOut(struct libalias *la, struct in_addr src_addr,
link_type = LINK_TCP;
break;
default:
return NULL;
return (NULL);
break;
}
@ -1642,12 +1642,12 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr)
if (link == NULL) {
la->newDefaultLink = 1;
if (la->targetAddress.s_addr == INADDR_ANY)
return alias_addr;
return (alias_addr);
else if (la->targetAddress.s_addr == INADDR_NONE)
return (la->aliasAddress.s_addr != INADDR_ANY) ?
la->aliasAddress : alias_addr;
else
return la->targetAddress;
return (la->targetAddress);
} else {
if (link->server != NULL) { /* LSNAT link */
struct in_addr src_addr;
@ -1659,7 +1659,7 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr)
return (la->aliasAddress.s_addr != INADDR_ANY) ?
la->aliasAddress : alias_addr;
else
return link->src_addr;
return (link->src_addr);
}
}
@ -1679,7 +1679,7 @@ FindAliasAddress(struct libalias *la, struct in_addr original_addr)
return (la->aliasAddress.s_addr != INADDR_ANY) ?
la->aliasAddress : original_addr;
else
return link->alias_addr;
return (link->alias_addr);
}
}
@ -1775,7 +1775,7 @@ int
GetStateIn(struct alias_link *link)
{
/* TCP input state */
return link->data.tcp->state.in;
return (link->data.tcp->state.in);
}
@ -1783,7 +1783,7 @@ int
GetStateOut(struct alias_link *link)
{
/* TCP output state */
return link->data.tcp->state.out;
return (link->data.tcp->state.out);
}
@ -1791,7 +1791,7 @@ struct in_addr
GetOriginalAddress(struct alias_link *link)
{
if (link->src_addr.s_addr == INADDR_ANY)
return link->la->aliasAddress;
return (link->la->aliasAddress);
else
return (link->src_addr);
}
@ -1808,16 +1808,16 @@ struct in_addr
GetAliasAddress(struct alias_link *link)
{
if (link->alias_addr.s_addr == INADDR_ANY)
return link->la->aliasAddress;
return (link->la->aliasAddress);
else
return link->alias_addr;
return (link->alias_addr);
}
struct in_addr
GetDefaultAliasAddress(struct libalias *la)
{
return la->aliasAddress;
return (la->aliasAddress);
}
@ -1861,7 +1861,7 @@ SetAckModified(struct alias_link *link)
struct in_addr
GetProxyAddress(struct alias_link *link)
{
return link->proxy_addr;
return (link->proxy_addr);
}
@ -1875,7 +1875,7 @@ SetProxyAddress(struct alias_link *link, struct in_addr addr)
u_short
GetProxyPort(struct alias_link *link)
{
return link->proxy_port;
return (link->proxy_port);
}
@ -1890,7 +1890,7 @@ int
GetAckModified(struct alias_link *link)
{
/* See if ACK numbers have been modified */
return link->data.tcp->state.ack_modified;
return (link->data.tcp->state.ack_modified);
}
@ -2200,7 +2200,7 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p
fprintf(stderr, "PacketAliasRedirectPort(): ");
fprintf(stderr, "only TCP and UDP protocols allowed\n");
#endif
return NULL;
return (NULL);
}
link = AddLink(la, src_addr, dst_addr, alias_addr,
@ -2217,7 +2217,7 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p
}
#endif
return link;
return (link);
}
/* Add server to the pool of servers */
@ -2274,7 +2274,7 @@ LibAliasRedirectProto(struct libalias *la, struct in_addr src_addr,
}
#endif
return link;
return (link);
}
/* Static address translation */
@ -2298,7 +2298,7 @@ LibAliasRedirectAddr(struct libalias *la, struct in_addr src_addr,
}
#endif
return link;
return (link);
}
@ -2451,14 +2451,14 @@ LibAliasSetMode(
/* Other flags can be set/cleared without special action */
la->packetAliasMode = (flags & mask) | (la->packetAliasMode & ~mask);
return la->packetAliasMode;
return (la->packetAliasMode);
}
int
LibAliasCheckNewLink(struct libalias *la)
{
return la->newDefaultLink;
return (la->newDefaultLink);
}
@ -2490,7 +2490,7 @@ next_cmd(ipfw_insn * cmd)
{
cmd += F_LEN(cmd);
bzero(cmd, sizeof(*cmd));
return cmd;
return (cmd);
}
/*

View File

@ -181,7 +181,7 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
/* Return if data length is too short. */
if (dlen < 18)
return 0;
return (0);
addr = port = octet = 0;
state = -4;
@ -192,25 +192,25 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
if (ch == 'P')
state++;
else
return 0;
return (0);
break;
case -3:
if (ch == 'O')
state++;
else
return 0;
return (0);
break;
case -2:
if (ch == 'R')
state++;
else
return 0;
return (0);
break;
case -1:
if (ch == 'T')
state++;
else
return 0;
return (0);
break;
case 0:
@ -228,7 +228,7 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
octet = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 2:
case 4:
@ -240,7 +240,7 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
addr = (addr << 8) + octet;
state++;
} else
return 0;
return (0);
break;
case 10:
case 12:
@ -250,7 +250,7 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
port = (port << 8) + octet;
state++;
} else
return 0;
return (0);
break;
}
}
@ -258,9 +258,9 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
if (state == 13) {
la->true_addr.s_addr = htonl(addr);
la->true_port = port;
return 1;
return (1);
} else
return 0;
return (0);
}
static int
@ -276,7 +276,7 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
/* Return if data length is too short. */
if (dlen < 18)
return 0;
return (0);
addr = port = octet = 0;
delim = '|'; /* XXX gcc -Wuninitialized */
@ -288,25 +288,25 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
if (ch == 'E')
state++;
else
return 0;
return (0);
break;
case -3:
if (ch == 'P')
state++;
else
return 0;
return (0);
break;
case -2:
if (ch == 'R')
state++;
else
return 0;
return (0);
break;
case -1:
if (ch == 'T')
state++;
else
return 0;
return (0);
break;
case 0:
@ -319,13 +319,13 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
if (ch == '1') /* IPv4 address */
state++;
else
return 0;
return (0);
break;
case 2:
if (ch == delim)
state++;
else
return 0;
return (0);
break;
case 3:
case 5:
@ -335,7 +335,7 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
octet = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 4:
case 6:
@ -347,14 +347,14 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
addr = (addr << 8) + octet;
state++;
} else
return 0;
return (0);
break;
case 11:
if (isdigit(ch)) {
port = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 12:
if (isdigit(ch))
@ -362,7 +362,7 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
else if (ch == delim)
state++;
else
return 0;
return (0);
break;
}
}
@ -370,9 +370,9 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
if (state == 13) {
la->true_addr.s_addr = htonl(addr);
la->true_port = port;
return 1;
return (1);
} else
return 0;
return (0);
}
static int
@ -388,7 +388,7 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
/* Return if data length is too short. */
if (dlen < 17)
return 0;
return (0);
addr = port = octet = 0;
@ -400,19 +400,19 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
if (ch == '2')
state++;
else
return 0;
return (0);
break;
case -2:
if (ch == '2')
state++;
else
return 0;
return (0);
break;
case -1:
if (ch == '7')
state++;
else
return 0;
return (0);
break;
case 0:
@ -429,7 +429,7 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
octet = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 2:
case 4:
@ -441,7 +441,7 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
addr = (addr << 8) + octet;
state++;
} else
return 0;
return (0);
break;
case 10:
case 12:
@ -451,7 +451,7 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
port = (port << 8) + octet;
state++;
} else
return 0;
return (0);
break;
}
}
@ -459,9 +459,9 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
if (state == 13) {
la->true_port = port;
la->true_addr.s_addr = htonl(addr);
return 1;
return (1);
} else
return 0;
return (0);
}
static int
@ -475,7 +475,7 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
/* Return if data length is too short. */
if (dlen < 11)
return 0;
return (0);
port = 0;
delim = '|'; /* XXX gcc -Wuninitialized */
@ -488,19 +488,19 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
if (ch == '2')
state++;
else
return 0;
return (0);
break;
case -2:
if (ch == '2')
state++;
else
return 0;
return (0);
break;
case -1:
if (ch == '9')
state++;
else
return 0;
return (0);
break;
case 0:
@ -516,14 +516,14 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
if (ch == delim)
state++;
else
return 0;
return (0);
break;
case 4:
if (isdigit(ch)) {
port = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 5:
if (isdigit(ch))
@ -531,22 +531,22 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
else if (ch == delim)
state++;
else
return 0;
return (0);
break;
case 6:
if (ch == ')')
state++;
else
return 0;
return (0);
break;
}
}
if (state == 7) {
la->true_port = port;
return 1;
return (1);
} else
return 0;
return (0);
}
static void

View File

@ -149,23 +149,23 @@ IpMask(int nbits, struct in_addr *mask)
u_int imask;
if (nbits < 0 || nbits > 32)
return -1;
return (-1);
imask = 0;
for (i = 0; i < nbits; i++)
imask = (imask >> 1) + 0x80000000;
mask->s_addr = htonl(imask);
return 0;
return (0);
}
static int
IpAddr(char *s, struct in_addr *addr)
{
if (inet_aton(s, addr) == 0)
return -1;
return (-1);
else
return 0;
return (0);
}
static int
@ -182,14 +182,14 @@ IpPort(char *s, int proto, int *port)
else if (proto == IPPROTO_UDP)
se = getservbyname(s, "udp");
else
return -1;
return (-1);
if (se == NULL)
return -1;
return (-1);
*port = (u_int) ntohs(se->s_port);
}
return 0;
return (0);
}
void
@ -270,7 +270,7 @@ RuleNumberDelete(struct libalias *la, int rule_index)
ptr = ptr_next;
}
return err;
return (err);
}
static void
@ -471,13 +471,13 @@ ProxyCheck(struct libalias *la, struct ip *pip,
if ((*proxy_server_port = ptr->server_port) == 0)
*proxy_server_port = dst_port;
*proxy_server_addr = ptr->server_addr;
return ptr->proxy_type;
return (ptr->proxy_type);
}
}
ptr = ptr->next;
}
return 0;
return (0);
}
void
@ -550,7 +550,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
cmd += strspn(cmd, " \t");
cmd_len = strlen(cmd);
if (cmd_len > (sizeof(buffer) - 1))
return -1;
return (-1);
strcpy(buffer, cmd);
/* Convert to lower case */
@ -609,7 +609,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
else if (strcmp(token, "dst") == 0)
state = STATE_READ_DST;
else
return -1;
return (-1);
break;
case STATE_READ_TYPE:
@ -620,7 +620,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
else if (strcmp(token, "no_encode") == 0)
proxy_type = PROXY_TYPE_ENCODE_NONE;
else
return -1;
return (-1);
state = STATE_READ_KEYWORD;
break;
@ -642,17 +642,17 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
if (*p != ':') {
err = IpAddr(token, &server_addr);
if (err)
return -1;
return (-1);
} else {
*p = ' ';
n = sscanf(token, "%s %s", s, str_server_port);
if (n != 2)
return -1;
return (-1);
err = IpAddr(s, &server_addr);
if (err)
return -1;
return (-1);
}
}
state = STATE_READ_KEYWORD;
@ -661,7 +661,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
case STATE_READ_RULE:
n = sscanf(token, "%d", &rule_index);
if (n != 1 || rule_index < 0)
return -1;
return (-1);
state = STATE_READ_KEYWORD;
break;
@ -671,15 +671,15 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
int rule_to_delete;
if (token_count != 2)
return -1;
return (-1);
n = sscanf(token, "%d", &rule_to_delete);
if (n != 1)
return -1;
return (-1);
err = RuleNumberDelete(la, rule_to_delete);
if (err)
return -1;
return 0;
return (-1);
return (0);
}
case STATE_READ_PROTO:
@ -688,7 +688,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
else if (strcmp(token, "udp") == 0)
proto = IPPROTO_UDP;
else
return -1;
return (-1);
state = STATE_READ_KEYWORD;
break;
@ -708,7 +708,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
IpMask(32, &mask);
err = IpAddr(token, &addr);
if (err)
return -1;
return (-1);
} else {
int nbits;
char s[sizeof(buffer)];
@ -716,15 +716,15 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
*p = ' ';
n = sscanf(token, "%s %d", s, &nbits);
if (n != 2)
return -1;
return (-1);
err = IpAddr(s, &addr);
if (err)
return -1;
return (-1);
err = IpMask(nbits, &mask);
if (err)
return -1;
return (-1);
}
if (state == STATE_READ_SRC) {
@ -739,7 +739,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
break;
default:
return -1;
return (-1);
break;
}
@ -766,7 +766,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
err = IpPort(str_port, proto, &proxy_port);
if (err)
return -1;
return (-1);
} else {
proxy_port = 0;
}
@ -776,19 +776,19 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
err = IpPort(str_server_port, proto, &server_port);
if (err)
return -1;
return (-1);
} else {
server_port = 0;
}
/* Check that at least the server address has been defined */
if (server_addr.s_addr == 0)
return -1;
return (-1);
/* Add to linked list */
proxy_entry = malloc(sizeof(struct proxy_entry));
if (proxy_entry == NULL)
return -1;
return (-1);
proxy_entry->proxy_type = proxy_type;
proxy_entry->rule_index = rule_index;
@ -803,5 +803,5 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
RuleAdd(la, proxy_entry);
return 0;
return (0);
}

View File

@ -140,7 +140,7 @@ alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
return 0;
return (0);
}
static int
@ -159,7 +159,7 @@ alias_skinny_startmedia(struct StartMediaTransmission *start_media,
* well.
*/
return 0;
return (0);
}
static int
@ -172,7 +172,7 @@ alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
return 0;
return (0);
}
static int
@ -198,7 +198,7 @@ alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opn
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
return 0;
return (0);
}
void

View File

@ -129,11 +129,11 @@ search_string(char *data, int dlen, const char *search_str)
break;
}
if (k == search_str_len - 1) {
return j + 1;
return (j + 1);
}
}
}
return -1;
return (-1);
}
static int
@ -163,7 +163,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
/* Find keyword, "Transport: " */
pos = search_string(data, dlen, transport_str);
if (pos < 0) {
return -1;
return (-1);
}
port_data = data + pos;
port_dlen = dlen - pos;
@ -298,7 +298,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
}
if (!pkt_updated)
return -1;
return (-1);
memcpy(port_newdata, port_data, port_dlen);
port_newdata += port_dlen;
@ -322,7 +322,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
return 0;
return (0);
}
/* Support the protocol used by early versions of RealPlayer */
@ -348,7 +348,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
work += 2;
if (ntohs(msg_id) == 0) {
/* end of options */
return 0;
return (0);
}
if ((ntohs(msg_id) == 1) || (ntohs(msg_id) == 7)) {
memcpy(&port, work, 2);
@ -371,7 +371,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
work += ntohs(msg_len);
}
return 0;
return (0);
}
void

View File

@ -417,7 +417,7 @@ IcmpAliasIn(struct libalias *la, struct ip *pip)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
@ -596,7 +596,7 @@ IcmpAliasOut(struct libalias *la, struct ip *pip, int create)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
ic = (struct icmp *)((char *)pip + (pip->ip_hl << 2));
@ -636,7 +636,7 @@ ProtoAliasIn(struct libalias *la, struct ip *pip)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
link = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (link != NULL) {
@ -667,7 +667,7 @@ ProtoAliasOut(struct libalias *la, struct ip *pip, int create)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
link = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
if (link != NULL) {
@ -694,7 +694,7 @@ UdpAliasIn(struct libalias *la, struct ip *pip)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
@ -758,7 +758,7 @@ UdpAliasOut(struct libalias *la, struct ip *pip, int create)
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
@ -920,7 +920,7 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create)
proxy_type = ProxyCheck(la, pip, &proxy_server_address, &proxy_server_port);
if (proxy_type == 0 && (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY))
return PKT_ALIAS_OK;
return (PKT_ALIAS_OK);
/* If this is a transparent proxy, save original destination,
then alter the destination and adjust checksums */
@ -1160,7 +1160,7 @@ LibAliasIn(struct libalias *la, char *ptr, int maxpacketsize)
la->packetAliasMode &= ~PKT_ALIAS_REVERSE;
iresult = PacketAliasOut(ptr, maxpacketsize);
la->packetAliasMode |= PKT_ALIAS_REVERSE;
return iresult;
return (iresult);
}
HouseKeeping(la);
ClearCheckNewLink(la);
@ -1170,7 +1170,7 @@ LibAliasIn(struct libalias *la, char *ptr, int maxpacketsize)
/* Defense against mangled packets */
if (ntohs(pip->ip_len) > maxpacketsize
|| (pip->ip_hl << 2) > maxpacketsize)
return PKT_ALIAS_IGNORED;
return (PKT_ALIAS_IGNORED);
iresult = PKT_ALIAS_IGNORED;
if ((ntohs(pip->ip_off) & IP_OFFMASK) == 0) {
@ -1254,7 +1254,7 @@ LibAliasOutTry(struct libalias *la, char *ptr, /* valid IP packet */
la->packetAliasMode &= ~PKT_ALIAS_REVERSE;
iresult = PacketAliasIn(ptr, maxpacketsize);
la->packetAliasMode |= PKT_ALIAS_REVERSE;
return iresult;
return (iresult);
}
HouseKeeping(la);
ClearCheckNewLink(la);
@ -1263,7 +1263,7 @@ LibAliasOutTry(struct libalias *la, char *ptr, /* valid IP packet */
/* Defense against mangled packets */
if (ntohs(pip->ip_len) > maxpacketsize
|| (pip->ip_hl << 2) > maxpacketsize)
return PKT_ALIAS_IGNORED;
return (PKT_ALIAS_IGNORED);
addr_save = GetDefaultAliasAddress(la);
if (la->packetAliasMode & PKT_ALIAS_UNREGISTERED_ONLY) {

View File

@ -1045,7 +1045,7 @@ ReLink(struct alias_link *old_link,
}
#endif
DeleteLink(old_link);
return new_link;
return (new_link);
}
static struct alias_link *
@ -1447,7 +1447,7 @@ FindUdpTcpIn(struct libalias *la, struct in_addr dst_addr,
link_type = LINK_TCP;
break;
default:
return NULL;
return (NULL);
break;
}
@ -1486,7 +1486,7 @@ FindUdpTcpOut(struct libalias *la, struct in_addr src_addr,
link_type = LINK_TCP;
break;
default:
return NULL;
return (NULL);
break;
}
@ -1614,7 +1614,7 @@ FindRtspOut(struct libalias *la, struct in_addr src_addr,
link_type = LINK_TCP;
break;
default:
return NULL;
return (NULL);
break;
}
@ -1642,12 +1642,12 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr)
if (link == NULL) {
la->newDefaultLink = 1;
if (la->targetAddress.s_addr == INADDR_ANY)
return alias_addr;
return (alias_addr);
else if (la->targetAddress.s_addr == INADDR_NONE)
return (la->aliasAddress.s_addr != INADDR_ANY) ?
la->aliasAddress : alias_addr;
else
return la->targetAddress;
return (la->targetAddress);
} else {
if (link->server != NULL) { /* LSNAT link */
struct in_addr src_addr;
@ -1659,7 +1659,7 @@ FindOriginalAddress(struct libalias *la, struct in_addr alias_addr)
return (la->aliasAddress.s_addr != INADDR_ANY) ?
la->aliasAddress : alias_addr;
else
return link->src_addr;
return (link->src_addr);
}
}
@ -1679,7 +1679,7 @@ FindAliasAddress(struct libalias *la, struct in_addr original_addr)
return (la->aliasAddress.s_addr != INADDR_ANY) ?
la->aliasAddress : original_addr;
else
return link->alias_addr;
return (link->alias_addr);
}
}
@ -1775,7 +1775,7 @@ int
GetStateIn(struct alias_link *link)
{
/* TCP input state */
return link->data.tcp->state.in;
return (link->data.tcp->state.in);
}
@ -1783,7 +1783,7 @@ int
GetStateOut(struct alias_link *link)
{
/* TCP output state */
return link->data.tcp->state.out;
return (link->data.tcp->state.out);
}
@ -1791,7 +1791,7 @@ struct in_addr
GetOriginalAddress(struct alias_link *link)
{
if (link->src_addr.s_addr == INADDR_ANY)
return link->la->aliasAddress;
return (link->la->aliasAddress);
else
return (link->src_addr);
}
@ -1808,16 +1808,16 @@ struct in_addr
GetAliasAddress(struct alias_link *link)
{
if (link->alias_addr.s_addr == INADDR_ANY)
return link->la->aliasAddress;
return (link->la->aliasAddress);
else
return link->alias_addr;
return (link->alias_addr);
}
struct in_addr
GetDefaultAliasAddress(struct libalias *la)
{
return la->aliasAddress;
return (la->aliasAddress);
}
@ -1861,7 +1861,7 @@ SetAckModified(struct alias_link *link)
struct in_addr
GetProxyAddress(struct alias_link *link)
{
return link->proxy_addr;
return (link->proxy_addr);
}
@ -1875,7 +1875,7 @@ SetProxyAddress(struct alias_link *link, struct in_addr addr)
u_short
GetProxyPort(struct alias_link *link)
{
return link->proxy_port;
return (link->proxy_port);
}
@ -1890,7 +1890,7 @@ int
GetAckModified(struct alias_link *link)
{
/* See if ACK numbers have been modified */
return link->data.tcp->state.ack_modified;
return (link->data.tcp->state.ack_modified);
}
@ -2200,7 +2200,7 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p
fprintf(stderr, "PacketAliasRedirectPort(): ");
fprintf(stderr, "only TCP and UDP protocols allowed\n");
#endif
return NULL;
return (NULL);
}
link = AddLink(la, src_addr, dst_addr, alias_addr,
@ -2217,7 +2217,7 @@ LibAliasRedirectPort(struct libalias *la, struct in_addr src_addr, u_short src_p
}
#endif
return link;
return (link);
}
/* Add server to the pool of servers */
@ -2274,7 +2274,7 @@ LibAliasRedirectProto(struct libalias *la, struct in_addr src_addr,
}
#endif
return link;
return (link);
}
/* Static address translation */
@ -2298,7 +2298,7 @@ LibAliasRedirectAddr(struct libalias *la, struct in_addr src_addr,
}
#endif
return link;
return (link);
}
@ -2451,14 +2451,14 @@ LibAliasSetMode(
/* Other flags can be set/cleared without special action */
la->packetAliasMode = (flags & mask) | (la->packetAliasMode & ~mask);
return la->packetAliasMode;
return (la->packetAliasMode);
}
int
LibAliasCheckNewLink(struct libalias *la)
{
return la->newDefaultLink;
return (la->newDefaultLink);
}
@ -2490,7 +2490,7 @@ next_cmd(ipfw_insn * cmd)
{
cmd += F_LEN(cmd);
bzero(cmd, sizeof(*cmd));
return cmd;
return (cmd);
}
/*

View File

@ -181,7 +181,7 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
/* Return if data length is too short. */
if (dlen < 18)
return 0;
return (0);
addr = port = octet = 0;
state = -4;
@ -192,25 +192,25 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
if (ch == 'P')
state++;
else
return 0;
return (0);
break;
case -3:
if (ch == 'O')
state++;
else
return 0;
return (0);
break;
case -2:
if (ch == 'R')
state++;
else
return 0;
return (0);
break;
case -1:
if (ch == 'T')
state++;
else
return 0;
return (0);
break;
case 0:
@ -228,7 +228,7 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
octet = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 2:
case 4:
@ -240,7 +240,7 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
addr = (addr << 8) + octet;
state++;
} else
return 0;
return (0);
break;
case 10:
case 12:
@ -250,7 +250,7 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
port = (port << 8) + octet;
state++;
} else
return 0;
return (0);
break;
}
}
@ -258,9 +258,9 @@ ParseFtpPortCommand(struct libalias *la, char *sptr, int dlen)
if (state == 13) {
la->true_addr.s_addr = htonl(addr);
la->true_port = port;
return 1;
return (1);
} else
return 0;
return (0);
}
static int
@ -276,7 +276,7 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
/* Return if data length is too short. */
if (dlen < 18)
return 0;
return (0);
addr = port = octet = 0;
delim = '|'; /* XXX gcc -Wuninitialized */
@ -288,25 +288,25 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
if (ch == 'E')
state++;
else
return 0;
return (0);
break;
case -3:
if (ch == 'P')
state++;
else
return 0;
return (0);
break;
case -2:
if (ch == 'R')
state++;
else
return 0;
return (0);
break;
case -1:
if (ch == 'T')
state++;
else
return 0;
return (0);
break;
case 0:
@ -319,13 +319,13 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
if (ch == '1') /* IPv4 address */
state++;
else
return 0;
return (0);
break;
case 2:
if (ch == delim)
state++;
else
return 0;
return (0);
break;
case 3:
case 5:
@ -335,7 +335,7 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
octet = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 4:
case 6:
@ -347,14 +347,14 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
addr = (addr << 8) + octet;
state++;
} else
return 0;
return (0);
break;
case 11:
if (isdigit(ch)) {
port = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 12:
if (isdigit(ch))
@ -362,7 +362,7 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
else if (ch == delim)
state++;
else
return 0;
return (0);
break;
}
}
@ -370,9 +370,9 @@ ParseFtpEprtCommand(struct libalias *la, char *sptr, int dlen)
if (state == 13) {
la->true_addr.s_addr = htonl(addr);
la->true_port = port;
return 1;
return (1);
} else
return 0;
return (0);
}
static int
@ -388,7 +388,7 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
/* Return if data length is too short. */
if (dlen < 17)
return 0;
return (0);
addr = port = octet = 0;
@ -400,19 +400,19 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
if (ch == '2')
state++;
else
return 0;
return (0);
break;
case -2:
if (ch == '2')
state++;
else
return 0;
return (0);
break;
case -1:
if (ch == '7')
state++;
else
return 0;
return (0);
break;
case 0:
@ -429,7 +429,7 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
octet = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 2:
case 4:
@ -441,7 +441,7 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
addr = (addr << 8) + octet;
state++;
} else
return 0;
return (0);
break;
case 10:
case 12:
@ -451,7 +451,7 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
port = (port << 8) + octet;
state++;
} else
return 0;
return (0);
break;
}
}
@ -459,9 +459,9 @@ ParseFtp227Reply(struct libalias *la, char *sptr, int dlen)
if (state == 13) {
la->true_port = port;
la->true_addr.s_addr = htonl(addr);
return 1;
return (1);
} else
return 0;
return (0);
}
static int
@ -475,7 +475,7 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
/* Return if data length is too short. */
if (dlen < 11)
return 0;
return (0);
port = 0;
delim = '|'; /* XXX gcc -Wuninitialized */
@ -488,19 +488,19 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
if (ch == '2')
state++;
else
return 0;
return (0);
break;
case -2:
if (ch == '2')
state++;
else
return 0;
return (0);
break;
case -1:
if (ch == '9')
state++;
else
return 0;
return (0);
break;
case 0:
@ -516,14 +516,14 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
if (ch == delim)
state++;
else
return 0;
return (0);
break;
case 4:
if (isdigit(ch)) {
port = ch - '0';
state++;
} else
return 0;
return (0);
break;
case 5:
if (isdigit(ch))
@ -531,22 +531,22 @@ ParseFtp229Reply(struct libalias *la, char *sptr, int dlen)
else if (ch == delim)
state++;
else
return 0;
return (0);
break;
case 6:
if (ch == ')')
state++;
else
return 0;
return (0);
break;
}
}
if (state == 7) {
la->true_port = port;
return 1;
return (1);
} else
return 0;
return (0);
}
static void

View File

@ -149,23 +149,23 @@ IpMask(int nbits, struct in_addr *mask)
u_int imask;
if (nbits < 0 || nbits > 32)
return -1;
return (-1);
imask = 0;
for (i = 0; i < nbits; i++)
imask = (imask >> 1) + 0x80000000;
mask->s_addr = htonl(imask);
return 0;
return (0);
}
static int
IpAddr(char *s, struct in_addr *addr)
{
if (inet_aton(s, addr) == 0)
return -1;
return (-1);
else
return 0;
return (0);
}
static int
@ -182,14 +182,14 @@ IpPort(char *s, int proto, int *port)
else if (proto == IPPROTO_UDP)
se = getservbyname(s, "udp");
else
return -1;
return (-1);
if (se == NULL)
return -1;
return (-1);
*port = (u_int) ntohs(se->s_port);
}
return 0;
return (0);
}
void
@ -270,7 +270,7 @@ RuleNumberDelete(struct libalias *la, int rule_index)
ptr = ptr_next;
}
return err;
return (err);
}
static void
@ -471,13 +471,13 @@ ProxyCheck(struct libalias *la, struct ip *pip,
if ((*proxy_server_port = ptr->server_port) == 0)
*proxy_server_port = dst_port;
*proxy_server_addr = ptr->server_addr;
return ptr->proxy_type;
return (ptr->proxy_type);
}
}
ptr = ptr->next;
}
return 0;
return (0);
}
void
@ -550,7 +550,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
cmd += strspn(cmd, " \t");
cmd_len = strlen(cmd);
if (cmd_len > (sizeof(buffer) - 1))
return -1;
return (-1);
strcpy(buffer, cmd);
/* Convert to lower case */
@ -609,7 +609,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
else if (strcmp(token, "dst") == 0)
state = STATE_READ_DST;
else
return -1;
return (-1);
break;
case STATE_READ_TYPE:
@ -620,7 +620,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
else if (strcmp(token, "no_encode") == 0)
proxy_type = PROXY_TYPE_ENCODE_NONE;
else
return -1;
return (-1);
state = STATE_READ_KEYWORD;
break;
@ -642,17 +642,17 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
if (*p != ':') {
err = IpAddr(token, &server_addr);
if (err)
return -1;
return (-1);
} else {
*p = ' ';
n = sscanf(token, "%s %s", s, str_server_port);
if (n != 2)
return -1;
return (-1);
err = IpAddr(s, &server_addr);
if (err)
return -1;
return (-1);
}
}
state = STATE_READ_KEYWORD;
@ -661,7 +661,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
case STATE_READ_RULE:
n = sscanf(token, "%d", &rule_index);
if (n != 1 || rule_index < 0)
return -1;
return (-1);
state = STATE_READ_KEYWORD;
break;
@ -671,15 +671,15 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
int rule_to_delete;
if (token_count != 2)
return -1;
return (-1);
n = sscanf(token, "%d", &rule_to_delete);
if (n != 1)
return -1;
return (-1);
err = RuleNumberDelete(la, rule_to_delete);
if (err)
return -1;
return 0;
return (-1);
return (0);
}
case STATE_READ_PROTO:
@ -688,7 +688,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
else if (strcmp(token, "udp") == 0)
proto = IPPROTO_UDP;
else
return -1;
return (-1);
state = STATE_READ_KEYWORD;
break;
@ -708,7 +708,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
IpMask(32, &mask);
err = IpAddr(token, &addr);
if (err)
return -1;
return (-1);
} else {
int nbits;
char s[sizeof(buffer)];
@ -716,15 +716,15 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
*p = ' ';
n = sscanf(token, "%s %d", s, &nbits);
if (n != 2)
return -1;
return (-1);
err = IpAddr(s, &addr);
if (err)
return -1;
return (-1);
err = IpMask(nbits, &mask);
if (err)
return -1;
return (-1);
}
if (state == STATE_READ_SRC) {
@ -739,7 +739,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
break;
default:
return -1;
return (-1);
break;
}
@ -766,7 +766,7 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
err = IpPort(str_port, proto, &proxy_port);
if (err)
return -1;
return (-1);
} else {
proxy_port = 0;
}
@ -776,19 +776,19 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
err = IpPort(str_server_port, proto, &server_port);
if (err)
return -1;
return (-1);
} else {
server_port = 0;
}
/* Check that at least the server address has been defined */
if (server_addr.s_addr == 0)
return -1;
return (-1);
/* Add to linked list */
proxy_entry = malloc(sizeof(struct proxy_entry));
if (proxy_entry == NULL)
return -1;
return (-1);
proxy_entry->proxy_type = proxy_type;
proxy_entry->rule_index = rule_index;
@ -803,5 +803,5 @@ LibAliasProxyRule(struct libalias *la, const char *cmd)
RuleAdd(la, proxy_entry);
return 0;
return (0);
}

View File

@ -140,7 +140,7 @@ alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
return 0;
return (0);
}
static int
@ -159,7 +159,7 @@ alias_skinny_startmedia(struct StartMediaTransmission *start_media,
* well.
*/
return 0;
return (0);
}
static int
@ -172,7 +172,7 @@ alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
return 0;
return (0);
}
static int
@ -198,7 +198,7 @@ alias_skinny_opnrcvch_ack(struct libalias *la, struct OpenReceiveChannelAck *opn
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
return 0;
return (0);
}
void

View File

@ -129,11 +129,11 @@ search_string(char *data, int dlen, const char *search_str)
break;
}
if (k == search_str_len - 1) {
return j + 1;
return (j + 1);
}
}
}
return -1;
return (-1);
}
static int
@ -163,7 +163,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
/* Find keyword, "Transport: " */
pos = search_string(data, dlen, transport_str);
if (pos < 0) {
return -1;
return (-1);
}
port_data = data + pos;
port_dlen = dlen - pos;
@ -298,7 +298,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
}
if (!pkt_updated)
return -1;
return (-1);
memcpy(port_newdata, port_data, port_dlen);
port_newdata += port_dlen;
@ -322,7 +322,7 @@ alias_rtsp_out(struct libalias *la, struct ip *pip,
tc->th_sum = 0;
tc->th_sum = TcpChecksum(pip);
return 0;
return (0);
}
/* Support the protocol used by early versions of RealPlayer */
@ -348,7 +348,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
work += 2;
if (ntohs(msg_id) == 0) {
/* end of options */
return 0;
return (0);
}
if ((ntohs(msg_id) == 1) || (ntohs(msg_id) == 7)) {
memcpy(&port, work, 2);
@ -371,7 +371,7 @@ alias_pna_out(struct libalias *la, struct ip *pip,
work += ntohs(msg_len);
}
return 0;
return (0);
}
void