ipfilter: Adjust kernel module returns to conform to style(9)

Adjust ipfilter's kernel module return statements to conform to style(9).

MFC after:	1 month
This commit is contained in:
Cy Schubert 2021-12-21 18:35:12 -08:00
parent 9be9c1c084
commit 8c82b37461
29 changed files with 1565 additions and 1565 deletions

File diff suppressed because it is too large Load Diff

View File

@ -135,7 +135,7 @@ static int ipf_auth_flush(void *);
int int
ipf_auth_main_load(void) ipf_auth_main_load(void)
{ {
return 0; return(0);
} }
@ -150,7 +150,7 @@ ipf_auth_main_load(void)
int int
ipf_auth_main_unload(void) ipf_auth_main_unload(void)
{ {
return 0; return(0);
} }
@ -169,7 +169,7 @@ ipf_auth_soft_create(ipf_main_softc_t *softc)
KMALLOC(softa, ipf_auth_softc_t *); KMALLOC(softa, ipf_auth_softc_t *);
if (softa == NULL) if (softa == NULL)
return NULL; return(NULL);
bzero((char *)softa, sizeof(*softa)); bzero((char *)softa, sizeof(*softa));
@ -182,7 +182,7 @@ ipf_auth_soft_create(ipf_main_softc_t *softc)
cv_init(&softa->ipf_auth_wait, "ipf auth condvar", CV_DRIVER, NULL); cv_init(&softa->ipf_auth_wait, "ipf auth condvar", CV_DRIVER, NULL);
#endif #endif
return softa; return(softa);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -202,19 +202,19 @@ ipf_auth_soft_init(ipf_main_softc_t *softc, void *arg)
KMALLOCS(softa->ipf_auth, frauth_t *, KMALLOCS(softa->ipf_auth, frauth_t *,
softa->ipf_auth_size * sizeof(*softa->ipf_auth)); softa->ipf_auth_size * sizeof(*softa->ipf_auth));
if (softa->ipf_auth == NULL) if (softa->ipf_auth == NULL)
return -1; return(-1);
bzero((char *)softa->ipf_auth, bzero((char *)softa->ipf_auth,
softa->ipf_auth_size * sizeof(*softa->ipf_auth)); softa->ipf_auth_size * sizeof(*softa->ipf_auth));
KMALLOCS(softa->ipf_auth_pkts, mb_t **, KMALLOCS(softa->ipf_auth_pkts, mb_t **,
softa->ipf_auth_size * sizeof(*softa->ipf_auth_pkts)); softa->ipf_auth_size * sizeof(*softa->ipf_auth_pkts));
if (softa->ipf_auth_pkts == NULL) if (softa->ipf_auth_pkts == NULL)
return -2; return(-2);
bzero((char *)softa->ipf_auth_pkts, bzero((char *)softa->ipf_auth_pkts,
softa->ipf_auth_size * sizeof(*softa->ipf_auth_pkts)); softa->ipf_auth_size * sizeof(*softa->ipf_auth_pkts));
return 0; return(0);
} }
@ -274,7 +274,7 @@ ipf_auth_soft_fini(ipf_main_softc_t *softc, void *arg)
} }
} }
return 0; return(0);
} }
@ -340,7 +340,7 @@ ipf_auth_check(fr_info_t *fin, u_32_t *passp)
int i; int i;
if (softa->ipf_auth_lock || !softa->ipf_auth_used) if (softa->ipf_auth_lock || !softa->ipf_auth_used)
return NULL; return(NULL);
ip = fin->fin_ip; ip = fin->fin_ip;
id = ip->ip_id; id = ip->ip_id;
@ -426,7 +426,7 @@ ipf_auth_check(fr_info_t *fin, u_32_t *passp)
if (passp != NULL) if (passp != NULL)
*passp = pass; *passp = pass;
softa->ipf_auth_stats.fas_hits++; softa->ipf_auth_stats.fas_hits++;
return fr; return(fr);
} }
i++; i++;
if (i == softa->ipf_auth_size) if (i == softa->ipf_auth_size)
@ -434,7 +434,7 @@ ipf_auth_check(fr_info_t *fin, u_32_t *passp)
} }
RWLOCK_EXIT(&softa->ipf_authlk); RWLOCK_EXIT(&softa->ipf_authlk);
softa->ipf_auth_stats.fas_miss++; softa->ipf_auth_stats.fas_miss++;
return NULL; return(NULL);
} }
@ -463,14 +463,14 @@ ipf_auth_new(mb_t *m, fr_info_t *fin)
int i; int i;
if (softa->ipf_auth_lock) if (softa->ipf_auth_lock)
return 0; return(0);
WRITE_ENTER(&softa->ipf_authlk); WRITE_ENTER(&softa->ipf_authlk);
if (((softa->ipf_auth_end + 1) % softa->ipf_auth_size) == if (((softa->ipf_auth_end + 1) % softa->ipf_auth_size) ==
softa->ipf_auth_start) { softa->ipf_auth_start) {
softa->ipf_auth_stats.fas_nospace++; softa->ipf_auth_stats.fas_nospace++;
RWLOCK_EXIT(&softa->ipf_authlk); RWLOCK_EXIT(&softa->ipf_authlk);
return 0; return(0);
} }
softa->ipf_auth_stats.fas_added++; softa->ipf_auth_stats.fas_added++;
@ -522,7 +522,7 @@ ipf_auth_new(mb_t *m, fr_info_t *fin)
RWLOCK_EXIT(&softa->ipf_authlk); RWLOCK_EXIT(&softa->ipf_authlk);
WAKEUP(&softa->ipf_auth_next, 0); WAKEUP(&softa->ipf_auth_next, 0);
#endif #endif
return 1; return(1);
} }
@ -625,7 +625,7 @@ ipf_auth_ioctl(ipf_main_softc_t *softc, caddr_t data, ioctlcmd_t cmd,
error = EINVAL; error = EINVAL;
break; break;
} }
return error; return(error);
} }
@ -717,7 +717,7 @@ ipf_auth_precmd(ipf_main_softc_t *softc, ioctlcmd_t cmd, frentry_t *fr,
if ((cmd != SIOCADAFR) && (cmd != SIOCRMAFR)) { if ((cmd != SIOCADAFR) && (cmd != SIOCRMAFR)) {
IPFERROR(10006); IPFERROR(10006);
return EIO; return(EIO);
} }
for (faep = &softa->ipf_auth_entries; ((fae = *faep) != NULL); ) { for (faep = &softa->ipf_auth_entries; ((fae = *faep) != NULL); ) {
@ -773,7 +773,7 @@ ipf_auth_precmd(ipf_main_softc_t *softc, ioctlcmd_t cmd, frentry_t *fr,
IPFERROR(10010); IPFERROR(10010);
error = EINVAL; error = EINVAL;
} }
return error; return(error);
} }
@ -797,7 +797,7 @@ ipf_auth_flush(void *arg)
mb_t *m; mb_t *m;
if (softa->ipf_auth_lock) if (softa->ipf_auth_lock)
return -1; return(-1);
num_flushed = 0; num_flushed = 0;
@ -822,7 +822,7 @@ ipf_auth_flush(void *arg)
softa->ipf_auth_used = 0; softa->ipf_auth_used = 0;
softa->ipf_auth_replies = 0; softa->ipf_auth_replies = 0;
return num_flushed; return(num_flushed);
} }
@ -839,7 +839,7 @@ ipf_auth_waiting(ipf_main_softc_t *softc)
{ {
ipf_auth_softc_t *softa = softc->ipf_auth_soft; ipf_auth_softc_t *softa = softc->ipf_auth_soft;
return (softa->ipf_auth_used != 0); return(softa->ipf_auth_used != 0);
} }
@ -864,12 +864,12 @@ ipf_auth_geniter(ipf_main_softc_t *softc, ipftoken_t *token,
if (itp->igi_data == NULL) { if (itp->igi_data == NULL) {
IPFERROR(10011); IPFERROR(10011);
return EFAULT; return(EFAULT);
} }
if (itp->igi_type != IPFGENITER_AUTH) { if (itp->igi_type != IPFGENITER_AUTH) {
IPFERROR(10012); IPFERROR(10012);
return EINVAL; return(EINVAL);
} }
objp->ipfo_type = IPFOBJ_FRAUTH; objp->ipfo_type = IPFOBJ_FRAUTH;
@ -906,7 +906,7 @@ ipf_auth_geniter(ipf_main_softc_t *softc, ipftoken_t *token,
if (next->fae_next == NULL) if (next->fae_next == NULL)
ipf_token_mark_complete(token); ipf_token_mark_complete(token);
return error; return(error);
} }
@ -975,7 +975,7 @@ ipf_auth_wait(ipf_main_softc_t *softc, ipf_auth_softc_t *softa, char *data)
ipf_auth_ioctlloop: ipf_auth_ioctlloop:
error = ipf_inobj(softc, data, NULL, au, IPFOBJ_FRAUTH); error = ipf_inobj(softc, data, NULL, au, IPFOBJ_FRAUTH);
if (error != 0) if (error != 0)
return error; return(error);
/* /*
* XXX Locks are held below over calls to copyout...a better * XXX Locks are held below over calls to copyout...a better
@ -1004,7 +1004,7 @@ ipf_auth_wait(ipf_main_softc_t *softc, ipf_auth_softc_t *softa, char *data)
if (error != 0) { if (error != 0) {
RWLOCK_EXIT(&softa->ipf_authlk); RWLOCK_EXIT(&softa->ipf_authlk);
SPL_X(s); SPL_X(s);
return error; return(error);
} }
if (auth.fra_len != 0 && auth.fra_buf != NULL) { if (auth.fra_len != 0 && auth.fra_buf != NULL) {
@ -1027,7 +1027,7 @@ ipf_auth_wait(ipf_main_softc_t *softc, ipf_auth_softc_t *softa, char *data)
if (error != 0) { if (error != 0) {
RWLOCK_EXIT(&softa->ipf_authlk); RWLOCK_EXIT(&softa->ipf_authlk);
SPL_X(s); SPL_X(s);
return error; return(error);
} }
m = m->m_next; m = m->m_next;
} }
@ -1042,7 +1042,7 @@ ipf_auth_wait(ipf_main_softc_t *softc, ipf_auth_softc_t *softa, char *data)
RWLOCK_EXIT(&softa->ipf_authlk); RWLOCK_EXIT(&softa->ipf_authlk);
SPL_X(s); SPL_X(s);
return 0; return(0);
} }
RWLOCK_EXIT(&softa->ipf_authlk); RWLOCK_EXIT(&softa->ipf_authlk);
SPL_X(s); SPL_X(s);
@ -1062,7 +1062,7 @@ ipf_auth_wait(ipf_main_softc_t *softc, ipf_auth_softc_t *softa, char *data)
MUTEX_EXIT(&softa->ipf_auth_mx); MUTEX_EXIT(&softa->ipf_auth_mx);
if (error == 0) if (error == 0)
goto ipf_auth_ioctlloop; goto ipf_auth_ioctlloop;
return error; return(error);
} }
@ -1087,7 +1087,7 @@ ipf_auth_reply(ipf_main_softc_t *softc, ipf_auth_softc_t *softa, char *data)
error = ipf_inobj(softc, data, NULL, &auth, IPFOBJ_FRAUTH); error = ipf_inobj(softc, data, NULL, &auth, IPFOBJ_FRAUTH);
if (error != 0) if (error != 0)
return error; return(error);
SPL_NET(s); SPL_NET(s);
WRITE_ENTER(&softa->ipf_authlk); WRITE_ENTER(&softa->ipf_authlk);
@ -1105,13 +1105,13 @@ ipf_auth_reply(ipf_main_softc_t *softc, ipf_auth_softc_t *softa, char *data)
RWLOCK_EXIT(&softa->ipf_authlk); RWLOCK_EXIT(&softa->ipf_authlk);
SPL_X(s); SPL_X(s);
IPFERROR(10015); IPFERROR(10015);
return ESRCH; return(ESRCH);
} }
if (fra->fra_info.fin_id != au->fra_info.fin_id) { if (fra->fra_info.fin_id != au->fra_info.fin_id) {
RWLOCK_EXIT(&softa->ipf_authlk); RWLOCK_EXIT(&softa->ipf_authlk);
SPL_X(s); SPL_X(s);
IPFERROR(10019); IPFERROR(10019);
return ESRCH; return(ESRCH);
} }
m = softa->ipf_auth_pkts[i]; m = softa->ipf_auth_pkts[i];
@ -1183,7 +1183,7 @@ ipf_auth_reply(ipf_main_softc_t *softc, ipf_auth_softc_t *softa, char *data)
#endif /* _KERNEL */ #endif /* _KERNEL */
SPL_X(s); SPL_X(s);
return 0; return(0);
} }
@ -1193,9 +1193,9 @@ ipf_auth_pre_scanlist(ipf_main_softc_t *softc, fr_info_t *fin, u_32_t pass)
ipf_auth_softc_t *softa = softc->ipf_auth_soft; ipf_auth_softc_t *softa = softc->ipf_auth_soft;
if (softa->ipf_auth_ip != NULL) if (softa->ipf_auth_ip != NULL)
return ipf_scanlist(fin, softc->ipf_pass); return(ipf_scanlist(fin, softc->ipf_pass));
return pass; return(pass);
} }
@ -1204,5 +1204,5 @@ ipf_auth_rulehead(ipf_main_softc_t *softc)
{ {
ipf_auth_softc_t *softa = softc->ipf_auth_soft; ipf_auth_softc_t *softa = softc->ipf_auth_soft;
return &softa->ipf_auth_ip; return(&softa->ipf_auth_ip);
} }

View File

@ -64,12 +64,12 @@ ipf_p_dns_soft_create(ipf_main_softc_t *softc)
KMALLOC(softd, ipf_dns_softc_t *); KMALLOC(softd, ipf_dns_softc_t *);
if (softd == NULL) if (softd == NULL)
return NULL; return(NULL);
bzero((char *)softd, sizeof(*softd)); bzero((char *)softd, sizeof(*softd));
RWLOCK_INIT(&softd->ipf_p_dns_rwlock, "ipf dns rwlock"); RWLOCK_INIT(&softd->ipf_p_dns_rwlock, "ipf dns rwlock");
return softd; return(softd);
} }
@ -162,7 +162,7 @@ ipf_p_dns_ctl(ipf_main_softc_t *softc, void *arg, ap_ctl_t *ctl)
tmp = NULL; tmp = NULL;
} }
return error; return(error);
} }
@ -174,21 +174,21 @@ ipf_p_dns_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
int dlen; int dlen;
if (fin->fin_v != 4) if (fin->fin_v != 4)
return -1; return(-1);
dlen = fin->fin_dlen - sizeof(udphdr_t); dlen = fin->fin_dlen - sizeof(udphdr_t);
if (dlen < sizeof(ipf_dns_hdr_t)) { if (dlen < sizeof(ipf_dns_hdr_t)) {
/* /*
* No real DNS packet is smaller than that. * No real DNS packet is smaller than that.
*/ */
return -1; return(-1);
} }
aps->aps_psiz = sizeof(dnsinfo_t); aps->aps_psiz = sizeof(dnsinfo_t);
KMALLOCS(di, dnsinfo_t *, sizeof(dnsinfo_t)); KMALLOCS(di, dnsinfo_t *, sizeof(dnsinfo_t));
if (di == NULL) { if (di == NULL) {
printf("ipf_dns_new:KMALLOCS(%d) failed\n", sizeof(*di)); printf("ipf_dns_new:KMALLOCS(%d) failed\n", sizeof(*di));
return -1; return(-1);
} }
MUTEX_INIT(&di->dnsi_lock, "dns lock"); MUTEX_INIT(&di->dnsi_lock, "dns lock");
@ -199,7 +199,7 @@ ipf_p_dns_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
COPYDATA(fin->fin_m, fin->fin_hlen + sizeof(udphdr_t), COPYDATA(fin->fin_m, fin->fin_hlen + sizeof(udphdr_t),
MIN(dlen, sizeof(di->dnsi_buffer)), di->dnsi_buffer); MIN(dlen, sizeof(di->dnsi_buffer)), di->dnsi_buffer);
di->dnsi_id = (di->dnsi_buffer[0] << 8) | di->dnsi_buffer[1]; di->dnsi_id = (di->dnsi_buffer[0] << 8) | di->dnsi_buffer[1];
return 0; return(0);
} }
@ -231,10 +231,10 @@ ipf_p_dns_match_names(ipf_dns_filter_t *idns, char *query, int qlen)
base = idns->idns_name; base = idns->idns_name;
if (blen > qlen) if (blen > qlen)
return 1; return(1);
if (blen == qlen) if (blen == qlen)
return strncasecmp(base, query, qlen); return(strncasecmp(base, query, qlen));
/* /*
* If the base string string is shorter than the query, allow the * If the base string string is shorter than the query, allow the
@ -248,9 +248,9 @@ ipf_p_dns_match_names(ipf_dns_filter_t *idns, char *query, int qlen)
base++; base++;
blen--; blen--;
} else if (*base != '.') } else if (*base != '.')
return 1; return(1);
return strncasecmp(base, query + qlen - blen, blen); return(strncasecmp(base, query + qlen - blen, blen));
} }
@ -270,15 +270,15 @@ ipf_p_dns_get_name(ipf_dns_softc_t *softd, char *start, int len,
clen = *s; clen = *s;
if ((clen & 0xc0) == 0xc0) { /* Doesn't do compression */ if ((clen & 0xc0) == 0xc0) { /* Doesn't do compression */
softd->ipf_p_dns_compress++; softd->ipf_p_dns_compress++;
return 0; return(0);
} }
if (clen > slen) { if (clen > slen) {
softd->ipf_p_dns_toolong++; softd->ipf_p_dns_toolong++;
return 0; /* Does the name run off the end? */ return(0); /* Does the name run off the end? */
} }
if ((clen + 1) > blen) { if ((clen + 1) > blen) {
softd->ipf_p_dns_nospace++; softd->ipf_p_dns_nospace++;
return 0; /* Enough room for name+.? */ return(0); /* Enough room for name+.? */
} }
s++; s++;
bcopy(s, t, clen); bcopy(s, t, clen);
@ -290,7 +290,7 @@ ipf_p_dns_get_name(ipf_dns_softc_t *softd, char *start, int len,
} }
*(t - 1) = '\0'; *(t - 1) = '\0';
return s - start; return(s - start);
} }
@ -304,8 +304,8 @@ ipf_p_dns_allow_query(ipf_dns_softc_t *softd, dnsinfo_t *dnsi)
for (idns = softd->ipf_p_dns_list; idns != NULL; idns = idns->idns_next) for (idns = softd->ipf_p_dns_list; idns != NULL; idns = idns->idns_next)
if (ipf_p_dns_match_names(idns, dnsi->dnsi_buffer, len) == 0) if (ipf_p_dns_match_names(idns, dnsi->dnsi_buffer, len) == 0)
return idns->idns_pass; return(idns->idns_pass);
return 0; return(0);
} }
@ -320,7 +320,7 @@ ipf_p_dns_inout(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
int dlen, q, rc = 0; int dlen, q, rc = 0;
if (fin->fin_dlen < sizeof(*dns)) if (fin->fin_dlen < sizeof(*dns))
return APR_ERR(1); return(APR_ERR(1));
dns = (ipf_dns_hdr_t *)((char *)fin->fin_dp + sizeof(udphdr_t)); dns = (ipf_dns_hdr_t *)((char *)fin->fin_dp + sizeof(udphdr_t));
@ -352,7 +352,7 @@ ipf_p_dns_inout(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
MUTEX_EXIT(&di->dnsi_lock); MUTEX_EXIT(&di->dnsi_lock);
RWLOCK_EXIT(&softd->ipf_p_dns_rwlock); RWLOCK_EXIT(&softd->ipf_p_dns_rwlock);
return APR_ERR(rc); return(APR_ERR(rc));
} }
@ -364,10 +364,10 @@ ipf_p_dns_match(fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ipf_dns_hdr_t *dnh; ipf_dns_hdr_t *dnh;
if ((fin->fin_dlen < sizeof(u_short)) || (fin->fin_flx & FI_FRAG)) if ((fin->fin_dlen < sizeof(u_short)) || (fin->fin_flx & FI_FRAG))
return -1; ( return(-1);
dnh = (ipf_dns_hdr_t *)((char *)fin->fin_dp + sizeof(udphdr_t)); dnh = (ipf_dns_hdr_t *)((char *)fin->fin_dp + sizeof(udphdr_t));
if (((dnh->dns_id[0] << 8) | dnh->dns_id[1]) != di->dnsi_id) if (((dnh->dns_id[0] << 8) | dnh->dns_id[1]) != di->dnsi_id)
return -1; return(-1);
return 0; return(0);
} }

View File

@ -150,14 +150,14 @@ ipf_dstlist_soft_create(ipf_main_softc_t *softc)
KMALLOC(softd, ipf_dstl_softc_t *); KMALLOC(softd, ipf_dstl_softc_t *);
if (softd == NULL) { if (softd == NULL) {
IPFERROR(120028); IPFERROR(120028);
return NULL; return(NULL);
} }
bzero((char *)softd, sizeof(*softd)); bzero((char *)softd, sizeof(*softd));
for (i = 0; i <= IPL_LOGMAX; i++) for (i = 0; i <= IPL_LOGMAX; i++)
softd->tails[i] = &softd->dstlist[i]; softd->tails[i] = &softd->dstlist[i];
return softd; return(softd);
} }
@ -190,7 +190,7 @@ ipf_dstlist_soft_destroy(ipf_main_softc_t *softc, void *arg)
static int static int
ipf_dstlist_soft_init(ipf_main_softc_t *softc, void *arg) ipf_dstlist_soft_init(ipf_main_softc_t *softc, void *arg)
{ {
return 0; return(0);
} }
@ -239,7 +239,7 @@ static int
ipf_dstlist_addr_find(ipf_main_softc_t *softc, void *arg1, int arg2, ipf_dstlist_addr_find(ipf_main_softc_t *softc, void *arg1, int arg2,
void *arg3, u_int arg4) void *arg3, u_int arg4)
{ {
return -1; return(-1);
} }
@ -276,7 +276,7 @@ ipf_dstlist_flush(ipf_main_softc_t *softc, void *arg, iplookupflush_t *fop)
n++; n++;
} }
} }
return n; return(n);
} }
@ -299,12 +299,12 @@ ipf_dstlist_iter_deref(ipf_main_softc_t *softc, void *arg, int otype,
{ {
if (data == NULL) { if (data == NULL) {
IPFERROR(120001); IPFERROR(120001);
return EINVAL; return(EINVAL);
} }
if (unit < -1 || unit > IPL_LOGMAX) { if (unit < -1 || unit > IPL_LOGMAX) {
IPFERROR(120002); IPFERROR(120002);
return EINVAL; return(EINVAL);
} }
switch (otype) switch (otype)
@ -318,7 +318,7 @@ ipf_dstlist_iter_deref(ipf_main_softc_t *softc, void *arg, int otype,
break; break;
} }
return 0; return(0);
} }
@ -406,7 +406,7 @@ ipf_dstlist_iter_next(ipf_main_softc_t *softc, void *arg,
} }
if (err != 0) if (err != 0)
return err; return(err);
switch (iter->ili_otype) switch (iter->ili_otype)
{ {
@ -434,7 +434,7 @@ ipf_dstlist_iter_next(ipf_main_softc_t *softc, void *arg,
if (hint == NULL) if (hint == NULL)
ipf_token_mark_complete(token); ipf_token_mark_complete(token);
return err; return(err);
} }
@ -469,19 +469,19 @@ ipf_dstlist_node_add(ipf_main_softc_t *softc, void *arg,
if (op->iplo_size < sizeof(frdest_t)) { if (op->iplo_size < sizeof(frdest_t)) {
IPFERROR(120007); IPFERROR(120007);
return EINVAL; return(EINVAL);
} }
err = COPYIN(op->iplo_struct, &dest, sizeof(dest)); err = COPYIN(op->iplo_struct, &dest, sizeof(dest));
if (err != 0) { if (err != 0) {
IPFERROR(120009); IPFERROR(120009);
return EFAULT; return(EFAULT);
} }
d = ipf_dstlist_table_find(arg, op->iplo_unit, op->iplo_name); d = ipf_dstlist_table_find(arg, op->iplo_unit, op->iplo_name);
if (d == NULL) { if (d == NULL) {
IPFERROR(120010); IPFERROR(120010);
return ESRCH; return(ESRCH);
} }
switch (dest.fd_addr.adf_family) switch (dest.fd_addr.adf_family)
@ -491,19 +491,19 @@ ipf_dstlist_node_add(ipf_main_softc_t *softc, void *arg,
break; break;
default : default :
IPFERROR(120019); IPFERROR(120019);
return EINVAL; return(EINVAL);
} }
if (dest.fd_name < -1 || dest.fd_name > 128) { if (dest.fd_name < -1 || dest.fd_name > 128) {
IPFERROR(120018); IPFERROR(120018);
return EINVAL; return(EINVAL);
} }
KMALLOCS(node, ipf_dstnode_t *, sizeof(*node) + dest.fd_name); KMALLOCS(node, ipf_dstnode_t *, sizeof(*node) + dest.fd_name);
if (node == NULL) { if (node == NULL) {
softd->stats.ipls_nomem++; softd->stats.ipls_nomem++;
IPFERROR(120008); IPFERROR(120008);
return ENOMEM; return(ENOMEM);
} }
bzero((char *)node, sizeof(*node) + dest.fd_name); bzero((char *)node, sizeof(*node) + dest.fd_name);
@ -521,7 +521,7 @@ ipf_dstlist_node_add(ipf_main_softc_t *softc, void *arg,
if (err != 0) { if (err != 0) {
IPFERROR(120017); IPFERROR(120017);
KFREES(node, node->ipfd_size); KFREES(node, node->ipfd_size);
return EFAULT; return(EFAULT);
} }
node->ipfd_dest.fd_name = 0; node->ipfd_dest.fd_name = 0;
} else { } else {
@ -535,7 +535,7 @@ ipf_dstlist_node_add(ipf_main_softc_t *softc, void *arg,
softd->stats.ipls_nomem++; softd->stats.ipls_nomem++;
IPFERROR(120022); IPFERROR(120022);
KFREES(node, node->ipfd_size); KFREES(node, node->ipfd_size);
return ENOMEM; return(ENOMEM);
} }
if (d->ipld_dests != NULL) { if (d->ipld_dests != NULL) {
bcopy(d->ipld_dests, nodes, bcopy(d->ipld_dests, nodes,
@ -571,7 +571,7 @@ ipf_dstlist_node_add(ipf_main_softc_t *softc, void *arg,
softd->stats.ipls_numnodes++; softd->stats.ipls_numnodes++;
return 0; return(0);
} }
@ -597,7 +597,7 @@ ipf_dstlist_node_deref(void *arg, ipf_dstnode_t *node)
MUTEX_EXIT(&node->ipfd_lock); MUTEX_EXIT(&node->ipfd_lock);
if (ref > 0) if (ref > 0)
return 0; return(0);
if ((node->ipfd_flags & IPDST_DELETE) != 0) if ((node->ipfd_flags & IPDST_DELETE) != 0)
softd->stats.ipls_numderefnodes--; softd->stats.ipls_numderefnodes--;
@ -605,7 +605,7 @@ ipf_dstlist_node_deref(void *arg, ipf_dstnode_t *node)
KFREES(node, node->ipfd_size); KFREES(node, node->ipfd_size);
softd->stats.ipls_numnodes--; softd->stats.ipls_numnodes--;
return 0; return(0);
} }
@ -635,13 +635,13 @@ ipf_dstlist_node_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
d = ipf_dstlist_table_find(arg, op->iplo_unit, op->iplo_name); d = ipf_dstlist_table_find(arg, op->iplo_unit, op->iplo_name);
if (d == NULL) { if (d == NULL) {
IPFERROR(120012); IPFERROR(120012);
return ESRCH; return(ESRCH);
} }
err = COPYIN(op->iplo_struct, &frd, sizeof(frd)); err = COPYIN(op->iplo_struct, &frd, sizeof(frd));
if (err != 0) { if (err != 0) {
IPFERROR(120011); IPFERROR(120011);
return EFAULT; return(EFAULT);
} }
size = sizeof(*temp) + frd.fd_name; size = sizeof(*temp) + frd.fd_name;
@ -649,14 +649,14 @@ ipf_dstlist_node_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
if (temp == NULL) { if (temp == NULL) {
softd->stats.ipls_nomem++; softd->stats.ipls_nomem++;
IPFERROR(120026); IPFERROR(120026);
return ENOMEM; return(ENOMEM);
} }
err = COPYIN(op->iplo_struct, temp, size); err = COPYIN(op->iplo_struct, temp, size);
if (err != 0) { if (err != 0) {
IPFERROR(120027); IPFERROR(120027);
KFREES(temp, size); KFREES(temp, size);
return EFAULT; return(EFAULT);
} }
MUTEX_ENTER(&d->ipld_lock); MUTEX_ENTER(&d->ipld_lock);
@ -670,13 +670,13 @@ ipf_dstlist_node_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
ipf_dstlist_node_free(softd, d, node); ipf_dstlist_node_free(softd, d, node);
MUTEX_EXIT(&d->ipld_lock); MUTEX_EXIT(&d->ipld_lock);
KFREES(temp, size); KFREES(temp, size);
return 0; return(0);
} }
} }
MUTEX_EXIT(&d->ipld_lock); MUTEX_EXIT(&d->ipld_lock);
KFREES(temp, size); KFREES(temp, size);
return ESRCH; return(ESRCH);
} }
@ -748,7 +748,7 @@ ipf_dstlist_stats_get(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
if (op->iplo_size != sizeof(ipf_dstl_stat_t)) { if (op->iplo_size != sizeof(ipf_dstl_stat_t)) {
IPFERROR(120023); IPFERROR(120023);
return EINVAL; return(EINVAL);
} }
stats = softd->stats; stats = softd->stats;
@ -774,10 +774,10 @@ ipf_dstlist_stats_get(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
err = COPYOUT(&stats, op->iplo_struct, sizeof(stats)); err = COPYOUT(&stats, op->iplo_struct, sizeof(stats));
if (err != 0) { if (err != 0) {
IPFERROR(120025); IPFERROR(120025);
return EFAULT; return(EFAULT);
} }
} }
return 0; return(0);
} }
@ -802,20 +802,20 @@ ipf_dstlist_table_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
d = ipf_dstlist_table_find(arg, op->iplo_unit, op->iplo_name); d = ipf_dstlist_table_find(arg, op->iplo_unit, op->iplo_name);
if (d != NULL) { if (d != NULL) {
IPFERROR(120013); IPFERROR(120013);
return EEXIST; return(EEXIST);
} }
err = COPYIN(op->iplo_struct, &user, sizeof(user)); err = COPYIN(op->iplo_struct, &user, sizeof(user));
if (err != 0) { if (err != 0) {
IPFERROR(120021); IPFERROR(120021);
return EFAULT; return(EFAULT);
} }
KMALLOC(new, ippool_dst_t *); KMALLOC(new, ippool_dst_t *);
if (new == NULL) { if (new == NULL) {
softd->stats.ipls_nomem++; softd->stats.ipls_nomem++;
IPFERROR(120014); IPFERROR(120014);
return ENOMEM; return(ENOMEM);
} }
bzero((char *)new, sizeof(*new)); bzero((char *)new, sizeof(*new));
@ -833,7 +833,7 @@ ipf_dstlist_table_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
softd->tails[unit + 1] = &new->ipld_next; softd->tails[unit + 1] = &new->ipld_next;
softd->stats.ipls_numlists++; softd->stats.ipls_numlists++;
return 0; return(0);
} }
@ -855,17 +855,17 @@ ipf_dstlist_table_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
d = ipf_dstlist_table_find(arg, op->iplo_unit, op->iplo_name); d = ipf_dstlist_table_find(arg, op->iplo_unit, op->iplo_name);
if (d == NULL) { if (d == NULL) {
IPFERROR(120015); IPFERROR(120015);
return ESRCH; return(ESRCH);
} }
if (d->ipld_dests != NULL) { if (d->ipld_dests != NULL) {
IPFERROR(120016); IPFERROR(120016);
return EBUSY; return(EBUSY);
} }
ipf_dstlist_table_remove(softc, arg, d); ipf_dstlist_table_remove(softc, arg, d);
return 0; return(0);
} }
@ -953,11 +953,11 @@ ipf_dstlist_table_deref(ipf_main_softc_t *softc, void *arg, void *table)
d->ipld_ref--; d->ipld_ref--;
if (d->ipld_ref > 0) if (d->ipld_ref > 0)
return d->ipld_ref; return(d->ipld_ref);
ipf_dstlist_table_free(arg, d); ipf_dstlist_table_free(arg, d);
return 0; return(0);
} }
@ -1002,11 +1002,11 @@ ipf_dstlist_table_find(void *arg, int unit, char *name)
for (d = softd->dstlist[unit + 1]; d != NULL; d = d->ipld_next) { for (d = softd->dstlist[unit + 1]; d != NULL; d = d->ipld_next) {
if ((d->ipld_unit == unit) && if ((d->ipld_unit == unit) &&
!strncmp(d->ipld_name, name, FR_GROUPLEN)) { !strncmp(d->ipld_name, name, FR_GROUPLEN)) {
return d; return(d);
} }
} }
return NULL; return(NULL);
} }
@ -1032,7 +1032,7 @@ ipf_dstlist_select_ref(void *arg, int unit, char *name)
d->ipld_ref++; d->ipld_ref++;
MUTEX_EXIT(&d->ipld_lock); MUTEX_EXIT(&d->ipld_lock);
} }
return d; return(d);
} }
@ -1073,7 +1073,7 @@ ipf_dstlist_select(fr_info_t *fin, ippool_dst_t *d)
int x; int x;
if (d == NULL || d->ipld_dests == NULL || *d->ipld_dests == NULL) if (d == NULL || d->ipld_dests == NULL || *d->ipld_dests == NULL)
return NULL; return(NULL);
family = fin->fin_family; family = fin->fin_family;
@ -1166,7 +1166,7 @@ ipf_dstlist_select(fr_info_t *fin, ippool_dst_t *d)
MUTEX_EXIT(&d->ipld_lock); MUTEX_EXIT(&d->ipld_lock);
return sel; return(sel);
} }
@ -1199,7 +1199,7 @@ ipf_dstlist_select_node(fr_info_t *fin, void *group, u_32_t *addr,
node = ipf_dstlist_select(fin, d); node = ipf_dstlist_select(fin, d);
if (node == NULL) { if (node == NULL) {
RWLOCK_EXIT(&softc->ipf_poolrw); RWLOCK_EXIT(&softc->ipf_poolrw);
return -1; return(-1);
} }
if (pfdp != NULL) { if (pfdp != NULL) {
@ -1225,7 +1225,7 @@ ipf_dstlist_select_node(fr_info_t *fin, void *group, u_32_t *addr,
RWLOCK_EXIT(&softc->ipf_poolrw); RWLOCK_EXIT(&softc->ipf_poolrw);
return 0; return(0);
} }

View File

@ -137,7 +137,7 @@ ipf_check_wrapper(struct mbuf **mp, struct ifnet *ifp, int flags,
rv = ipf_check(&V_ipfmain, ip, ip->ip_hl << 2, ifp, rv = ipf_check(&V_ipfmain, ip, ip->ip_hl << 2, ifp,
!!(flags & PFIL_OUT), mp); !!(flags & PFIL_OUT), mp);
CURVNET_RESTORE(); CURVNET_RESTORE();
return (rv == 0 ? PFIL_PASS : PFIL_DROPPED); return(rv == 0 ? PFIL_PASS : PFIL_DROPPED);
} }
#ifdef USE_INET6 #ifdef USE_INET6
@ -152,15 +152,15 @@ ipf_check_wrapper6(struct mbuf **mp, struct ifnet *ifp, int flags,
sizeof(struct ip6_hdr), ifp, !!(flags & PFIL_OUT), mp); sizeof(struct ip6_hdr), ifp, !!(flags & PFIL_OUT), mp);
CURVNET_RESTORE(); CURVNET_RESTORE();
return (rv == 0 ? PFIL_PASS : PFIL_DROPPED); return(rv == 0 ? PFIL_PASS : PFIL_DROPPED);
} }
# endif # endif
#if defined(IPFILTER_LKM) #if defined(IPFILTER_LKM)
int ipf_identify(char *s) int ipf_identify(char *s)
{ {
if (strcmp(s, "ipl") == 0) if (strcmp(s, "ipl") == 0)
return 1; return(1);
return 0; return(0);
} }
#endif /* IPFILTER_LKM */ #endif /* IPFILTER_LKM */
@ -201,12 +201,12 @@ ipfattach(ipf_main_softc_t *softc)
SPL_NET(s); SPL_NET(s);
if (softc->ipf_running > 0) { if (softc->ipf_running > 0) {
SPL_X(s); SPL_X(s);
return EBUSY; return(EBUSY);
} }
if (ipf_init_all(softc) < 0) { if (ipf_init_all(softc) < 0) {
SPL_X(s); SPL_X(s);
return EIO; return(EIO);
} }
@ -224,7 +224,7 @@ ipfattach(ipf_main_softc_t *softc)
callout_init(&softc->ipf_slow_ch, 1); callout_init(&softc->ipf_slow_ch, 1);
callout_reset(&softc->ipf_slow_ch, (hz / IPF_HZ_DIVIDE) * IPF_HZ_MULT, callout_reset(&softc->ipf_slow_ch, (hz / IPF_HZ_DIVIDE) * IPF_HZ_MULT,
ipf_timer_func, softc); ipf_timer_func, softc);
return 0; return(0);
} }
@ -257,7 +257,7 @@ ipfdetach(ipf_main_softc_t *softc)
SPL_X(s); SPL_X(s);
return 0; return(0);
} }
@ -278,21 +278,21 @@ ipfioctl(struct cdev *dev, ioctlcmd_t cmd, caddr_t data,
{ {
V_ipfmain.ipf_interror = 130001; V_ipfmain.ipf_interror = 130001;
CURVNET_RESTORE(); CURVNET_RESTORE();
return EPERM; return(EPERM);
} }
unit = GET_MINOR(dev); unit = GET_MINOR(dev);
if ((IPL_LOGMAX < unit) || (unit < 0)) { if ((IPL_LOGMAX < unit) || (unit < 0)) {
V_ipfmain.ipf_interror = 130002; V_ipfmain.ipf_interror = 130002;
CURVNET_RESTORE(); CURVNET_RESTORE();
return ENXIO; return(ENXIO);
} }
if (V_ipfmain.ipf_running <= 0) { if (V_ipfmain.ipf_running <= 0) {
if (unit != IPL_LOGIPF && cmd != SIOCIPFINTERROR) { if (unit != IPL_LOGIPF && cmd != SIOCIPFINTERROR) {
V_ipfmain.ipf_interror = 130003; V_ipfmain.ipf_interror = 130003;
CURVNET_RESTORE(); CURVNET_RESTORE();
return EIO; return(EIO);
} }
if (cmd != SIOCIPFGETNEXT && cmd != SIOCIPFGET && if (cmd != SIOCIPFGETNEXT && cmd != SIOCIPFGET &&
cmd != SIOCIPFSET && cmd != SIOCFRENB && cmd != SIOCIPFSET && cmd != SIOCFRENB &&
@ -300,7 +300,7 @@ ipfioctl(struct cdev *dev, ioctlcmd_t cmd, caddr_t data,
cmd != SIOCIPFINTERROR) { cmd != SIOCIPFINTERROR) {
V_ipfmain.ipf_interror = 130004; V_ipfmain.ipf_interror = 130004;
CURVNET_RESTORE(); CURVNET_RESTORE();
return EIO; return(EIO);
} }
} }
@ -310,12 +310,12 @@ ipfioctl(struct cdev *dev, ioctlcmd_t cmd, caddr_t data,
CURVNET_RESTORE(); CURVNET_RESTORE();
if (error != -1) { if (error != -1) {
SPL_X(s); SPL_X(s);
return error; return(error);
} }
SPL_X(s); SPL_X(s);
return error; return(error);
} }
@ -336,10 +336,10 @@ ipf_send_reset(fr_info_t *fin)
tcp = fin->fin_dp; tcp = fin->fin_dp;
if (tcp->th_flags & TH_RST) if (tcp->th_flags & TH_RST)
return -1; /* feedback loop */ return(-1); /* feedback loop */
if (ipf_checkl4sum(fin) == -1) if (ipf_checkl4sum(fin) == -1)
return -1; return(-1);
tlen = fin->fin_dlen - (TCP_OFF(tcp) << 2) + tlen = fin->fin_dlen - (TCP_OFF(tcp) << 2) +
((tcp->th_flags & TH_SYN) ? 1 : 0) + ((tcp->th_flags & TH_SYN) ? 1 : 0) +
@ -356,11 +356,11 @@ ipf_send_reset(fr_info_t *fin)
MGET(m, M_NOWAIT, MT_HEADER); MGET(m, M_NOWAIT, MT_HEADER);
#endif #endif
if (m == NULL) if (m == NULL)
return -1; return(-1);
if (sizeof(*tcp2) + hlen > MLEN) { if (sizeof(*tcp2) + hlen > MLEN) {
if (!(MCLGET(m, M_NOWAIT))) { if (!(MCLGET(m, M_NOWAIT))) {
FREE_MB_T(m); FREE_MB_T(m);
return -1; return(-1);
} }
} }
@ -404,7 +404,7 @@ ipf_send_reset(fr_info_t *fin)
ip6->ip6_dst = fin->fin_src6.in6; ip6->ip6_dst = fin->fin_src6.in6;
tcp2->th_sum = in6_cksum(m, IPPROTO_TCP, tcp2->th_sum = in6_cksum(m, IPPROTO_TCP,
sizeof(*ip6), sizeof(*tcp2)); sizeof(*ip6), sizeof(*tcp2));
return ipf_send_ip(fin, m); return(ipf_send_ip(fin, m));
} }
#endif #endif
ip->ip_p = IPPROTO_TCP; ip->ip_p = IPPROTO_TCP;
@ -413,7 +413,7 @@ ipf_send_reset(fr_info_t *fin)
ip->ip_dst.s_addr = fin->fin_saddr; ip->ip_dst.s_addr = fin->fin_saddr;
tcp2->th_sum = in_cksum(m, hlen + sizeof(*tcp2)); tcp2->th_sum = in_cksum(m, hlen + sizeof(*tcp2));
ip->ip_len = htons(hlen + sizeof(*tcp2)); ip->ip_len = htons(hlen + sizeof(*tcp2));
return ipf_send_ip(fin, m); return(ipf_send_ip(fin, m));
} }
@ -463,7 +463,7 @@ ipf_send_ip(fr_info_t *fin, mb_t *m)
} }
#endif #endif
default : default :
return EINVAL; return(EINVAL);
} }
#ifdef IPSEC_SUPPORT #ifdef IPSEC_SUPPORT
m->m_pkthdr.rcvif = NULL; m->m_pkthdr.rcvif = NULL;
@ -478,7 +478,7 @@ ipf_send_ip(fr_info_t *fin, mb_t *m)
fnew.fin_dp = (char *)ip + hlen; fnew.fin_dp = (char *)ip + hlen;
(void) ipf_makefrip(hlen, ip, &fnew); (void) ipf_makefrip(hlen, ip, &fnew);
return ipf_fastroute(m, &m, &fnew, NULL); return(ipf_fastroute(m, &m, &fnew, NULL));
} }
@ -497,24 +497,24 @@ ipf_send_icmp_err(int type, fr_info_t *fin, int dst)
ip_t *ip, *ip2; ip_t *ip, *ip2;
if ((type < 0) || (type >= ICMP_MAXTYPE)) if ((type < 0) || (type >= ICMP_MAXTYPE))
return -1; return(-1);
code = fin->fin_icode; code = fin->fin_icode;
#ifdef USE_INET6 #ifdef USE_INET6
/* See NetBSD ip_fil_netbsd.c r1.4: */ /* See NetBSD ip_fil_netbsd.c r1.4: */
if ((code < 0) || (code >= sizeof(icmptoicmp6unreach)/sizeof(int))) if ((code < 0) || (code >= sizeof(icmptoicmp6unreach)/sizeof(int)))
return -1; return(-1);
#endif #endif
if (ipf_checkl4sum(fin) == -1) if (ipf_checkl4sum(fin) == -1)
return -1; return(-1);
#ifdef MGETHDR #ifdef MGETHDR
MGETHDR(m, M_NOWAIT, MT_HEADER); MGETHDR(m, M_NOWAIT, MT_HEADER);
#else #else
MGET(m, M_NOWAIT, MT_HEADER); MGET(m, M_NOWAIT, MT_HEADER);
#endif #endif
if (m == NULL) if (m == NULL)
return -1; return(-1);
avail = MHLEN; avail = MHLEN;
xtra = 0; xtra = 0;
@ -533,14 +533,14 @@ ipf_send_icmp_err(int type, fr_info_t *fin, int dst)
break; break;
default : default :
FREE_MB_T(m); FREE_MB_T(m);
return 0; return(0);
} }
if (dst == 0) { if (dst == 0) {
if (ipf_ifpaddr(&V_ipfmain, 4, FRI_NORMAL, ifp, if (ipf_ifpaddr(&V_ipfmain, 4, FRI_NORMAL, ifp,
&dst6, NULL) == -1) { &dst6, NULL) == -1) {
FREE_MB_T(m); FREE_MB_T(m);
return -1; return(-1);
} }
dst4 = dst6.in4; dst4 = dst6.in4;
} else } else
@ -567,7 +567,7 @@ ipf_send_icmp_err(int type, fr_info_t *fin, int dst)
if (iclen + max_linkhdr + fin->fin_plen > avail) { if (iclen + max_linkhdr + fin->fin_plen > avail) {
if (!(MCLGET(m, M_NOWAIT))) { if (!(MCLGET(m, M_NOWAIT))) {
FREE_MB_T(m); FREE_MB_T(m);
return -1; return(-1);
} }
avail = MCLBYTES; avail = MCLBYTES;
} }
@ -577,7 +577,7 @@ ipf_send_icmp_err(int type, fr_info_t *fin, int dst)
if (ipf_ifpaddr(&V_ipfmain, 6, FRI_NORMAL, ifp, if (ipf_ifpaddr(&V_ipfmain, 6, FRI_NORMAL, ifp,
&dst6, NULL) == -1) { &dst6, NULL) == -1) {
FREE_MB_T(m); FREE_MB_T(m);
return -1; return(-1);
} }
} else } else
dst6 = fin->fin_dst6; dst6 = fin->fin_dst6;
@ -585,13 +585,13 @@ ipf_send_icmp_err(int type, fr_info_t *fin, int dst)
#endif #endif
else { else {
FREE_MB_T(m); FREE_MB_T(m);
return -1; return(-1);
} }
avail -= (max_linkhdr + iclen); avail -= (max_linkhdr + iclen);
if (avail < 0) { if (avail < 0) {
FREE_MB_T(m); FREE_MB_T(m);
return -1; return(-1);
} }
if (xtra > avail) if (xtra > avail)
xtra = avail; xtra = avail;
@ -653,7 +653,7 @@ ipf_send_icmp_err(int type, fr_info_t *fin, int dst)
ip->ip_p = IPPROTO_ICMP; ip->ip_p = IPPROTO_ICMP;
} }
err = ipf_send_ip(fin, m); err = ipf_send_ip(fin, m);
return err; return(err);
} }
@ -711,7 +711,7 @@ ipf_fastroute(mb_t *m0, mb_t **mpp, fr_info_t *fin, frdest_t *fdp)
* currently "to <if>" and "to <if>:ip#" are not supported * currently "to <if>" and "to <if>:ip#" are not supported
* for IPv6 * for IPv6
*/ */
return ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL); return(ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL));
} }
#endif #endif
@ -900,7 +900,7 @@ ipf_fastroute(mb_t *m0, mb_t **mpp, fr_info_t *fin, frdest_t *fdp)
else else
V_ipfmain.ipf_frouteok[1]++; V_ipfmain.ipf_frouteok[1]++;
return 0; return(0);
bad: bad:
if (error == EMSGSIZE) { if (error == EMSGSIZE) {
sifp = fin->fin_ifp; sifp = fin->fin_ifp;
@ -925,13 +925,13 @@ ipf_verifysrc(fin)
NET_EPOCH_ASSERT(); NET_EPOCH_ASSERT();
nh = fib4_lookup(RT_DEFAULT_FIB, fin->fin_src, 0, NHR_NONE, 0); nh = fib4_lookup(RT_DEFAULT_FIB, fin->fin_src, 0, NHR_NONE, 0);
if (nh == NULL) if (nh == NULL)
return (0); return(0);
return (fin->fin_ifp == nh->nh_ifp); return(fin->fin_ifp == nh->nh_ifp);
} }
/* /*
* return the first IP Address associated with an interface * return the first IP Address associated with an interface
*/ */
int int
ipf_ifpaddr(ipf_main_softc_t *softc, int v, int atype, void *ifptr, ipf_ifpaddr(ipf_main_softc_t *softc, int v, int atype, void *ifptr,
@ -946,7 +946,7 @@ ipf_ifpaddr(ipf_main_softc_t *softc, int v, int atype, void *ifptr,
struct ifnet *ifp; struct ifnet *ifp;
if ((ifptr == NULL) || (ifptr == (void *)-1)) if ((ifptr == NULL) || (ifptr == (void *)-1))
return -1; return(-1);
sin = NULL; sin = NULL;
ifp = ifptr; ifp = ifptr;
@ -978,7 +978,7 @@ ipf_ifpaddr(ipf_main_softc_t *softc, int v, int atype, void *ifptr,
} }
if (ifa == NULL || sin == NULL) if (ifa == NULL || sin == NULL)
return -1; return(-1);
mask = ifa->ifa_netmask; mask = ifa->ifa_netmask;
if (atype == FRI_BROADCAST) if (atype == FRI_BROADCAST)
@ -987,18 +987,18 @@ ipf_ifpaddr(ipf_main_softc_t *softc, int v, int atype, void *ifptr,
sock = ifa->ifa_dstaddr; sock = ifa->ifa_dstaddr;
if (sock == NULL) if (sock == NULL)
return -1; return(-1);
#ifdef USE_INET6 #ifdef USE_INET6
if (v == 6) { if (v == 6) {
return ipf_ifpfillv6addr(atype, (struct sockaddr_in6 *)sock, return(ipf_ifpfillv6addr(atype, (struct sockaddr_in6 *)sock,
(struct sockaddr_in6 *)mask, (struct sockaddr_in6 *)mask,
inp, inpmask); inp, inpmask));
} }
#endif #endif
return ipf_ifpfillv4addr(atype, (struct sockaddr_in *)sock, return(ipf_ifpfillv4addr(atype, (struct sockaddr_in *)sock,
(struct sockaddr_in *)mask, (struct sockaddr_in *)mask,
&inp->in4, &inpmask->in4); &inp->in4, &inpmask->in4));
} }
@ -1008,7 +1008,7 @@ ipf_newisn(fin)
{ {
u_32_t newiss; u_32_t newiss;
newiss = arc4random(); newiss = arc4random();
return newiss; return(newiss);
} }
@ -1022,13 +1022,13 @@ ipf_checkv4sum(fr_info_t *fin)
mb_t *m; mb_t *m;
if ((fin->fin_flx & FI_NOCKSUM) != 0) if ((fin->fin_flx & FI_NOCKSUM) != 0)
return 0; return(0);
if ((fin->fin_flx & FI_SHORT) != 0) if ((fin->fin_flx & FI_SHORT) != 0)
return 1; return(1);
if (fin->fin_cksum != FI_CK_NEEDED) if (fin->fin_cksum != FI_CK_NEEDED)
return (fin->fin_cksum > FI_CK_NEEDED) ? 0 : -1; return(fin->fin_cksum > FI_CK_NEEDED) ? 0 : -1;
m = fin->fin_m; m = fin->fin_m;
if (m == NULL) { if (m == NULL) {
@ -1042,7 +1042,7 @@ ipf_checkv4sum(fr_info_t *fin)
fin->fin_cksum = FI_CK_BAD; fin->fin_cksum = FI_CK_BAD;
fin->fin_flx |= FI_BAD; fin->fin_flx |= FI_BAD;
DT2(ipf_fi_bad_checkv4sum_csum_ip_checked, fr_info_t *, fin, u_int, m->m_pkthdr.csum_flags & (CSUM_IP_CHECKED|CSUM_IP_VALID)); DT2(ipf_fi_bad_checkv4sum_csum_ip_checked, fr_info_t *, fin, u_int, m->m_pkthdr.csum_flags & (CSUM_IP_CHECKED|CSUM_IP_VALID));
return -1; return(-1);
} }
if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) {
/* Depending on the driver, UDP may have zero checksum */ /* Depending on the driver, UDP may have zero checksum */
@ -1057,7 +1057,7 @@ ipf_checkv4sum(fr_info_t *fin)
* consistent across all drivers) * consistent across all drivers)
*/ */
fin->fin_cksum = 1; fin->fin_cksum = 1;
return 0; return(0);
} }
} }
@ -1074,19 +1074,19 @@ ipf_checkv4sum(fr_info_t *fin)
DT2(ipf_fi_bad_checkv4sum_sum, fr_info_t *, fin, u_int, sum); DT2(ipf_fi_bad_checkv4sum_sum, fr_info_t *, fin, u_int, sum);
} else { } else {
fin->fin_cksum = FI_CK_SUMOK; fin->fin_cksum = FI_CK_SUMOK;
return 0; return(0);
} }
} else { } else {
if (m->m_pkthdr.csum_flags == CSUM_DELAY_DATA) { if (m->m_pkthdr.csum_flags == CSUM_DELAY_DATA) {
fin->fin_cksum = FI_CK_L4FULL; fin->fin_cksum = FI_CK_L4FULL;
return 0; return(0);
} else if (m->m_pkthdr.csum_flags == CSUM_TCP || } else if (m->m_pkthdr.csum_flags == CSUM_TCP ||
m->m_pkthdr.csum_flags == CSUM_UDP) { m->m_pkthdr.csum_flags == CSUM_UDP) {
fin->fin_cksum = FI_CK_L4PART; fin->fin_cksum = FI_CK_L4PART;
return 0; return(0);
} else if (m->m_pkthdr.csum_flags == CSUM_IP) { } else if (m->m_pkthdr.csum_flags == CSUM_IP) {
fin->fin_cksum = FI_CK_L4PART; fin->fin_cksum = FI_CK_L4PART;
return 0; return(0);
} else { } else {
manual = 1; manual = 1;
} }
@ -1096,17 +1096,17 @@ ipf_checkv4sum(fr_info_t *fin)
if (ipf_checkl4sum(fin) == -1) { if (ipf_checkl4sum(fin) == -1) {
fin->fin_flx |= FI_BAD; fin->fin_flx |= FI_BAD;
DT2(ipf_fi_bad_checkv4sum_manual, fr_info_t *, fin, u_int, manual); DT2(ipf_fi_bad_checkv4sum_manual, fr_info_t *, fin, u_int, manual);
return -1; return(-1);
} }
} }
#else #else
if (ipf_checkl4sum(fin) == -1) { if (ipf_checkl4sum(fin) == -1) {
fin->fin_flx |= FI_BAD; fin->fin_flx |= FI_BAD;
DT2(ipf_fi_bad_checkv4sum_checkl4sum, fr_info_t *, fin, u_int, -1); DT2(ipf_fi_bad_checkv4sum_checkl4sum, fr_info_t *, fin, u_int, -1);
return -1; return(-1);
} }
#endif #endif
return 0; return(0);
} }
@ -1116,25 +1116,25 @@ ipf_checkv6sum(fr_info_t *fin)
{ {
if ((fin->fin_flx & FI_NOCKSUM) != 0) { if ((fin->fin_flx & FI_NOCKSUM) != 0) {
DT(ipf_checkv6sum_fi_nocksum); DT(ipf_checkv6sum_fi_nocksum);
return 0; return(0);
} }
if ((fin->fin_flx & FI_SHORT) != 0) { if ((fin->fin_flx & FI_SHORT) != 0) {
DT(ipf_checkv6sum_fi_short); DT(ipf_checkv6sum_fi_short);
return 1; return(1);
} }
if (fin->fin_cksum != FI_CK_NEEDED) { if (fin->fin_cksum != FI_CK_NEEDED) {
DT(ipf_checkv6sum_fi_ck_needed); DT(ipf_checkv6sum_fi_ck_needed);
return (fin->fin_cksum > FI_CK_NEEDED) ? 0 : -1; return(fin->fin_cksum > FI_CK_NEEDED) ? 0 : -1;
} }
if (ipf_checkl4sum(fin) == -1) { if (ipf_checkl4sum(fin) == -1) {
fin->fin_flx |= FI_BAD; fin->fin_flx |= FI_BAD;
DT2(ipf_fi_bad_checkv6sum_checkl4sum, fr_info_t *, fin, u_int, -1); DT2(ipf_fi_bad_checkv6sum_checkl4sum, fr_info_t *, fin, u_int, -1);
return -1; return(-1);
} }
return 0; return(0);
} }
#endif /* USE_INET6 */ #endif /* USE_INET6 */
@ -1152,7 +1152,7 @@ mbufchainlen(struct mbuf *m0)
for (m = m0, len = 0; m != NULL; m = m->m_next) for (m = m0, len = 0; m != NULL; m = m->m_next)
len += m->m_len; len += m->m_len;
} }
return len; return(len);
} }
@ -1181,11 +1181,11 @@ ipf_pullup(mb_t *xmin, fr_info_t *fin, int len)
char *ip; char *ip;
if (m == NULL) if (m == NULL)
return NULL; return(NULL);
ip = (char *)fin->fin_ip; ip = (char *)fin->fin_ip;
if ((fin->fin_flx & FI_COALESCE) != 0) if ((fin->fin_flx & FI_COALESCE) != 0)
return ip; return(ip);
ipoff = fin->fin_ipoff; ipoff = fin->fin_ipoff;
if (fin->fin_dp != NULL) if (fin->fin_dp != NULL)
@ -1244,7 +1244,7 @@ ipf_pullup(mb_t *xmin, fr_info_t *fin, int len)
*fin->fin_mp = NULL; *fin->fin_mp = NULL;
fin->fin_m = NULL; fin->fin_m = NULL;
return NULL; return(NULL);
} }
if (n == NULL) if (n == NULL)
@ -1267,7 +1267,7 @@ ipf_pullup(mb_t *xmin, fr_info_t *fin, int len)
if (len == fin->fin_plen) if (len == fin->fin_plen)
fin->fin_flx |= FI_COALESCE; fin->fin_flx |= FI_COALESCE;
return ip; return(ip);
} }
@ -1287,7 +1287,7 @@ ipf_inject(fr_info_t *fin, mb_t *m)
} }
NET_EPOCH_EXIT(et); NET_EPOCH_EXIT(et);
return error; return(error);
} }
VNET_DEFINE_STATIC(pfil_hook_t, ipf_inet_hook); VNET_DEFINE_STATIC(pfil_hook_t, ipf_inet_hook);
@ -1303,7 +1303,7 @@ int ipf_pfil_unhook(void) {
pfil_remove_hook(V_ipf_inet6_hook); pfil_remove_hook(V_ipf_inet6_hook);
#endif #endif
return (0); return(0);
} }
int ipf_pfil_hook(void) { int ipf_pfil_hook(void) {
@ -1346,7 +1346,7 @@ int ipf_pfil_hook(void) {
else else
error = 0; error = 0;
return (error); return(error);
} }
void void
@ -1384,7 +1384,7 @@ ipf_event_dereg(void)
u_32_t u_32_t
ipf_random(void) ipf_random(void)
{ {
return arc4random(); return(arc4random());
} }
@ -1410,7 +1410,7 @@ ipf_pcksum(fr_info_t *fin, int hlen, u_int sum)
while (sum > 0xffff) while (sum > 0xffff)
sum = (sum & 0xffff) + (sum >> 16); sum = (sum & 0xffff) + (sum >> 16);
sum2 = ~sum & 0xffff; sum2 = ~sum & 0xffff;
return sum2; return(sum2);
} }
#ifdef USE_INET6 #ifdef USE_INET6
@ -1421,7 +1421,7 @@ ipf_pcksum6(struct mbuf *m, ip6_t *ip6, u_int32_t off, u_int32_t len)
int sum; int sum;
if (m->m_len < sizeof(struct ip6_hdr)) { if (m->m_len < sizeof(struct ip6_hdr)) {
return 0xffff; return(0xffff);
} }
sum = in6_cksum(m, ip6->ip6_nxt, off, len); sum = in6_cksum(m, ip6->ip6_nxt, off, len);

View File

@ -135,7 +135,7 @@ ipf_frag_main_load(void)
ipfr_block.fr_flags = FR_BLOCK|FR_QUICK; ipfr_block.fr_flags = FR_BLOCK|FR_QUICK;
ipfr_block.fr_ref = 1; ipfr_block.fr_ref = 1;
return 0; return(0);
} }
@ -150,7 +150,7 @@ ipf_frag_main_load(void)
int int
ipf_frag_main_unload(void) ipf_frag_main_unload(void)
{ {
return 0; return(0);
} }
@ -169,7 +169,7 @@ ipf_frag_soft_create(ipf_main_softc_t *softc)
KMALLOC(softf, ipf_frag_softc_t *); KMALLOC(softf, ipf_frag_softc_t *);
if (softf == NULL) if (softf == NULL)
return NULL; return(NULL);
bzero((char *)softf, sizeof(*softf)); bzero((char *)softf, sizeof(*softf));
@ -182,11 +182,11 @@ ipf_frag_soft_create(ipf_main_softc_t *softc)
ipf_frag_tuneables); ipf_frag_tuneables);
if (softf->ipf_frag_tune == NULL) { if (softf->ipf_frag_tune == NULL) {
ipf_frag_soft_destroy(softc, softf); ipf_frag_soft_destroy(softc, softf);
return NULL; return(NULL);
} }
if (ipf_tune_array_link(softc, softf->ipf_frag_tune) == -1) { if (ipf_tune_array_link(softc, softf->ipf_frag_tune) == -1) {
ipf_frag_soft_destroy(softc, softf); ipf_frag_soft_destroy(softc, softf);
return NULL; return(NULL);
} }
softf->ipfr_size = IPFT_SIZE; softf->ipfr_size = IPFT_SIZE;
@ -196,7 +196,7 @@ ipf_frag_soft_create(ipf_main_softc_t *softc)
softf->ipfr_nattail = &softf->ipfr_natlist; softf->ipfr_nattail = &softf->ipfr_natlist;
softf->ipfr_ipidtail = &softf->ipfr_ipidlist; softf->ipfr_ipidtail = &softf->ipfr_ipidlist;
return softf; return(softf);
} }
@ -244,21 +244,21 @@ ipf_frag_soft_init(ipf_main_softc_t *softc, void *arg)
KMALLOCS(softf->ipfr_heads, ipfr_t **, KMALLOCS(softf->ipfr_heads, ipfr_t **,
softf->ipfr_size * sizeof(ipfr_t *)); softf->ipfr_size * sizeof(ipfr_t *));
if (softf->ipfr_heads == NULL) if (softf->ipfr_heads == NULL)
return -1; return(-1);
bzero((char *)softf->ipfr_heads, softf->ipfr_size * sizeof(ipfr_t *)); bzero((char *)softf->ipfr_heads, softf->ipfr_size * sizeof(ipfr_t *));
KMALLOCS(softf->ipfr_nattab, ipfr_t **, KMALLOCS(softf->ipfr_nattab, ipfr_t **,
softf->ipfr_size * sizeof(ipfr_t *)); softf->ipfr_size * sizeof(ipfr_t *));
if (softf->ipfr_nattab == NULL) if (softf->ipfr_nattab == NULL)
return -2; return(-2);
bzero((char *)softf->ipfr_nattab, softf->ipfr_size * sizeof(ipfr_t *)); bzero((char *)softf->ipfr_nattab, softf->ipfr_size * sizeof(ipfr_t *));
KMALLOCS(softf->ipfr_ipidtab, ipfr_t **, KMALLOCS(softf->ipfr_ipidtab, ipfr_t **,
softf->ipfr_size * sizeof(ipfr_t *)); softf->ipfr_size * sizeof(ipfr_t *));
if (softf->ipfr_ipidtab == NULL) if (softf->ipfr_ipidtab == NULL)
return -3; return(-3);
bzero((char *)softf->ipfr_ipidtab, bzero((char *)softf->ipfr_ipidtab,
softf->ipfr_size * sizeof(ipfr_t *)); softf->ipfr_size * sizeof(ipfr_t *));
@ -266,7 +266,7 @@ ipf_frag_soft_init(ipf_main_softc_t *softc, void *arg)
softf->ipfr_lock = 0; softf->ipfr_lock = 0;
softf->ipfr_inited = 1; softf->ipfr_inited = 1;
return 0; return(0);
} }
@ -306,7 +306,7 @@ ipf_frag_soft_fini(ipf_main_softc_t *softc, void *arg)
softf->ipfr_size * sizeof(ipfr_t *)); softf->ipfr_size * sizeof(ipfr_t *));
softf->ipfr_ipidtab = NULL; softf->ipfr_ipidtab = NULL;
return 0; return(0);
} }
@ -341,7 +341,7 @@ ipf_frag_stats(void *arg)
softf->ipfr_stats.ifs_table = softf->ipfr_heads; softf->ipfr_stats.ifs_table = softf->ipfr_heads;
softf->ipfr_stats.ifs_nattab = softf->ipfr_nattab; softf->ipfr_stats.ifs_nattab = softf->ipfr_nattab;
return &softf->ipfr_stats; return(&softf->ipfr_stats);
} }
@ -372,18 +372,18 @@ ipfr_frag_new(ipf_main_softc_t *softc, ipf_frag_softc_t *softf,
if (softf->ipfr_stats.ifs_inuse >= softf->ipfr_size) { if (softf->ipfr_stats.ifs_inuse >= softf->ipfr_size) {
FBUMPD(ifs_maximum); FBUMPD(ifs_maximum);
return NULL; return(NULL);
} }
if ((fin->fin_flx & (FI_FRAG|FI_BAD)) != FI_FRAG) { if ((fin->fin_flx & (FI_FRAG|FI_BAD)) != FI_FRAG) {
FBUMPD(ifs_newbad); FBUMPD(ifs_newbad);
return NULL; return(NULL);
} }
if (pass & FR_FRSTRICT) { if (pass & FR_FRSTRICT) {
if (fin->fin_off != 0) { if (fin->fin_off != 0) {
FBUMPD(ifs_newrestrictnot0); FBUMPD(ifs_newrestrictnot0);
return NULL; return(NULL);
} }
} }
@ -434,7 +434,7 @@ ipfr_frag_new(ipf_main_softc_t *softc, ipf_frag_softc_t *softf,
KMALLOC(fran, ipfr_t *); KMALLOC(fran, ipfr_t *);
if (fran == NULL) { if (fran == NULL) {
FBUMPD(ifs_nomem); FBUMPD(ifs_nomem);
return NULL; return(NULL);
} }
memset(fran, 0, sizeof(*fran)); memset(fran, 0, sizeof(*fran));
@ -449,7 +449,7 @@ ipfr_frag_new(ipf_main_softc_t *softc, ipf_frag_softc_t *softf,
RWLOCK_EXIT(lock); RWLOCK_EXIT(lock);
FBUMPD(ifs_exists); FBUMPD(ifs_exists);
KFREE(fran); KFREE(fran);
return NULL; return(NULL);
} }
fra = fran; fra = fran;
@ -490,7 +490,7 @@ ipfr_frag_new(ipf_main_softc_t *softc, ipf_frag_softc_t *softf,
fra->ipfr_bytes = fin->fin_plen; fra->ipfr_bytes = fin->fin_plen;
FBUMP(ifs_inuse); FBUMP(ifs_inuse);
FBUMP(ifs_new); FBUMP(ifs_new);
return fra; return(fra);
} }
@ -508,7 +508,7 @@ ipf_frag_new(ipf_main_softc_t *softc, fr_info_t *fin, u_32_t pass)
ipfr_t *fra; ipfr_t *fra;
if (softf->ipfr_lock != 0) if (softf->ipfr_lock != 0)
return -1; return(-1);
#ifdef USE_MUTEXES #ifdef USE_MUTEXES
fra = ipfr_frag_new(softc, softf, fin, pass, softf->ipfr_heads, &softc->ipf_frag); fra = ipfr_frag_new(softc, softf, fin, pass, softf->ipfr_heads, &softc->ipf_frag);
@ -522,7 +522,7 @@ ipf_frag_new(ipf_main_softc_t *softc, fr_info_t *fin, u_32_t pass)
fra->ipfr_next = NULL; fra->ipfr_next = NULL;
RWLOCK_EXIT(&softc->ipf_frag); RWLOCK_EXIT(&softc->ipf_frag);
} }
return fra ? 0 : -1; return(fra ? 0 : -1);
} }
@ -543,7 +543,7 @@ ipf_frag_natnew(ipf_main_softc_t *softc, fr_info_t *fin, u_32_t pass,
ipfr_t *fra; ipfr_t *fra;
if (softf->ipfr_lock != 0) if (softf->ipfr_lock != 0)
return 0; return(0);
#ifdef USE_MUTEXES #ifdef USE_MUTEXES
fra = ipfr_frag_new(softc, softf, fin, pass, softf->ipfr_nattab, fra = ipfr_frag_new(softc, softf, fin, pass, softf->ipfr_nattab,
@ -559,9 +559,9 @@ ipf_frag_natnew(ipf_main_softc_t *softc, fr_info_t *fin, u_32_t pass,
softf->ipfr_nattail = &fra->ipfr_next; softf->ipfr_nattail = &fra->ipfr_next;
fra->ipfr_next = NULL; fra->ipfr_next = NULL;
RWLOCK_EXIT(&softf->ipfr_natfrag); RWLOCK_EXIT(&softf->ipfr_natfrag);
return 0; return(0);
} }
return -1; return(-1);
} }
@ -582,7 +582,7 @@ ipf_frag_ipidnew(fr_info_t *fin, u_32_t ipid)
ipfr_t *fra; ipfr_t *fra;
if (softf->ipfr_lock) if (softf->ipfr_lock)
return 0; return(0);
#ifdef USE_MUTEXES #ifdef USE_MUTEXES
fra = ipfr_frag_new(softc, softf, fin, 0, softf->ipfr_ipidtab, &softf->ipfr_ipidfrag); fra = ipfr_frag_new(softc, softf, fin, 0, softf->ipfr_ipidtab, &softf->ipfr_ipidfrag);
@ -597,7 +597,7 @@ ipf_frag_ipidnew(fr_info_t *fin, u_32_t ipid)
fra->ipfr_next = NULL; fra->ipfr_next = NULL;
RWLOCK_EXIT(&softf->ipfr_ipidfrag); RWLOCK_EXIT(&softf->ipfr_ipidfrag);
} }
return fra ? 0 : -1; return(fra ? 0 : -1);
} }
@ -635,12 +635,12 @@ ipf_frag_lookup(ipf_main_softc_t *softc, ipf_frag_softc_t *softf,
*/ */
if (fin->fin_flx & FI_SHORT) { if (fin->fin_flx & FI_SHORT) {
FBUMPD(ifs_short); FBUMPD(ifs_short);
return NULL; return(NULL);
} }
if ((fin->fin_flx & FI_BAD) != 0) { if ((fin->fin_flx & FI_BAD) != 0) {
FBUMPD(ifs_bad); FBUMPD(ifs_bad);
return NULL; return(NULL);
} }
/* /*
@ -763,13 +763,13 @@ ipf_frag_lookup(ipf_main_softc_t *softc, ipf_frag_softc_t *softf,
f->ipfr_pkts++; f->ipfr_pkts++;
f->ipfr_bytes += fin->fin_plen; f->ipfr_bytes += fin->fin_plen;
FBUMP(ifs_hits); FBUMP(ifs_hits);
return f; return(f);
} }
} }
RWLOCK_EXIT(lock); RWLOCK_EXIT(lock);
FBUMP(ifs_miss); FBUMP(ifs_miss);
return NULL; return(NULL);
} }
@ -790,7 +790,7 @@ ipf_frag_natknown(fr_info_t *fin)
ipfr_t *ipf; ipfr_t *ipf;
if ((softf->ipfr_lock) || !softf->ipfr_natlist) if ((softf->ipfr_lock) || !softf->ipfr_natlist)
return NULL; return(NULL);
#ifdef USE_MUTEXES #ifdef USE_MUTEXES
ipf = ipf_frag_lookup(softc, softf, fin, softf->ipfr_nattab, ipf = ipf_frag_lookup(softc, softf, fin, softf->ipfr_nattab,
&softf->ipfr_natfrag); &softf->ipfr_natfrag);
@ -809,7 +809,7 @@ ipf_frag_natknown(fr_info_t *fin)
RWLOCK_EXIT(&softf->ipfr_natfrag); RWLOCK_EXIT(&softf->ipfr_natfrag);
} else } else
nat = NULL; nat = NULL;
return nat; return(nat);
} }
@ -830,7 +830,7 @@ ipf_frag_ipidknown(fr_info_t *fin)
u_32_t id; u_32_t id;
if (softf->ipfr_lock || !softf->ipfr_ipidlist) if (softf->ipfr_lock || !softf->ipfr_ipidlist)
return 0xffffffff; return(0xffffffff);
#ifdef USE_MUTEXES #ifdef USE_MUTEXES
ipf = ipf_frag_lookup(softc, softf, fin, softf->ipfr_ipidtab, ipf = ipf_frag_lookup(softc, softf, fin, softf->ipfr_ipidtab,
@ -843,7 +843,7 @@ ipf_frag_ipidknown(fr_info_t *fin)
RWLOCK_EXIT(&softf->ipfr_ipidfrag); RWLOCK_EXIT(&softf->ipfr_ipidfrag);
} else } else
id = 0xffffffff; id = 0xffffffff;
return id; return(id);
} }
@ -868,7 +868,7 @@ ipf_frag_known(fr_info_t *fin, u_32_t *passp)
u_32_t pass; u_32_t pass;
if ((softf->ipfr_lock) || (softf->ipfr_list == NULL)) if ((softf->ipfr_lock) || (softf->ipfr_list == NULL))
return NULL; return(NULL);
#ifdef USE_MUTEXES #ifdef USE_MUTEXES
fra = ipf_frag_lookup(softc, softf, fin, softf->ipfr_heads, fra = ipf_frag_lookup(softc, softf, fin, softf->ipfr_heads,
@ -903,7 +903,7 @@ ipf_frag_known(fr_info_t *fin, u_32_t *passp)
} }
RWLOCK_EXIT(&softc->ipf_frag); RWLOCK_EXIT(&softc->ipf_frag);
} }
return fr; return(fr);
} }
@ -1112,10 +1112,10 @@ ipf_frag_pkt_next(ipf_main_softc_t *softc, ipftoken_t *token,
ipf_frag_softc_t *softf = softc->ipf_frag_soft; ipf_frag_softc_t *softf = softc->ipf_frag_soft;
#ifdef USE_MUTEXES #ifdef USE_MUTEXES
return ipf_frag_next(softc, token, itp, &softf->ipfr_list, return(ipf_frag_next(softc, token, itp, &softf->ipfr_list,
&softf->ipfr_frag); &softf->ipfr_frag));
#else #else
return ipf_frag_next(softc, token, itp, &softf->ipfr_list); return(ipf_frag_next(softc, token, itp, &softf->ipfr_list));
#endif #endif
} }
@ -1137,10 +1137,10 @@ ipf_frag_nat_next(ipf_main_softc_t *softc, ipftoken_t *token,
ipf_frag_softc_t *softf = softc->ipf_frag_soft; ipf_frag_softc_t *softf = softc->ipf_frag_soft;
#ifdef USE_MUTEXES #ifdef USE_MUTEXES
return ipf_frag_next(softc, token, itp, &softf->ipfr_natlist, return(ipf_frag_next(softc, token, itp, &softf->ipfr_natlist,
&softf->ipfr_natfrag); &softf->ipfr_natfrag));
#else #else
return ipf_frag_next(softc, token, itp, &softf->ipfr_natlist); return(ipf_frag_next(softc, token, itp, &softf->ipfr_natlist));
#endif #endif
} }
@ -1173,12 +1173,12 @@ ipf_frag_next(ipf_main_softc_t *softc, ipftoken_t *token, ipfgeniter_t *itp,
if (itp->igi_data == NULL) { if (itp->igi_data == NULL) {
IPFERROR(20001); IPFERROR(20001);
return EFAULT; return(EFAULT);
} }
if (itp->igi_nitems != 1) { if (itp->igi_nitems != 1) {
IPFERROR(20003); IPFERROR(20003);
return EFAULT; return(EFAULT);
} }
frag = token->ipt_data; frag = token->ipt_data;
@ -1214,7 +1214,7 @@ ipf_frag_next(ipf_main_softc_t *softc, ipftoken_t *token, ipfgeniter_t *itp,
ipf_frag_deref(softc, &frag); ipf_frag_deref(softc, &frag);
#endif #endif
} }
return error; return(error);
} }

View File

@ -180,7 +180,7 @@ ipf_p_ftp_soft_create(ipf_main_softc_t *softc)
KMALLOC(softf, ipf_ftp_softc_t *); KMALLOC(softf, ipf_ftp_softc_t *);
if (softf == NULL) if (softf == NULL)
return NULL; return(NULL);
bzero((char *)softf, sizeof(*softf)); bzero((char *)softf, sizeof(*softf));
#if defined(_KERNEL) #if defined(_KERNEL)
@ -195,14 +195,14 @@ ipf_p_ftp_soft_create(ipf_main_softc_t *softc)
ipf_ftp_tuneables); ipf_ftp_tuneables);
if (softf->ipf_p_ftp_tune == NULL) { if (softf->ipf_p_ftp_tune == NULL) {
ipf_p_ftp_soft_destroy(softc, softf); ipf_p_ftp_soft_destroy(softc, softf);
return NULL; return(NULL);
} }
if (ipf_tune_array_link(softc, softf->ipf_p_ftp_tune) == -1) { if (ipf_tune_array_link(softc, softf->ipf_p_ftp_tune) == -1) {
ipf_p_ftp_soft_destroy(softc, softf); ipf_p_ftp_soft_destroy(softc, softf);
return NULL; return(NULL);
} }
return softf; return(softf);
} }
@ -229,7 +229,7 @@ ipf_p_ftp_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
KMALLOC(ftp, ftpinfo_t *); KMALLOC(ftp, ftpinfo_t *);
if (ftp == NULL) if (ftp == NULL)
return -1; return(-1);
nat = nat; /* LINT */ nat = nat; /* LINT */
@ -247,7 +247,7 @@ ipf_p_ftp_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
f->ftps_wptr = f->ftps_buf; f->ftps_wptr = f->ftps_buf;
ftp->ftp_passok = FTPXY_INIT; ftp->ftp_passok = FTPXY_INIT;
ftp->ftp_incok = 0; ftp->ftp_incok = 0;
return 0; return(0);
} }
@ -305,7 +305,7 @@ ipf_p_ftp_port(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_PARSE) if (softf->ipf_p_ftp_debug & DEBUG_PARSE)
printf("ipf_p_ftp_port:dlen(%d) < IPF_MINPORTLEN\n", printf("ipf_p_ftp_port:dlen(%d) < IPF_MINPORTLEN\n",
dlen); dlen);
return 0; return(0);
} }
/* /*
* Skip the PORT command + space * Skip the PORT command + space
@ -319,14 +319,14 @@ ipf_p_ftp_port(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
DT2(ftp_PORT_error_atoi_1, nat_t *, nat, ftpside_t *, f); DT2(ftp_PORT_error_atoi_1, nat_t *, nat, ftpside_t *, f);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_port:ipf_p_ftp_atoi(%d) failed\n", 1); printf("ipf_p_ftp_port:ipf_p_ftp_atoi(%d) failed\n", 1);
return 0; return(0);
} }
a2 = ipf_p_ftp_atoi(&s); a2 = ipf_p_ftp_atoi(&s);
if (s == NULL) { if (s == NULL) {
DT2(ftp_PORT_error_atoi_2, nat_t *, nat, ftpside_t *, f); DT2(ftp_PORT_error_atoi_2, nat_t *, nat, ftpside_t *, f);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_port:ipf_p_ftp_atoi(%d) failed\n", 2); printf("ipf_p_ftp_port:ipf_p_ftp_atoi(%d) failed\n", 2);
return 0; return(0);
} }
/* /*
@ -343,7 +343,7 @@ ipf_p_ftp_port(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
u_int, a1); u_int, a1);
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_port:%s != nat->nat_inip\n", "a1"); printf("ipf_p_ftp_port:%s != nat->nat_inip\n", "a1");
return APR_ERR(1); return(APR_ERR(1));
} }
a5 = ipf_p_ftp_atoi(&s); a5 = ipf_p_ftp_atoi(&s);
@ -351,7 +351,7 @@ ipf_p_ftp_port(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
DT2(ftp_PORT_error_atoi_3, nat_t *, nat, ftpside_t *, f); DT2(ftp_PORT_error_atoi_3, nat_t *, nat, ftpside_t *, f);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_port:ipf_p_ftp_atoi(%d) failed\n", 3); printf("ipf_p_ftp_port:ipf_p_ftp_atoi(%d) failed\n", 3);
return 0; return(0);
} }
if (*s == ')') if (*s == ')')
s++; s++;
@ -365,7 +365,7 @@ ipf_p_ftp_port(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
DT2(ftp_PORT_error_no_crlf, nat_t *, nat, ftpside_t *, f); DT2(ftp_PORT_error_no_crlf, nat_t *, nat, ftpside_t *, f);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_port:missing %s\n", "cr-lf"); printf("ipf_p_ftp_port:missing %s\n", "cr-lf");
return 0; return(0);
} }
s += 2; s += 2;
a6 = a5 & 0xff; a6 = a5 & 0xff;
@ -402,7 +402,7 @@ ipf_p_ftp_port(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_port:inc(%d) + ip->ip_len > 65535\n", printf("ipf_p_ftp_port:inc(%d) + ip->ip_len > 65535\n",
inc); inc);
return 0; return(0);
} }
#if !defined(_KERNEL) #if !defined(_KERNEL)
@ -426,7 +426,7 @@ ipf_p_ftp_port(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
} }
f->ftps_cmd = FTPXY_C_PORT; f->ftps_cmd = FTPXY_C_PORT;
return ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, sp, inc); return(ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, sp, inc));
} }
@ -454,7 +454,7 @@ ipf_p_ftp_addport(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_addport:xfer active %p/%p\n", printf("ipf_p_ftp_addport:xfer active %p/%p\n",
ftp->ftp_pendnat, ftp->ftp_pendstate); ftp->ftp_pendnat, ftp->ftp_pendstate);
return 0; return(0);
} }
ipf_p_ftp_setpending(softc, ftp); ipf_p_ftp_setpending(softc, ftp);
} }
@ -473,7 +473,7 @@ ipf_p_ftp_addport(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
u_int, sp); u_int, sp);
if (softf->ipf_p_ftp_debug & DEBUG_SECURITY) if (softf->ipf_p_ftp_debug & DEBUG_SECURITY)
printf("ipf_p_ftp_addport:sp(%d) < 1024\n", sp); printf("ipf_p_ftp_addport:sp(%d) < 1024\n", sp);
return 0; return(0);
} }
/* /*
* The server may not make the connection back from port 20, but * The server may not make the connection back from port 20, but
@ -489,7 +489,7 @@ ipf_p_ftp_addport(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
#ifndef USE_INET6 #ifndef USE_INET6
if (nat->nat_v[0] == 6) if (nat->nat_v[0] == 6)
return APR_INC(inc); return(APR_INC(inc));
#endif #endif
/* /*
@ -524,14 +524,14 @@ ipf_p_ftp_addport(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
} }
} }
if (nat2 != NULL) if (nat2 != NULL)
return APR_INC(inc); return(APR_INC(inc));
/* /*
* An existing entry doesn't exist. Let's make one. * An existing entry doesn't exist. Let's make one.
*/ */
ipn = ipf_proxy_rule_rev(nat); ipn = ipf_proxy_rule_rev(nat);
if (ipn == NULL) if (ipn == NULL)
return APR_ERR(1); return(APR_ERR(1));
ipn->in_use = 0; ipn->in_use = 0;
fi.fin_fr = &ftppxyfr; fi.fin_fr = &ftppxyfr;
@ -572,7 +572,7 @@ ipf_p_ftp_addport(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (nat2 == NULL) { if (nat2 == NULL) {
KFREES(ipn, ipn->in_size); KFREES(ipn, ipn->in_size);
return APR_ERR(1); return(APR_ERR(1));
} }
(void) ipf_nat_proto(&fi, nat2, IPN_TCP); (void) ipf_nat_proto(&fi, nat2, IPN_TCP);
@ -586,7 +586,7 @@ ipf_p_ftp_addport(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
SI_W_SPORT) != 0) SI_W_SPORT) != 0)
ipf_nat_setpending(softc, nat2); ipf_nat_setpending(softc, nat2);
return APR_INC(inc); return(APR_INC(inc));
} }
@ -665,7 +665,7 @@ ipf_p_ftp_client(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip,
while ((*rptr++ != '\n') && (rptr < wptr)) while ((*rptr++ != '\n') && (rptr < wptr))
; ;
f->ftps_rptr = rptr; f->ftps_rptr = rptr;
return inc; return(inc);
} }
@ -686,7 +686,7 @@ ipf_p_ftp_pasv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_pasv:ftps_cmd(%d) != FTPXY_C_PASV\n", printf("ipf_p_ftp_pasv:ftps_cmd(%d) != FTPXY_C_PASV\n",
ftp->ftp_side[0].ftps_cmd); ftp->ftp_side[0].ftps_cmd);
return 0; return(0);
} }
f = &ftp->ftp_side[1]; f = &ftp->ftp_side[1];
@ -701,13 +701,13 @@ ipf_p_ftp_pasv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_pasv:dlen(%d) < IPF_MIN227LEN\n", printf("ipf_p_ftp_pasv:dlen(%d) < IPF_MIN227LEN\n",
dlen); dlen);
return 0; return(0);
} else if (strncmp(f->ftps_rptr, } else if (strncmp(f->ftps_rptr,
"227 Entering Passive Mod", PASV_REPLEN)) { "227 Entering Passive Mod", PASV_REPLEN)) {
DT2(ftp_PASV_error_string, nat_t *, nat, ftpinfo_t *, ftp); DT2(ftp_PASV_error_string, nat_t *, nat, ftpinfo_t *, ftp);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_pasv:%d reply wrong\n", 227); printf("ipf_p_ftp_pasv:%d reply wrong\n", 227);
return 0; return(0);
} }
brackets[0] = ""; brackets[0] = "";
@ -732,14 +732,14 @@ ipf_p_ftp_pasv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
DT2(ftp_PASV_error_atoi_1, nat_t *, nat, ftpside_t *, f); DT2(ftp_PASV_error_atoi_1, nat_t *, nat, ftpside_t *, f);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_pasv:ipf_p_ftp_atoi(%d) failed\n", 1); printf("ipf_p_ftp_pasv:ipf_p_ftp_atoi(%d) failed\n", 1);
return 0; return(0);
} }
a2 = ipf_p_ftp_atoi(&s); a2 = ipf_p_ftp_atoi(&s);
if (s == NULL) { if (s == NULL) {
DT2(ftp_PASV_error_atoi_2, nat_t *, nat, ftpside_t *, f); DT2(ftp_PASV_error_atoi_2, nat_t *, nat, ftpside_t *, f);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_pasv:ipf_p_ftp_atoi(%d) failed\n", 2); printf("ipf_p_ftp_pasv:ipf_p_ftp_atoi(%d) failed\n", 2);
return 0; return(0);
} }
/* /*
@ -757,7 +757,7 @@ ipf_p_ftp_pasv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
u_int, a1); u_int, a1);
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_pasv:%s != nat->nat_oip\n", "a1"); printf("ipf_p_ftp_pasv:%s != nat->nat_oip\n", "a1");
return 0; return(0);
} }
a5 = ipf_p_ftp_atoi(&s); a5 = ipf_p_ftp_atoi(&s);
@ -765,7 +765,7 @@ ipf_p_ftp_pasv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
DT2(ftp_PASV_error_atoi_3, nat_t *, nat, ftpside_t *, f); DT2(ftp_PASV_error_atoi_3, nat_t *, nat, ftpside_t *, f);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_pasv:ipf_p_ftp_atoi(%d) failed\n", 3); printf("ipf_p_ftp_pasv:ipf_p_ftp_atoi(%d) failed\n", 3);
return 0; return(0);
} }
if (*s == ')') if (*s == ')')
@ -781,7 +781,7 @@ ipf_p_ftp_pasv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
DT(pasv_missing_crlf); DT(pasv_missing_crlf);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_pasv:missing %s", "cr-lf\n"); printf("ipf_p_ftp_pasv:missing %s", "cr-lf\n");
return 0; return(0);
} }
s += 2; s += 2;
@ -804,8 +804,8 @@ ipf_p_ftp_pasv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
(void) snprintf(newbuf, sizeof(newbuf), "%s %s%u,%u,%u,%u,%u,%u%s\r\n", (void) snprintf(newbuf, sizeof(newbuf), "%s %s%u,%u,%u,%u,%u,%u%s\r\n",
"227 Entering Passive Mode", brackets[0], a1, a2, a3, a4, "227 Entering Passive Mode", brackets[0], a1, a2, a3, a4,
a5, a6, brackets[1]); a5, a6, brackets[1]);
return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (a5 << 8 | a6), return(ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (a5 << 8 | a6),
newbuf, s); newbuf, s));
} }
int int
@ -849,12 +849,12 @@ ipf_p_ftp_pasvreply(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip,
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_pasv:inc(%d) + ip->ip_len > 65535\n", printf("ipf_p_ftp_pasv:inc(%d) + ip->ip_len > 65535\n",
inc); inc);
return 0; return(0);
} }
ipn = ipf_proxy_rule_fwd(nat); ipn = ipf_proxy_rule_fwd(nat);
if (ipn == NULL) if (ipn == NULL)
return APR_ERR(1); return(APR_ERR(1));
ipn->in_use = 0; ipn->in_use = 0;
/* /*
@ -895,7 +895,7 @@ ipf_p_ftp_pasvreply(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip,
if (nat2 == NULL) { if (nat2 == NULL) {
KFREES(ipn, ipn->in_size); KFREES(ipn, ipn->in_size);
return APR_ERR(1); return(APR_ERR(1));
} }
(void) ipf_nat_proto(&fi, nat2, IPN_TCP); (void) ipf_nat_proto(&fi, nat2, IPN_TCP);
@ -942,7 +942,7 @@ ipf_p_ftp_pasvreply(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip,
ip->ip_len = htons(fin->fin_plen); ip->ip_len = htons(fin->fin_plen);
} }
return APR_INC(inc); return(APR_INC(inc));
} }
@ -963,7 +963,7 @@ ipf_p_ftp_server(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (*rptr == ' ') if (*rptr == ' ')
goto server_cmd_ok; goto server_cmd_ok;
if (!ISDIGIT(*rptr) || !ISDIGIT(*(rptr + 1)) || !ISDIGIT(*(rptr + 2))) if (!ISDIGIT(*rptr) || !ISDIGIT(*(rptr + 1)) || !ISDIGIT(*(rptr + 2)))
return 0; return(0);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE) if (softf->ipf_p_ftp_debug & DEBUG_PARSE)
printf("ipf_p_ftp_server_1: cmd[%4.4s] passok %d\n", printf("ipf_p_ftp_server_1: cmd[%4.4s] passok %d\n",
rptr, ftp->ftp_passok); rptr, ftp->ftp_passok);
@ -1017,7 +1017,7 @@ ipf_p_ftp_server(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
while ((*rptr++ != '\n') && (rptr < wptr)) while ((*rptr++ != '\n') && (rptr < wptr))
; ;
f->ftps_rptr = rptr; f->ftps_rptr = rptr;
return inc; return(inc);
} }
@ -1041,13 +1041,13 @@ ipf_p_ftp_client_valid(ipf_ftp_softc_t *softf, ftpside_t *ftps, char *buf,
s = buf; s = buf;
if (ftps->ftps_junk == FTPXY_JUNK_BAD) if (ftps->ftps_junk == FTPXY_JUNK_BAD)
return FTPXY_JUNK_BAD; return(FTPXY_JUNK_BAD);
if (i < 5) { if (i < 5) {
DT1(client_valid, int, i); DT1(client_valid, int, i);
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_client_valid:i(%d) < 5\n", (int)i); printf("ipf_p_ftp_client_valid:i(%d) < 5\n", (int)i);
return 2; return(2);
} }
i--; i--;
@ -1085,7 +1085,7 @@ ipf_p_ftp_client_valid(ipf_ftp_softc_t *softf, ftpside_t *ftps, char *buf,
"ipf_p_ftp_client_valid", "ipf_p_ftp_client_valid",
ftps->ftps_junk, (int)len, (int)i, c, ftps->ftps_junk, (int)len, (int)i, c,
(int)len, (int)len, buf); (int)len, (int)len, buf);
return FTPXY_JUNK_BAD; return(FTPXY_JUNK_BAD);
} }
for (; i; i--) { for (; i; i--) {
@ -1100,14 +1100,14 @@ ipf_p_ftp_client_valid(ipf_ftp_softc_t *softf, ftpside_t *ftps, char *buf,
} else { } else {
ftps->ftps_cmd = 0; ftps->ftps_cmd = 0;
} }
return 0; return(0);
} }
} }
#if !defined(_KERNEL) #if !defined(_KERNEL)
printf("ipf_p_ftp_client_valid:junk after cmd[%*.*s]\n", printf("ipf_p_ftp_client_valid:junk after cmd[%*.*s]\n",
(int)len, (int)len, buf); (int)len, (int)len, buf);
#endif #endif
return FTPXY_JUNK_EOL; return(FTPXY_JUNK_EOL);
} }
@ -1123,13 +1123,13 @@ ipf_p_ftp_server_valid(ipf_ftp_softc_t *softf, ftpside_t *ftps, char *buf,
cmd = 0; cmd = 0;
if (ftps->ftps_junk == FTPXY_JUNK_BAD) if (ftps->ftps_junk == FTPXY_JUNK_BAD)
return FTPXY_JUNK_BAD; return(FTPXY_JUNK_BAD);
if (i < 5) { if (i < 5) {
DT1(server_valid, int, i); DT1(server_valid, int, i);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_servert_valid:i(%d) < 5\n", (int)i); printf("ipf_p_ftp_servert_valid:i(%d) < 5\n", (int)i);
return 2; return(2);
} }
c = *s++; c = *s++;
@ -1154,7 +1154,7 @@ ipf_p_ftp_server_valid(ipf_ftp_softc_t *softf, ftpside_t *ftps, char *buf,
if ((c != '-') && (c != ' ')) if ((c != '-') && (c != ' '))
goto bad_server_command; goto bad_server_command;
if (c == '-') if (c == '-')
return FTPXY_JUNK_CONT; return(FTPXY_JUNK_CONT);
} else } else
goto bad_server_command; goto bad_server_command;
} else } else
@ -1168,8 +1168,8 @@ ipf_p_ftp_server_valid(ipf_ftp_softc_t *softf, ftpside_t *ftps, char *buf,
ftps->ftps_junk, (int)len, (int)i, ftps->ftps_junk, (int)len, (int)i,
c, (int)len, (int)len, buf); c, (int)len, (int)len, buf);
if (ftps->ftps_junk == FTPXY_JUNK_CONT) if (ftps->ftps_junk == FTPXY_JUNK_CONT)
return FTPXY_JUNK_CONT; return(FTPXY_JUNK_CONT);
return FTPXY_JUNK_BAD; return(FTPXY_JUNK_BAD);
} }
search_eol: search_eol:
for (; i; i--) { for (; i; i--) {
@ -1178,11 +1178,11 @@ ipf_p_ftp_server_valid(ipf_ftp_softc_t *softf, ftpside_t *ftps, char *buf,
if ((pc == '\r') && (c == '\n')) { if ((pc == '\r') && (c == '\n')) {
if (cmd == -1) { if (cmd == -1) {
if (ftps->ftps_junk == FTPXY_JUNK_CONT) if (ftps->ftps_junk == FTPXY_JUNK_CONT)
return FTPXY_JUNK_CONT; return(FTPXY_JUNK_CONT);
} else { } else {
ftps->ftps_cmd = cmd; ftps->ftps_cmd = cmd;
} }
return FTPXY_JUNK_OK; return(FTPXY_JUNK_OK);
} }
} }
@ -1190,7 +1190,7 @@ ipf_p_ftp_server_valid(ipf_ftp_softc_t *softf, ftpside_t *ftps, char *buf,
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_INFO) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_INFO)
printf("ipf_p_ftp_server_valid:junk after cmd[%*.*s]\n", printf("ipf_p_ftp_server_valid:junk after cmd[%*.*s]\n",
(int)len, (int)len, buf); (int)len, (int)len, buf);
return FTPXY_JUNK_EOL; return(FTPXY_JUNK_EOL);
} }
@ -1250,9 +1250,9 @@ ipf_p_ftp_process(ipf_ftp_softc_t *softf, fr_info_t *fin, nat_t *nat,
if ((mlen == 0) && ((tcp->th_flags & TH_OPENING) == TH_OPENING)) { if ((mlen == 0) && ((tcp->th_flags & TH_OPENING) == TH_OPENING)) {
f->ftps_seq[0] = thseq + 1; f->ftps_seq[0] = thseq + 1;
t->ftps_seq[0] = thack; t->ftps_seq[0] = thack;
return 0; return(0);
} else if (mlen < 0) { } else if (mlen < 0) {
return 0; return(0);
} }
aps = nat->nat_aps; aps = nat->nat_aps;
@ -1354,7 +1354,7 @@ ipf_p_ftp_process(ipf_ftp_softc_t *softf, fr_info_t *fin, nat_t *nat,
"ipf_p_ftp_process", t->ftps_seq[1], "ipf_p_ftp_process", t->ftps_seq[1],
ackoff, thack); ackoff, thack);
} }
return APR_ERR(1); return(APR_ERR(1));
} }
if (softf->ipf_p_ftp_debug & DEBUG_PARSE) { if (softf->ipf_p_ftp_debug & DEBUG_PARSE) {
@ -1372,11 +1372,11 @@ ipf_p_ftp_process(ipf_ftp_softc_t *softf, fr_info_t *fin, nat_t *nat,
printf("FIN: thseq %x seqoff %d ftps_seq %x\n", printf("FIN: thseq %x seqoff %d ftps_seq %x\n",
thseq, seqoff, f->ftps_seq[0]); thseq, seqoff, f->ftps_seq[0]);
} }
return APR_ERR(1); return(APR_ERR(1));
} }
} }
f->ftps_len = 0; f->ftps_len = 0;
return 0; return(0);
} }
ok = 0; ok = 0;
@ -1403,7 +1403,7 @@ ipf_p_ftp_process(ipf_ftp_softc_t *softf, fr_info_t *fin, nat_t *nat,
aps->aps_seqoff[sel]); aps->aps_seqoff[sel]);
} }
return APR_ERR(1); return(APR_ERR(1));
} }
inc = 0; inc = 0;
@ -1496,7 +1496,7 @@ ipf_p_ftp_process(ipf_ftp_softc_t *softf, fr_info_t *fin, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("%s:cmds == 0 junk == 1\n", printf("%s:cmds == 0 junk == 1\n",
"ipf_p_ftp_process"); "ipf_p_ftp_process");
return APR_ERR(2); return(APR_ERR(2));
} }
retry = 0; retry = 0;
@ -1546,7 +1546,7 @@ ipf_p_ftp_process(ipf_ftp_softc_t *softf, fr_info_t *fin, nat_t *nat,
f->ftps_rptr = rptr; f->ftps_rptr = rptr;
f->ftps_wptr = wptr; f->ftps_wptr = wptr;
return APR_INC(inc); return(APR_INC(inc));
} }
@ -1559,13 +1559,13 @@ ipf_p_ftp_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ftp = aps->aps_data; ftp = aps->aps_data;
if (ftp == NULL) if (ftp == NULL)
return 0; return(0);
rev = (nat->nat_dir == NAT_OUTBOUND) ? 0 : 1; rev = (nat->nat_dir == NAT_OUTBOUND) ? 0 : 1;
if (ftp->ftp_side[1 - rev].ftps_ifp == NULL) if (ftp->ftp_side[1 - rev].ftps_ifp == NULL)
ftp->ftp_side[1 - rev].ftps_ifp = fin->fin_ifp; ftp->ftp_side[1 - rev].ftps_ifp = fin->fin_ifp;
return ipf_p_ftp_process(softf, fin, nat, ftp, rev); return(ipf_p_ftp_process(softf, fin, nat, ftp, rev));
} }
@ -1578,13 +1578,13 @@ ipf_p_ftp_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ftp = aps->aps_data; ftp = aps->aps_data;
if (ftp == NULL) if (ftp == NULL)
return 0; return(0);
rev = (nat->nat_dir == NAT_OUTBOUND) ? 0 : 1; rev = (nat->nat_dir == NAT_OUTBOUND) ? 0 : 1;
if (ftp->ftp_side[rev].ftps_ifp == NULL) if (ftp->ftp_side[rev].ftps_ifp == NULL)
ftp->ftp_side[rev].ftps_ifp = fin->fin_ifp; ftp->ftp_side[rev].ftps_ifp = fin->fin_ifp;
return ipf_p_ftp_process(softf, fin, nat, ftp, 1 - rev); return(ipf_p_ftp_process(softf, fin, nat, ftp, 1 - rev));
} }
@ -1606,7 +1606,7 @@ ipf_p_ftp_atoi(char **ptr)
} }
if (c != ',') { if (c != ',') {
*ptr = NULL; *ptr = NULL;
return 0; return(0);
} }
while (((c = *s++) != '\0') && ISDIGIT(c)) { while (((c = *s++) != '\0') && ISDIGIT(c)) {
j *= 10; j *= 10;
@ -1615,7 +1615,7 @@ ipf_p_ftp_atoi(char **ptr)
*ptr = s; *ptr = s;
i &= 0xff; i &= 0xff;
j &= 0xff; j &= 0xff;
return (i << 8) | j; return(i << 8) | j;
} }
@ -1633,7 +1633,7 @@ ipf_p_ftp_eprt(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_eprt:dlen(%d) < IPF_MINEPRTLEN\n", printf("ipf_p_ftp_eprt:dlen(%d) < IPF_MINEPRTLEN\n",
dlen); dlen);
return 0; return(0);
} }
/* /*
@ -1643,16 +1643,16 @@ ipf_p_ftp_eprt(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
*/ */
f = &ftp->ftp_side[0]; f = &ftp->ftp_side[0];
if (f->ftps_rptr[5] != '|') if (f->ftps_rptr[5] != '|')
return 0; return(0);
if (f->ftps_rptr[5] == f->ftps_rptr[7]) { if (f->ftps_rptr[5] == f->ftps_rptr[7]) {
if (f->ftps_rptr[6] == '1' && nat->nat_v[0] == 4) if (f->ftps_rptr[6] == '1' && nat->nat_v[0] == 4)
return ipf_p_ftp_eprt4(softf, fin, ip, nat, ftp, dlen); return(ipf_p_ftp_eprt4(softf, fin, ip, nat, ftp, dlen));
#ifdef USE_INET6 #ifdef USE_INET6
if (f->ftps_rptr[6] == '2' && nat->nat_v[0] == 6) if (f->ftps_rptr[6] == '2' && nat->nat_v[0] == 6)
return ipf_p_ftp_eprt6(softf, fin, ip, nat, ftp, dlen); return(ipf_p_ftp_eprt6(softf, fin, ip, nat, ftp, dlen));
#endif #endif
} }
return 0; return(0);
} }
@ -1684,9 +1684,9 @@ ipf_p_ftp_eprt4(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
i += c - '0'; i += c - '0';
} }
if (i > 255) if (i > 255)
return 0; return(0);
if (c != '.') if (c != '.')
return 0; return(0);
addr = (i << 24); addr = (i << 24);
i = 0; i = 0;
@ -1695,9 +1695,9 @@ ipf_p_ftp_eprt4(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
i += c - '0'; i += c - '0';
} }
if (i > 255) if (i > 255)
return 0; return(0);
if (c != '.') if (c != '.')
return 0; return(0);
addr |= (addr << 16); addr |= (addr << 16);
i = 0; i = 0;
@ -1706,9 +1706,9 @@ ipf_p_ftp_eprt4(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
i += c - '0'; i += c - '0';
} }
if (i > 255) if (i > 255)
return 0; return(0);
if (c != '.') if (c != '.')
return 0; return(0);
addr |= (addr << 8); addr |= (addr << 8);
i = 0; i = 0;
@ -1717,9 +1717,9 @@ ipf_p_ftp_eprt4(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
i += c - '0'; i += c - '0';
} }
if (i > 255) if (i > 255)
return 0; return(0);
if (c != delim) if (c != delim)
return 0; return(0);
addr |= addr; addr |= addr;
/* /*
@ -1731,9 +1731,9 @@ ipf_p_ftp_eprt4(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
i += c - '0'; i += c - '0';
} }
if (i > 65535) if (i > 65535)
return 0; return(0);
if (c != delim) if (c != delim)
return 0; return(0);
port = i; port = i;
/* /*
@ -1743,7 +1743,7 @@ ipf_p_ftp_eprt4(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
DT(eprt4_no_crlf); DT(eprt4_no_crlf);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_eprt4:missing %s\n", "cr-lf"); printf("ipf_p_ftp_eprt4:missing %s\n", "cr-lf");
return 0; return(0);
} }
s += 2; s += 2;
@ -1776,7 +1776,7 @@ ipf_p_ftp_eprt4(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_eprt4:inc(%d) + ip->ip_len > 65535\n", printf("ipf_p_ftp_eprt4:inc(%d) + ip->ip_len > 65535\n",
inc); inc);
return 0; return(0);
} }
off = (char *)tcp - (char *)ip + (TCP_OFF(tcp) << 2) + fin->fin_ipoff; off = (char *)tcp - (char *)ip + (TCP_OFF(tcp) << 2) + fin->fin_ipoff;
@ -1797,7 +1797,7 @@ ipf_p_ftp_eprt4(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
} }
f->ftps_cmd = FTPXY_C_EPRT; f->ftps_cmd = FTPXY_C_EPRT;
return ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, port, inc); return(ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, port, inc));
} }
@ -1816,7 +1816,7 @@ ipf_p_ftp_epsv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_epsv:ftps_cmd(%d) != FTPXY_C_EPSV\n", printf("ipf_p_ftp_epsv:ftps_cmd(%d) != FTPXY_C_EPSV\n",
ftp->ftp_side[0].ftps_cmd); ftp->ftp_side[0].ftps_cmd);
return 0; return(0);
} }
f = &ftp->ftp_side[1]; f = &ftp->ftp_side[1];
@ -1825,10 +1825,10 @@ ipf_p_ftp_epsv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
* Check for EPSV reply message. * Check for EPSV reply message.
*/ */
if (dlen < IPF_MIN229LEN) { if (dlen < IPF_MIN229LEN) {
return (0); return(0);
} else if (strncmp(f->ftps_rptr, } else if (strncmp(f->ftps_rptr,
"229 Entering Extended Passive Mode", EPSV_REPLEN)) { "229 Entering Extended Passive Mode", EPSV_REPLEN)) {
return (0); return(0);
} }
/* /*
@ -1857,15 +1857,15 @@ ipf_p_ftp_epsv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
* check for CR-LF at the end. * check for CR-LF at the end.
*/ */
if ((*s != '\r') || (*(s + 1) != '\n')) { if ((*s != '\r') || (*(s + 1) != '\n')) {
return 0; return(0);
} }
s += 2; s += 2;
(void) snprintf(newbuf, sizeof(newbuf), "%s (|||%u|)\r\n", (void) snprintf(newbuf, sizeof(newbuf), "%s (|||%u|)\r\n",
"229 Entering Extended Passive Mode", ap); "229 Entering Extended Passive Mode", ap);
return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (u_int)ap, return(ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (u_int)ap,
newbuf, s); newbuf, s));
} }
#ifdef USE_INET6 #ifdef USE_INET6
@ -1958,7 +1958,7 @@ ipf_p_ftp_eprt6(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
s--; s--;
} }
if (c != ':' && c != delim) if (c != ':' && c != delim)
return 0; return(0);
while (*s != '|') while (*s != '|')
s++; s++;
@ -1973,9 +1973,9 @@ ipf_p_ftp_eprt6(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
i += c - '0'; i += c - '0';
} }
if (i > 65535) if (i > 65535)
return 0; return(0);
if (c != delim) if (c != delim)
return 0; return(0);
port = (u_short)(i & 0xffff); port = (u_short)(i & 0xffff);
/* /*
@ -1985,7 +1985,7 @@ ipf_p_ftp_eprt6(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
DT(eprt6_no_crlf); DT(eprt6_no_crlf);
if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR) if (softf->ipf_p_ftp_debug & DEBUG_PARSE_ERR)
printf("ipf_p_ftp_eprt6:missing %s\n", "cr-lf"); printf("ipf_p_ftp_eprt6:missing %s\n", "cr-lf");
return 0; return(0);
} }
s += 2; s += 2;
@ -2028,7 +2028,7 @@ ipf_p_ftp_eprt6(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
if (softf->ipf_p_ftp_debug & DEBUG_ERROR) if (softf->ipf_p_ftp_debug & DEBUG_ERROR)
printf("ipf_p_ftp_eprt6:inc(%d) + ip->ip_len > 65535\n", printf("ipf_p_ftp_eprt6:inc(%d) + ip->ip_len > 65535\n",
inc); inc);
return 0; return(0);
} }
off = (char *)tcp - (char *)ip + (TCP_OFF(tcp) << 2) + fin->fin_ipoff; off = (char *)tcp - (char *)ip + (TCP_OFF(tcp) << 2) + fin->fin_ipoff;
@ -2049,6 +2049,6 @@ ipf_p_ftp_eprt6(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat,
} }
f->ftps_cmd = FTPXY_C_EPRT; f->ftps_cmd = FTPXY_C_EPRT;
return ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, port, inc); return(ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, port, inc));
} }
#endif #endif

View File

@ -141,12 +141,12 @@ ipf_htable_soft_create(ipf_main_softc_t *softc)
KMALLOC(softh, ipf_htable_softc_t *); KMALLOC(softh, ipf_htable_softc_t *);
if (softh == NULL) { if (softh == NULL) {
IPFERROR(30026); IPFERROR(30026);
return NULL; return(NULL);
} }
bzero((char *)softh, sizeof(*softh)); bzero((char *)softh, sizeof(*softh));
return softh; return(softh);
} }
@ -185,7 +185,7 @@ ipf_htable_soft_init(softc, arg)
bzero((char *)softh, sizeof(*softh)); bzero((char *)softh, sizeof(*softh));
return 0; return(0);
} }
@ -233,7 +233,7 @@ ipf_htable_stats_get(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
if (op->iplo_size != sizeof(stats)) { if (op->iplo_size != sizeof(stats)) {
IPFERROR(30001); IPFERROR(30001);
return EINVAL; return(EINVAL);
} }
stats.iphs_tables = softh->ipf_htables[op->iplo_unit + 1]; stats.iphs_tables = softh->ipf_htables[op->iplo_unit + 1];
@ -244,9 +244,9 @@ ipf_htable_stats_get(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
err = COPYOUT(&stats, op->iplo_struct, sizeof(stats)); err = COPYOUT(&stats, op->iplo_struct, sizeof(stats));
if (err != 0) { if (err != 0) {
IPFERROR(30013); IPFERROR(30013);
return EFAULT; return(EFAULT);
} }
return 0; return(0);
} }
@ -270,22 +270,22 @@ ipf_htable_create(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
if (op->iplo_size != sizeof(htab)) { if (op->iplo_size != sizeof(htab)) {
IPFERROR(30024); IPFERROR(30024);
return EINVAL; return(EINVAL);
} }
err = COPYIN(op->iplo_struct, &htab, sizeof(htab)); err = COPYIN(op->iplo_struct, &htab, sizeof(htab));
if (err != 0) { if (err != 0) {
IPFERROR(30003); IPFERROR(30003);
return EFAULT; return(EFAULT);
} }
unit = op->iplo_unit; unit = op->iplo_unit;
if (htab.iph_unit != unit) { if (htab.iph_unit != unit) {
IPFERROR(30005); IPFERROR(30005);
return EINVAL; return(EINVAL);
} }
if (htab.iph_size < 1) { if (htab.iph_size < 1) {
IPFERROR(30025); IPFERROR(30025);
return EINVAL; return(EINVAL);
} }
@ -294,11 +294,11 @@ ipf_htable_create(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
if (iph != NULL) { if (iph != NULL) {
if ((iph->iph_flags & IPHASH_DELETE) == 0) { if ((iph->iph_flags & IPHASH_DELETE) == 0) {
IPFERROR(30004); IPFERROR(30004);
return EEXIST; return(EEXIST);
} }
iph->iph_flags &= ~IPHASH_DELETE; iph->iph_flags &= ~IPHASH_DELETE;
iph->iph_ref++; iph->iph_ref++;
return 0; return(0);
} }
} }
@ -306,7 +306,7 @@ ipf_htable_create(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
if (iph == NULL) { if (iph == NULL) {
softh->ipht_nomem[op->iplo_unit + 1]++; softh->ipht_nomem[op->iplo_unit + 1]++;
IPFERROR(30002); IPFERROR(30002);
return ENOMEM; return(ENOMEM);
} }
*iph = htab; *iph = htab;
@ -337,7 +337,7 @@ ipf_htable_create(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
KFREE(iph); KFREE(iph);
softh->ipht_nomem[unit + 1]++; softh->ipht_nomem[unit + 1]++;
IPFERROR(30006); IPFERROR(30006);
return ENOMEM; return(ENOMEM);
} }
bzero((char *)iph->iph_table, iph->iph_size * sizeof(*iph->iph_table)); bzero((char *)iph->iph_table, iph->iph_size * sizeof(*iph->iph_table));
@ -357,7 +357,7 @@ ipf_htable_create(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
softh->ipf_nhtables[unit + 1]++; softh->ipf_nhtables[unit + 1]++;
return 0; return(0);
} }
@ -372,7 +372,7 @@ ipf_htable_create(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
static int static int
ipf_htable_table_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op) ipf_htable_table_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
{ {
return ipf_htable_destroy(softc, arg, op->iplo_unit, op->iplo_name); return(ipf_htable_destroy(softc, arg, op->iplo_unit, op->iplo_name));
} }
@ -396,23 +396,23 @@ ipf_htable_destroy(ipf_main_softc_t *softc, void *arg, int unit, char *name)
iph = ipf_htable_find(arg, unit, name); iph = ipf_htable_find(arg, unit, name);
if (iph == NULL) { if (iph == NULL) {
IPFERROR(30007); IPFERROR(30007);
return ESRCH; return(ESRCH);
} }
if (iph->iph_unit != unit) { if (iph->iph_unit != unit) {
IPFERROR(30008); IPFERROR(30008);
return EINVAL; return(EINVAL);
} }
if (iph->iph_ref != 0) { if (iph->iph_ref != 0) {
ipf_htable_clear(softc, arg, iph); ipf_htable_clear(softc, arg, iph);
iph->iph_flags |= IPHASH_DELETE; iph->iph_flags |= IPHASH_DELETE;
return 0; return(0);
} }
ipf_htable_remove(softc, arg, iph); ipf_htable_remove(softc, arg, iph);
return 0; return(0);
} }
@ -433,8 +433,8 @@ ipf_htable_clear(ipf_main_softc_t *softc, void *arg, iphtable_t *iph)
while ((ipe = iph->iph_list) != NULL) while ((ipe = iph->iph_list) != NULL)
if (ipf_htent_remove(softc, arg, iph, ipe) != 0) if (ipf_htent_remove(softc, arg, iph, ipe) != 0)
return 1; return(1);
return 0; return(0);
} }
@ -479,7 +479,7 @@ ipf_htable_remove(ipf_main_softc_t *softc, void *arg, iphtable_t *iph)
{ {
if (ipf_htable_clear(softc, arg, iph) != 0) if (ipf_htable_clear(softc, arg, iph) != 0)
return 1; return(1);
if (iph->iph_pnext != NULL) if (iph->iph_pnext != NULL)
*iph->iph_pnext = iph->iph_next; *iph->iph_pnext = iph->iph_next;
@ -488,7 +488,7 @@ ipf_htable_remove(ipf_main_softc_t *softc, void *arg, iphtable_t *iph)
iph->iph_pnext = NULL; iph->iph_pnext = NULL;
iph->iph_next = NULL; iph->iph_next = NULL;
return ipf_htable_deref(softc, arg, iph); return(ipf_htable_deref(softc, arg, iph));
} }
@ -511,35 +511,35 @@ ipf_htable_node_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
if (op->iplo_size != sizeof(hte)) { if (op->iplo_size != sizeof(hte)) {
IPFERROR(30014); IPFERROR(30014);
return EINVAL; return(EINVAL);
} }
err = COPYIN(op->iplo_struct, &hte, sizeof(hte)); err = COPYIN(op->iplo_struct, &hte, sizeof(hte));
if (err != 0) { if (err != 0) {
IPFERROR(30015); IPFERROR(30015);
return EFAULT; return(EFAULT);
} }
iph = ipf_htable_find(arg, op->iplo_unit, op->iplo_name); iph = ipf_htable_find(arg, op->iplo_unit, op->iplo_name);
if (iph == NULL) { if (iph == NULL) {
IPFERROR(30016); IPFERROR(30016);
return ESRCH; return(ESRCH);
} }
ent = ipf_htent_find(iph, &hte); ent = ipf_htent_find(iph, &hte);
if (ent == NULL) { if (ent == NULL) {
IPFERROR(30022); IPFERROR(30022);
return ESRCH; return(ESRCH);
} }
if ((uid != 0) && (ent->ipe_uid != uid)) { if ((uid != 0) && (ent->ipe_uid != uid)) {
IPFERROR(30023); IPFERROR(30023);
return EACCES; return(EACCES);
} }
err = ipf_htent_remove(softc, arg, iph, ent); err = ipf_htent_remove(softc, arg, iph, ent);
return err; return(err);
} }
@ -563,7 +563,7 @@ ipf_htable_table_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
err = ipf_htable_create(softc, arg, op); err = ipf_htable_create(softc, arg, op);
} }
return err; return(err);
} }
@ -619,7 +619,7 @@ ipf_htent_remove(ipf_main_softc_t *softc, void *arg, iphtable_t *iph,
break; break;
} }
return ipf_htent_deref(arg, ipe); return(ipf_htent_deref(arg, ipe));
} }
@ -645,7 +645,7 @@ ipf_htable_deref(ipf_main_softc_t *softc, void *arg, void *object)
ipf_htable_free(softh, iph); ipf_htable_free(softh, iph);
} }
return refs; return(refs);
} }
@ -665,10 +665,10 @@ ipf_htent_deref(void *arg, iphtent_t *ipe)
softh->ipf_nhtnodes[ipe->ipe_unit + 1]--; softh->ipf_nhtnodes[ipe->ipe_unit + 1]--;
KFREE(ipe); KFREE(ipe);
return 0; return(0);
} }
return ipe->ipe_ref; return(ipe->ipe_ref);
} }
@ -704,7 +704,7 @@ ipf_htable_exists(void *arg, int unit, char *name)
break; break;
} }
} }
return iph; return(iph);
} }
@ -725,7 +725,7 @@ ipf_htable_select_add_ref(void *arg, int unit, char *name)
if (iph != NULL) { if (iph != NULL) {
ATOMIC_INC32(iph->iph_ref); ATOMIC_INC32(iph->iph_ref);
} }
return iph; return(iph);
} }
@ -745,9 +745,9 @@ ipf_htable_find(void *arg, int unit, char *name)
iph = ipf_htable_exists(arg, unit, name); iph = ipf_htable_exists(arg, unit, name);
if ((iph != NULL) && (iph->iph_flags & IPHASH_DELETE) == 0) if ((iph != NULL) && (iph->iph_flags & IPHASH_DELETE) == 0)
return iph; return(iph);
return NULL; return(NULL);
} }
@ -781,7 +781,7 @@ ipf_htable_flush(ipf_main_softc_t *softc, void *arg, iplookupflush_t *op)
} }
} }
return freed; return(freed);
} }
@ -804,30 +804,30 @@ ipf_htable_node_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
if (op->iplo_size != sizeof(hte)) { if (op->iplo_size != sizeof(hte)) {
IPFERROR(30018); IPFERROR(30018);
return EINVAL; return(EINVAL);
} }
err = COPYIN(op->iplo_struct, &hte, sizeof(hte)); err = COPYIN(op->iplo_struct, &hte, sizeof(hte));
if (err != 0) { if (err != 0) {
IPFERROR(30019); IPFERROR(30019);
return EFAULT; return(EFAULT);
} }
hte.ipe_uid = uid; hte.ipe_uid = uid;
iph = ipf_htable_find(arg, op->iplo_unit, op->iplo_name); iph = ipf_htable_find(arg, op->iplo_unit, op->iplo_name);
if (iph == NULL) { if (iph == NULL) {
IPFERROR(30020); IPFERROR(30020);
return ESRCH; return(ESRCH);
} }
if (ipf_htent_find(iph, &hte) != NULL) { if (ipf_htent_find(iph, &hte) != NULL) {
IPFERROR(30021); IPFERROR(30021);
return EEXIST; return(EEXIST);
} }
err = ipf_htent_insert(softc, arg, iph, &hte); err = ipf_htent_insert(softc, arg, iph, &hte);
return err; return(err);
} }
@ -852,7 +852,7 @@ ipf_htent_insert(ipf_main_softc_t *softc, void *arg, iphtable_t *iph,
KMALLOC(ipe, iphtent_t *); KMALLOC(ipe, iphtent_t *);
if (ipe == NULL) if (ipe == NULL)
return -1; return(-1);
bcopy((char *)ipeo, (char *)ipe, sizeof(*ipe)); bcopy((char *)ipeo, (char *)ipe, sizeof(*ipe));
ipe->ipe_addr.i6[0] &= ipe->ipe_mask.i6[0]; ipe->ipe_addr.i6[0] &= ipe->ipe_mask.i6[0];
@ -880,7 +880,7 @@ ipf_htent_insert(ipf_main_softc_t *softc, void *arg, iphtable_t *iph,
#endif #endif
{ {
KFREE(ipe); KFREE(ipe);
return -1; return(-1);
} }
ipe->ipe_owner = iph; ipe->ipe_owner = iph;
@ -960,7 +960,7 @@ ipf_htent_insert(ipf_main_softc_t *softc, void *arg, iphtable_t *iph,
ipe->ipe_unit = iph->iph_unit; ipe->ipe_unit = iph->iph_unit;
softh->ipf_nhtnodes[ipe->ipe_unit + 1]++; softh->ipf_nhtnodes[ipe->ipe_unit + 1]++;
return 0; return(0);
} }
@ -1004,7 +1004,7 @@ ipf_htent_find(iphtable_t *iph, iphtent_t *ipeo)
ipe.ipe_mask.i6, iph->iph_size); ipe.ipe_mask.i6, iph->iph_size);
} else } else
#endif #endif
return NULL; return(NULL);
for (ent = iph->iph_table[hv]; ent != NULL; ent = ent->ipe_hnext) { for (ent = iph->iph_table[hv]; ent != NULL; ent = ent->ipe_hnext) {
if (ent->ipe_family != ipe.ipe_family) if (ent->ipe_family != ipe.ipe_family)
@ -1016,7 +1016,7 @@ ipf_htent_find(iphtable_t *iph, iphtent_t *ipeo)
break; break;
} }
return ent; return(ent);
} }
@ -1050,7 +1050,7 @@ ipf_iphmfindgroup(ipf_main_softc_t *softc, void *tptr, void *aptr)
else else
rval = NULL; rval = NULL;
RWLOCK_EXIT(&softc->ipf_poolrw); RWLOCK_EXIT(&softc->ipf_poolrw);
return rval; return(rval);
} }
@ -1075,7 +1075,7 @@ ipf_iphmfindip(ipf_main_softc_t *softc, void *tptr, int ipversion, void *aptr,
int rval; int rval;
if (tptr == NULL || aptr == NULL) if (tptr == NULL || aptr == NULL)
return -1; return(-1);
iph = tptr; iph = tptr;
addr = aptr; addr = aptr;
@ -1099,7 +1099,7 @@ ipf_iphmfindip(ipf_main_softc_t *softc, void *tptr, int ipversion, void *aptr,
rval = 1; rval = 1;
} }
RWLOCK_EXIT(&softc->ipf_poolrw); RWLOCK_EXIT(&softc->ipf_poolrw);
return rval; return(rval);
} }
@ -1137,7 +1137,7 @@ ipf_iphmfind(iphtable_t *iph, struct in_addr *addr)
if (i < iph->iph_v4_masks.imt4_max) if (i < iph->iph_v4_masks.imt4_max)
goto maskloop; goto maskloop;
} }
return ipe; return(ipe);
} }
@ -1224,7 +1224,7 @@ ipf_htable_iter_next(ipf_main_softc_t *softc, void *arg, ipftoken_t *token,
RWLOCK_EXIT(&softc->ipf_poolrw); RWLOCK_EXIT(&softc->ipf_poolrw);
if (err != 0) if (err != 0)
return err; return(err);
switch (ilp->ili_otype) switch (ilp->ili_otype)
{ {
@ -1258,7 +1258,7 @@ ipf_htable_iter_next(ipf_main_softc_t *softc, void *arg, ipftoken_t *token,
if (hnext == NULL) if (hnext == NULL)
ipf_token_mark_complete(token); ipf_token_mark_complete(token);
return err; return(err);
} }
@ -1278,10 +1278,10 @@ ipf_htable_iter_deref(ipf_main_softc_t *softc, void *arg, int otype, int unit,
{ {
if (data == NULL) if (data == NULL)
return EFAULT; return(EFAULT);
if (unit < -1 || unit > IPL_LOGMAX) if (unit < -1 || unit > IPL_LOGMAX)
return EINVAL; return(EINVAL);
switch (otype) switch (otype)
{ {
@ -1296,7 +1296,7 @@ ipf_htable_iter_deref(ipf_main_softc_t *softc, void *arg, int otype, int unit,
break; break;
} }
return 0; return(0);
} }
@ -1338,7 +1338,7 @@ ipf_iphmfind6(iphtable_t *iph, i6addr_t *addr)
if (i < iph->iph_v6_masks.imt6_max) if (i < iph->iph_v6_masks.imt6_max)
goto maskloop; goto maskloop;
} }
return ipe; return(ipe);
} }
#endif #endif

View File

@ -47,7 +47,7 @@ ipf_p_ipsec_soft_create(ipf_main_softc_t *softc)
KMALLOC(softi, ipf_ipsec_softc_t *); KMALLOC(softi, ipf_ipsec_softc_t *);
if (softi == NULL) if (softi == NULL)
return NULL; return(NULL);
bzero((char *)softi, sizeof(*softi)); bzero((char *)softi, sizeof(*softi));
softi->ipsec_fr.fr_ref = 1; softi->ipsec_fr.fr_ref = 1;
@ -56,7 +56,7 @@ ipf_p_ipsec_soft_create(ipf_main_softc_t *softc)
softi->ipsec_proxy_init = 1; softi->ipsec_proxy_init = 1;
softi->ipsec_proxy_ttl = 60; softi->ipsec_proxy_ttl = 60;
return softi; return(softi);
} }
@ -67,20 +67,20 @@ ipf_p_ipsec_soft_init(ipf_main_softc_t *softc, void *arg)
softi->ipsec_nat_tqe = ipf_state_add_tq(softc, softi->ipsec_proxy_ttl); softi->ipsec_nat_tqe = ipf_state_add_tq(softc, softi->ipsec_proxy_ttl);
if (softi->ipsec_nat_tqe == NULL) if (softi->ipsec_nat_tqe == NULL)
return -1; return(-1);
softi->ipsec_state_tqe = ipf_nat_add_tq(softc, softi->ipsec_proxy_ttl); softi->ipsec_state_tqe = ipf_nat_add_tq(softc, softi->ipsec_proxy_ttl);
if (softi->ipsec_state_tqe == NULL) { if (softi->ipsec_state_tqe == NULL) {
if (ipf_deletetimeoutqueue(softi->ipsec_nat_tqe) == 0) if (ipf_deletetimeoutqueue(softi->ipsec_nat_tqe) == 0)
ipf_freetimeoutqueue(softc, softi->ipsec_nat_tqe); ipf_freetimeoutqueue(softc, softi->ipsec_nat_tqe);
softi->ipsec_nat_tqe = NULL; softi->ipsec_nat_tqe = NULL;
return -1; return(-1);
} }
softi->ipsec_nat_tqe->ifq_flags |= IFQF_PROXY; softi->ipsec_nat_tqe->ifq_flags |= IFQF_PROXY;
softi->ipsec_state_tqe->ifq_flags |= IFQF_PROXY; softi->ipsec_state_tqe->ifq_flags |= IFQF_PROXY;
softi->ipsec_fr.fr_age[0] = softi->ipsec_proxy_ttl; softi->ipsec_fr.fr_age[0] = softi->ipsec_proxy_ttl;
softi->ipsec_fr.fr_age[1] = softi->ipsec_proxy_ttl; softi->ipsec_fr.fr_age[1] = softi->ipsec_proxy_ttl;
return 0; return(0);
} }
@ -140,7 +140,7 @@ ipf_p_ipsec_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
mb_t *m; mb_t *m;
if (fin->fin_v != 4) if (fin->fin_v != 4)
return -1; return(-1);
off = fin->fin_plen - fin->fin_dlen + fin->fin_ipoff; off = fin->fin_plen - fin->fin_dlen + fin->fin_ipoff;
bzero(softi->ipsec_buffer, sizeof(softi->ipsec_buffer)); bzero(softi->ipsec_buffer, sizeof(softi->ipsec_buffer));
@ -149,24 +149,24 @@ ipf_p_ipsec_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
dlen = M_LEN(m) - off; dlen = M_LEN(m) - off;
if (dlen < 16) if (dlen < 16)
return -1; return(-1);
COPYDATA(m, off, MIN(sizeof(softi->ipsec_buffer), dlen), COPYDATA(m, off, MIN(sizeof(softi->ipsec_buffer), dlen),
softi->ipsec_buffer); softi->ipsec_buffer);
if (ipf_nat_outlookup(fin, 0, IPPROTO_ESP, nat->nat_nsrcip, if (ipf_nat_outlookup(fin, 0, IPPROTO_ESP, nat->nat_nsrcip,
ip->ip_dst) != NULL) ip->ip_dst) != NULL)
return -1; return(-1);
np = nat->nat_ptr; np = nat->nat_ptr;
size = np->in_size; size = np->in_size;
KMALLOC(ipsec, ipsec_pxy_t *); KMALLOC(ipsec, ipsec_pxy_t *);
if (ipsec == NULL) if (ipsec == NULL)
return -1; return(-1);
KMALLOCS(ipn, ipnat_t *, size); KMALLOCS(ipn, ipnat_t *, size);
if (ipn == NULL) { if (ipn == NULL) {
KFREE(ipsec); KFREE(ipsec);
return -1; return(-1);
} }
aps->aps_data = ipsec; aps->aps_data = ipsec;
@ -246,7 +246,7 @@ ipf_p_ipsec_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
(void) ipf_state_add(softc, &fi, &ipsec->ipsc_state, SI_WILDP); (void) ipf_state_add(softc, &fi, &ipsec->ipsc_state, SI_WILDP);
} }
ip->ip_p = p & 0xff; ip->ip_p = p & 0xff;
return 0; return(0);
} }
@ -265,10 +265,10 @@ ipf_p_ipsec_inout(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
int p; int p;
if ((fin->fin_out == 1) && (nat->nat_dir == NAT_INBOUND)) if ((fin->fin_out == 1) && (nat->nat_dir == NAT_INBOUND))
return 0; return(0);
if ((fin->fin_out == 0) && (nat->nat_dir == NAT_OUTBOUND)) if ((fin->fin_out == 0) && (nat->nat_dir == NAT_OUTBOUND))
return 0; return(0);
ipsec = aps->aps_data; ipsec = aps->aps_data;
@ -330,7 +330,7 @@ ipf_p_ipsec_inout(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
} }
ip->ip_p = p; ip->ip_p = p;
} }
return 0; return(0);
} }
@ -351,7 +351,7 @@ ipf_p_ipsec_match(fr_info_t *fin, ap_session_t *aps, nat_t *nat)
nat = nat; /* LINT */ nat = nat; /* LINT */
if ((fin->fin_dlen < sizeof(cookies)) || (fin->fin_flx & FI_FRAG)) if ((fin->fin_dlen < sizeof(cookies)) || (fin->fin_flx & FI_FRAG))
return -1; return(-1);
off = fin->fin_plen - fin->fin_dlen + fin->fin_ipoff; off = fin->fin_plen - fin->fin_dlen + fin->fin_ipoff;
ipsec = aps->aps_data; ipsec = aps->aps_data;
@ -360,22 +360,22 @@ ipf_p_ipsec_match(fr_info_t *fin, ap_session_t *aps, nat_t *nat)
if ((cookies[0] != ipsec->ipsc_icookie[0]) || if ((cookies[0] != ipsec->ipsc_icookie[0]) ||
(cookies[1] != ipsec->ipsc_icookie[1])) (cookies[1] != ipsec->ipsc_icookie[1]))
return -1; return(-1);
if (ipsec->ipsc_rckset == 0) { if (ipsec->ipsc_rckset == 0) {
if ((cookies[2]|cookies[3]) == 0) { if ((cookies[2]|cookies[3]) == 0) {
return 0; return(0);
} }
ipsec->ipsc_rckset = 1; ipsec->ipsc_rckset = 1;
ipsec->ipsc_rcookie[0] = cookies[2]; ipsec->ipsc_rcookie[0] = cookies[2];
ipsec->ipsc_rcookie[1] = cookies[3]; ipsec->ipsc_rcookie[1] = cookies[3];
return 0; return(0);
} }
if ((cookies[2] != ipsec->ipsc_rcookie[0]) || if ((cookies[2] != ipsec->ipsc_rcookie[0]) ||
(cookies[3] != ipsec->ipsc_rcookie[1])) (cookies[3] != ipsec->ipsc_rcookie[1]))
return -1; return(-1);
return 0; return(0);
} }

View File

@ -76,13 +76,13 @@ ipf_p_irc_complete(ircinfo_t *ircp, char *buf, size_t len)
ircp->irc_port = 0; ircp->irc_port = 0;
if (len < 31) if (len < 31)
return 0; return(0);
s = buf; s = buf;
c = *s++; c = *s++;
i = len - 1; i = len - 1;
if ((c != ':') && (c != 'P')) if ((c != ':') && (c != 'P'))
return 0; return(0);
if (c == ':') { if (c == ':') {
/* /*
@ -92,14 +92,14 @@ ipf_p_irc_complete(ircinfo_t *ircp, char *buf, size_t len)
c = *s; c = *s;
ircp->irc_snick = s; ircp->irc_snick = s;
if (!ISALPHA(c)) if (!ISALPHA(c))
return 0; return(0);
i--; i--;
for (c = *s; !ISSPACE(c) && (i > 0); i--) for (c = *s; !ISSPACE(c) && (i > 0); i--)
c = *s++; c = *s++;
if (i < 31) if (i < 31)
return 0; return(0);
if (c != 'P') if (c != 'P')
return 0; return(0);
} else } else
ircp->irc_snick = NULL; ircp->irc_snick = NULL;
@ -107,7 +107,7 @@ ipf_p_irc_complete(ircinfo_t *ircp, char *buf, size_t len)
* Check command string * Check command string
*/ */
if (strncmp(s, "PRIVMSG ", 8)) if (strncmp(s, "PRIVMSG ", 8))
return 0; return(0);
i -= 8; i -= 8;
s += 8; s += 8;
c = *s; c = *s;
@ -117,11 +117,11 @@ ipf_p_irc_complete(ircinfo_t *ircp, char *buf, size_t len)
* Loosely check that the destination is a nickname of some sort * Loosely check that the destination is a nickname of some sort
*/ */
if (!ISALPHA(c)) if (!ISALPHA(c))
return 0; return(0);
for (; !ISSPACE(c) && (i > 0); i--) for (; !ISSPACE(c) && (i > 0); i--)
c = *s++; c = *s++;
if (i < 20) if (i < 20)
return 0; return(0);
s++, s++,
i--; i--;
@ -135,7 +135,7 @@ ipf_p_irc_complete(ircinfo_t *ircp, char *buf, size_t len)
} }
if (strncmp(s, "\001DCC ", 4)) if (strncmp(s, "\001DCC ", 4))
return 0; return(0);
i -= 4; i -= 4;
s += 4; s += 4;
@ -149,36 +149,36 @@ ipf_p_irc_complete(ircinfo_t *ircp, char *buf, size_t len)
break; break;
} }
if (!ipf_p_irc_dcctypes[j]) if (!ipf_p_irc_dcctypes[j])
return 0; return(0);
ircp->irc_type = s; ircp->irc_type = s;
i -= k; i -= k;
s += k; s += k;
if (i < 11) if (i < 11)
return 0; return(0);
/* /*
* Check for the arg * Check for the arg
*/ */
c = *s; c = *s;
if (ISSPACE(c)) if (ISSPACE(c))
return 0; return(0);
ircp->irc_arg = s; ircp->irc_arg = s;
for (; (c != ' ') && (c != '\001') && (i > 0); i--) for (; (c != ' ') && (c != '\001') && (i > 0); i--)
c = *s++; c = *s++;
if (c == '\001') /* In reality a ^A can quote another ^A...*/ if (c == '\001') /* In reality a ^A can quote another ^A...*/
return 0; return(0);
if (i < 5) if (i < 5)
return 0; return(0);
s++; s++;
i--; i--;
c = *s; c = *s;
if (!ISDIGIT(c)) if (!ISDIGIT(c))
return 0; return(0);
ircp->irc_addr = s; ircp->irc_addr = s;
/* /*
* Get the IP# * Get the IP#
@ -190,17 +190,17 @@ ipf_p_irc_complete(ircinfo_t *ircp, char *buf, size_t len)
} }
if (i < 4) if (i < 4)
return 0; return(0);
if (c != ' ') if (c != ' ')
return 0; return(0);
ircp->irc_ipnum = l; ircp->irc_ipnum = l;
s++; s++;
i--; i--;
c = *s; c = *s;
if (!ISDIGIT(c)) if (!ISDIGIT(c))
return 0; return(0);
/* /*
* Get the port# * Get the port#
*/ */
@ -210,13 +210,13 @@ ipf_p_irc_complete(ircinfo_t *ircp, char *buf, size_t len)
c = *s++; c = *s++;
} }
if (i < 3) if (i < 3)
return 0; return(0);
if (strncmp(s, "\001\r\n", 3)) if (strncmp(s, "\001\r\n", 3))
return 0; return(0);
s += 3; s += 3;
ircp->irc_len = s - buf; ircp->irc_len = s - buf;
ircp->irc_port = l; ircp->irc_port = l;
return 1; return(1);
} }
@ -226,11 +226,11 @@ ipf_p_irc_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ircinfo_t *irc; ircinfo_t *irc;
if (fin->fin_v != 4) if (fin->fin_v != 4)
return -1; return(-1);
KMALLOC(irc, ircinfo_t *); KMALLOC(irc, ircinfo_t *);
if (irc == NULL) if (irc == NULL)
return -1; return(-1);
nat = nat; /* LINT */ nat = nat; /* LINT */
@ -238,7 +238,7 @@ ipf_p_irc_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
aps->aps_psiz = sizeof(ircinfo_t); aps->aps_psiz = sizeof(ircinfo_t);
bzero((char *)irc, sizeof(*irc)); bzero((char *)irc, sizeof(*irc));
return 0; return(0);
} }
@ -271,24 +271,24 @@ ipf_p_irc_send(fr_info_t *fin, nat_t *nat)
dlen = MSGDSIZE(m) - off; dlen = MSGDSIZE(m) - off;
if (dlen <= 0) if (dlen <= 0)
return 0; return(0);
COPYDATA(m, off, MIN(sizeof(ctcpbuf), dlen), ctcpbuf); COPYDATA(m, off, MIN(sizeof(ctcpbuf), dlen), ctcpbuf);
if (dlen <= 0) if (dlen <= 0)
return 0; return(0);
ctcpbuf[sizeof(ctcpbuf) - 1] = '\0'; ctcpbuf[sizeof(ctcpbuf) - 1] = '\0';
*newbuf = '\0'; *newbuf = '\0';
irc = nat->nat_aps->aps_data; irc = nat->nat_aps->aps_data;
if (ipf_p_irc_complete(irc, ctcpbuf, dlen) == 0) if (ipf_p_irc_complete(irc, ctcpbuf, dlen) == 0)
return 0; return(0);
/* /*
* check that IP address in the DCC reply is the same as the * check that IP address in the DCC reply is the same as the
* sender of the command - prevents use for port scanning. * sender of the command - prevents use for port scanning.
*/ */
if (irc->irc_ipnum != ntohl(nat->nat_osrcaddr)) if (irc->irc_ipnum != ntohl(nat->nat_osrcaddr))
return 0; return(0);
a5 = irc->irc_port; a5 = irc->irc_port;
@ -307,7 +307,7 @@ ipf_p_irc_send(fr_info_t *fin, nat_t *nat)
inc = nlen - olen; inc = nlen - olen;
if ((inc + fin->fin_plen) > 65535) if ((inc + fin->fin_plen) > 65535)
return 0; return(0);
#if SOLARIS #if SOLARIS
for (m1 = m; m1->b_cont; m1 = m1->b_cont) for (m1 = m; m1->b_cont; m1 = m1->b_cont)
@ -373,7 +373,7 @@ ipf_p_irc_send(fr_info_t *fin, nat_t *nat)
* security crap. * security crap.
*/ */
if (ntohs(sp) < 1024) if (ntohs(sp) < 1024)
return 0; return(0);
/* /*
* The server may not make the connection back from port 20, but * The server may not make the connection back from port 20, but
@ -417,7 +417,7 @@ ipf_p_irc_send(fr_info_t *fin, nat_t *nat)
} }
ip->ip_src = swip; ip->ip_src = swip;
} }
return inc; return(inc);
} }
@ -425,5 +425,5 @@ int
ipf_p_irc_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat) ipf_p_irc_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
{ {
aps = aps; /* LINT */ aps = aps; /* LINT */
return ipf_p_irc_send(fin, nat); return(ipf_p_irc_send(fin, nat));
} }

View File

@ -165,14 +165,14 @@ static ipftuneable_t ipf_log_tuneables[] = {
int int
ipf_log_main_load(void) ipf_log_main_load(void)
{ {
return 0; return(0);
} }
int int
ipf_log_main_unload(void) ipf_log_main_unload(void)
{ {
return 0; return(0);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -191,7 +191,7 @@ ipf_log_soft_create(ipf_main_softc_t *softc)
KMALLOC(softl, ipf_log_softc_t *); KMALLOC(softl, ipf_log_softc_t *);
if (softl == NULL) if (softl == NULL)
return NULL; return(NULL);
bzero((char *)softl, sizeof(*softl)); bzero((char *)softl, sizeof(*softl));
bcopy((char *)magic, (char *)softl->ipl_magic, sizeof(magic)); bcopy((char *)magic, (char *)softl->ipl_magic, sizeof(magic));
@ -201,11 +201,11 @@ ipf_log_soft_create(ipf_main_softc_t *softc)
ipf_log_tuneables); ipf_log_tuneables);
if (softl->ipf_log_tune == NULL) { if (softl->ipf_log_tune == NULL) {
ipf_log_soft_destroy(softc, softl); ipf_log_soft_destroy(softc, softl);
return NULL; return(NULL);
} }
if (ipf_tune_array_link(softc, softl->ipf_log_tune) == -1) { if (ipf_tune_array_link(softc, softl->ipf_log_tune) == -1) {
ipf_log_soft_destroy(softc, softl); ipf_log_soft_destroy(softc, softl);
return NULL; return(NULL);
} }
for (i = IPL_LOGMAX; i >= 0; i--) { for (i = IPL_LOGMAX; i >= 0; i--) {
@ -217,7 +217,7 @@ ipf_log_soft_create(ipf_main_softc_t *softc)
softl->ipl_log_init = 0; softl->ipl_log_init = 0;
softl->ipl_logsize = IPFILTER_LOGSIZE; softl->ipl_logsize = IPFILTER_LOGSIZE;
return softl; return(softl);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -248,7 +248,7 @@ ipf_log_soft_init(ipf_main_softc_t *softc, void *arg)
softl->ipl_log_init = 1; softl->ipl_log_init = 1;
return 0; return(0);
} }
@ -266,7 +266,7 @@ ipf_log_soft_fini(ipf_main_softc_t *softc, void *arg)
int i; int i;
if (softl->ipl_log_init == 0) if (softl->ipl_log_init == 0)
return 0; return(0);
softl->ipl_log_init = 0; softl->ipl_log_init = 0;
@ -294,7 +294,7 @@ ipf_log_soft_fini(ipf_main_softc_t *softc, void *arg)
MUTEX_EXIT(&softl->ipl_mutex[i]); MUTEX_EXIT(&softl->ipl_mutex[i]);
} }
return 0; return(0);
} }
@ -361,7 +361,7 @@ ipf_log_pkt(fr_info_t *fin, u_int flags)
m = fin->fin_m; m = fin->fin_m;
if (m == NULL) if (m == NULL)
return -1; return(-1);
ipfl.fl_nattag.ipt_num[0] = 0; ipfl.fl_nattag.ipt_num[0] = 0;
ifp = fin->fin_ifp; ifp = fin->fin_ifp;
@ -497,7 +497,7 @@ ipf_log_pkt(fr_info_t *fin, u_int flags)
sizes[1] = hlen + mlen; sizes[1] = hlen + mlen;
types[1] = 1; types[1] = 1;
# endif /* SOLARIS */ # endif /* SOLARIS */
return ipf_log_items(softc, IPL_LOGIPF, fin, ptrs, sizes, types, 2); return(ipf_log_items(softc, IPL_LOGIPF, fin, ptrs, sizes, types, 2));
} }
@ -543,14 +543,14 @@ ipf_log_items(ipf_main_softc_t *softc, int unit, fr_info_t *fin, void **items,
if ((softl->ipl_used[unit] + len) > softl->ipl_logsize) { if ((softl->ipl_used[unit] + len) > softl->ipl_logsize) {
softl->ipl_logfail[unit]++; softl->ipl_logfail[unit]++;
MUTEX_EXIT(&softl->ipl_mutex[unit]); MUTEX_EXIT(&softl->ipl_mutex[unit]);
return -1; return(-1);
} }
KMALLOCS(buf, caddr_t, len); KMALLOCS(buf, caddr_t, len);
if (buf == NULL) { if (buf == NULL) {
softl->ipl_logfail[unit]++; softl->ipl_logfail[unit]++;
MUTEX_EXIT(&softl->ipl_mutex[unit]); MUTEX_EXIT(&softl->ipl_mutex[unit]);
return -1; return(-1);
} }
ipl = (iplog_t *)buf; ipl = (iplog_t *)buf;
ipl->ipl_magic = softl->ipl_magic[unit]; ipl->ipl_magic = softl->ipl_magic[unit];
@ -592,7 +592,7 @@ ipf_log_items(ipf_main_softc_t *softc, int unit, fr_info_t *fin, void **items,
MUTEX_EXIT(&softl->ipl_mutex[unit]); MUTEX_EXIT(&softl->ipl_mutex[unit]);
SPL_X(s); SPL_X(s);
KFREES(buf, len); KFREES(buf, len);
return 0; return(0);
} }
bcopy((char *)fin, (char *)&softl->ipl_crc[unit], bcopy((char *)fin, (char *)&softl->ipl_crc[unit],
FI_LCSIZE); FI_LCSIZE);
@ -628,7 +628,7 @@ ipf_log_items(ipf_main_softc_t *softc, int unit, fr_info_t *fin, void **items,
# ifdef IPL_SELECT # ifdef IPL_SELECT
iplog_input_ready(unit); iplog_input_ready(unit);
# endif # endif
return 0; return(0);
} }
@ -656,7 +656,7 @@ ipf_log_read(ipf_main_softc_t *softc, minor_t unit, struct uio *uio)
if (softl->ipl_log_init == 0) { if (softl->ipl_log_init == 0) {
IPFERROR(40007); IPFERROR(40007);
return 0; return(0);
} }
/* /*
@ -665,18 +665,18 @@ ipf_log_read(ipf_main_softc_t *softc, minor_t unit, struct uio *uio)
*/ */
if (IPL_LOGMAX < unit) { if (IPL_LOGMAX < unit) {
IPFERROR(40001); IPFERROR(40001);
return ENXIO; return(ENXIO);
} }
if (uio->uio_resid == 0) if (uio->uio_resid == 0)
return 0; return(0);
if (uio->uio_resid < sizeof(iplog_t)) { if (uio->uio_resid < sizeof(iplog_t)) {
IPFERROR(40002); IPFERROR(40002);
return EINVAL; return(EINVAL);
} }
if (uio->uio_resid > softl->ipl_logsize) { if (uio->uio_resid > softl->ipl_logsize) {
IPFERROR(40005); IPFERROR(40005);
return EINVAL; return(EINVAL);
} }
/* /*
@ -694,7 +694,7 @@ ipf_log_read(ipf_main_softc_t *softc, minor_t unit, struct uio *uio)
softl->ipl_readers[unit]--; softl->ipl_readers[unit]--;
MUTEX_EXIT(&softl->ipl_mutex[unit]); MUTEX_EXIT(&softl->ipl_mutex[unit]);
IPFERROR(40003); IPFERROR(40003);
return EINTR; return(EINTR);
} }
# else # else
MUTEX_EXIT(&softl->ipl_mutex[unit]); MUTEX_EXIT(&softl->ipl_mutex[unit]);
@ -706,7 +706,7 @@ ipf_log_read(ipf_main_softc_t *softc, minor_t unit, struct uio *uio)
softl->ipl_readers[unit]--; softl->ipl_readers[unit]--;
MUTEX_EXIT(&softl->ipl_mutex[unit]); MUTEX_EXIT(&softl->ipl_mutex[unit]);
IPFERROR(40004); IPFERROR(40004);
return error; return(error);
} }
# endif /* SOLARIS */ # endif /* SOLARIS */
} }
@ -714,7 +714,7 @@ ipf_log_read(ipf_main_softc_t *softc, minor_t unit, struct uio *uio)
softl->ipl_readers[unit]--; softl->ipl_readers[unit]--;
MUTEX_EXIT(&softl->ipl_mutex[unit]); MUTEX_EXIT(&softl->ipl_mutex[unit]);
IPFERROR(40008); IPFERROR(40008);
return EIO; return(EIO);
} }
# if defined(BSD) # if defined(BSD)
@ -755,7 +755,7 @@ ipf_log_read(ipf_main_softc_t *softc, minor_t unit, struct uio *uio)
softl->ipl_readers[unit]--; softl->ipl_readers[unit]--;
MUTEX_EXIT(&softl->ipl_mutex[unit]); MUTEX_EXIT(&softl->ipl_mutex[unit]);
SPL_X(s); SPL_X(s);
return error; return(error);
} }
@ -788,7 +788,7 @@ ipf_log_clear(ipf_main_softc_t *softc, minor_t unit)
bzero((char *)&softl->ipl_crc[unit], FI_CSIZE); bzero((char *)&softl->ipl_crc[unit], FI_CSIZE);
MUTEX_EXIT(&softl->ipl_mutex[unit]); MUTEX_EXIT(&softl->ipl_mutex[unit]);
SPL_X(s); SPL_X(s);
return used; return(used);
} }
@ -806,7 +806,7 @@ ipf_log_canread(ipf_main_softc_t *softc, int unit)
{ {
ipf_log_softc_t *softl = softc->ipf_log_soft; ipf_log_softc_t *softl = softc->ipf_log_soft;
return softl->iplt[unit] != NULL; return(softl->iplt[unit] != NULL);
} }
@ -825,9 +825,9 @@ ipf_log_bytesused(ipf_main_softc_t *softc, int unit)
ipf_log_softc_t *softl = softc->ipf_log_soft; ipf_log_softc_t *softl = softc->ipf_log_soft;
if (softl == NULL) if (softl == NULL)
return 0; return(0);
return softl->ipl_used[unit]; return(softl->ipl_used[unit]);
} }
@ -846,9 +846,9 @@ ipf_log_failures(ipf_main_softc_t *softc, int unit)
ipf_log_softc_t *softl = softc->ipf_log_soft; ipf_log_softc_t *softl = softc->ipf_log_soft;
if (softl == NULL) if (softl == NULL)
return 0; return(0);
return softl->ipl_logfail[unit]; return(softl->ipl_logfail[unit]);
} }
@ -867,8 +867,8 @@ ipf_log_logok(ipf_main_softc_t *softc, int unit)
ipf_log_softc_t *softl = softc->ipf_log_soft; ipf_log_softc_t *softl = softc->ipf_log_soft;
if (softl == NULL) if (softl == NULL)
return 0; return(0);
return softl->ipl_logok[unit]; return(softl->ipl_logok[unit]);
} }
#endif /* IPFILTER_LOG */ #endif /* IPFILTER_LOG */

View File

@ -104,7 +104,7 @@ ipf_lookup_soft_create(ipf_main_softc_t *softc)
KMALLOC(softl, ipf_lookup_softc_t *); KMALLOC(softl, ipf_lookup_softc_t *);
if (softl == NULL) if (softl == NULL)
return NULL; return(NULL);
bzero((char *)softl, sizeof(*softl)); bzero((char *)softl, sizeof(*softl));
@ -112,11 +112,11 @@ ipf_lookup_soft_create(ipf_main_softc_t *softc)
softl->ipf_back[i] = (*(*l)->ipfl_create)(softc); softl->ipf_back[i] = (*(*l)->ipfl_create)(softc);
if (softl->ipf_back[i] == NULL) { if (softl->ipf_back[i] == NULL) {
ipf_lookup_soft_destroy(softc, softl); ipf_lookup_soft_destroy(softc, softl);
return NULL; return(NULL);
} }
} }
return softl; return(softl);
} }
@ -141,7 +141,7 @@ ipf_lookup_soft_init(ipf_main_softc_t *softc, void *arg)
break; break;
} }
return err; return(err);
} }
@ -165,7 +165,7 @@ ipf_lookup_soft_fini(ipf_main_softc_t *softc, void *arg)
softl->ipf_back[i]); softl->ipf_back[i]);
} }
return 0; return(0);
} }
@ -298,7 +298,7 @@ ipf_lookup_ioctl(ipf_main_softc_t *softc, caddr_t data, ioctlcmd_t cmd,
break; break;
} }
SPL_X(s); SPL_X(s);
return err; return(err);
} }
@ -324,13 +324,13 @@ ipf_lookup_addnode(ipf_main_softc_t *softc, caddr_t data, int uid)
err = BCOPYIN(data, &op, sizeof(op)); err = BCOPYIN(data, &op, sizeof(op));
if (err != 0) { if (err != 0) {
IPFERROR(50002); IPFERROR(50002);
return EFAULT; return(EFAULT);
} }
if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) && if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) &&
(op.iplo_unit != IPLT_ALL)) { (op.iplo_unit != IPLT_ALL)) {
IPFERROR(50003); IPFERROR(50003);
return EINVAL; return(EINVAL);
} }
op.iplo_name[sizeof(op.iplo_name) - 1] = '\0'; op.iplo_name[sizeof(op.iplo_name) - 1] = '\0';
@ -349,7 +349,7 @@ ipf_lookup_addnode(ipf_main_softc_t *softc, caddr_t data, int uid)
err = EINVAL; err = EINVAL;
} }
return err; return(err);
} }
@ -374,13 +374,13 @@ ipf_lookup_delnode(ipf_main_softc_t *softc, caddr_t data, int uid)
err = BCOPYIN(data, &op, sizeof(op)); err = BCOPYIN(data, &op, sizeof(op));
if (err != 0) { if (err != 0) {
IPFERROR(50042); IPFERROR(50042);
return EFAULT; return(EFAULT);
} }
if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) && if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) &&
(op.iplo_unit != IPLT_ALL)) { (op.iplo_unit != IPLT_ALL)) {
IPFERROR(50013); IPFERROR(50013);
return EINVAL; return(EINVAL);
} }
op.iplo_name[sizeof(op.iplo_name) - 1] = '\0'; op.iplo_name[sizeof(op.iplo_name) - 1] = '\0';
@ -397,7 +397,7 @@ ipf_lookup_delnode(ipf_main_softc_t *softc, caddr_t data, int uid)
IPFERROR(50021); IPFERROR(50021);
err = EINVAL; err = EINVAL;
} }
return err; return(err);
} }
@ -421,13 +421,13 @@ ipf_lookup_addtable(ipf_main_softc_t *softc, caddr_t data)
err = BCOPYIN(data, &op, sizeof(op)); err = BCOPYIN(data, &op, sizeof(op));
if (err != 0) { if (err != 0) {
IPFERROR(50022); IPFERROR(50022);
return EFAULT; return(EFAULT);
} }
if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) && if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) &&
(op.iplo_unit != IPLT_ALL)) { (op.iplo_unit != IPLT_ALL)) {
IPFERROR(50023); IPFERROR(50023);
return EINVAL; return(EINVAL);
} }
op.iplo_name[sizeof(op.iplo_name) - 1] = '\0'; op.iplo_name[sizeof(op.iplo_name) - 1] = '\0';
@ -458,7 +458,7 @@ ipf_lookup_addtable(ipf_main_softc_t *softc, caddr_t data)
} }
} }
return err; return(err);
} }
@ -482,13 +482,13 @@ ipf_lookup_deltable(ipf_main_softc_t *softc, caddr_t data)
err = BCOPYIN(data, &op, sizeof(op)); err = BCOPYIN(data, &op, sizeof(op));
if (err != 0) { if (err != 0) {
IPFERROR(50028); IPFERROR(50028);
return EFAULT; return(EFAULT);
} }
if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) && if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) &&
(op.iplo_unit != IPLT_ALL)) { (op.iplo_unit != IPLT_ALL)) {
IPFERROR(50029); IPFERROR(50029);
return EINVAL; return(EINVAL);
} }
op.iplo_name[sizeof(op.iplo_name) - 1] = '\0'; op.iplo_name[sizeof(op.iplo_name) - 1] = '\0';
@ -506,7 +506,7 @@ ipf_lookup_deltable(ipf_main_softc_t *softc, caddr_t data)
IPFERROR(50030); IPFERROR(50030);
err = EINVAL; err = EINVAL;
} }
return err; return(err);
} }
@ -530,13 +530,13 @@ ipf_lookup_stats(ipf_main_softc_t *softc, caddr_t data)
err = BCOPYIN(data, &op, sizeof(op)); err = BCOPYIN(data, &op, sizeof(op));
if (err != 0) { if (err != 0) {
IPFERROR(50031); IPFERROR(50031);
return EFAULT; return(EFAULT);
} }
if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) && if ((op.iplo_unit < 0 || op.iplo_unit > IPL_LOGMAX) &&
(op.iplo_unit != IPLT_ALL)) { (op.iplo_unit != IPLT_ALL)) {
IPFERROR(50032); IPFERROR(50032);
return EINVAL; return(EINVAL);
} }
for (i = 0, l = backends; i < MAX_BACKENDS; i++, l++) { for (i = 0, l = backends; i < MAX_BACKENDS; i++, l++) {
@ -553,7 +553,7 @@ ipf_lookup_stats(ipf_main_softc_t *softc, caddr_t data)
err = EINVAL; err = EINVAL;
} }
return err; return(err);
} }
@ -577,13 +577,13 @@ ipf_lookup_flush(ipf_main_softc_t *softc, caddr_t data)
err = BCOPYIN(data, &flush, sizeof(flush)); err = BCOPYIN(data, &flush, sizeof(flush));
if (err != 0) { if (err != 0) {
IPFERROR(50034); IPFERROR(50034);
return EFAULT; return(EFAULT);
} }
unit = flush.iplf_unit; unit = flush.iplf_unit;
if ((unit < 0 || unit > IPL_LOGMAX) && (unit != IPLT_ALL)) { if ((unit < 0 || unit > IPL_LOGMAX) && (unit != IPLT_ALL)) {
IPFERROR(50035); IPFERROR(50035);
return EINVAL; return(EINVAL);
} }
flush.iplf_name[sizeof(flush.iplf_name) - 1] = '\0'; flush.iplf_name[sizeof(flush.iplf_name) - 1] = '\0';
@ -610,7 +610,7 @@ ipf_lookup_flush(ipf_main_softc_t *softc, caddr_t data)
err = EFAULT; err = EFAULT;
} }
} }
return err; return(err);
} }
@ -667,16 +667,16 @@ ipf_lookup_iterate(ipf_main_softc_t *softc, void *data, int uid, void *ctx)
err = ipf_inobj(softc, data, NULL, &iter, IPFOBJ_LOOKUPITER); err = ipf_inobj(softc, data, NULL, &iter, IPFOBJ_LOOKUPITER);
if (err != 0) if (err != 0)
return err; return(err);
if (iter.ili_unit < IPL_LOGALL && iter.ili_unit > IPL_LOGMAX) { if (iter.ili_unit < IPL_LOGALL && iter.ili_unit > IPL_LOGMAX) {
IPFERROR(50038); IPFERROR(50038);
return EINVAL; return(EINVAL);
} }
if (iter.ili_ival != IPFGENITER_LOOKUP) { if (iter.ili_ival != IPFGENITER_LOOKUP) {
IPFERROR(50039); IPFERROR(50039);
return EINVAL; return(EINVAL);
} }
SPL_SCHED(s); SPL_SCHED(s);
@ -684,7 +684,7 @@ ipf_lookup_iterate(ipf_main_softc_t *softc, void *data, int uid, void *ctx)
if (token == NULL) { if (token == NULL) {
SPL_X(s); SPL_X(s);
IPFERROR(50040); IPFERROR(50040);
return ESRCH; return(ESRCH);
} }
for (i = 0; i < MAX_BACKENDS; i++) { for (i = 0; i < MAX_BACKENDS; i++) {
@ -706,7 +706,7 @@ ipf_lookup_iterate(ipf_main_softc_t *softc, void *data, int uid, void *ctx)
ipf_token_deref(softc, token); ipf_token_deref(softc, token);
RWLOCK_EXIT(&softc->ipf_tokens); RWLOCK_EXIT(&softc->ipf_tokens);
return err; return(err);
} }
@ -776,7 +776,7 @@ ipf_lookup_deltok(ipf_main_softc_t *softc, void *data, int uid, void *ctx)
if (error == 0) if (error == 0)
error = ipf_token_del(softc, key, uid, ctx); error = ipf_token_del(softc, key, uid, ctx);
SPL_X(s); SPL_X(s);
return error; return(error);
} }
@ -803,7 +803,7 @@ ipf_lookup_res_num(ipf_main_softc_t *softc, int unit, u_int type, u_int number,
(void) snprintf(name, sizeof(name), "%u", number); (void) snprintf(name, sizeof(name), "%u", number);
return ipf_lookup_res_name(softc, unit, type, name, funcptr); return(ipf_lookup_res_name(softc, unit, type, name, funcptr));
} }
@ -852,7 +852,7 @@ ipf_lookup_res_name(ipf_main_softc_t *softc, int unit, u_int type, char *name,
RWLOCK_EXIT(&softc->ipf_poolrw); RWLOCK_EXIT(&softc->ipf_poolrw);
return ptr; return(ptr);
} }
@ -885,7 +885,7 @@ ipf_lookup_find_htable(ipf_main_softc_t *softc, int unit, char *name)
RWLOCK_EXIT(&softc->ipf_poolrw); RWLOCK_EXIT(&softc->ipf_poolrw);
return tab; return(tab);
} }

File diff suppressed because it is too large Load Diff

View File

@ -172,26 +172,26 @@ ipf_nat6_ruleaddrinit(ipf_main_softc_t *softc, ipf_nat_softc_t *softn,
error = ipf_nat6_nextaddrinit(softc, n->in_names, &n->in_osrc, 1, error = ipf_nat6_nextaddrinit(softc, n->in_names, &n->in_osrc, 1,
n->in_ifps[idx]); n->in_ifps[idx]);
if (error != 0) if (error != 0)
return error; return(error);
error = ipf_nat6_nextaddrinit(softc, n->in_names, &n->in_odst, 1, error = ipf_nat6_nextaddrinit(softc, n->in_names, &n->in_odst, 1,
n->in_ifps[idx]); n->in_ifps[idx]);
if (error != 0) if (error != 0)
return error; return(error);
error = ipf_nat6_nextaddrinit(softc, n->in_names, &n->in_nsrc, 1, error = ipf_nat6_nextaddrinit(softc, n->in_names, &n->in_nsrc, 1,
n->in_ifps[idx]); n->in_ifps[idx]);
if (error != 0) if (error != 0)
return error; return(error);
error = ipf_nat6_nextaddrinit(softc, n->in_names, &n->in_ndst, 1, error = ipf_nat6_nextaddrinit(softc, n->in_names, &n->in_ndst, 1,
n->in_ifps[idx]); n->in_ifps[idx]);
if (error != 0) if (error != 0)
return error; return(error);
if (n->in_redir & NAT_DIVERTUDP) if (n->in_redir & NAT_DIVERTUDP)
ipf_nat6_builddivertmp(softn, n); ipf_nat6_builddivertmp(softn, n);
return 0; return(0);
} }
@ -385,12 +385,12 @@ ipf_nat6_hostmap(ipf_nat_softc_t *softn, ipnat_t *np,
((port == 0) || (port == hm->hm_port))) { ((port == 0) || (port == hm->hm_port))) {
softn->ipf_nat_stats.ns_hm_addref++; softn->ipf_nat_stats.ns_hm_addref++;
hm->hm_ref++; hm->hm_ref++;
return hm; return(hm);
} }
if (np == NULL) { if (np == NULL) {
softn->ipf_nat_stats.ns_hm_nullnp++; softn->ipf_nat_stats.ns_hm_nullnp++;
return NULL; return(NULL);
} }
KMALLOC(hm, hostmap_t *); KMALLOC(hm, hostmap_t *);
@ -422,7 +422,7 @@ ipf_nat6_hostmap(ipf_nat_softc_t *softn, ipnat_t *np,
} else { } else {
softn->ipf_nat_stats.ns_hm_newfail++; softn->ipf_nat_stats.ns_hm_newfail++;
} }
return hm; return(hm);
} }
@ -497,7 +497,7 @@ ipf_nat6_newmap(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
if (IP6_ISONES(&np->in_nsrcmsk6) && (np->in_spnext == 0)) { if (IP6_ISONES(&np->in_nsrcmsk6) && (np->in_spnext == 0)) {
if (l > 0) { if (l > 0) {
NBUMPSIDE6DX(1, ns_exhausted, ns_exhausted_1); NBUMPSIDE6DX(1, ns_exhausted, ns_exhausted_1);
return -1; return(-1);
} }
} }
@ -523,7 +523,7 @@ ipf_nat6_newmap(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
if ((l >= np->in_ppip) || ((l > 0) && if ((l >= np->in_ppip) || ((l > 0) &&
!(flags & IPN_TCPUDP))) { !(flags & IPN_TCPUDP))) {
NBUMPSIDE6DX(1, ns_exhausted, ns_exhausted_2); NBUMPSIDE6DX(1, ns_exhausted, ns_exhausted_2);
return -1; return(-1);
} }
/* /*
* map-block - Calculate destination address. * map-block - Calculate destination address.
@ -558,7 +558,7 @@ ipf_nat6_newmap(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
&in, NULL) == -1) { &in, NULL) == -1) {
NBUMPSIDE6DX(1, ns_new_ifpaddr, NBUMPSIDE6DX(1, ns_new_ifpaddr,
ns_new_ifpaddr_1); ns_new_ifpaddr_1);
return -1; return(-1);
} }
} else if (IP6_ISZERO(&np->in_nsrcip6) && } else if (IP6_ISZERO(&np->in_nsrcip6) &&
@ -568,7 +568,7 @@ ipf_nat6_newmap(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
*/ */
if (l > 0) { if (l > 0) {
NBUMPSIDE6DX(1, ns_exhausted, ns_exhausted_3); NBUMPSIDE6DX(1, ns_exhausted, ns_exhausted_3);
return -1; return(-1);
} }
in = fin->fin_src6; in = fin->fin_src6;
@ -675,7 +675,7 @@ ipf_nat6_newmap(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
(!IP6_ISZERO(&np->in_snip6) && (!IP6_ISZERO(&np->in_snip6) &&
IP6_EQ(&st_ip, &np->in_snip6))) { IP6_EQ(&st_ip, &np->in_snip6))) {
NBUMPSIDE6D(1, ns_wrap); NBUMPSIDE6D(1, ns_wrap);
return -1; return(-1);
} }
l++; l++;
} while (natl != NULL); } while (natl != NULL);
@ -701,7 +701,7 @@ ipf_nat6_newmap(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
((struct icmp6_hdr *)fin->fin_dp)->icmp6_id = port; ((struct icmp6_hdr *)fin->fin_dp)->icmp6_id = port;
nat->nat_nicmpid = port; nat->nat_nicmpid = port;
} }
return 0; return(0);
} }
@ -806,7 +806,7 @@ ipf_nat6_newrdr(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
if (ipf_ifpaddr(softc, 6, FRI_NORMAL, fin->fin_ifp, if (ipf_ifpaddr(softc, 6, FRI_NORMAL, fin->fin_ifp,
&in, NULL) == -1) { &in, NULL) == -1) {
NBUMPSIDE6DX(0, ns_new_ifpaddr, ns_new_ifpaddr_2); NBUMPSIDE6DX(0, ns_new_ifpaddr, ns_new_ifpaddr_2);
return -1; return(-1);
} }
} else if (IP6_ISZERO(&np->in_ndstip6) && } else if (IP6_ISZERO(&np->in_ndstip6) &&
@ -859,14 +859,14 @@ ipf_nat6_newrdr(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
if (IP6_ISZERO(&in)) { if (IP6_ISZERO(&in)) {
if (nport == dport) { if (nport == dport) {
NBUMPSIDE6D(0, ns_xlate_null); NBUMPSIDE6D(0, ns_xlate_null);
return -1; return(-1);
} }
in = fin->fin_dst6; in = fin->fin_dst6;
} }
/* /*
* Check to see if this redirect mapping already exists and if * Check to see if this redirect mapping already exists and if
* it does, return "failure" (allowing it to be created will just * it does, return "failure" (allowing it to be created will just
* cause one or both of these "connections" to stop working.) * cause one or both of these "connections" to stop working.)
*/ */
sp = fin->fin_data[0]; sp = fin->fin_data[0];
@ -880,7 +880,7 @@ ipf_nat6_newrdr(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
fin->fin_data[1] = dp; fin->fin_data[1] = dp;
if (natl != NULL) { if (natl != NULL) {
NBUMPSIDE6D(0, ns_xlate_exists); NBUMPSIDE6D(0, ns_xlate_exists);
return -1; return(-1);
} }
nat->nat_ndst6 = in; nat->nat_ndst6 = in;
@ -904,7 +904,7 @@ ipf_nat6_newrdr(fr_info_t *fin, nat_t *nat, natinfo_t *ni)
nat->nat_nicmpid = nport; nat->nat_nicmpid = nport;
} }
return move; return(move);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -954,7 +954,7 @@ ipf_nat6_add(fr_info_t *fin, ipnat_t *np, nat_t **natsave, u_int flags,
if (nsp->ns_active >= softn->ipf_nat_table_max) { if (nsp->ns_active >= softn->ipf_nat_table_max) {
NBUMPSIDE6(fin->fin_out, ns_table_max); NBUMPSIDE6(fin->fin_out, ns_table_max);
return NULL; return(NULL);
} }
move = 1; move = 1;
@ -981,7 +981,7 @@ ipf_nat6_add(fr_info_t *fin, ipnat_t *np, nat_t **natsave, u_int flags,
printf("table_max reduced to %d\n", printf("table_max reduced to %d\n",
softn->ipf_nat_table_max); softn->ipf_nat_table_max);
} }
return NULL; return(NULL);
} }
if (flags & IPN_ICMPQUERY) { if (flags & IPN_ICMPQUERY) {
@ -1111,7 +1111,7 @@ ipf_nat6_add(fr_info_t *fin, ipnat_t *np, nat_t **natsave, u_int flags,
np->in_hits++; np->in_hits++;
if (natsave != NULL) if (natsave != NULL)
*natsave = nat; *natsave = nat;
return nat; return(nat);
} }
@ -1221,7 +1221,7 @@ ipf_nat6_finalise(fr_info_t *fin, nat_t *nat)
fr->fr_ref++; fr->fr_ref++;
MUTEX_EXIT(&fr->fr_lock); MUTEX_EXIT(&fr->fr_lock);
} }
return 0; return(0);
} }
NBUMPSIDE6D(fin->fin_out, ns_unfinalised); NBUMPSIDE6D(fin->fin_out, ns_unfinalised);
@ -1230,7 +1230,7 @@ ipf_nat6_finalise(fr_info_t *fin, nat_t *nat)
*/ */
if (nat->nat_sync != NULL) if (nat->nat_sync != NULL)
ipf_sync_del_nat(softc->ipf_sync_soft, nat->nat_sync); ipf_sync_del_nat(softc->ipf_sync_soft, nat->nat_sync);
return -1; return(-1);
} }
@ -1253,7 +1253,7 @@ ipf_nat6_insert(ipf_main_softc_t *softc, ipf_nat_softc_t *softn, nat_t *nat)
ipnat_t *in; ipnat_t *in;
/* /*
* Try and return an error as early as possible, so calculate the hash * Try and return an error as early as possible, so calculate the hash
* entry numbers first and then proceed. * entry numbers first and then proceed.
*/ */
if ((nat->nat_flags & (SI_W_SPORT|SI_W_DPORT)) == 0) { if ((nat->nat_flags & (SI_W_SPORT|SI_W_DPORT)) == 0) {
@ -1339,7 +1339,7 @@ ipf_nat6_insert(ipf_main_softc_t *softc, ipf_nat_softc_t *softn, nat_t *nat)
nat->nat_mtu[1] = GETIFMTU_6(nat->nat_ifps[1]); nat->nat_mtu[1] = GETIFMTU_6(nat->nat_ifps[1]);
} }
return ipf_nat_hashtab_add(softc, softn, nat); return(ipf_nat_hashtab_add(softc, softn, nat));
} }
@ -1372,13 +1372,13 @@ ipf_nat6_icmperrorlookup(fr_info_t *fin, int dir)
type = icmp6->icmp6_type; type = icmp6->icmp6_type;
nside = &softn->ipf_nat_stats.ns_side6[fin->fin_out]; nside = &softn->ipf_nat_stats.ns_side6[fin->fin_out];
/* /*
* Does it at least have the return (basic) IP header ? * Does it at least have the return(basic) IP header ?
* Only a basic IP header (no options) should be with an ICMP error * Only a basic IP header (no options) should be with an ICMP error
* header. Also, if it's not an error type, then return. * header. Also, if it's not an error type, then return.
*/ */
if (!(fin->fin_flx & FI_ICMPERR)) { if (!(fin->fin_flx & FI_ICMPERR)) {
ATOMIC_INCL(nside->ns_icmp_basic); ATOMIC_INCL(nside->ns_icmp_basic);
return NULL; return(NULL);
} }
/* /*
@ -1386,7 +1386,7 @@ ipf_nat6_icmperrorlookup(fr_info_t *fin, int dir)
*/ */
if (fin->fin_plen < ICMP6ERR_IPICMPHLEN) { if (fin->fin_plen < ICMP6ERR_IPICMPHLEN) {
ATOMIC_INCL(nside->ns_icmp_size); ATOMIC_INCL(nside->ns_icmp_size);
return NULL; return(NULL);
} }
oip6 = (ip6_t *)((char *)fin->fin_dp + 8); oip6 = (ip6_t *)((char *)fin->fin_dp + 8);
@ -1408,13 +1408,13 @@ ipf_nat6_icmperrorlookup(fr_info_t *fin, int dir)
if ((char *)oip6 + fin->fin_dlen - ICMPERR_ICMPHLEN > if ((char *)oip6 + fin->fin_dlen - ICMPERR_ICMPHLEN >
(char *)m->b_wptr) { (char *)m->b_wptr) {
ATOMIC_INCL(nside->ns_icmp_mbuf); ATOMIC_INCL(nside->ns_icmp_mbuf);
return NULL; return(NULL);
} }
# else # else
if ((char *)oip6 + fin->fin_dlen - ICMPERR_ICMPHLEN > if ((char *)oip6 + fin->fin_dlen - ICMPERR_ICMPHLEN >
(char *)fin->fin_ip + M_LEN(m)) { (char *)fin->fin_ip + M_LEN(m)) {
ATOMIC_INCL(nside->ns_icmp_mbuf); ATOMIC_INCL(nside->ns_icmp_mbuf);
return NULL; return(NULL);
} }
# endif # endif
} }
@ -1422,7 +1422,7 @@ ipf_nat6_icmperrorlookup(fr_info_t *fin, int dir)
if (IP6_NEQ(&fin->fin_dst6, &oip6->ip6_src)) { if (IP6_NEQ(&fin->fin_dst6, &oip6->ip6_src)) {
ATOMIC_INCL(nside->ns_icmp_address); ATOMIC_INCL(nside->ns_icmp_address);
return NULL; return(NULL);
} }
p = oip6->ip6_nxt; p = oip6->ip6_nxt;
@ -1456,7 +1456,7 @@ ipf_nat6_icmperrorlookup(fr_info_t *fin, int dir)
&oip6->ip6_src); &oip6->ip6_src);
fin->fin_data[0] = data[0]; fin->fin_data[0] = data[0];
fin->fin_data[1] = data[1]; fin->fin_data[1] = data[1];
return nat; return(nat);
} }
} }
@ -1465,7 +1465,7 @@ ipf_nat6_icmperrorlookup(fr_info_t *fin, int dir)
/* TRACE (fin,minlen) */ /* TRACE (fin,minlen) */
if (fin->fin_plen < ICMPERR_IPICMPHLEN + minlen) { if (fin->fin_plen < ICMPERR_IPICMPHLEN + minlen) {
ATOMIC_INCL(nside->ns_icmp_short); ATOMIC_INCL(nside->ns_icmp_short);
return NULL; return(NULL);
} }
data[0] = fin->fin_data[0]; data[0] = fin->fin_data[0];
@ -1483,7 +1483,7 @@ ipf_nat6_icmperrorlookup(fr_info_t *fin, int dir)
} }
fin->fin_data[0] = data[0]; fin->fin_data[0] = data[0];
fin->fin_data[1] = data[1]; fin->fin_data[1] = data[1];
return nat; return(nat);
} }
if (dir == NAT_INBOUND) if (dir == NAT_INBOUND)
nat = ipf_nat6_inlookup(fin, 0, p, &oip6->ip6_dst, nat = ipf_nat6_inlookup(fin, 0, p, &oip6->ip6_dst,
@ -1492,7 +1492,7 @@ ipf_nat6_icmperrorlookup(fr_info_t *fin, int dir)
nat = ipf_nat6_outlookup(fin, 0, p, &oip6->ip6_dst, nat = ipf_nat6_outlookup(fin, 0, p, &oip6->ip6_dst,
&oip6->ip6_src); &oip6->ip6_src);
return nat; return(nat);
} }
@ -1531,7 +1531,7 @@ ipf_nat6_ip6subtract(i6addr_t *ip1, i6addr_t *ip2)
r += ds[i]; r += ds[i];
} }
return r; return(r);
} }
@ -1565,15 +1565,15 @@ ipf_nat6_icmperror(fr_info_t *fin, u_int *nflags, int dir)
if ((fin->fin_flx & (FI_SHORT|FI_FRAGBODY))) { if ((fin->fin_flx & (FI_SHORT|FI_FRAGBODY))) {
NBUMPSIDE6D(fin->fin_out, ns_icmp_short); NBUMPSIDE6D(fin->fin_out, ns_icmp_short);
return NULL; return(NULL);
} }
/* /*
* ipf_nat6_icmperrorlookup() will return NULL for `defective' packets. * ipf_nat6_icmperrorlookup() will return NULL for `defective' packets.
*/ */
if ((fin->fin_v != 6) || !(nat = ipf_nat6_icmperrorlookup(fin, dir))) { if ((fin->fin_v != 6) || !(nat = ipf_nat6_icmperrorlookup(fin, dir))) {
NBUMPSIDE6D(fin->fin_out, ns_icmp_notfound); NBUMPSIDE6D(fin->fin_out, ns_icmp_notfound);
return NULL; return(NULL);
} }
tcp = NULL; tcp = NULL;
@ -1827,7 +1827,7 @@ ipf_nat6_icmperror(fr_info_t *fin, u_int *nflags, int dir)
} }
} /* nat6_dir == NAT_INBOUND is impossible for icmp queries */ } /* nat6_dir == NAT_INBOUND is impossible for icmp queries */
} }
return nat; return(nat);
} }
@ -1976,7 +1976,7 @@ ipf_nat6_inlookup(fr_info_t *fin, u_int flags, u_int p,
nat->nat_ifps[0] = ifp; nat->nat_ifps[0] = ifp;
nat->nat_mtu[0] = GETIFMTU_6(ifp); nat->nat_mtu[0] = GETIFMTU_6(ifp);
} }
return nat; return(nat);
} }
/* /*
@ -1989,11 +1989,11 @@ ipf_nat6_inlookup(fr_info_t *fin, u_int flags, u_int p,
find_in_wild_ports: find_in_wild_ports:
if (!(flags & NAT_TCPUDP) || !(flags & NAT_SEARCH)) { if (!(flags & NAT_TCPUDP) || !(flags & NAT_SEARCH)) {
NBUMPSIDE6DX(0, ns_lookup_miss, ns_lookup_miss_1); NBUMPSIDE6DX(0, ns_lookup_miss, ns_lookup_miss_1);
return NULL; return(NULL);
} }
if (softn->ipf_nat_stats.ns_wilds == 0 || (fin->fin_flx & FI_NOWILD)) { if (softn->ipf_nat_stats.ns_wilds == 0 || (fin->fin_flx & FI_NOWILD)) {
NBUMPSIDE6D(0, ns_lookup_nowild); NBUMPSIDE6D(0, ns_lookup_nowild);
return NULL; return(NULL);
} }
RWLOCK_EXIT(&softc->ipf_nat); RWLOCK_EXIT(&softc->ipf_nat);
@ -2083,7 +2083,7 @@ ipf_nat6_inlookup(fr_info_t *fin, u_int flags, u_int p,
if (nat == NULL) { if (nat == NULL) {
NBUMPSIDE6DX(0, ns_lookup_miss, ns_lookup_miss_2); NBUMPSIDE6DX(0, ns_lookup_miss, ns_lookup_miss_2);
} }
return nat; return(nat);
} }
@ -2294,7 +2294,7 @@ ipf_nat6_outlookup(fr_info_t *fin, u_int flags, u_int p,
nat->nat_ifps[1] = ifp; nat->nat_ifps[1] = ifp;
nat->nat_mtu[1] = GETIFMTU_6(ifp); nat->nat_mtu[1] = GETIFMTU_6(ifp);
} }
return nat; return(nat);
} }
/* /*
@ -2307,11 +2307,11 @@ ipf_nat6_outlookup(fr_info_t *fin, u_int flags, u_int p,
find_out_wild_ports: find_out_wild_ports:
if (!(flags & NAT_TCPUDP) || !(flags & NAT_SEARCH)) { if (!(flags & NAT_TCPUDP) || !(flags & NAT_SEARCH)) {
NBUMPSIDE6DX(1, ns_lookup_miss, ns_lookup_miss_3); NBUMPSIDE6DX(1, ns_lookup_miss, ns_lookup_miss_3);
return NULL; return(NULL);
} }
if (softn->ipf_nat_stats.ns_wilds == 0 || (fin->fin_flx & FI_NOWILD)) { if (softn->ipf_nat_stats.ns_wilds == 0 || (fin->fin_flx & FI_NOWILD)) {
NBUMPSIDE6D(1, ns_lookup_nowild); NBUMPSIDE6D(1, ns_lookup_nowild);
return NULL; return(NULL);
} }
RWLOCK_EXIT(&softc->ipf_nat); RWLOCK_EXIT(&softc->ipf_nat);
@ -2400,7 +2400,7 @@ ipf_nat6_outlookup(fr_info_t *fin, u_int flags, u_int p,
if (nat == NULL) { if (nat == NULL) {
NBUMPSIDE6DX(1, ns_lookup_miss, ns_lookup_miss_4); NBUMPSIDE6DX(1, ns_lookup_miss, ns_lookup_miss_4);
} }
return nat; return(nat);
} }
@ -2484,7 +2484,7 @@ ipf_nat6_lookupredir(natlookup_t *np)
} }
} }
return nat; return(nat);
} }
@ -2518,7 +2518,7 @@ ipf_nat6_match(fr_info_t *fin, ipnat_t *np)
} }
match ^= ((np->in_flags & IPN_NOTSRC) != 0); match ^= ((np->in_flags & IPN_NOTSRC) != 0);
if (match) if (match)
return 0; return(0);
match = 0; match = 0;
switch (np->in_odstatype) switch (np->in_odstatype)
@ -2535,17 +2535,17 @@ ipf_nat6_match(fr_info_t *fin, ipnat_t *np)
match ^= ((np->in_flags & IPN_NOTDST) != 0); match ^= ((np->in_flags & IPN_NOTDST) != 0);
if (match) if (match)
return 0; return(0);
ft = &np->in_tuc; ft = &np->in_tuc;
if (!(fin->fin_flx & FI_TCPUDP) || if (!(fin->fin_flx & FI_TCPUDP) ||
(fin->fin_flx & (FI_SHORT|FI_FRAGBODY))) { (fin->fin_flx & (FI_SHORT|FI_FRAGBODY))) {
if (ft->ftu_scmp || ft->ftu_dcmp) if (ft->ftu_scmp || ft->ftu_dcmp)
return 0; return(0);
return 1; return(1);
} }
return ipf_tcpudpchk(&fin->fin_fi, ft); return(ipf_tcpudpchk(&fin->fin_fi, ft));
} }
@ -2581,7 +2581,7 @@ ipf_nat6_checkout(fr_info_t *fin, u_32_t *passp)
nat_t *nat; nat_t *nat;
if (softn->ipf_nat_stats.ns_rules == 0 || softn->ipf_nat_lock != 0) if (softn->ipf_nat_stats.ns_rules == 0 || softn->ipf_nat_lock != 0)
return 0; return(0);
icmp6 = NULL; icmp6 = NULL;
natfailed = 0; natfailed = 0;
@ -2612,7 +2612,7 @@ ipf_nat6_checkout(fr_info_t *fin, u_32_t *passp)
* so as to keep IPv6 working. * so as to keep IPv6 working.
*/ */
if (icmp6->icmp6_type > ICMP6_ECHO_REPLY) if (icmp6->icmp6_type > ICMP6_ECHO_REPLY)
return 0; return(0);
/* /*
* This is an incoming packet, so the destination is * This is an incoming packet, so the destination is
@ -2748,7 +2748,7 @@ ipf_nat6_checkout(fr_info_t *fin, u_32_t *passp)
break; break;
} }
fin->fin_ifp = sifp; fin->fin_ifp = sifp;
return rval; return(rval);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -2809,7 +2809,7 @@ ipf_nat6_out(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
skip = ipf_nat6_decap(fin, nat); skip = ipf_nat6_decap(fin, nat);
if (skip <= 0) { if (skip <= 0) {
NBUMPSIDE6D(1, ns_decap_fail); NBUMPSIDE6D(1, ns_decap_fail);
return -1; return(-1);
} }
m = fin->fin_m; m = fin->fin_m;
@ -2832,7 +2832,7 @@ ipf_nat6_out(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
fin->fin_flx |= FI_NATED; fin->fin_flx |= FI_NATED;
if (np != NULL && np->in_tag.ipt_num[0] != 0) if (np != NULL && np->in_tag.ipt_num[0] != 0)
fin->fin_nattag = &np->in_tag; fin->fin_nattag = &np->in_tag;
return 1; return(1);
/* NOTREACHED */ /* NOTREACHED */
} }
@ -2845,7 +2845,7 @@ ipf_nat6_out(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
m = M_DUP(np->in_divmp); m = M_DUP(np->in_divmp);
if (m == NULL) { if (m == NULL) {
NBUMPSIDE6D(1, ns_divert_dup); NBUMPSIDE6D(1, ns_divert_dup);
return -1; return(-1);
} }
ip6 = MTOD(m, ip6_t *); ip6 = MTOD(m, ip6_t *);
@ -2939,7 +2939,7 @@ ipf_nat6_out(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
i = 1; i = 1;
} }
fin->fin_flx |= FI_NATED; fin->fin_flx |= FI_NATED;
return i; return(i);
} }
@ -2974,7 +2974,7 @@ ipf_nat6_checkin(fr_info_t *fin, u_32_t *passp)
nat_t *nat; nat_t *nat;
if (softn->ipf_nat_stats.ns_rules == 0 || softn->ipf_nat_lock != 0) if (softn->ipf_nat_stats.ns_rules == 0 || softn->ipf_nat_lock != 0)
return 0; return(0);
tcp = NULL; tcp = NULL;
icmp6 = NULL; icmp6 = NULL;
@ -3002,7 +3002,7 @@ ipf_nat6_checkin(fr_info_t *fin, u_32_t *passp)
* so as to keep IPv6 working. * so as to keep IPv6 working.
*/ */
if (icmp6->icmp6_type > ICMP6_ECHO_REPLY) if (icmp6->icmp6_type > ICMP6_ECHO_REPLY)
return 0; return(0);
/* /*
* This is an incoming packet, so the destination is * This is an incoming packet, so the destination is
@ -3139,7 +3139,7 @@ ipf_nat6_checkin(fr_info_t *fin, u_32_t *passp)
NBUMPSIDE6D(0, ns_translated); NBUMPSIDE6D(0, ns_translated);
break; break;
} }
return rval; return(rval);
} }
@ -3190,7 +3190,7 @@ ipf_nat6_in(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
i = ipf_proxy_check(fin, nat); i = ipf_proxy_check(fin, nat);
if (i == -1) { if (i == -1) {
NBUMPSIDE6D(0, ns_ipf_proxy_fail); NBUMPSIDE6D(0, ns_ipf_proxy_fail);
return -1; return(-1);
} }
} }
} }
@ -3237,7 +3237,7 @@ ipf_nat6_in(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
m = M_DUP(np->in_divmp); m = M_DUP(np->in_divmp);
if (m == NULL) { if (m == NULL) {
NBUMPSIDE6D(0, ns_divert_dup); NBUMPSIDE6D(0, ns_divert_dup);
return -1; return(-1);
} }
ip6 = MTOD(m, ip6_t *); ip6 = MTOD(m, ip6_t *);
@ -3264,7 +3264,7 @@ ipf_nat6_in(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
skip = ipf_nat6_decap(fin, nat); skip = ipf_nat6_decap(fin, nat);
if (skip <= 0) { if (skip <= 0) {
NBUMPSIDE6D(0, ns_decap_fail); NBUMPSIDE6D(0, ns_decap_fail);
return -1; return(-1);
} }
m = fin->fin_m; m = fin->fin_m;
@ -3285,7 +3285,7 @@ ipf_nat6_in(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
fin->fin_flx |= FI_NATED; fin->fin_flx |= FI_NATED;
if (np != NULL && np->in_tag.ipt_num[0] != 0) if (np != NULL && np->in_tag.ipt_num[0] != 0)
fin->fin_nattag = &np->in_tag; fin->fin_nattag = &np->in_tag;
return 1; return(1);
/* NOTREACHED */ /* NOTREACHED */
} }
} }
@ -3334,7 +3334,7 @@ ipf_nat6_in(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
fin->fin_flx |= FI_NATED; fin->fin_flx |= FI_NATED;
if (np != NULL && np->in_tag.ipt_num[0] != 0) if (np != NULL && np->in_tag.ipt_num[0] != 0)
fin->fin_nattag = &np->in_tag; fin->fin_nattag = &np->in_tag;
return 1; return(1);
} }
@ -3384,7 +3384,7 @@ ipf_nat6_newrewrite(fr_info_t *fin, nat_t *nat, natinfo_t *nai)
if ((src_search == 0) && (np->in_spnext == 0) && if ((src_search == 0) && (np->in_spnext == 0) &&
(dst_search == 0) && (np->in_dpnext == 0)) { (dst_search == 0) && (np->in_dpnext == 0)) {
if (l > 0) if (l > 0)
return -1; return(-1);
} }
/* /*
@ -3392,7 +3392,7 @@ ipf_nat6_newrewrite(fr_info_t *fin, nat_t *nat, natinfo_t *nai)
*/ */
if (ipf_nat6_nextaddr(fin, &np->in_nsrc, &frnat.fin_src6, if (ipf_nat6_nextaddr(fin, &np->in_nsrc, &frnat.fin_src6,
&frnat.fin_src6) == -1) { &frnat.fin_src6) == -1) {
return -1; return(-1);
} }
if (IP6_ISZERO(&np->in_nsrcip6) && if (IP6_ISZERO(&np->in_nsrcip6) &&
@ -3449,7 +3449,7 @@ ipf_nat6_newrewrite(fr_info_t *fin, nat_t *nat, natinfo_t *nai)
if (ipf_nat6_nextaddr(fin, &np->in_ndst, &frnat.fin_dst6, if (ipf_nat6_nextaddr(fin, &np->in_ndst, &frnat.fin_dst6,
&frnat.fin_dst6) == -1) &frnat.fin_dst6) == -1)
return -1; return(-1);
if (IP6_ISZERO(&np->in_ndstip6) && if (IP6_ISZERO(&np->in_ndstip6) &&
IP6_ISONES(&np->in_ndstmsk6)) { IP6_ISONES(&np->in_ndstmsk6)) {
@ -3542,7 +3542,7 @@ ipf_nat6_newrewrite(fr_info_t *fin, nat_t *nat, natinfo_t *nai)
/* TRACE natl, in_stepnext, l */ /* TRACE natl, in_stepnext, l */
if ((natl != NULL) && (l > 8)) /* XXX 8 is arbitrary */ if ((natl != NULL) && (l > 8)) /* XXX 8 is arbitrary */
return -1; return(-1);
np->in_stepnext &= 0x3; np->in_stepnext &= 0x3;
@ -3564,7 +3564,7 @@ ipf_nat6_newrewrite(fr_info_t *fin, nat_t *nat, natinfo_t *nai)
nat->nat_nicmpid = frnat.fin_data[1]; nat->nat_nicmpid = frnat.fin_data[1];
} }
return 0; return(0);
} }
@ -3624,7 +3624,7 @@ ipf_nat6_newdivert(fr_info_t *fin, nat_t *nat, natinfo_t *nai)
if (natl != NULL) { if (natl != NULL) {
NBUMPSIDE6D(fin->fin_out, ns_divert_exist); NBUMPSIDE6D(fin->fin_out, ns_divert_exist);
return -1; return(-1);
} }
nat->nat_nsrc6 = frnat.fin_src6; nat->nat_nsrc6 = frnat.fin_src6;
@ -3641,7 +3641,7 @@ ipf_nat6_newdivert(fr_info_t *fin, nat_t *nat, natinfo_t *nai)
else else
nat->nat_dir = NAT_DIVERTOUT; nat->nat_dir = NAT_DIVERTOUT;
return 0; return(0);
} }
@ -3671,7 +3671,7 @@ ipf_nat6_builddivertmp(ipf_nat_softc_t *softn, ipnat_t *np)
ALLOC_MB_T(np->in_divmp, len); ALLOC_MB_T(np->in_divmp, len);
if (np->in_divmp == NULL) { if (np->in_divmp == NULL) {
ATOMIC_INCL(softn->ipf_nat_stats.ns_divert_build); ATOMIC_INCL(softn->ipf_nat_stats.ns_divert_build);
return -1; return(-1);
} }
/* /*
@ -3696,7 +3696,7 @@ ipf_nat6_builddivertmp(ipf_nat_softc_t *softn, ipnat_t *np)
uh->uh_dport = htons(np->in_dpnext); uh->uh_dport = htons(np->in_dpnext);
} }
return 0; return(0);
} }
@ -3727,7 +3727,7 @@ ipf_nat6_decap(fr_info_t *fin, nat_t *nat)
mb_t *m; mb_t *m;
if ((fin->fin_flx & FI_ICMPERR) != 0) { if ((fin->fin_flx & FI_ICMPERR) != 0) {
return 0; return(0);
} }
m = fin->fin_m; m = fin->fin_m;
@ -3738,17 +3738,17 @@ ipf_nat6_decap(fr_info_t *fin, nat_t *nat)
case NAT_DIVERTIN : case NAT_DIVERTIN :
case NAT_DIVERTOUT : case NAT_DIVERTOUT :
if (fin->fin_plen < MINDECAP) if (fin->fin_plen < MINDECAP)
return -1; return(-1);
skip += sizeof(udphdr_t); skip += sizeof(udphdr_t);
break; break;
case NAT_ENCAPIN : case NAT_ENCAPIN :
case NAT_ENCAPOUT : case NAT_ENCAPOUT :
if (fin->fin_plen < (skip + sizeof(ip6_t))) if (fin->fin_plen < (skip + sizeof(ip6_t)))
return -1; return(-1);
break; break;
default : default :
return -1; return(-1);
/* NOTREACHED */ /* NOTREACHED */
} }
@ -3759,7 +3759,7 @@ ipf_nat6_decap(fr_info_t *fin, nat_t *nat)
*/ */
if (M_LEN(m) < skip + sizeof(ip6_t)) { if (M_LEN(m) < skip + sizeof(ip6_t)) {
if (ipf_pr_pullup(fin, skip + sizeof(ip6_t)) == -1) if (ipf_pr_pullup(fin, skip + sizeof(ip6_t)) == -1)
return -1; return(-1);
} }
hdr = MTOD(fin->fin_m, char *); hdr = MTOD(fin->fin_m, char *);
@ -3767,7 +3767,7 @@ ipf_nat6_decap(fr_info_t *fin, nat_t *nat)
if (ipf_pr_pullup(fin, skip + sizeof(ip6_t)) == -1) { if (ipf_pr_pullup(fin, skip + sizeof(ip6_t)) == -1) {
NBUMPSIDE6D(fin->fin_out, ns_decap_pullup); NBUMPSIDE6D(fin->fin_out, ns_decap_pullup);
return -1; return(-1);
} }
fin->fin_hlen = sizeof(ip6_t); fin->fin_hlen = sizeof(ip6_t);
@ -3777,10 +3777,10 @@ ipf_nat6_decap(fr_info_t *fin, nat_t *nat)
if (ipf_makefrip(sizeof(ip6_t), (ip_t *)hdr, fin) == -1) { if (ipf_makefrip(sizeof(ip6_t), (ip_t *)hdr, fin) == -1) {
NBUMPSIDE6D(fin->fin_out, ns_decap_bad); NBUMPSIDE6D(fin->fin_out, ns_decap_bad);
return -1; return(-1);
} }
return skip; return(skip);
} }
@ -3837,7 +3837,7 @@ ipf_nat6_nextaddr(fr_info_t *fin, nat_addr_t *na, i6addr_t *old, i6addr_t *dst)
case FRI_PEERADDR : case FRI_PEERADDR :
case FRI_NETWORK : case FRI_NETWORK :
default : default :
return -1; return(-1);
} }
error = -1; error = -1;
@ -3864,7 +3864,7 @@ ipf_nat6_nextaddr(fr_info_t *fin, nat_addr_t *na, i6addr_t *old, i6addr_t *dst)
if (ipf_ifpaddr(softc, 6, na->na_atype, if (ipf_ifpaddr(softc, 6, na->na_atype,
fin->fin_ifp, &newip, NULL) == -1) { fin->fin_ifp, &newip, NULL) == -1) {
NBUMPSIDE6(fin->fin_out, ns_ifpaddrfail); NBUMPSIDE6(fin->fin_out, ns_ifpaddrfail);
return -1; return(-1);
} }
new = newip; new = newip;
} else { } else {
@ -3879,7 +3879,7 @@ ipf_nat6_nextaddr(fr_info_t *fin, nat_addr_t *na, i6addr_t *old, i6addr_t *dst)
break; break;
} }
return error; return(error);
} }
@ -3923,11 +3923,11 @@ ipf_nat6_nextaddrinit(ipf_main_softc_t *softc, char *base, nat_addr_t *na,
} }
if (na->na_func == NULL) { if (na->na_func == NULL) {
IPFERROR(60072); IPFERROR(60072);
return ESRCH; return(ESRCH);
} }
if (na->na_ptr == NULL) { if (na->na_ptr == NULL) {
IPFERROR(60073); IPFERROR(60073);
return ESRCH; return(ESRCH);
} }
break; break;
case FRI_DYNAMIC : case FRI_DYNAMIC :
@ -3949,7 +3949,7 @@ ipf_nat6_nextaddrinit(ipf_main_softc_t *softc, char *base, nat_addr_t *na,
case FRI_NONE : case FRI_NONE :
IP6_ANDASSIGN(&na->na_addr[0].in6, &na->na_addr[1].in6); IP6_ANDASSIGN(&na->na_addr[0].in6, &na->na_addr[1].in6);
return 0; return(0);
case FRI_NORMAL : case FRI_NORMAL :
IP6_ANDASSIGN(&na->na_addr[0].in6, &na->na_addr[1].in6); IP6_ANDASSIGN(&na->na_addr[0].in6, &na->na_addr[1].in6);
@ -3957,14 +3957,14 @@ ipf_nat6_nextaddrinit(ipf_main_softc_t *softc, char *base, nat_addr_t *na,
default : default :
IPFERROR(60074); IPFERROR(60074);
return EINVAL; return(EINVAL);
} }
if (initial && (na->na_atype == FRI_NORMAL)) { if (initial && (na->na_atype == FRI_NORMAL)) {
if (IP6_ISZERO(&na->na_addr[0].in6)) { if (IP6_ISZERO(&na->na_addr[0].in6)) {
if (IP6_ISONES(&na->na_addr[1].in6) || if (IP6_ISONES(&na->na_addr[1].in6) ||
IP6_ISZERO(&na->na_addr[1].in6)) { IP6_ISZERO(&na->na_addr[1].in6)) {
return 0; return(0);
} }
} }
@ -3974,7 +3974,7 @@ ipf_nat6_nextaddrinit(ipf_main_softc_t *softc, char *base, nat_addr_t *na,
} }
} }
return 0; return(0);
} }
@ -4014,9 +4014,9 @@ ipf_nat6_icmpquerytype(int icmptype)
case ICMP6_WRUREPLY: case ICMP6_WRUREPLY:
case MLD6_MTRACE_RESP: case MLD6_MTRACE_RESP:
case MLD6_MTRACE: case MLD6_MTRACE:
return 1; return(1);
default: default:
return 0; return(0);
} }
} }
#endif /* USE_INET6 */ #endif /* USE_INET6 */

View File

@ -84,7 +84,7 @@ ipf_p_netbios_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
* no net bios datagram could possibly be shorter than this * no net bios datagram could possibly be shorter than this
*/ */
if (dlen < 11) if (dlen < 11)
return 0; return(0);
ip = fin->fin_ip; ip = fin->fin_ip;
udp = (udphdr_t *)fin->fin_dp; udp = (udphdr_t *)fin->fin_dp;
@ -112,5 +112,5 @@ ipf_p_netbios_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
/* replace data in packet */ /* replace data in packet */
COPYBACK(m, off, sizeof(dgmbuf), dgmbuf); COPYBACK(m, off, sizeof(dgmbuf), dgmbuf);
return 0; return(0);
} }

View File

@ -228,7 +228,7 @@ main(int argc, char *argv[])
ipf_pool_fini(); ipf_pool_fini();
return 0; return(0);
} }
@ -261,7 +261,7 @@ ipf_pool_soft_create(ipf_main_softc_t *softc)
KMALLOC(softp, ipf_pool_softc_t *); KMALLOC(softp, ipf_pool_softc_t *);
if (softp == NULL) { if (softp == NULL) {
IPFERROR(70032); IPFERROR(70032);
return NULL; return(NULL);
} }
bzero((char *)softp, sizeof(*softp)); bzero((char *)softp, sizeof(*softp));
@ -270,10 +270,10 @@ ipf_pool_soft_create(ipf_main_softc_t *softc)
if (softp->ipf_radix == NULL) { if (softp->ipf_radix == NULL) {
IPFERROR(70033); IPFERROR(70033);
KFREE(softp); KFREE(softp);
return NULL; return(NULL);
} }
return softp; return(softp);
} }
@ -292,7 +292,7 @@ ipf_pool_soft_init(ipf_main_softc_t *softc, void *arg)
ipf_rx_init(softp->ipf_radix); ipf_rx_init(softp->ipf_radix);
return 0; return(0);
} }
@ -366,26 +366,26 @@ ipf_pool_node_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
if (op->iplo_size != sizeof(node)) { if (op->iplo_size != sizeof(node)) {
IPFERROR(70014); IPFERROR(70014);
return EINVAL; return(EINVAL);
} }
err = COPYIN(op->iplo_struct, &node, sizeof(node)); err = COPYIN(op->iplo_struct, &node, sizeof(node));
if (err != 0) { if (err != 0) {
IPFERROR(70015); IPFERROR(70015);
return EFAULT; return(EFAULT);
} }
p = ipf_pool_find(arg, op->iplo_unit, op->iplo_name); p = ipf_pool_find(arg, op->iplo_unit, op->iplo_name);
if (p == NULL) { if (p == NULL) {
IPFERROR(70017); IPFERROR(70017);
return ESRCH; return(ESRCH);
} }
if (node.ipn_addr.adf_family == AF_INET) { if (node.ipn_addr.adf_family == AF_INET) {
if (node.ipn_addr.adf_len != offsetof(addrfamily_t, adf_addr) + if (node.ipn_addr.adf_len != offsetof(addrfamily_t, adf_addr) +
sizeof(struct in_addr)) { sizeof(struct in_addr)) {
IPFERROR(70028); IPFERROR(70028);
return EINVAL; return(EINVAL);
} }
} }
#ifdef USE_INET6 #ifdef USE_INET6
@ -393,13 +393,13 @@ ipf_pool_node_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
if (node.ipn_addr.adf_len != offsetof(addrfamily_t, adf_addr) + if (node.ipn_addr.adf_len != offsetof(addrfamily_t, adf_addr) +
sizeof(struct in6_addr)) { sizeof(struct in6_addr)) {
IPFERROR(70034); IPFERROR(70034);
return EINVAL; return(EINVAL);
} }
} }
#endif #endif
if (node.ipn_mask.adf_len != node.ipn_addr.adf_len) { if (node.ipn_mask.adf_len != node.ipn_addr.adf_len) {
IPFERROR(70029); IPFERROR(70029);
return EINVAL; return(EINVAL);
} }
/* /*
@ -410,7 +410,7 @@ ipf_pool_node_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
node.ipn_mask.adf_addr.in4.s_addr) != node.ipn_mask.adf_addr.in4.s_addr) !=
node.ipn_addr.adf_addr.in4.s_addr) { node.ipn_addr.adf_addr.in4.s_addr) {
IPFERROR(70035); IPFERROR(70035);
return EINVAL; return(EINVAL);
} }
} }
#ifdef USE_INET6 #ifdef USE_INET6
@ -419,24 +419,24 @@ ipf_pool_node_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
&node.ipn_mask.adf_addr.in6, &node.ipn_mask.adf_addr.in6,
&node.ipn_addr.adf_addr.in6)) { &node.ipn_addr.adf_addr.in6)) {
IPFERROR(70036); IPFERROR(70036);
return EINVAL; return(EINVAL);
} }
} }
#endif #endif
/* /*
* add an entry to a pool - return an error if it already * add an entry to a pool - return an error if it already
* exists remove an entry from a pool - if it exists * exists remove an entry from a pool - if it exists
* - in both cases, the pool *must* exist! * - in both cases, the pool *must* exist!
*/ */
m = ipf_pool_findeq(arg, p, &node.ipn_addr, &node.ipn_mask); m = ipf_pool_findeq(arg, p, &node.ipn_addr, &node.ipn_mask);
if (m != NULL) { if (m != NULL) {
IPFERROR(70018); IPFERROR(70018);
return EEXIST; return(EEXIST);
} }
err = ipf_pool_insert_node(softc, arg, p, &node); err = ipf_pool_insert_node(softc, arg, p, &node);
return err; return(err);
} }
@ -459,21 +459,21 @@ ipf_pool_node_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
if (op->iplo_size != sizeof(node)) { if (op->iplo_size != sizeof(node)) {
IPFERROR(70019); IPFERROR(70019);
return EINVAL; return(EINVAL);
} }
node.ipn_uid = uid; node.ipn_uid = uid;
err = COPYIN(op->iplo_struct, &node, sizeof(node)); err = COPYIN(op->iplo_struct, &node, sizeof(node));
if (err != 0) { if (err != 0) {
IPFERROR(70020); IPFERROR(70020);
return EFAULT; return(EFAULT);
} }
if (node.ipn_addr.adf_family == AF_INET) { if (node.ipn_addr.adf_family == AF_INET) {
if (node.ipn_addr.adf_len != offsetof(addrfamily_t, adf_addr) + if (node.ipn_addr.adf_len != offsetof(addrfamily_t, adf_addr) +
sizeof(struct in_addr)) { sizeof(struct in_addr)) {
IPFERROR(70030); IPFERROR(70030);
return EINVAL; return(EINVAL);
} }
} }
#ifdef USE_INET6 #ifdef USE_INET6
@ -481,35 +481,35 @@ ipf_pool_node_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op,
if (node.ipn_addr.adf_len != offsetof(addrfamily_t, adf_addr) + if (node.ipn_addr.adf_len != offsetof(addrfamily_t, adf_addr) +
sizeof(struct in6_addr)) { sizeof(struct in6_addr)) {
IPFERROR(70037); IPFERROR(70037);
return EINVAL; return(EINVAL);
} }
} }
#endif #endif
if (node.ipn_mask.adf_len != node.ipn_addr.adf_len) { if (node.ipn_mask.adf_len != node.ipn_addr.adf_len) {
IPFERROR(70031); IPFERROR(70031);
return EINVAL; return(EINVAL);
} }
p = ipf_pool_find(arg, op->iplo_unit, op->iplo_name); p = ipf_pool_find(arg, op->iplo_unit, op->iplo_name);
if (p == NULL) { if (p == NULL) {
IPFERROR(70021); IPFERROR(70021);
return ESRCH; return(ESRCH);
} }
m = ipf_pool_findeq(arg, p, &node.ipn_addr, &node.ipn_mask); m = ipf_pool_findeq(arg, p, &node.ipn_addr, &node.ipn_mask);
if (m == NULL) { if (m == NULL) {
IPFERROR(70022); IPFERROR(70022);
return ENOENT; return(ENOENT);
} }
if ((uid != 0) && (uid != m->ipn_uid)) { if ((uid != 0) && (uid != m->ipn_uid)) {
IPFERROR(70024); IPFERROR(70024);
return EACCES; return(EACCES);
} }
err = ipf_pool_remove_node(softc, arg, p, m); err = ipf_pool_remove_node(softc, arg, p, m);
return err; return(err);
} }
@ -534,7 +534,7 @@ ipf_pool_table_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
err = ipf_pool_create(softc, arg, op); err = ipf_pool_create(softc, arg, op);
} }
return err; return(err);
} }
@ -549,7 +549,7 @@ ipf_pool_table_add(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
static int static int
ipf_pool_table_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op) ipf_pool_table_del(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
{ {
return ipf_pool_destroy(softc, arg, op->iplo_unit, op->iplo_name); return(ipf_pool_destroy(softc, arg, op->iplo_unit, op->iplo_name));
} }
@ -572,7 +572,7 @@ ipf_pool_stats_get(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
if (op->iplo_size != sizeof(ipf_pool_stat_t)) { if (op->iplo_size != sizeof(ipf_pool_stat_t)) {
IPFERROR(70001); IPFERROR(70001);
return EINVAL; return(EINVAL);
} }
bcopy((char *)&softp->ipf_pool_stats, (char *)&stats, sizeof(stats)); bcopy((char *)&softp->ipf_pool_stats, (char *)&stats, sizeof(stats));
@ -595,10 +595,10 @@ ipf_pool_stats_get(ipf_main_softc_t *softc, void *arg, iplookupop_t *op)
err = COPYOUT(&stats, op->iplo_struct, sizeof(stats)); err = COPYOUT(&stats, op->iplo_struct, sizeof(stats));
if (err != 0) { if (err != 0) {
IPFERROR(70026); IPFERROR(70026);
return EFAULT; return(EFAULT);
} }
} }
return 0; return(0);
} }
@ -636,7 +636,7 @@ ipf_pool_exists(ipf_pool_softc_t *softp, int unit, char *name)
sizeof(p->ipo_name)) == 0) sizeof(p->ipo_name)) == 0)
break; break;
} }
return p; return(p);
} }
@ -659,9 +659,9 @@ ipf_pool_find(void *arg, int unit, char *name)
p = ipf_pool_exists(softp, unit, name); p = ipf_pool_exists(softp, unit, name);
if ((p != NULL) && (p->ipo_flags & IPOOL_DELETE)) if ((p != NULL) && (p->ipo_flags & IPOOL_DELETE))
return NULL; return(NULL);
return p; return(p);
} }
@ -684,7 +684,7 @@ ipf_pool_select_add_ref(void *arg, int unit, char *name)
if (p != NULL) { if (p != NULL) {
ATOMIC_INC32(p->ipo_ref); ATOMIC_INC32(p->ipo_ref);
} }
return p; return(p);
} }
@ -706,7 +706,7 @@ ipf_pool_findeq(ipf_pool_softc_t *softp, ip_pool_t *ipo, addrfamily_t *addr,
ipf_rdx_node_t *n; ipf_rdx_node_t *n;
n = ipo->ipo_head->lookup(ipo->ipo_head, addr, mask); n = ipo->ipo_head->lookup(ipo->ipo_head, addr, mask);
return (ip_pool_node_t *)n; return(ip_pool_node_t *)n;
} }
@ -734,7 +734,7 @@ ipf_pool_search(ipf_main_softc_t *softc, void *tptr, int ipversion, void *dptr,
ipo = tptr; ipo = tptr;
if (ipo == NULL) if (ipo == NULL)
return -1; return(-1);
rv = 1; rv = 1;
m = NULL; m = NULL;
@ -754,7 +754,7 @@ ipf_pool_search(ipf_main_softc_t *softc, void *tptr, int ipversion, void *dptr,
v.adf_addr.in6 = addr->in6; v.adf_addr.in6 = addr->in6;
#endif #endif
} else } else
return -1; return(-1);
READ_ENTER(&softc->ipf_poolrw); READ_ENTER(&softc->ipf_poolrw);
@ -768,7 +768,7 @@ ipf_pool_search(ipf_main_softc_t *softc, void *tptr, int ipversion, void *dptr,
rv = m->ipn_info; rv = m->ipn_info;
} }
RWLOCK_EXIT(&softc->ipf_poolrw); RWLOCK_EXIT(&softc->ipf_poolrw);
return rv; return(rv);
} }
@ -794,19 +794,19 @@ ipf_pool_insert_node(ipf_main_softc_t *softc, ipf_pool_softc_t *softp,
if ((node->ipn_addr.adf_len > sizeof(*rn)) || if ((node->ipn_addr.adf_len > sizeof(*rn)) ||
(node->ipn_addr.adf_len < 4)) { (node->ipn_addr.adf_len < 4)) {
IPFERROR(70003); IPFERROR(70003);
return EINVAL; return(EINVAL);
} }
if ((node->ipn_mask.adf_len > sizeof(*rn)) || if ((node->ipn_mask.adf_len > sizeof(*rn)) ||
(node->ipn_mask.adf_len < 4)) { (node->ipn_mask.adf_len < 4)) {
IPFERROR(70004); IPFERROR(70004);
return EINVAL; return(EINVAL);
} }
KMALLOC(x, ip_pool_node_t *); KMALLOC(x, ip_pool_node_t *);
if (x == NULL) { if (x == NULL) {
IPFERROR(70002); IPFERROR(70002);
return ENOMEM; return(ENOMEM);
} }
*x = *node; *x = *node;
@ -864,7 +864,7 @@ ipf_pool_insert_node(ipf_main_softc_t *softc, ipf_pool_softc_t *softp,
if (rn == NULL) { if (rn == NULL) {
KFREE(x); KFREE(x);
IPFERROR(70005); IPFERROR(70005);
return ENOMEM; return(ENOMEM);
} }
x->ipn_ref = 1; x->ipn_ref = 1;
@ -874,7 +874,7 @@ ipf_pool_insert_node(ipf_main_softc_t *softc, ipf_pool_softc_t *softp,
softp->ipf_pool_stats.ipls_nodes++; softp->ipf_pool_stats.ipls_nodes++;
return 0; return(0);
} }
@ -911,24 +911,24 @@ ipf_pool_create(ipf_main_softc_t *softc, ipf_pool_softc_t *softp,
if (h != NULL) { if (h != NULL) {
if ((h->ipo_flags & IPOOL_DELETE) == 0) { if ((h->ipo_flags & IPOOL_DELETE) == 0) {
IPFERROR(70006); IPFERROR(70006);
return EEXIST; return(EEXIST);
} }
h->ipo_flags &= ~IPOOL_DELETE; h->ipo_flags &= ~IPOOL_DELETE;
return 0; return(0);
} }
} }
KMALLOC(h, ip_pool_t *); KMALLOC(h, ip_pool_t *);
if (h == NULL) { if (h == NULL) {
IPFERROR(70007); IPFERROR(70007);
return ENOMEM; return(ENOMEM);
} }
bzero(h, sizeof(*h)); bzero(h, sizeof(*h));
if (ipf_rx_inithead(softp->ipf_radix, &h->ipo_head) != 0) { if (ipf_rx_inithead(softp->ipf_radix, &h->ipo_head) != 0) {
KFREE(h); KFREE(h);
IPFERROR(70008); IPFERROR(70008);
return ENOMEM; return(ENOMEM);
} }
if ((op->iplo_arg & LOOKUP_ANON) != 0) { if ((op->iplo_arg & LOOKUP_ANON) != 0) {
@ -968,7 +968,7 @@ ipf_pool_create(ipf_main_softc_t *softc, ipf_pool_softc_t *softp,
softp->ipf_pool_stats.ipls_pools++; softp->ipf_pool_stats.ipls_pools++;
return 0; return(0);
} }
@ -1006,10 +1006,10 @@ ipf_pool_remove_node(ipf_main_softc_t *softc, ipf_pool_softc_t *softp,
if (ptr != NULL) { if (ptr != NULL) {
ipf_pool_node_deref(softp, ipe); ipf_pool_node_deref(softp, ipe);
return 0; return(0);
} }
IPFERROR(70027); IPFERROR(70027);
return ESRCH; return(ESRCH);
} }
@ -1039,17 +1039,17 @@ ipf_pool_destroy(ipf_main_softc_t *softc, ipf_pool_softc_t *softp,
ipo = ipf_pool_exists(softp, unit, name); ipo = ipf_pool_exists(softp, unit, name);
if (ipo == NULL) { if (ipo == NULL) {
IPFERROR(70009); IPFERROR(70009);
return ESRCH; return(ESRCH);
} }
if (ipo->ipo_ref != 1) { if (ipo->ipo_ref != 1) {
ipf_pool_clearnodes(softc, softp, ipo); ipf_pool_clearnodes(softc, softp, ipo);
ipo->ipo_flags |= IPOOL_DELETE; ipo->ipo_flags |= IPOOL_DELETE;
return 0; return(0);
} }
ipf_pool_free(softc, softp, ipo); ipf_pool_free(softc, softp, ipo);
return 0; return(0);
} }
@ -1086,7 +1086,7 @@ ipf_pool_flush(ipf_main_softc_t *softc, void *arg, iplookupflush_t *fp)
num++; num++;
} }
} }
return num; return(num);
} }
@ -1169,7 +1169,7 @@ ipf_pool_deref(ipf_main_softc_t *softc, void *arg, void *pool)
else if ((ipo->ipo_ref == 1) && (ipo->ipo_flags & IPOOL_DELETE)) else if ((ipo->ipo_ref == 1) && (ipo->ipo_flags & IPOOL_DELETE))
ipf_pool_destroy(softc, arg, ipo->ipo_unit, ipo->ipo_name); ipf_pool_destroy(softc, arg, ipo->ipo_unit, ipo->ipo_name);
return 0; return(0);
} }
@ -1280,7 +1280,7 @@ ipf_pool_iter_next(ipf_main_softc_t *softc, void *arg, ipftoken_t *token,
RWLOCK_EXIT(&softc->ipf_poolrw); RWLOCK_EXIT(&softc->ipf_poolrw);
if (err != 0) if (err != 0)
return err; return(err);
switch (ilp->ili_otype) switch (ilp->ili_otype)
{ {
@ -1313,7 +1313,7 @@ ipf_pool_iter_next(ipf_main_softc_t *softc, void *arg, ipftoken_t *token,
if (pnext == NULL) if (pnext == NULL)
ipf_token_mark_complete(token); ipf_token_mark_complete(token);
return err; return(err);
} }
@ -1333,10 +1333,10 @@ ipf_pool_iter_deref(ipf_main_softc_t *softc, void *arg, int otype, int unit,
ipf_pool_softc_t *softp = arg; ipf_pool_softc_t *softp = arg;
if (data == NULL) if (data == NULL)
return EINVAL; return(EINVAL);
if (unit < 0 || unit > IPL_LOGMAX) if (unit < 0 || unit > IPL_LOGMAX)
return EINVAL; return(EINVAL);
switch (otype) switch (otype)
{ {
@ -1351,7 +1351,7 @@ ipf_pool_iter_deref(ipf_main_softc_t *softc, void *arg, int otype, int unit,
break; break;
} }
return 0; return(0);
} }

View File

@ -116,7 +116,7 @@ ipf_p_pptp_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ip_t *ip; ip_t *ip;
if (fin->fin_v != 4) if (fin->fin_v != 4)
return -1; return(-1);
ip = fin->fin_ip; ip = fin->fin_ip;
np = nat->nat_ptr; np = nat->nat_ptr;
@ -126,19 +126,19 @@ ipf_p_pptp_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ip->ip_dst) != NULL) { ip->ip_dst) != NULL) {
if (ipf_p_pptp_debug > 0) if (ipf_p_pptp_debug > 0)
printf("ipf_p_pptp_new: GRE session already exists\n"); printf("ipf_p_pptp_new: GRE session already exists\n");
return -1; return(-1);
} }
KMALLOC(pptp, pptp_pxy_t *); KMALLOC(pptp, pptp_pxy_t *);
if (pptp == NULL) { if (pptp == NULL) {
if (ipf_p_pptp_debug > 0) if (ipf_p_pptp_debug > 0)
printf("ipf_p_pptp_new: malloc for aps_data failed\n"); printf("ipf_p_pptp_new: malloc for aps_data failed\n");
return -1; return(-1);
} }
KMALLOCS(ipn, ipnat_t *, size); KMALLOCS(ipn, ipnat_t *, size);
if (ipn == NULL) { if (ipn == NULL) {
KFREE(pptp); KFREE(pptp);
return -1; return(-1);
} }
aps->aps_data = pptp; aps->aps_data = pptp;
@ -182,7 +182,7 @@ ipf_p_pptp_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
pptp->pptp_side[0].pptps_wptr = pptp->pptp_side[0].pptps_buffer; pptp->pptp_side[0].pptps_wptr = pptp->pptp_side[0].pptps_buffer;
pptp->pptp_side[1].pptps_wptr = pptp->pptp_side[1].pptps_buffer; pptp->pptp_side[1].pptps_wptr = pptp->pptp_side[1].pptps_buffer;
return 0; return(0);
} }
@ -291,7 +291,7 @@ ipf_p_pptp_nextmessage(fr_info_t *fin, nat_t *nat, pptp_pxy_t *pptp, int rev)
fin->fin_ipoff; fin->fin_ipoff;
if (dlen <= 0) if (dlen <= 0)
return 0; return(0);
/* /*
* If the complete data packet is before what we expect to see * If the complete data packet is before what we expect to see
* "next", just ignore it as the chances are we've already seen it. * "next", just ignore it as the chances are we've already seen it.
@ -301,13 +301,13 @@ ipf_p_pptp_nextmessage(fr_info_t *fin, nat_t *nat, pptp_pxy_t *pptp, int rev)
*/ */
end = start + dlen; end = start + dlen;
if (pptps->pptps_next > end && pptps->pptps_next > start) if (pptps->pptps_next > end && pptps->pptps_next > start)
return 0; return(0);
if (pptps->pptps_next != start) { if (pptps->pptps_next != start) {
if (ipf_p_pptp_debug > 5) if (ipf_p_pptp_debug > 5)
printf("%s: next (%x) != start (%x)\n", funcname, printf("%s: next (%x) != start (%x)\n", funcname,
pptps->pptps_next, start); pptps->pptps_next, start);
return -1; return(-1);
} }
msg = (char *)fin->fin_dp + (TCP_OFF(tcp) << 2); msg = (char *)fin->fin_dp + (TCP_OFF(tcp) << 2);
@ -333,7 +333,7 @@ ipf_p_pptp_nextmessage(fr_info_t *fin, nat_t *nat, pptp_pxy_t *pptp, int rev)
printf("%s: bad cookie (%x)\n", printf("%s: bad cookie (%x)\n",
funcname, funcname,
hdr->pptph_cookie); hdr->pptph_cookie);
return -1; return(-1);
} }
} }
dlen -= len; dlen -= len;
@ -385,7 +385,7 @@ ipf_p_pptp_nextmessage(fr_info_t *fin, nat_t *nat, pptp_pxy_t *pptp, int rev)
dlen -= len; dlen -= len;
} }
return 0; return(0);
} }
@ -407,7 +407,7 @@ ipf_p_pptp_message(fr_info_t *fin, nat_t *nat, pptp_pxy_t *pptp,
default : default :
break; break;
} }
return 0; return(0);
} }
@ -492,7 +492,7 @@ ipf_p_pptp_mctl(fr_info_t *fin, nat_t *nat, pptp_pxy_t *pptp,
break; break;
} }
return 0; return(0);
} }
@ -522,8 +522,8 @@ ipf_p_pptp_inout(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
pptp->pptp_side[rev].pptps_next = ntohl(tcp->th_seq) + 1; pptp->pptp_side[rev].pptps_next = ntohl(tcp->th_seq) + 1;
pptp->pptp_side[rev].pptps_nexthdr = ntohl(tcp->th_seq) + 1; pptp->pptp_side[rev].pptps_nexthdr = ntohl(tcp->th_seq) + 1;
} }
return ipf_p_pptp_nextmessage(fin, nat, (pptp_pxy_t *)aps->aps_data, return(ipf_p_pptp_nextmessage(fin, nat, (pptp_pxy_t *)aps->aps_data,
rev); rev));
} }

View File

@ -259,7 +259,7 @@ ipf_proxy_main_load(void)
if (ap->apr_load != NULL) if (ap->apr_load != NULL)
(*ap->apr_load)(); (*ap->apr_load)();
} }
return 0; return(0);
} }
@ -283,7 +283,7 @@ ipf_proxy_main_unload(void)
if (ap->apr_unload != NULL) if (ap->apr_unload != NULL)
(*ap->apr_unload)(); (*ap->apr_unload)();
return 0; return(0);
} }
@ -304,7 +304,7 @@ ipf_proxy_soft_create(ipf_main_softc_t *softc)
KMALLOC(softp, ipf_proxy_softc_t *); KMALLOC(softp, ipf_proxy_softc_t *);
if (softp == NULL) if (softp == NULL)
return softp; return(softp);
bzero((char *)softp, sizeof(*softp)); bzero((char *)softp, sizeof(*softp));
@ -320,11 +320,11 @@ ipf_proxy_soft_create(ipf_main_softc_t *softc)
ipf_proxy_tuneables); ipf_proxy_tuneables);
if (softp->ipf_proxy_tune == NULL) { if (softp->ipf_proxy_tune == NULL) {
ipf_proxy_soft_destroy(softc, softp); ipf_proxy_soft_destroy(softc, softp);
return NULL; return(NULL);
} }
if (ipf_tune_array_link(softc, softp->ipf_proxy_tune) == -1) { if (ipf_tune_array_link(softc, softp->ipf_proxy_tune) == -1) {
ipf_proxy_soft_destroy(softc, softp); ipf_proxy_soft_destroy(softc, softp);
return NULL; return(NULL);
} }
last = NULL; last = NULL;
@ -349,10 +349,10 @@ ipf_proxy_soft_create(ipf_main_softc_t *softc)
last = apn; last = apn;
} }
return softp; return(softp);
failed: failed:
ipf_proxy_soft_destroy(softc, softp); ipf_proxy_soft_destroy(softc, softp);
return NULL; return(NULL);
} }
@ -372,7 +372,7 @@ ipf_proxy_create_clone(ipf_main_softc_t *softc, aproxy_t *orig)
KMALLOC(apn, aproxy_t *); KMALLOC(apn, aproxy_t *);
if (apn == NULL) if (apn == NULL)
return NULL; return(NULL);
bcopy((char *)orig, (char *)apn, sizeof(*apn)); bcopy((char *)orig, (char *)apn, sizeof(*apn));
apn->apr_next = NULL; apn->apr_next = NULL;
@ -382,14 +382,14 @@ ipf_proxy_create_clone(ipf_main_softc_t *softc, aproxy_t *orig)
apn->apr_soft = (*apn->apr_create)(softc); apn->apr_soft = (*apn->apr_create)(softc);
if (apn->apr_soft == NULL) { if (apn->apr_soft == NULL) {
KFREE(apn); KFREE(apn);
return NULL; return(NULL);
} }
} }
apn->apr_parent = orig; apn->apr_parent = orig;
orig->apr_clones++; orig->apr_clones++;
return apn; return(apn);
} }
@ -417,7 +417,7 @@ ipf_proxy_soft_init(ipf_main_softc_t *softc, void *arg)
KMALLOCS(softp->ips_sess_tab, ap_session_t **, size); KMALLOCS(softp->ips_sess_tab, ap_session_t **, size);
if (softp->ips_sess_tab == NULL) if (softp->ips_sess_tab == NULL)
return -1; return(-1);
bzero(softp->ips_sess_tab, size); bzero(softp->ips_sess_tab, size);
@ -425,12 +425,12 @@ ipf_proxy_soft_init(ipf_main_softc_t *softc, void *arg)
if (ap->apr_init != NULL) { if (ap->apr_init != NULL) {
err = (*ap->apr_init)(softc, ap->apr_soft); err = (*ap->apr_init)(softc, ap->apr_soft);
if (err != 0) if (err != 0)
return -2; return(-2);
} }
} }
softp->ips_init_run = 1; softp->ips_init_run = 1;
return 0; return(0);
} }
@ -463,7 +463,7 @@ ipf_proxy_soft_fini(ipf_main_softc_t *softc, void *arg)
} }
softp->ips_init_run = 0; softp->ips_init_run = 0;
return 0; return(0);
} }
@ -554,7 +554,7 @@ ipf_proxy_add(void *arg, aproxy_t *ap)
if (softp->ips_proxy_debug & 0x01) if (softp->ips_proxy_debug & 0x01)
printf("ipf_proxy_add: %s/%d present (B)\n", printf("ipf_proxy_add: %s/%d present (B)\n",
a->apr_label, a->apr_p); a->apr_label, a->apr_p);
return -1; return(-1);
} }
for (a = ap_proxylist; (a != NULL); a = a->apr_next) for (a = ap_proxylist; (a != NULL); a = a->apr_next)
@ -564,13 +564,13 @@ ipf_proxy_add(void *arg, aproxy_t *ap)
if (softp->ips_proxy_debug & 0x01) if (softp->ips_proxy_debug & 0x01)
printf("ipf_proxy_add: %s/%d present (D)\n", printf("ipf_proxy_add: %s/%d present (D)\n",
a->apr_label, a->apr_p); a->apr_label, a->apr_p);
return -1; return(-1);
} }
ap->apr_next = ap_proxylist; ap->apr_next = ap_proxylist;
ap_proxylist = ap; ap_proxylist = ap;
if (ap->apr_load != NULL) if (ap->apr_load != NULL)
(*ap->apr_load)(); (*ap->apr_load)();
return 0; return(0);
} }
@ -611,7 +611,7 @@ ipf_proxy_ctl(ipf_main_softc_t *softc, void *arg, ap_ctl_t *ctl)
printf("ipf_proxy_ctl: %s/%d ctl error %d\n", printf("ipf_proxy_ctl: %s/%d ctl error %d\n",
a->apr_label, a->apr_p, error); a->apr_label, a->apr_p, error);
} }
return error; return(error);
} }
@ -634,13 +634,13 @@ ipf_proxy_del(aproxy_t *ap)
a->apr_flags |= APR_DELETE; a->apr_flags |= APR_DELETE;
if (ap->apr_ref == 0 && ap->apr_clones == 0) { if (ap->apr_ref == 0 && ap->apr_clones == 0) {
*app = a->apr_next; *app = a->apr_next;
return 0; return(0);
} }
return 1; return(1);
} }
} }
return -1; return(-1);
} }
@ -664,10 +664,10 @@ ipf_proxy_ok(fr_info_t *fin, tcphdr_t *tcp, ipnat_t *np)
if ((apr == NULL) || (apr->apr_flags & APR_DELETE) || if ((apr == NULL) || (apr->apr_flags & APR_DELETE) ||
(fin->fin_p != apr->apr_p)) (fin->fin_p != apr->apr_p))
return 0; return(0);
if ((tcp == NULL) && dport) if ((tcp == NULL) && dport)
return 0; return(0);
return 1; return(1);
} }
@ -696,7 +696,7 @@ ipf_proxy_ioctl(ipf_main_softc_t *softc, caddr_t data, ioctlcmd_t cmd,
case SIOCPROXY : case SIOCPROXY :
error = ipf_inobj(softc, data, NULL, &ctl, IPFOBJ_PROXYCTL); error = ipf_inobj(softc, data, NULL, &ctl, IPFOBJ_PROXYCTL);
if (error != 0) { if (error != 0) {
return error; return(error);
} }
ptr = NULL; ptr = NULL;
@ -729,7 +729,7 @@ ipf_proxy_ioctl(ipf_main_softc_t *softc, caddr_t data, ioctlcmd_t cmd,
IPFERROR(80004); IPFERROR(80004);
error = EINVAL; error = EINVAL;
} }
return error; return(error);
} }
@ -763,7 +763,7 @@ ipf_proxy_match(fr_info_t *fin, nat_t *nat)
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_match: flx 0x%x (BAD|SHORT)\n", printf("ipf_proxy_match: flx 0x%x (BAD|SHORT)\n",
fin->fin_flx); fin->fin_flx);
return -1; return(-1);
} }
apr = ipn->in_apr; apr = ipn->in_apr;
@ -771,7 +771,7 @@ ipf_proxy_match(fr_info_t *fin, nat_t *nat)
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_match:apr %lx apr_flags 0x%x\n", printf("ipf_proxy_match:apr %lx apr_flags 0x%x\n",
(u_long)apr, apr ? apr->apr_flags : 0); (u_long)apr, apr ? apr->apr_flags : 0);
return -1; return(-1);
} }
if (apr->apr_match != NULL) { if (apr->apr_match != NULL) {
@ -779,10 +779,10 @@ ipf_proxy_match(fr_info_t *fin, nat_t *nat)
if (result != 0) { if (result != 0) {
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_match: result %d\n", result); printf("ipf_proxy_match: result %d\n", result);
return -1; return(-1);
} }
} }
return 0; return(0);
} }
@ -811,7 +811,7 @@ ipf_proxy_new(fr_info_t *fin, nat_t *nat)
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_new: nat_ptr %lx nat_aps %lx\n", printf("ipf_proxy_new: nat_ptr %lx nat_aps %lx\n",
(u_long)nat->nat_ptr, (u_long)nat->nat_aps); (u_long)nat->nat_ptr, (u_long)nat->nat_aps);
return -1; return(-1);
} }
apr = nat->nat_ptr->in_apr; apr = nat->nat_ptr->in_apr;
@ -821,7 +821,7 @@ ipf_proxy_new(fr_info_t *fin, nat_t *nat)
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_new: apr_flags 0x%x p %d/%d\n", printf("ipf_proxy_new: apr_flags 0x%x p %d/%d\n",
apr->apr_flags, fin->fin_p, apr->apr_p); apr->apr_flags, fin->fin_p, apr->apr_p);
return -1; return(-1);
} }
KMALLOC(aps, ap_session_t *); KMALLOC(aps, ap_session_t *);
@ -829,7 +829,7 @@ ipf_proxy_new(fr_info_t *fin, nat_t *nat)
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_new: malloc failed (%lu)\n", printf("ipf_proxy_new: malloc failed (%lu)\n",
(u_long)sizeof(ap_session_t)); (u_long)sizeof(ap_session_t));
return -1; return(-1);
} }
bzero((char *)aps, sizeof(*aps)); bzero((char *)aps, sizeof(*aps));
@ -845,14 +845,14 @@ ipf_proxy_new(fr_info_t *fin, nat_t *nat)
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_new: new(%lx) failed\n", printf("ipf_proxy_new: new(%lx) failed\n",
(u_long)apr->apr_new); (u_long)apr->apr_new);
return -1; return(-1);
} }
aps->aps_nat = nat; aps->aps_nat = nat;
aps->aps_next = softp->ips_sess_list; aps->aps_next = softp->ips_sess_list;
softp->ips_sess_list = aps; softp->ips_sess_list = aps;
nat->nat_aps = aps; nat->nat_aps = aps;
return 0; return(0);
} }
@ -892,7 +892,7 @@ ipf_proxy_check(fr_info_t *fin, nat_t *nat)
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_check: flx 0x%x (BAD)\n", printf("ipf_proxy_check: flx 0x%x (BAD)\n",
fin->fin_flx); fin->fin_flx);
return -1; return(-1);
} }
#ifndef IPFILTER_CKSUM #ifndef IPFILTER_CKSUM
@ -902,7 +902,7 @@ ipf_proxy_check(fr_info_t *fin, nat_t *nat)
fin->fin_p); fin->fin_p);
if (fin->fin_p == IPPROTO_TCP) if (fin->fin_p == IPPROTO_TCP)
softc->ipf_stats[fin->fin_out].fr_tcpbad++; softc->ipf_stats[fin->fin_out].fr_tcpbad++;
return -1; return(-1);
} }
#endif #endif
@ -918,7 +918,7 @@ ipf_proxy_check(fr_info_t *fin, nat_t *nat)
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_check: %s %x\n", printf("ipf_proxy_check: %s %x\n",
"coalesce failed", fin->fin_flx); "coalesce failed", fin->fin_flx);
return -1; return(-1);
} }
#endif #endif
ip = fin->fin_ip; ip = fin->fin_ip;
@ -962,12 +962,12 @@ ipf_proxy_check(fr_info_t *fin, nat_t *nat)
printf("ipf_proxy_check: out %d err %x rv %d\n", printf("ipf_proxy_check: out %d err %x rv %d\n",
fin->fin_out, err, rv); fin->fin_out, err, rv);
if (rv == 1) if (rv == 1)
return -1; return(-1);
if (rv == 2) { if (rv == 2) {
ipf_proxy_deref(apr); ipf_proxy_deref(apr);
nat->nat_aps = NULL; nat->nat_aps = NULL;
return -1; return(-1);
} }
/* /*
@ -1019,7 +1019,7 @@ ipf_proxy_check(fr_info_t *fin, nat_t *nat)
aps->aps_bytes += fin->fin_plen; aps->aps_bytes += fin->fin_plen;
aps->aps_pkts++; aps->aps_pkts++;
} }
return 1; return(1);
} }
@ -1045,12 +1045,12 @@ ipf_proxy_lookup(void *arg, u_int pr, char *name)
if ((ap->apr_p == pr) && if ((ap->apr_p == pr) &&
!strncmp(name, ap->apr_label, sizeof(ap->apr_label))) { !strncmp(name, ap->apr_label, sizeof(ap->apr_label))) {
ap->apr_ref++; ap->apr_ref++;
return ap; return(ap);
} }
if (softp->ips_proxy_debug & 0x08) if (softp->ips_proxy_debug & 0x08)
printf("ipf_proxy_lookup: failed for %d/%s\n", pr, name); printf("ipf_proxy_lookup: failed for %d/%s\n", pr, name);
return NULL; return(NULL);
} }
@ -1254,7 +1254,7 @@ ipf_proxy_fixseqack(fr_info_t *fin, ip_t *ip, ap_session_t *aps, int inc)
if (softp->ips_proxy_debug & 0x10) if (softp->ips_proxy_debug & 0x10)
printf("ipf_proxy_fixseqack: seq %u ack %u\n", printf("ipf_proxy_fixseqack: seq %u ack %u\n",
(u_32_t)ntohl(tcp->th_seq), (u_32_t)ntohl(tcp->th_ack)); (u_32_t)ntohl(tcp->th_seq), (u_32_t)ntohl(tcp->th_ack));
return ch ? 2 : 0; return(ch ? 2 : 0);
} }
@ -1288,7 +1288,7 @@ ipf_proxy_rule_rev(nat_t *nat)
KMALLOCS(ipn, ipnat_t *, size); KMALLOCS(ipn, ipnat_t *, size);
if (ipn == NULL) if (ipn == NULL)
return NULL; return(NULL);
bzero((char *)ipn, size); bzero((char *)ipn, size);
@ -1347,7 +1347,7 @@ ipf_proxy_rule_rev(nat_t *nat)
bcopy(old->in_names, ipn->in_names, ipn->in_namelen); bcopy(old->in_names, ipn->in_names, ipn->in_namelen);
MUTEX_INIT(&ipn->in_lock, "ipnat rev rule lock"); MUTEX_INIT(&ipn->in_lock, "ipnat rev rule lock");
return ipn; return(ipn);
} }
@ -1375,7 +1375,7 @@ ipf_proxy_rule_fwd(nat_t *nat)
KMALLOCS(ipn, ipnat_t *, size); KMALLOCS(ipn, ipnat_t *, size);
if (ipn == NULL) if (ipn == NULL)
return NULL; return(NULL);
bzero((char *)ipn, size); bzero((char *)ipn, size);
@ -1419,5 +1419,5 @@ ipf_proxy_rule_fwd(nat_t *nat)
bcopy(old->in_names, ipn->in_names, ipn->in_namelen); bcopy(old->in_names, ipn->in_names, ipn->in_namelen);
MUTEX_INIT(&ipn->in_lock, "ipnat fwd rule lock"); MUTEX_INIT(&ipn->in_lock, "ipnat fwd rule lock");
return ipn; return(ipn);
} }

View File

@ -57,17 +57,17 @@ ipf_p_raudio_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
nat = nat; /* LINT */ nat = nat; /* LINT */
if (fin->fin_v != 4) if (fin->fin_v != 4)
return -1; return(-1);
KMALLOCS(aps->aps_data, void *, sizeof(raudio_t)); KMALLOCS(aps->aps_data, void *, sizeof(raudio_t));
if (aps->aps_data == NULL) if (aps->aps_data == NULL)
return -1; return(-1);
bzero(aps->aps_data, sizeof(raudio_t)); bzero(aps->aps_data, sizeof(raudio_t));
rap = aps->aps_data; rap = aps->aps_data;
aps->aps_psiz = sizeof(raudio_t); aps->aps_psiz = sizeof(raudio_t);
rap->rap_mode = RAP_M_TCP; /* default is for TCP */ rap->rap_mode = RAP_M_TCP; /* default is for TCP */
return 0; return(0);
} }
@ -90,7 +90,7 @@ ipf_p_raudio_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
* for the proxy to do. * for the proxy to do.
*/ */
if (rap->rap_eos == 1) if (rap->rap_eos == 1)
return 0; return(0);
m = fin->fin_m; m = fin->fin_m;
tcp = (tcphdr_t *)fin->fin_dp; tcp = (tcphdr_t *)fin->fin_dp;
@ -99,7 +99,7 @@ ipf_p_raudio_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
dlen = MSGDSIZE(m) - off; dlen = MSGDSIZE(m) - off;
if (dlen <= 0) if (dlen <= 0)
return 0; return(0);
if (dlen > sizeof(membuf)) if (dlen > sizeof(membuf))
dlen = sizeof(membuf); dlen = sizeof(membuf);
@ -116,7 +116,7 @@ ipf_p_raudio_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
if (rap->rap_seenpna == 0) { if (rap->rap_seenpna == 0) {
s = (u_char *)memstr("PNA", (char *)membuf, 3, dlen); s = (u_char *)memstr("PNA", (char *)membuf, 3, dlen);
if (s == NULL) if (s == NULL)
return 0; return(0);
s += 3; s += 3;
rap->rap_seenpna = 1; rap->rap_seenpna = 1;
} else } else
@ -132,7 +132,7 @@ ipf_p_raudio_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
s += 2; s += 2;
rap->rap_seenver = 1; rap->rap_seenver = 1;
} else } else
return 0; return(0);
} }
/* /*
@ -168,7 +168,7 @@ ipf_p_raudio_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
rap->rap_gotid = 0; rap->rap_gotid = 0;
} }
} }
return 0; return(0);
} }
@ -199,7 +199,7 @@ ipf_p_raudio_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
* then data is sent back on the same channel that is already open. * then data is sent back on the same channel that is already open.
*/ */
if (rap->rap_sdone != 0) if (rap->rap_sdone != 0)
return 0; return(0);
m = fin->fin_m; m = fin->fin_m;
tcp = (tcphdr_t *)fin->fin_dp; tcp = (tcphdr_t *)fin->fin_dp;
@ -208,7 +208,7 @@ ipf_p_raudio_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
dlen = MSGDSIZE(m) - off; dlen = MSGDSIZE(m) - off;
if (dlen <= 0) if (dlen <= 0)
return 0; return(0);
if (dlen > sizeof(membuf)) if (dlen > sizeof(membuf))
dlen = sizeof(membuf); dlen = sizeof(membuf);
@ -224,7 +224,7 @@ ipf_p_raudio_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
if (rap->rap_sseq == 0) { if (rap->rap_sseq == 0) {
s = (u_char *)memstr("PNA", (char *)membuf, 3, dlen); s = (u_char *)memstr("PNA", (char *)membuf, 3, dlen);
if (s == NULL) if (s == NULL)
return 0; return(0);
a1 = s - membuf; a1 = s - membuf;
dlen -= a1; dlen -= a1;
a1 = 0; a1 = 0;
@ -240,7 +240,7 @@ ipf_p_raudio_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
a2 -= a1; a2 -= a1;
s = membuf; s = membuf;
} else } else
return 0; return(0);
for (a3 = a1, a4 = a2; (a4 > 0) && (a3 < 19) && (a3 >= 0); a4--,a3++) { for (a3 = a1, a4 = a2; (a4 > 0) && (a3 < 19) && (a3 >= 0); a4--,a3++) {
rap->rap_sbf |= (1 << a3); rap->rap_sbf |= (1 << a3);
@ -248,7 +248,7 @@ ipf_p_raudio_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
} }
if ((rap->rap_sbf != 0x7ffff) || (!rap->rap_eos)) /* 19 bits */ if ((rap->rap_sbf != 0x7ffff) || (!rap->rap_eos)) /* 19 bits */
return 0; return(0);
rap->rap_sdone = 1; rap->rap_sdone = 1;
s = (u_char *)rap->rap_svr + 11; s = (u_char *)rap->rap_svr + 11;
@ -329,5 +329,5 @@ ipf_p_raudio_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ip->ip_len = slen; ip->ip_len = slen;
ip->ip_src = swa; ip->ip_src = swa;
ip->ip_dst = swb; ip->ip_dst = swb;
return 0; return(0);
} }

View File

@ -82,7 +82,7 @@ ipf_p_rcmd_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
#ifdef IP_RCMD_PROXY_DEBUG #ifdef IP_RCMD_PROXY_DEBUG
printf("ipf_p_rcmd_new:KMALLOCS(%d) failed\n", sizeof(*rc)); printf("ipf_p_rcmd_new:KMALLOCS(%d) failed\n", sizeof(*rc));
#endif #endif
return -1; return(-1);
} }
aps->aps_sport = tcp->th_sport; aps->aps_sport = tcp->th_sport;
aps->aps_dport = tcp->th_dport; aps->aps_dport = tcp->th_dport;
@ -90,7 +90,7 @@ ipf_p_rcmd_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ipn = ipf_proxy_rule_rev(nat); ipn = ipf_proxy_rule_rev(nat);
if (ipn == NULL) { if (ipn == NULL) {
KFREE(rc); KFREE(rc);
return -1; return(-1);
} }
aps->aps_data = rc; aps->aps_data = rc;
@ -99,7 +99,7 @@ ipf_p_rcmd_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
rc->rcmd_rule = ipn; rc->rcmd_rule = ipn;
return 0; return(0);
} }
@ -129,7 +129,7 @@ ipf_rcmd_atoi(char *ptr)
i *= 10; i *= 10;
i += c - '0'; i += c - '0';
} }
return i; return(i);
} }
@ -167,12 +167,12 @@ ipf_p_rcmd_portmsg(fr_info_t *fin, ap_session_t *aps, nat_t *nat)
dlen = fin->fin_dlen - tcpsz; dlen = fin->fin_dlen - tcpsz;
if (dlen <= 0) if (dlen <= 0)
return 0; return(0);
rc = (rcmdinfo_t *)aps->aps_data; rc = (rcmdinfo_t *)aps->aps_data;
if ((rc->rcmd_portseq != 0) && if ((rc->rcmd_portseq != 0) &&
(tcp->th_seq != rc->rcmd_portseq)) (tcp->th_seq != rc->rcmd_portseq))
return 0; return(0);
bzero(portbuf, sizeof(portbuf)); bzero(portbuf, sizeof(portbuf));
COPYDATA(m, off, MIN(sizeof(portbuf), dlen), portbuf); COPYDATA(m, off, MIN(sizeof(portbuf), dlen), portbuf);
@ -185,7 +185,7 @@ ipf_p_rcmd_portmsg(fr_info_t *fin, ap_session_t *aps, nat_t *nat)
printf("ipf_p_rcmd_portmsg:sp == 0 dlen %d [%s]\n", printf("ipf_p_rcmd_portmsg:sp == 0 dlen %d [%s]\n",
dlen, portbuf); dlen, portbuf);
#endif #endif
return 0; return(0);
} }
if (rc->rcmd_port != 0 && sp != rc->rcmd_port) { if (rc->rcmd_port != 0 && sp != rc->rcmd_port) {
@ -193,7 +193,7 @@ ipf_p_rcmd_portmsg(fr_info_t *fin, ap_session_t *aps, nat_t *nat)
printf("ipf_p_rcmd_portmsg:sp(%d) != rcmd_port(%d)\n", printf("ipf_p_rcmd_portmsg:sp(%d) != rcmd_port(%d)\n",
sp, rc->rcmd_port); sp, rc->rcmd_port);
#endif #endif
return 0; return(0);
} }
rc->rcmd_port = sp; rc->rcmd_port = sp;
@ -241,7 +241,7 @@ ipf_p_rcmd_portmsg(fr_info_t *fin, ap_session_t *aps, nat_t *nat)
} }
} }
if (nat2 != NULL) if (nat2 != NULL)
return APR_ERR(1); return(APR_ERR(1));
/* /*
* Add skeleton NAT entry for connection which will come * Add skeleton NAT entry for connection which will come
@ -311,8 +311,8 @@ ipf_p_rcmd_portmsg(fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ip->ip_len = slen; ip->ip_len = slen;
} }
if (nat2 == NULL) if (nat2 == NULL)
return APR_ERR(1); return(APR_ERR(1));
return 0; return(0);
} }
@ -320,8 +320,8 @@ int
ipf_p_rcmd_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat) ipf_p_rcmd_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
{ {
if (nat->nat_dir == NAT_OUTBOUND) if (nat->nat_dir == NAT_OUTBOUND)
return ipf_p_rcmd_portmsg(fin, aps, nat); return(ipf_p_rcmd_portmsg(fin, aps, nat));
return 0; return(0);
} }
@ -329,6 +329,6 @@ int
ipf_p_rcmd_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat) ipf_p_rcmd_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
{ {
if (nat->nat_dir == NAT_INBOUND) if (nat->nat_dir == NAT_INBOUND)
return ipf_p_rcmd_portmsg(fin, aps, nat); return(ipf_p_rcmd_portmsg(fin, aps, nat));
return 0; return(0);
} }

View File

@ -151,7 +151,7 @@ ipf_p_rpcb_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
nat = nat; /* LINT */ nat = nat; /* LINT */
if (fin->fin_v != 4) if (fin->fin_v != 4)
return -1; return(-1);
KMALLOC(rs, rpcb_session_t *); KMALLOC(rs, rpcb_session_t *);
if (rs == NULL) if (rs == NULL)
@ -722,7 +722,7 @@ ipf_p_rpcb_atoi(char *ptr)
i *= 10; i *= 10;
i += c - '0'; i += c - '0';
} }
return i; return(i);
} }
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@ -90,7 +90,7 @@ u_32_t *passp;
frentry_t *fr = NULL; frentry_t *fr = NULL;
fr = (frentry_t *)&in_rule__0; fr = (frentry_t *)&in_rule__0;
return fr; return(fr);
} }
frentry_t *ipfrule_match_out_(fin, passp) frentry_t *ipfrule_match_out_(fin, passp)
@ -100,7 +100,7 @@ u_32_t *passp;
frentry_t *fr = NULL; frentry_t *fr = NULL;
fr = (frentry_t *)&out_rule__0; fr = (frentry_t *)&out_rule__0;
return fr; return(fr);
} }
static frentry_t ipfrule_out_; static frentry_t ipfrule_out_;
@ -137,7 +137,7 @@ int ipfrule_add_out_(void)
fp->fr_func = (ipfunc_t)ipfrule_match_out_; fp->fr_func = (ipfunc_t)ipfrule_match_out_;
err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp, err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp,
V_ipfmain.ipf_active, 0); V_ipfmain.ipf_active, 0);
return err; return(err);
} }
@ -166,10 +166,10 @@ int ipfrule_remove_out_(void)
(caddr_t)&ipfrule_out_, (caddr_t)&ipfrule_out_,
V_ipfmain.ipf_active, 0); V_ipfmain.ipf_active, 0);
if (err) if (err)
return err; return(err);
return err; return(err);
} }
static frentry_t ipfrule_in_; static frentry_t ipfrule_in_;
@ -206,7 +206,7 @@ int ipfrule_add_in_(void)
fp->fr_func = (ipfunc_t)ipfrule_match_in_; fp->fr_func = (ipfunc_t)ipfrule_match_in_;
err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp, err = frrequest(&V_ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp,
V_ipfmain.ipf_active, 0); V_ipfmain.ipf_active, 0);
return err; return(err);
} }
@ -235,10 +235,10 @@ int ipfrule_remove_in_(void)
(caddr_t)&ipfrule_in_, (caddr_t)&ipfrule_in_,
V_ipfmain.ipf_active, 0); V_ipfmain.ipf_active, 0);
if (err) if (err)
return err; return(err);
return err; return(err);
} }
int ipfrule_add(void) int ipfrule_add(void)
@ -247,11 +247,11 @@ int ipfrule_add(void)
err = ipfrule_add_out_(); err = ipfrule_add_out_();
if (err != 0) if (err != 0)
return err; return(err);
err = ipfrule_add_in_(); err = ipfrule_add_in_();
if (err != 0) if (err != 0)
return err; return(err);
return 0; return(0);
} }
@ -261,10 +261,10 @@ int ipfrule_remove(void)
err = ipfrule_remove_out_(); err = ipfrule_remove_out_();
if (err != 0) if (err != 0)
return err; return(err);
err = ipfrule_remove_in_(); err = ipfrule_remove_in_();
if (err != 0) if (err != 0)
return err; return(err);
return 0; return(0);
} }
#endif /* IPFILTER_COMPILED */ #endif /* IPFILTER_COMPILED */

View File

@ -84,7 +84,7 @@ ipf_scan_init(void)
{ {
RWLOCK_INIT(&ipf_scan_rwlock, "ip scan rwlock"); RWLOCK_INIT(&ipf_scan_rwlock, "ip scan rwlock");
ipf_scan_inited = 1; ipf_scan_inited = 1;
return 0; return(0);
} }
@ -107,13 +107,13 @@ ipf_scan_add(caddr_t data)
KMALLOC(isc, ipscan_t *); KMALLOC(isc, ipscan_t *);
if (!isc) { if (!isc) {
ipf_interror = 90001; ipf_interror = 90001;
return ENOMEM; return(ENOMEM);
} }
err = copyinptr(data, isc, sizeof(*isc)); err = copyinptr(data, isc, sizeof(*isc));
if (err) { if (err) {
KFREE(isc); KFREE(isc);
return err; return(err);
} }
WRITE_ENTER(&ipf_scan_rwlock); WRITE_ENTER(&ipf_scan_rwlock);
@ -123,7 +123,7 @@ ipf_scan_add(caddr_t data)
RWLOCK_EXIT(&ipf_scan_rwlock); RWLOCK_EXIT(&ipf_scan_rwlock);
KFREE(isc); KFREE(isc);
ipf_interror = 90002; ipf_interror = 90002;
return EEXIST; return(EEXIST);
} }
if (ipf_scan_tail) { if (ipf_scan_tail) {
@ -144,7 +144,7 @@ ipf_scan_add(caddr_t data)
ipf_scan_stat.iscs_entries++; ipf_scan_stat.iscs_entries++;
RWLOCK_EXIT(&ipf_scan_rwlock); RWLOCK_EXIT(&ipf_scan_rwlock);
return 0; return(0);
} }
@ -156,7 +156,7 @@ ipf_scan_remove(caddr_t data)
err = copyinptr(data, &isc, sizeof(isc)); err = copyinptr(data, &isc, sizeof(isc));
if (err) if (err)
return err; return(err);
WRITE_ENTER(&ipf_scan_rwlock); WRITE_ENTER(&ipf_scan_rwlock);
@ -167,7 +167,7 @@ ipf_scan_remove(caddr_t data)
if (i->ipsc_fref) { if (i->ipsc_fref) {
RWLOCK_EXIT(&ipf_scan_rwlock); RWLOCK_EXIT(&ipf_scan_rwlock);
ipf_interror = 90003; ipf_interror = 90003;
return EBUSY; return(EBUSY);
} }
*i->ipsc_pnext = i->ipsc_next; *i->ipsc_pnext = i->ipsc_next;
@ -184,7 +184,7 @@ ipf_scan_remove(caddr_t data)
KFREE(i); KFREE(i);
} }
RWLOCK_EXIT(&ipf_scan_rwlock); RWLOCK_EXIT(&ipf_scan_rwlock);
return err; return(err);
} }
@ -195,8 +195,8 @@ ipf_scan_lookup(char *tag)
for (i = ipf_scan_list; i; i = i->ipsc_next) for (i = ipf_scan_list; i; i = i->ipsc_next)
if (!strcmp(i->ipsc_tag, tag)) if (!strcmp(i->ipsc_tag, tag))
return i; return(i);
return NULL; return(NULL);
} }
@ -214,11 +214,11 @@ ipf_scan_attachfr(struct frentry *fr)
RWLOCK_EXIT(&ipf_scan_rwlock); RWLOCK_EXIT(&ipf_scan_rwlock);
if (i == NULL) { if (i == NULL) {
ipf_interror = 90004; ipf_interror = 90004;
return ENOENT; return(ENOENT);
} }
fr->fr_isc = i; fr->fr_isc = i;
} }
return 0; return(0);
} }
@ -246,7 +246,7 @@ ipf_scan_attachis(struct ipstate *is)
} }
} }
RWLOCK_EXIT(&ipf_scan_rwlock); RWLOCK_EXIT(&ipf_scan_rwlock);
return 0; return(0);
} }
@ -259,7 +259,7 @@ ipf_scan_detachfr(struct frentry *fr)
if (i != NULL) { if (i != NULL) {
ATOMIC_DEC32(i->ipsc_fref); ATOMIC_DEC32(i->ipsc_fref);
} }
return 0; return(0);
} }
@ -276,7 +276,7 @@ ipf_scan_detachis(is)
is->is_flags &= ~(IS_SC_CLIENT|IS_SC_SERVER); is->is_flags &= ~(IS_SC_CLIENT|IS_SC_SERVER);
} }
RWLOCK_EXIT(&ipf_scan_rwlock); RWLOCK_EXIT(&ipf_scan_rwlock);
return 0; return(0);
} }
@ -298,16 +298,16 @@ ipf_scan_matchstr(sinfo_t *sp, char *str, int n)
{ {
case '.' : case '.' :
if (*s != *up) if (*s != *up)
return 1; return(1);
break; break;
case '?' : case '?' :
if (!ISALPHA(*up) || ((*s & 0x5f) != (*up & 0x5f))) if (!ISALPHA(*up) || ((*s & 0x5f) != (*up & 0x5f)))
return 1; return(1);
break; break;
case '*' : case '*' :
break; break;
} }
return 0; return(0);
} }
@ -328,9 +328,9 @@ ipf_scan_matchisc(ipscan_t *isc, ipstate_t *is, int cl, int sl, int maxm[2])
*/ */
if (maxm != NULL) { if (maxm != NULL) {
if (isc->ipsc_clen < maxm[0]) if (isc->ipsc_clen < maxm[0])
return 0; return(0);
if (isc->ipsc_slen < maxm[1]) if (isc->ipsc_slen < maxm[1])
return 0; return(0);
j = maxm[0]; j = maxm[0];
k = maxm[1]; k = maxm[1];
} else { } else {
@ -376,7 +376,7 @@ ipf_scan_matchisc(ipscan_t *isc, ipstate_t *is, int cl, int sl, int maxm[2])
maxm[0] = j; maxm[0] = j;
maxm[1] = k; maxm[1] = k;
} }
return ret; return(ret);
} }
@ -435,7 +435,7 @@ ipf_scan_match(ipstate_t *is)
if (k == 1) if (k == 1)
isc = lm; isc = lm;
if (isc == NULL) if (isc == NULL)
return 0; return(0);
/* /*
* No matches or partial matches, so reset the respective * No matches or partial matches, so reset the respective
@ -500,7 +500,7 @@ ipf_scan_match(ipstate_t *is)
break; break;
} }
return i; return(i);
} }
@ -519,7 +519,7 @@ ipf_scan_packet(fr_info_t *fin, ipstate_t *is)
seq = ntohl(tcp->th_seq); seq = ntohl(tcp->th_seq);
if (!is->is_s0[rv]) if (!is->is_s0[rv])
return 1; return(1);
/* /*
* check if this packet has more data that falls within the first * check if this packet has more data that falls within the first
@ -528,11 +528,11 @@ ipf_scan_packet(fr_info_t *fin, ipstate_t *is)
s0 = is->is_s0[rv]; s0 = is->is_s0[rv];
off = seq - s0; off = seq - s0;
if ((off > 15) || (off < 0)) if ((off > 15) || (off < 0))
return 1; return(1);
thoff = TCP_OFF(tcp) << 2; thoff = TCP_OFF(tcp) << 2;
dlen = fin->fin_dlen - thoff; dlen = fin->fin_dlen - thoff;
if (dlen <= 0) if (dlen <= 0)
return 1; return(1);
if (dlen > 16) if (dlen > 16)
dlen = 16; dlen = 16;
if (off + dlen > 16) if (off + dlen > 16)
@ -548,7 +548,7 @@ ipf_scan_packet(fr_info_t *fin, ipstate_t *is)
for (j = 0, i = is->is_smsk[rv]; i & 1; i >>= 1) for (j = 0, i = is->is_smsk[rv]; i & 1; i >>= 1)
j++; j++;
if (j == 0) if (j == 0)
return 1; return(1);
(void) ipf_scan_match(is); (void) ipf_scan_match(is);
#if 0 #if 0
@ -561,7 +561,7 @@ ipf_scan_packet(fr_info_t *fin, ipstate_t *is)
if (!(is->is_flags & IS_SC_SERVER)) if (!(is->is_flags & IS_SC_SERVER))
bzero(is->is_sbuf[1], sizeof(is->is_sbuf[1])); bzero(is->is_sbuf[1], sizeof(is->is_sbuf[1]));
#endif #endif
return 0; return(0);
} }
@ -593,6 +593,6 @@ ipf_scan_ioctl(caddr_t data, ioctlcmd_t cmd, int mode, int uid, void *ctx)
break; break;
} }
return err; return(err);
} }
#endif /* IPFILTER_SCAN */ #endif /* IPFILTER_SCAN */

View File

@ -198,7 +198,7 @@ static int ipf_state_putent(ipf_main_softc_t *, ipf_state_softc_t *,
int int
ipf_state_main_load(void) ipf_state_main_load(void)
{ {
return 0; return(0);
} }
@ -213,7 +213,7 @@ ipf_state_main_load(void)
int int
ipf_state_main_unload(void) ipf_state_main_unload(void)
{ {
return 0; return(0);
} }
@ -232,7 +232,7 @@ ipf_state_soft_create(ipf_main_softc_t *softc)
KMALLOC(softs, ipf_state_softc_t *); KMALLOC(softs, ipf_state_softc_t *);
if (softs == NULL) if (softs == NULL)
return NULL; return(NULL);
bzero((char *)softs, sizeof(*softs)); bzero((char *)softs, sizeof(*softs));
@ -241,11 +241,11 @@ ipf_state_soft_create(ipf_main_softc_t *softc)
ipf_state_tuneables); ipf_state_tuneables);
if (softs->ipf_state_tune == NULL) { if (softs->ipf_state_tune == NULL) {
ipf_state_soft_destroy(softc, softs); ipf_state_soft_destroy(softc, softs);
return NULL; return(NULL);
} }
if (ipf_tune_array_link(softc, softs->ipf_state_tune) == -1) { if (ipf_tune_array_link(softc, softs->ipf_state_tune) == -1) {
ipf_state_soft_destroy(softc, softs); ipf_state_soft_destroy(softc, softs);
return NULL; return(NULL);
} }
#ifdef IPFILTER_LOG #ifdef IPFILTER_LOG
@ -264,7 +264,7 @@ ipf_state_soft_create(ipf_main_softc_t *softc)
softs->ipf_state_lock = 0; softs->ipf_state_lock = 0;
softs->ipf_state_doflush = 0; softs->ipf_state_doflush = 0;
return softs; return(softs);
} }
@ -298,7 +298,7 @@ ipf_state_seed_alloc(u_int state_size, u_int state_max)
u_long *state_seed; u_long *state_seed;
KMALLOCS(state_seed, u_long *, state_size * sizeof(*state_seed)); KMALLOCS(state_seed, u_long *, state_size * sizeof(*state_seed));
if (state_seed == NULL) if (state_seed == NULL)
return NULL; return(NULL);
for (i = 0; i < state_size; i++) { for (i = 0; i < state_size; i++) {
/* /*
@ -314,7 +314,7 @@ ipf_state_seed_alloc(u_int state_size, u_int state_max)
state_seed[i] *= state_max; state_seed[i] *= state_max;
#endif #endif
} }
return state_seed; return(state_seed);
} }
@ -342,7 +342,7 @@ ipf_state_soft_init(ipf_main_softc_t *softc, void *arg)
KMALLOCS(softs->ipf_state_table, KMALLOCS(softs->ipf_state_table,
ipstate_t **, softs->ipf_state_size * sizeof(ipstate_t *)); ipstate_t **, softs->ipf_state_size * sizeof(ipstate_t *));
if (softs->ipf_state_table == NULL) if (softs->ipf_state_table == NULL)
return -1; return(-1);
bzero((char *)softs->ipf_state_table, bzero((char *)softs->ipf_state_table,
softs->ipf_state_size * sizeof(ipstate_t *)); softs->ipf_state_size * sizeof(ipstate_t *));
@ -350,12 +350,12 @@ ipf_state_soft_init(ipf_main_softc_t *softc, void *arg)
softs->ipf_state_seed = ipf_state_seed_alloc(softs->ipf_state_size, softs->ipf_state_seed = ipf_state_seed_alloc(softs->ipf_state_size,
softs->ipf_state_max); softs->ipf_state_max);
if (softs->ipf_state_seed == NULL) if (softs->ipf_state_seed == NULL)
return -2; return(-2);
KMALLOCS(softs->ipf_state_stats.iss_bucketlen, u_int *, KMALLOCS(softs->ipf_state_stats.iss_bucketlen, u_int *,
softs->ipf_state_size * sizeof(u_int)); softs->ipf_state_size * sizeof(u_int));
if (softs->ipf_state_stats.iss_bucketlen == NULL) if (softs->ipf_state_stats.iss_bucketlen == NULL)
return -3; return(-3);
bzero((char *)softs->ipf_state_stats.iss_bucketlen, bzero((char *)softs->ipf_state_stats.iss_bucketlen,
softs->ipf_state_size * sizeof(u_int)); softs->ipf_state_size * sizeof(u_int));
@ -403,7 +403,7 @@ ipf_state_soft_init(ipf_main_softc_t *softc, void *arg)
softs->ipf_state_wm_last = softc->ipf_ticks; softs->ipf_state_wm_last = softc->ipf_ticks;
softs->ipf_state_inited = 1; softs->ipf_state_inited = 1;
return 0; return(0);
} }
@ -474,7 +474,7 @@ ipf_state_soft_fini(ipf_main_softc_t *softc, void *arg)
softs->ipf_state_stats.iss_bucketlen = NULL; softs->ipf_state_stats.iss_bucketlen = NULL;
} }
return 0; return(0);
} }
@ -522,7 +522,7 @@ ipf_state_stats(ipf_main_softc_t *softc)
issp->iss_log_ok = 0; issp->iss_log_ok = 0;
issp->iss_log_fail = 0; issp->iss_log_fail = 0;
#endif #endif
return issp; return(issp);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -544,7 +544,7 @@ ipf_state_remove(ipf_main_softc_t *softc, caddr_t data)
sp = &st; sp = &st;
error = ipf_inobj(softc, data, NULL, &st, IPFOBJ_IPSTATE); error = ipf_inobj(softc, data, NULL, &st, IPFOBJ_IPSTATE);
if (error) if (error)
return EFAULT; return(EFAULT);
WRITE_ENTER(&softc->ipf_state); WRITE_ENTER(&softc->ipf_state);
for (sp = softs->ipf_state_list; sp; sp = sp->is_next) for (sp = softs->ipf_state_list; sp; sp = sp->is_next)
@ -557,12 +557,12 @@ ipf_state_remove(ipf_main_softc_t *softc, caddr_t data)
sizeof(st.is_ps))) { sizeof(st.is_ps))) {
ipf_state_del(softc, sp, ISL_REMOVE); ipf_state_del(softc, sp, ISL_REMOVE);
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
return 0; return(0);
} }
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
IPFERROR(100001); IPFERROR(100001);
return ESRCH; return(ESRCH);
} }
@ -814,7 +814,7 @@ ipf_state_ioctl(ipf_main_softc_t *softc, caddr_t data, ioctlcmd_t cmd,
error = EINVAL; error = EINVAL;
break; break;
} }
return error; return(error);
} }
@ -841,7 +841,7 @@ ipf_state_getent(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
error = ipf_inobj(softc, data, NULL, &ips, IPFOBJ_STATESAVE); error = ipf_inobj(softc, data, NULL, &ips, IPFOBJ_STATESAVE);
if (error) if (error)
return EFAULT; return(EFAULT);
READ_ENTER(&softc->ipf_state); READ_ENTER(&softc->ipf_state);
isn = ips.ips_next; isn = ips.ips_next;
@ -851,9 +851,9 @@ ipf_state_getent(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
if (ips.ips_next == NULL) { if (ips.ips_next == NULL) {
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
IPFERROR(100021); IPFERROR(100021);
return ENOENT; return(ENOENT);
} }
return 0; return(0);
} }
} else { } else {
/* /*
@ -867,7 +867,7 @@ ipf_state_getent(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
if (!is) { if (!is) {
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
IPFERROR(100022); IPFERROR(100022);
return ESRCH; return(ESRCH);
} }
} }
ips.ips_next = isn->is_next; ips.ips_next = isn->is_next;
@ -878,7 +878,7 @@ ipf_state_getent(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
sizeof(ips.ips_fr)); sizeof(ips.ips_fr));
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
error = ipf_outobj(softc, data, &ips, IPFOBJ_STATESAVE); error = ipf_outobj(softc, data, &ips, IPFOBJ_STATESAVE);
return error; return(error);
} }
@ -906,12 +906,12 @@ ipf_state_putent(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
error = ipf_inobj(softc, data, NULL, &ips, IPFOBJ_STATESAVE); error = ipf_inobj(softc, data, NULL, &ips, IPFOBJ_STATESAVE);
if (error != 0) if (error != 0)
return error; return(error);
KMALLOC(isn, ipstate_t *); KMALLOC(isn, ipstate_t *);
if (isn == NULL) { if (isn == NULL) {
IPFERROR(100023); IPFERROR(100023);
return ENOMEM; return(ENOMEM);
} }
bcopy((char *)&ips.ips_is, (char *)isn, sizeof(*isn)); bcopy((char *)&ips.ips_is, (char *)isn, sizeof(*isn));
@ -935,7 +935,7 @@ ipf_state_putent(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
MUTEX_EXIT(&isn->is_lock); MUTEX_EXIT(&isn->is_lock);
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
return inserr; return(inserr);
} }
if (isn->is_flags & SI_NEWFR) { if (isn->is_flags & SI_NEWFR) {
@ -943,7 +943,7 @@ ipf_state_putent(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
if (fr == NULL) { if (fr == NULL) {
KFREE(isn); KFREE(isn);
IPFERROR(100024); IPFERROR(100024);
return ENOMEM; return(ENOMEM);
} }
bcopy((char *)&ips.ips_fr, (char *)fr, sizeof(*fr)); bcopy((char *)&ips.ips_fr, (char *)fr, sizeof(*fr));
out = fr->fr_flags & FR_OUTQUE ? 1 : 0; out = fr->fr_flags & FR_OUTQUE ? 1 : 0;
@ -993,7 +993,7 @@ ipf_state_putent(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
MUTEX_DESTROY(&fr->fr_lock); MUTEX_DESTROY(&fr->fr_lock);
KFREE(fr); KFREE(fr);
IPFERROR(100025); IPFERROR(100025);
return EFAULT; return(EFAULT);
} }
READ_ENTER(&softc->ipf_state); READ_ENTER(&softc->ipf_state);
error = ipf_state_insert(softc, isn, 0); error = ipf_state_insert(softc, isn, 0);
@ -1021,7 +1021,7 @@ ipf_state_putent(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
} }
} }
return error; return(error);
} }
@ -1084,7 +1084,7 @@ ipf_state_insert(ipf_main_softc_t *softc, ipstate_t *is, int rev)
is->is_family, &is->is_src) == -1)) { is->is_family, &is->is_src) == -1)) {
SBUMPD(ipf_state_stats, iss_max_track); SBUMPD(ipf_state_stats, iss_max_track);
MUTEX_EXIT(&softs->ipf_stinsert); MUTEX_EXIT(&softs->ipf_stinsert);
return -1; return(-1);
} }
MUTEX_ENTER(&fr->fr_lock); MUTEX_ENTER(&fr->fr_lock);
@ -1123,7 +1123,7 @@ ipf_state_insert(ipf_main_softc_t *softc, ipstate_t *is, int rev)
ipf_state_setqueue(softc, is, rev); ipf_state_setqueue(softc, is, rev);
return 0; return(0);
} }
@ -1151,7 +1151,7 @@ ipf_state_matchipv4addrs(ipstate_t *is1, ipstate_t *is2)
else else
rv = 0; rv = 0;
return (rv); return(rv);
} }
@ -1180,7 +1180,7 @@ ipf_state_matchipv6addrs(ipstate_t *is1, ipstate_t *is2)
else else
rv = 0; rv = 0;
return (rv); return(rv);
} }
@ -1220,7 +1220,7 @@ ipf_state_matchaddresses(ipstate_t *is1, ipstate_t *is2)
rv = ipf_state_matchipv6addrs(is1, is2); rv = ipf_state_matchipv6addrs(is1, is2);
} }
return (rv); return(rv);
} }
@ -1245,7 +1245,7 @@ ipf_state_matchports(udpinfo_t *ppairs1, udpinfo_t *ppairs2)
else else
rv = 0; rv = 0;
return (rv); return(rv);
} }
@ -1290,7 +1290,7 @@ ipf_state_matchisps(ipstate_t *is1, ipstate_t *is2)
rv = 0; rv = 0;
} }
return (rv); return(rv);
} }
@ -1318,7 +1318,7 @@ ipf_state_match(ipstate_t *is1, ipstate_t *is2)
rv = 0; rv = 0;
} }
return (rv); return(rv);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -1356,24 +1356,24 @@ ipf_state_add(ipf_main_softc_t *softc, fr_info_t *fin, ipstate_t **stsave,
/* /*
* If a locally created packet is trying to egress but it * If a locally created packet is trying to egress but it
* does not match because of this lock, it is likely that * does not match because of this lock, it is likely that
* the policy will block it and return network unreachable further * the policy will block it and return network unreachable further
* up the stack. To mitigate this error, EAGAIN is returned instead, * up the stack. To mitigate this error, EAGAIN is returned instead,
* telling the IP stack to try sending this packet again later. * telling the IP stack to try sending this packet again later.
*/ */
if (softs->ipf_state_lock) { if (softs->ipf_state_lock) {
SBUMPD(ipf_state_stats, iss_add_locked); SBUMPD(ipf_state_stats, iss_add_locked);
fin->fin_error = EAGAIN; fin->fin_error = EAGAIN;
return -1; return(-1);
} }
if (fin->fin_flx & (FI_SHORT|FI_STATE|FI_FRAGBODY|FI_BAD)) { if (fin->fin_flx & (FI_SHORT|FI_STATE|FI_FRAGBODY|FI_BAD)) {
SBUMPD(ipf_state_stats, iss_add_bad); SBUMPD(ipf_state_stats, iss_add_bad);
return -1; return(-1);
} }
if ((fin->fin_flx & FI_OOW) && !(fin->fin_tcpf & TH_SYN)) { if ((fin->fin_flx & FI_OOW) && !(fin->fin_tcpf & TH_SYN)) {
SBUMPD(ipf_state_stats, iss_add_oow); SBUMPD(ipf_state_stats, iss_add_oow);
return -1; return(-1);
} }
if ((softs->ipf_state_stats.iss_active * 100 / softs->ipf_state_max) > if ((softs->ipf_state_stats.iss_active * 100 / softs->ipf_state_max) >
@ -1396,12 +1396,12 @@ ipf_state_add(ipf_main_softc_t *softc, fr_info_t *fin, ipstate_t **stsave,
if ((softs->ipf_state_stats.iss_active >= if ((softs->ipf_state_stats.iss_active >=
softs->ipf_state_max) && (fr->fr_statemax == 0)) { softs->ipf_state_max) && (fr->fr_statemax == 0)) {
SBUMPD(ipf_state_stats, iss_max); SBUMPD(ipf_state_stats, iss_max);
return 1; return(1);
} }
if ((fr->fr_statemax != 0) && if ((fr->fr_statemax != 0) &&
(fr->fr_statecnt >= fr->fr_statemax)) { (fr->fr_statecnt >= fr->fr_statemax)) {
SBUMPD(ipf_state_stats, iss_max_ref); SBUMPD(ipf_state_stats, iss_max_ref);
return 2; return(2);
} }
} }
@ -1499,7 +1499,7 @@ ipf_state_add(ipf_main_softc_t *softc, fr_info_t *fin, ipstate_t **stsave,
break; break;
default : default :
SBUMPD(ipf_state_stats, iss_icmp6_notquery); SBUMPD(ipf_state_stats, iss_icmp6_notquery);
return -2; return(-2);
} }
break; break;
#endif #endif
@ -1517,7 +1517,7 @@ ipf_state_add(ipf_main_softc_t *softc, fr_info_t *fin, ipstate_t **stsave,
break; break;
default : default :
SBUMPD(ipf_state_stats, iss_icmp_notquery); SBUMPD(ipf_state_stats, iss_icmp_notquery);
return -3; return(-3);
} }
break; break;
@ -1539,7 +1539,7 @@ ipf_state_add(ipf_main_softc_t *softc, fr_info_t *fin, ipstate_t **stsave,
if (tcp->th_flags & TH_RST) { if (tcp->th_flags & TH_RST) {
SBUMPD(ipf_state_stats, iss_tcp_rstadd); SBUMPD(ipf_state_stats, iss_tcp_rstadd);
return -4; return(-4);
} }
/* TRACE is, flags, hv */ /* TRACE is, flags, hv */
@ -1637,13 +1637,13 @@ ipf_state_add(ipf_main_softc_t *softc, fr_info_t *fin, ipstate_t **stsave,
} }
if (is != NULL) { if (is != NULL) {
SBUMPD(ipf_state_stats, iss_add_dup); SBUMPD(ipf_state_stats, iss_add_dup);
return 3; return(3);
} }
if (softs->ipf_state_stats.iss_bucketlen[hv] >= if (softs->ipf_state_stats.iss_bucketlen[hv] >=
softs->ipf_state_maxbucket) { softs->ipf_state_maxbucket) {
SBUMPD(ipf_state_stats, iss_bucket_full); SBUMPD(ipf_state_stats, iss_bucket_full);
return 4; return(4);
} }
/* /*
@ -1652,7 +1652,7 @@ ipf_state_add(ipf_main_softc_t *softc, fr_info_t *fin, ipstate_t **stsave,
KMALLOC(is, ipstate_t *); KMALLOC(is, ipstate_t *);
if (is == NULL) { if (is == NULL) {
SBUMPD(ipf_state_stats, iss_nomem); SBUMPD(ipf_state_stats, iss_nomem);
return 5; return(5);
} }
bcopy((char *)&ips, (char *)is, sizeof(*is)); bcopy((char *)&ips, (char *)is, sizeof(*is));
is->is_flags = flags & IS_INHERITED; is->is_flags = flags & IS_INHERITED;
@ -1742,7 +1742,7 @@ ipf_state_add(ipf_main_softc_t *softc, fr_info_t *fin, ipstate_t **stsave,
is->is_tqehead[1] = NULL; is->is_tqehead[1] = NULL;
} }
KFREE(is); KFREE(is);
return -1; return(-1);
} }
/* /*
@ -1845,7 +1845,7 @@ ipf_state_add(ipf_main_softc_t *softc, fr_info_t *fin, ipstate_t **stsave,
} }
fin->fin_dif = &is->is_dif; fin->fin_dif = &is->is_dif;
return 0; return(0);
} }
@ -1872,7 +1872,7 @@ ipf_tcpoptions(ipf_state_softc_t *softs, fr_info_t *fin, tcphdr_t *tcp,
len = (TCP_OFF(tcp) << 2); len = (TCP_OFF(tcp) << 2);
if (fin->fin_dlen < len) { if (fin->fin_dlen < len) {
SBUMPD(ipf_state_stats, iss_tcp_toosmall); SBUMPD(ipf_state_stats, iss_tcp_toosmall);
return 0; return(0);
} }
len -= sizeof(*tcp); len -= sizeof(*tcp);
@ -1948,7 +1948,7 @@ ipf_tcpoptions(ipf_state_softc_t *softs, fr_info_t *fin, tcphdr_t *tcp,
if (retval == -1) { if (retval == -1) {
SBUMPD(ipf_state_stats, iss_tcp_badopt); SBUMPD(ipf_state_stats, iss_tcp_badopt);
} }
return retval; return(retval);
} }
@ -1995,7 +1995,7 @@ ipf_state_tcp(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
MUTEX_EXIT(&is->is_lock); MUTEX_EXIT(&is->is_lock);
DT1(iss_tcp_closing, ipstate_t *, is); DT1(iss_tcp_closing, ipstate_t *, is);
SBUMP(ipf_state_stats.iss_tcp_closing); SBUMP(ipf_state_stats.iss_tcp_closing);
return 0; return(0);
} }
} }
@ -2014,7 +2014,7 @@ ipf_state_tcp(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
MUTEX_EXIT(&is->is_lock); MUTEX_EXIT(&is->is_lock);
DT2(iss_tcp_fsm, fr_info_t *, fin, ipstate_t *, is); DT2(iss_tcp_fsm, fr_info_t *, fin, ipstate_t *, is);
SBUMP(ipf_state_stats.iss_tcp_fsm); SBUMP(ipf_state_stats.iss_tcp_fsm);
return 0; return(0);
} }
if (softs->ipf_state_logging > 4) if (softs->ipf_state_logging > 4)
@ -2062,7 +2062,7 @@ ipf_state_tcp(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
ret = 0; ret = 0;
} }
MUTEX_EXIT(&is->is_lock); MUTEX_EXIT(&is->is_lock);
return ret; return(ret);
} }
@ -2192,7 +2192,7 @@ ipf_state_tcpinwindow(fr_info_t *fin, tcpdata_t *fdata, tcpdata_t *tdata,
DT2(iss_tcp_struct, tcpdata_t *, fdata, int, seq); DT2(iss_tcp_struct, tcpdata_t *, fdata, int, seq);
SBUMP(ipf_state_stats.iss_tcp_strict); SBUMP(ipf_state_stats.iss_tcp_strict);
fin->fin_flx |= FI_OOW; fin->fin_flx |= FI_OOW;
return 0; return(0);
} }
} }
@ -2278,11 +2278,11 @@ ipf_state_tcpinwindow(fr_info_t *fin, tcpdata_t *fdata, tcpdata_t *tdata,
fdata->td_end = end; fdata->td_end = end;
if (SEQ_GE(ack + win, tdata->td_maxend)) if (SEQ_GE(ack + win, tdata->td_maxend))
tdata->td_maxend = ack + win; tdata->td_maxend = ack + win;
return 1; return(1);
} }
SBUMP(ipf_state_stats.iss_oow); SBUMP(ipf_state_stats.iss_oow);
fin->fin_flx |= FI_OOW; fin->fin_flx |= FI_OOW;
return 0; return(0);
} }
@ -2307,12 +2307,12 @@ ipf_state_clone(fr_info_t *fin, tcphdr_t *tcp, ipstate_t *is)
if (softs->ipf_state_stats.iss_active == softs->ipf_state_max) { if (softs->ipf_state_stats.iss_active == softs->ipf_state_max) {
SBUMPD(ipf_state_stats, iss_max); SBUMPD(ipf_state_stats, iss_max);
softs->ipf_state_doflush = 1; softs->ipf_state_doflush = 1;
return NULL; return(NULL);
} }
KMALLOC(clone, ipstate_t *); KMALLOC(clone, ipstate_t *);
if (clone == NULL) { if (clone == NULL) {
SBUMPD(ipf_state_stats, iss_clone_nomem); SBUMPD(ipf_state_stats, iss_clone_nomem);
return NULL; return(NULL);
} }
bcopy((char *)is, (char *)clone, sizeof(*clone)); bcopy((char *)is, (char *)clone, sizeof(*clone));
@ -2355,7 +2355,7 @@ ipf_state_clone(fr_info_t *fin, tcphdr_t *tcp, ipstate_t *is)
clone->is_flags |= SI_CLONED; clone->is_flags |= SI_CLONED;
if (ipf_state_insert(softc, clone, fin->fin_rev) == -1) { if (ipf_state_insert(softc, clone, fin->fin_rev) == -1) {
KFREE(clone); KFREE(clone);
return NULL; return(NULL);
} }
clone->is_ref = 1; clone->is_ref = 1;
@ -2368,7 +2368,7 @@ ipf_state_clone(fr_info_t *fin, tcphdr_t *tcp, ipstate_t *is)
clone->is_sync = ipf_sync_new(softc, SMC_STATE, fin, clone); clone->is_sync = ipf_sync_new(softc, SMC_STATE, fin, clone);
DT2(iss_clone, ipstate_t *, is, ipstate_t *, clone); DT2(iss_clone, ipstate_t *, is, ipstate_t *, clone);
SBUMP(ipf_state_stats.iss_cloned); SBUMP(ipf_state_stats.iss_cloned);
return clone; return(clone);
} }
@ -2402,7 +2402,7 @@ ipf_matchsrcdst(fr_info_t *fin, ipstate_t *is, i6addr_t *src, i6addr_t *dst,
* are allowed to match it. * are allowed to match it.
*/ */
if (is->is_sti.tqe_ifq == &softs->ipf_state_deletetq) if (is->is_sti.tqe_ifq == &softs->ipf_state_deletetq)
return NULL; return(NULL);
rev = IP6_NEQ(&is->is_dst, dst); rev = IP6_NEQ(&is->is_dst, dst);
ifp = fin->fin_ifp; ifp = fin->fin_ifp;
@ -2439,7 +2439,7 @@ ipf_matchsrcdst(fr_info_t *fin, ipstate_t *is, i6addr_t *src, i6addr_t *dst,
DT2(iss_lookup_badifp, fr_info_t *, fin, ipstate_t *, is); DT2(iss_lookup_badifp, fr_info_t *, fin, ipstate_t *, is);
SBUMP(ipf_state_stats.iss_lookup_badifp); SBUMP(ipf_state_stats.iss_lookup_badifp);
/* TRACE is, out, rev, idx */ /* TRACE is, out, rev, idx */
return NULL; return(NULL);
} }
ret = 0; ret = 0;
@ -2476,7 +2476,7 @@ ipf_matchsrcdst(fr_info_t *fin, ipstate_t *is, i6addr_t *src, i6addr_t *dst,
SBUMP(ipf_state_stats.iss_lookup_badport); SBUMP(ipf_state_stats.iss_lookup_badport);
DT2(iss_lookup_badport, fr_info_t *, fin, ipstate_t *, is); DT2(iss_lookup_badport, fr_info_t *, fin, ipstate_t *, is);
/* TRACE rev, is, sp, dp, src, dst */ /* TRACE rev, is, sp, dp, src, dst */
return NULL; return(NULL);
} }
/* /*
@ -2533,12 +2533,12 @@ ipf_matchsrcdst(fr_info_t *fin, ipstate_t *is, i6addr_t *src, i6addr_t *dst,
((fin->fin_secmsk & is->is_secmsk) != is->is_sec) || ((fin->fin_secmsk & is->is_secmsk) != is->is_sec) ||
((fin->fin_auth & is->is_authmsk) != is->is_auth)) { ((fin->fin_auth & is->is_authmsk) != is->is_auth)) {
SBUMPD(ipf_state_stats, iss_miss_mask); SBUMPD(ipf_state_stats, iss_miss_mask);
return NULL; return(NULL);
} }
if ((fin->fin_flx & FI_IGNORE) != 0) { if ((fin->fin_flx & FI_IGNORE) != 0) {
fin->fin_rev = rev; fin->fin_rev = rev;
return is; return(is);
} }
/* /*
@ -2552,7 +2552,7 @@ ipf_matchsrcdst(fr_info_t *fin, ipstate_t *is, i6addr_t *src, i6addr_t *dst,
clone = ipf_state_clone(fin, tcp, is); clone = ipf_state_clone(fin, tcp, is);
if (clone == NULL) if (clone == NULL)
return NULL; return(NULL);
is = clone; is = clone;
} else { } else {
ATOMIC_DECL(softs->ipf_state_stats.iss_wild); ATOMIC_DECL(softs->ipf_state_stats.iss_wild);
@ -2606,7 +2606,7 @@ ipf_matchsrcdst(fr_info_t *fin, ipstate_t *is, i6addr_t *src, i6addr_t *dst,
COPYIFNAME(fin->fin_v, ifp, is->is_ifname[idx]); COPYIFNAME(fin->fin_v, ifp, is->is_ifname[idx]);
} }
fin->fin_rev = rev; fin->fin_rev = rev;
return is; return(is);
} }
@ -2639,7 +2639,7 @@ ipf_checkicmpmatchingstate(fr_info_t *fin)
u_int hv; u_int hv;
/* /*
* Does it at least have the return (basic) IP header ? * Does it at least have the return(basic) IP header ?
* Is it an actual recognised ICMP error type? * Is it an actual recognised ICMP error type?
* Only a basic IP header (no options) should be with * Only a basic IP header (no options) should be with
* an ICMP error header. * an ICMP error header.
@ -2648,7 +2648,7 @@ ipf_checkicmpmatchingstate(fr_info_t *fin)
(fin->fin_plen < ICMPERR_MINPKTLEN) || (fin->fin_plen < ICMPERR_MINPKTLEN) ||
!(fin->fin_flx & FI_ICMPERR)) { !(fin->fin_flx & FI_ICMPERR)) {
SBUMPD(ipf_state_stats, iss_icmp_bad); SBUMPD(ipf_state_stats, iss_icmp_bad);
return NULL; return(NULL);
} }
ic = fin->fin_dp; ic = fin->fin_dp;
type = ic->icmp_type; type = ic->icmp_type;
@ -2660,7 +2660,7 @@ ipf_checkicmpmatchingstate(fr_info_t *fin)
*/ */
if (fin->fin_plen < ICMPERR_MAXPKTLEN + ((IP_HL(oip) - 5) << 2)) { if (fin->fin_plen < ICMPERR_MAXPKTLEN + ((IP_HL(oip) - 5) << 2)) {
SBUMPDX(ipf_state_stats, iss_icmp_short, iss_icmp_short_1); SBUMPDX(ipf_state_stats, iss_icmp_short, iss_icmp_short_1);
return NULL; return(NULL);
} }
/* /*
@ -2670,7 +2670,7 @@ ipf_checkicmpmatchingstate(fr_info_t *fin)
if ((len <= 0) || ((IP_HL(oip) << 2) > len)) { if ((len <= 0) || ((IP_HL(oip) << 2) > len)) {
DT2(iss_icmp_len, fr_info_t *, fin, struct ip*, oip); DT2(iss_icmp_len, fr_info_t *, fin, struct ip*, oip);
SBUMPDX(ipf_state_stats, iss_icmp_short, iss_icmp_short_1); SBUMPDX(ipf_state_stats, iss_icmp_short, iss_icmp_short_1);
return NULL; return(NULL);
} }
/* /*
@ -2690,12 +2690,12 @@ ipf_checkicmpmatchingstate(fr_info_t *fin)
# if SOLARIS # if SOLARIS
if ((char *)oip + len > (char *)m->b_wptr) { if ((char *)oip + len > (char *)m->b_wptr) {
SBUMPDX(ipf_state_stats, iss_icmp_short, iss_icmp_short_2); SBUMPDX(ipf_state_stats, iss_icmp_short, iss_icmp_short_2);
return NULL; return(NULL);
} }
# else # else
if ((char *)oip + len > (char *)fin->fin_ip + m->m_len) { if ((char *)oip + len > (char *)fin->fin_ip + m->m_len) {
SBUMPDX(ipf_state_stats, iss_icmp_short, iss_icmp_short_3); SBUMPDX(ipf_state_stats, iss_icmp_short, iss_icmp_short_3);
return NULL; return(NULL);
} }
# endif # endif
} }
@ -2766,7 +2766,7 @@ ipf_checkicmpmatchingstate(fr_info_t *fin)
if ((ofin.fin_flx & FI_ICMPERR) != 0) { if ((ofin.fin_flx & FI_ICMPERR) != 0) {
DT1(iss_icmp_icmperr, fr_info_t *, &ofin); DT1(iss_icmp_icmperr, fr_info_t *, &ofin);
SBUMP(ipf_state_stats.iss_icmp_icmperr); SBUMP(ipf_state_stats.iss_icmp_icmperr);
return NULL; return(NULL);
} }
/* /*
@ -2788,17 +2788,17 @@ ipf_checkicmpmatchingstate(fr_info_t *fin)
is = ipf_matchsrcdst(&ofin, is, &src, &dst, is = ipf_matchsrcdst(&ofin, is, &src, &dst,
NULL, FI_ICMPCMP); NULL, FI_ICMPCMP);
if ((is != NULL) && !ipf_allowstateicmp(fin, is, &src)) if ((is != NULL) && !ipf_allowstateicmp(fin, is, &src))
return is; return(is);
} }
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
SBUMPDX(ipf_state_stats, iss_icmp_miss, iss_icmp_miss_1); SBUMPDX(ipf_state_stats, iss_icmp_miss, iss_icmp_miss_1);
return NULL; return(NULL);
case IPPROTO_TCP : case IPPROTO_TCP :
case IPPROTO_UDP : case IPPROTO_UDP :
break; break;
default : default :
SBUMPDX(ipf_state_stats, iss_icmp_miss, iss_icmp_miss_2); SBUMPDX(ipf_state_stats, iss_icmp_miss, iss_icmp_miss_2);
return NULL; return(NULL);
} }
tcp = (tcphdr_t *)((char *)oip + (IP_HL(oip) << 2)); tcp = (tcphdr_t *)((char *)oip + (IP_HL(oip) << 2));
@ -2823,12 +2823,12 @@ ipf_checkicmpmatchingstate(fr_info_t *fin)
(is = ipf_matchsrcdst(&ofin, is, &src, &dst, (is = ipf_matchsrcdst(&ofin, is, &src, &dst,
tcp, FI_ICMPCMP))) { tcp, FI_ICMPCMP))) {
if (ipf_allowstateicmp(fin, is, &src) == 0) if (ipf_allowstateicmp(fin, is, &src) == 0)
return is; return(is);
} }
} }
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
SBUMPDX(ipf_state_stats, iss_icmp_miss, iss_icmp_miss_3); SBUMPDX(ipf_state_stats, iss_icmp_miss, iss_icmp_miss_3);
return NULL; return(NULL);
} }
@ -2864,7 +2864,7 @@ ipf_allowstateicmp(fr_info_t *fin, ipstate_t *is, i6addr_t *src)
fin->fin_fr = savefr; fin->fin_fr = savefr;
if (FR_ISBLOCK(ipass)) { if (FR_ISBLOCK(ipass)) {
SBUMPD(ipf_state_stats, iss_icmp_headblock); SBUMPD(ipf_state_stats, iss_icmp_headblock);
return 1; return(1);
} }
} }
@ -2882,11 +2882,11 @@ ipf_allowstateicmp(fr_info_t *fin, ipstate_t *is, i6addr_t *src)
if (is->is_pass & FR_NOICMPERR) { if (is->is_pass & FR_NOICMPERR) {
SBUMPD(ipf_state_stats, iss_icmp_banned); SBUMPD(ipf_state_stats, iss_icmp_banned);
return 1; return(1);
} }
if (is->is_icmppkts[i] > is->is_pkts[oi]) { if (is->is_icmppkts[i] > is->is_pkts[oi]) {
SBUMPD(ipf_state_stats, iss_icmp_toomany); SBUMPD(ipf_state_stats, iss_icmp_toomany);
return 1; return(1);
} }
DT2(iss_icmp_hits, fr_info_t *, fin, ipstate_t *, is); DT2(iss_icmp_hits, fr_info_t *, fin, ipstate_t *, is);
@ -2898,7 +2898,7 @@ ipf_allowstateicmp(fr_info_t *fin, ipstate_t *is, i6addr_t *src)
* for the accompanying state table entry. * for the accompanying state table entry.
* It remains to be seen if that is correct. XXX * It remains to be seen if that is correct. XXX
*/ */
return 0; return(0);
} }
@ -3089,7 +3089,7 @@ ipf_state_lookup(fr_info_t *fin, tcphdr_t *tcp, ipftq_t **ifqp)
is = ipf_checkicmp6matchingstate(fin); is = ipf_checkicmp6matchingstate(fin);
if (is != NULL) if (is != NULL)
return is; return(is);
break; break;
#endif #endif
@ -3234,7 +3234,7 @@ ipf_state_lookup(fr_info_t *fin, tcphdr_t *tcp, ipftq_t **ifqp)
} else { } else {
SBUMP(ipf_state_stats.iss_lookup_miss); SBUMP(ipf_state_stats.iss_lookup_miss);
} }
return is; return(is);
} }
@ -3261,11 +3261,11 @@ ipf_state_check(fr_info_t *fin, u_32_t *passp)
int inout; int inout;
if (softs->ipf_state_lock || (softs->ipf_state_list == NULL)) if (softs->ipf_state_lock || (softs->ipf_state_list == NULL))
return NULL; return(NULL);
if (fin->fin_flx & (FI_SHORT|FI_FRAGBODY|FI_BAD)) { if (fin->fin_flx & (FI_SHORT|FI_FRAGBODY|FI_BAD)) {
SBUMPD(ipf_state_stats, iss_check_bad); SBUMPD(ipf_state_stats, iss_check_bad);
return NULL; return(NULL);
} }
if ((fin->fin_flx & FI_TCPUDP) || if ((fin->fin_flx & FI_TCPUDP) ||
@ -3325,7 +3325,7 @@ ipf_state_check(fr_info_t *fin, u_32_t *passp)
} }
if (is == NULL) { if (is == NULL) {
SBUMP(ipf_state_stats.iss_check_miss); SBUMP(ipf_state_stats.iss_check_miss);
return NULL; return(NULL);
} }
fr = is->is_rule; fr = is->is_rule;
@ -3334,12 +3334,12 @@ ipf_state_check(fr_info_t *fin, u_32_t *passp)
if (fin->fin_nattag == NULL) { if (fin->fin_nattag == NULL) {
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
SBUMPD(ipf_state_stats, iss_check_notag); SBUMPD(ipf_state_stats, iss_check_notag);
return NULL; return(NULL);
} }
if (ipf_matchtag(&fr->fr_nattag, fin->fin_nattag)!=0) { if (ipf_matchtag(&fr->fr_nattag, fin->fin_nattag)!=0) {
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
SBUMPD(ipf_state_stats, iss_check_nattag); SBUMPD(ipf_state_stats, iss_check_nattag);
return NULL; return(NULL);
} }
} }
(void) strncpy(fin->fin_group, FR_NAME(fr, fr_group), (void) strncpy(fin->fin_group, FR_NAME(fr, fr_group),
@ -3393,7 +3393,7 @@ ipf_state_check(fr_info_t *fin, u_32_t *passp)
if ((pass & FR_LOGFIRST) != 0) if ((pass & FR_LOGFIRST) != 0)
pass &= ~(FR_LOGFIRST|FR_LOG); pass &= ~(FR_LOGFIRST|FR_LOG);
*passp = pass; *passp = pass;
return fr; return(fr);
} }
@ -3592,7 +3592,7 @@ ipf_state_del(ipf_main_softc_t *softc, ipstate_t *is, int why)
MUTEX_EXIT(&is->is_lock); MUTEX_EXIT(&is->is_lock);
if (!orphan) if (!orphan)
softs->ipf_state_stats.iss_orphan++; softs->ipf_state_stats.iss_orphan++;
return refs; return(refs);
} }
fr = is->is_rule; fr = is->is_rule;
@ -3653,7 +3653,7 @@ ipf_state_del(ipf_main_softc_t *softc, ipstate_t *is, int why)
KFREE(is); KFREE(is);
softs->ipf_state_stats.iss_active--; softs->ipf_state_stats.iss_active--;
return 0; return(0);
} }
@ -3864,7 +3864,7 @@ ipf_state_flush(ipf_main_softc_t *softc, int which, int proto)
if (which != 2) { if (which != 2) {
SPL_X(s); SPL_X(s);
return removed; return(removed);
} }
SBUMP(ipf_state_stats.iss_flush_timeout); SBUMP(ipf_state_stats.iss_flush_timeout);
@ -3887,7 +3887,7 @@ ipf_state_flush(ipf_main_softc_t *softc, int which, int proto)
} }
SPL_X(s); SPL_X(s);
return removed; return(removed);
} }
@ -3905,7 +3905,7 @@ ipf_state_flush(ipf_main_softc_t *softc, int which, int proto)
static int static int
ipf_state_flush_entry(ipf_main_softc_t *softc, void *entry) ipf_state_flush_entry(ipf_main_softc_t *softc, void *entry)
{ {
return ipf_state_del(softc, entry, ISL_FLUSH); return(ipf_state_del(softc, entry, ISL_FLUSH));
} }
@ -4281,7 +4281,7 @@ ipf_tcp_age(ipftqent_t *tqe, fr_info_t *fin, ipftq_t *tqtab, int flags, int ok)
tqtab + nstate); tqtab + nstate);
} }
return rval; return(rval);
} }
@ -4382,7 +4382,7 @@ ipf_checkicmp6matchingstate(fr_info_t *fin)
int type; int type;
/* /*
* Does it at least have the return (basic) IP header ? * Does it at least have the return(basic) IP header ?
* Is it an actual recognised ICMP error type? * Is it an actual recognised ICMP error type?
* Only a basic IP header (no options) should be with * Only a basic IP header (no options) should be with
* an ICMP error header. * an ICMP error header.
@ -4390,7 +4390,7 @@ ipf_checkicmp6matchingstate(fr_info_t *fin)
if ((fin->fin_v != 6) || (fin->fin_plen < ICMP6ERR_MINPKTLEN) || if ((fin->fin_v != 6) || (fin->fin_plen < ICMP6ERR_MINPKTLEN) ||
!(fin->fin_flx & FI_ICMPERR)) { !(fin->fin_flx & FI_ICMPERR)) {
SBUMPD(ipf_state_stats, iss_icmp_bad); SBUMPD(ipf_state_stats, iss_icmp_bad);
return NULL; return(NULL);
} }
ic6 = fin->fin_dp; ic6 = fin->fin_dp;
@ -4399,7 +4399,7 @@ ipf_checkicmp6matchingstate(fr_info_t *fin)
oip6 = (ip6_t *)((char *)ic6 + ICMPERR_ICMPHLEN); oip6 = (ip6_t *)((char *)ic6 + ICMPERR_ICMPHLEN);
if (fin->fin_plen < sizeof(*oip6)) { if (fin->fin_plen < sizeof(*oip6)) {
SBUMPD(ipf_state_stats, iss_icmp_short); SBUMPD(ipf_state_stats, iss_icmp_short);
return NULL; return(NULL);
} }
bcopy((char *)fin, (char *)&ofin, sizeof(*fin)); bcopy((char *)fin, (char *)&ofin, sizeof(*fin));
@ -4434,7 +4434,7 @@ ipf_checkicmp6matchingstate(fr_info_t *fin)
if (ofin.fin_flx & FI_ICMPERR) { if (ofin.fin_flx & FI_ICMPERR) {
DT1(iss_icmp6_icmperr, fr_info_t *, &ofin); DT1(iss_icmp6_icmperr, fr_info_t *, &ofin);
SBUMP(ipf_state_stats.iss_icmp6_icmperr); SBUMP(ipf_state_stats.iss_icmp6_icmperr);
return NULL; return(NULL);
} }
if (oip6->ip6_nxt == IPPROTO_ICMPV6) { if (oip6->ip6_nxt == IPPROTO_ICMPV6) {
@ -4449,7 +4449,7 @@ ipf_checkicmp6matchingstate(fr_info_t *fin)
if (!(oic->icmp6_type & ICMP6_INFOMSG_MASK)) { if (!(oic->icmp6_type & ICMP6_INFOMSG_MASK)) {
DT1(iss_icmp6_notinfo, fr_info_t *, &ofin); DT1(iss_icmp6_notinfo, fr_info_t *, &ofin);
SBUMP(ipf_state_stats.iss_icmp6_notinfo); SBUMP(ipf_state_stats.iss_icmp6_notinfo);
return NULL; return(NULL);
} }
/* /*
@ -4484,13 +4484,13 @@ ipf_checkicmp6matchingstate(fr_info_t *fin)
(oic->icmp6_type == ICMP6_ECHO_REQUEST)) || (oic->icmp6_type == ICMP6_ECHO_REQUEST)) ||
(ic->ici_type - 1 == oic->icmp6_type )) { (ic->ici_type - 1 == oic->icmp6_type )) {
if (!ipf_allowstateicmp(fin, is, &src)) if (!ipf_allowstateicmp(fin, is, &src))
return is; return(is);
} }
} }
} }
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
SBUMPD(ipf_state_stats, iss_icmp6_miss); SBUMPD(ipf_state_stats, iss_icmp6_miss);
return NULL; return(NULL);
} }
hv = (pr = oip6->ip6_nxt); hv = (pr = oip6->ip6_nxt);
@ -4545,11 +4545,11 @@ ipf_checkicmp6matchingstate(fr_info_t *fin)
continue; continue;
is = ipf_matchsrcdst(&ofin, is, &src, &dst, tcp, FI_ICMPCMP); is = ipf_matchsrcdst(&ofin, is, &src, &dst, tcp, FI_ICMPCMP);
if ((is != NULL) && (ipf_allowstateicmp(fin, is, &src) == 0)) if ((is != NULL) && (ipf_allowstateicmp(fin, is, &src) == 0))
return is; return(is);
} }
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
SBUMPD(ipf_state_stats, iss_icmp_miss); SBUMPD(ipf_state_stats, iss_icmp_miss);
return NULL; return(NULL);
} }
#endif #endif
@ -4757,23 +4757,23 @@ ipf_state_iter(ipf_main_softc_t *softc, ipftoken_t *token, ipfgeniter_t *itp,
if (itp->igi_data == NULL) { if (itp->igi_data == NULL) {
IPFERROR(100026); IPFERROR(100026);
return EFAULT; return(EFAULT);
} }
if (itp->igi_nitems < 1) { if (itp->igi_nitems < 1) {
IPFERROR(100027); IPFERROR(100027);
return ENOSPC; return(ENOSPC);
} }
if (itp->igi_type != IPFGENITER_STATE) { if (itp->igi_type != IPFGENITER_STATE) {
IPFERROR(100028); IPFERROR(100028);
return EINVAL; return(EINVAL);
} }
is = token->ipt_data; is = token->ipt_data;
if (is == (void *)-1) { if (is == (void *)-1) {
IPFERROR(100029); IPFERROR(100029);
return ESRCH; return(ESRCH);
} }
error = 0; error = 0;
@ -4813,7 +4813,7 @@ ipf_state_iter(ipf_main_softc_t *softc, ipftoken_t *token, ipfgeniter_t *itp,
if (is != NULL) if (is != NULL)
ipf_state_deref(softc, &is); ipf_state_deref(softc, &is);
return error; return(error);
} }
@ -4836,11 +4836,11 @@ ipf_state_gettable(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
error = ipf_inobj(softc, data, NULL, &table, IPFOBJ_GTABLE); error = ipf_inobj(softc, data, NULL, &table, IPFOBJ_GTABLE);
if (error != 0) if (error != 0)
return error; return(error);
if (table.ita_type != IPFTABLE_BUCKETS) { if (table.ita_type != IPFTABLE_BUCKETS) {
IPFERROR(100031); IPFERROR(100031);
return EINVAL; return(EINVAL);
} }
error = COPYOUT(softs->ipf_state_stats.iss_bucketlen, table.ita_table, error = COPYOUT(softs->ipf_state_stats.iss_bucketlen, table.ita_table,
@ -4849,7 +4849,7 @@ ipf_state_gettable(ipf_main_softc_t *softc, ipf_state_softc_t *softs,
IPFERROR(100032); IPFERROR(100032);
error = EFAULT; error = EFAULT;
} }
return error; return(error);
} }
@ -4908,7 +4908,7 @@ ipf_state_matchflush(ipf_main_softc_t *softc, caddr_t data)
error = ipf_matcharray_load(softc, data, &obj, &array); error = ipf_matcharray_load(softc, data, &obj, &array);
if (error != 0) if (error != 0)
return error; return(error);
flushed = 0; flushed = 0;
@ -4925,7 +4925,7 @@ ipf_state_matchflush(ipf_main_softc_t *softc, caddr_t data)
KFREES(array, array[0] * sizeof(*array)); KFREES(array, array[0] * sizeof(*array));
return error; return(error);
} }
@ -5083,7 +5083,7 @@ ipf_state_matcharray(ipstate_t *state, int *array, u_long ticks)
break; break;
} }
return rv; return(rv);
} }
@ -5109,10 +5109,10 @@ ipf_state_settimeout(struct ipf_main_softc_s *softc, ipftuneable_t *t,
* In case there is nothing to do... * In case there is nothing to do...
*/ */
if (*t->ipft_pint == p->ipftu_int) if (*t->ipft_pint == p->ipftu_int)
return 0; return(0);
if (!strncmp(t->ipft_name, "tcp_", 4)) if (!strncmp(t->ipft_name, "tcp_", 4))
return ipf_settimeout_tcp(t, p, softs->ipf_state_tcptq); return(ipf_settimeout_tcp(t, p, softs->ipf_state_tcptq));
if (!strcmp(t->ipft_name, "udp_timeout")) { if (!strcmp(t->ipft_name, "udp_timeout")) {
ipf_apply_timeout(&softs->ipf_state_udptq, p->ipftu_int); ipf_apply_timeout(&softs->ipf_state_udptq, p->ipftu_int);
@ -5126,7 +5126,7 @@ ipf_state_settimeout(struct ipf_main_softc_s *softc, ipftuneable_t *t,
ipf_apply_timeout(&softs->ipf_state_iptq, p->ipftu_int); ipf_apply_timeout(&softs->ipf_state_iptq, p->ipftu_int);
} else { } else {
IPFERROR(100034); IPFERROR(100034);
return ESRCH; return(ESRCH);
} }
/* /*
@ -5134,7 +5134,7 @@ ipf_state_settimeout(struct ipf_main_softc_s *softc, ipftuneable_t *t,
*/ */
*t->ipft_pint = p->ipftu_int; *t->ipft_pint = p->ipftu_int;
return 0; return(0);
} }
@ -5166,19 +5166,19 @@ ipf_state_rehash(ipf_main_softc_t *softc, ipftuneable_t *t, ipftuneval_t *p)
* In case there is nothing to do... * In case there is nothing to do...
*/ */
if (newsize == softs->ipf_state_size) if (newsize == softs->ipf_state_size)
return 0; return(0);
KMALLOCS(newtab, ipstate_t **, newsize * sizeof(ipstate_t *)); KMALLOCS(newtab, ipstate_t **, newsize * sizeof(ipstate_t *));
if (newtab == NULL) { if (newtab == NULL) {
IPFERROR(100035); IPFERROR(100035);
return ENOMEM; return(ENOMEM);
} }
KMALLOCS(bucketlens, u_int *, newsize * sizeof(u_int)); KMALLOCS(bucketlens, u_int *, newsize * sizeof(u_int));
if (bucketlens == NULL) { if (bucketlens == NULL) {
KFREES(newtab, newsize * sizeof(*softs->ipf_state_table)); KFREES(newtab, newsize * sizeof(*softs->ipf_state_table));
IPFERROR(100036); IPFERROR(100036);
return ENOMEM; return(ENOMEM);
} }
newseed = ipf_state_seed_alloc(newsize, softs->ipf_state_max); newseed = ipf_state_seed_alloc(newsize, softs->ipf_state_max);
@ -5186,7 +5186,7 @@ ipf_state_rehash(ipf_main_softc_t *softc, ipftuneable_t *t, ipftuneval_t *p)
KFREES(bucketlens, newsize * sizeof(*bucketlens)); KFREES(bucketlens, newsize * sizeof(*bucketlens));
KFREES(newtab, newsize * sizeof(*newtab)); KFREES(newtab, newsize * sizeof(*newtab));
IPFERROR(100037); IPFERROR(100037);
return ENOMEM; return(ENOMEM);
} }
for (maxbucket = 0, i = newsize; i > 0; i >>= 1) for (maxbucket = 0, i = newsize; i > 0; i >>= 1)
@ -5240,7 +5240,7 @@ ipf_state_rehash(ipf_main_softc_t *softc, ipftuneable_t *t, ipftuneval_t *p)
} }
RWLOCK_EXIT(&softc->ipf_state); RWLOCK_EXIT(&softc->ipf_state);
return 0; return(0);
} }
@ -5260,7 +5260,7 @@ ipf_state_add_tq(ipf_main_softc_t *softc, int ttl)
{ {
ipf_state_softc_t *softs = softc->ipf_state_soft; ipf_state_softc_t *softs = softc->ipf_state_soft;
return ipf_addtimeoutqueue(softc, &softs->ipf_state_usertq, ttl); return(ipf_addtimeoutqueue(softc, &softs->ipf_state_usertq, ttl));
} }

View File

@ -147,7 +147,7 @@ ipf_sync_soft_create(ipf_main_softc_t *softc)
KMALLOC(softs, ipf_sync_softc_t *); KMALLOC(softs, ipf_sync_softc_t *);
if (softs == NULL) { if (softs == NULL) {
IPFERROR(110024); IPFERROR(110024);
return NULL; return(NULL);
} }
bzero((char *)softs, sizeof(*softs)); bzero((char *)softs, sizeof(*softs));
@ -158,7 +158,7 @@ ipf_sync_soft_create(ipf_main_softc_t *softc)
softs->ipf_sync_event_high_wm = SYNCLOG_SZ * 100 / 90; /* 90% */ softs->ipf_sync_event_high_wm = SYNCLOG_SZ * 100 / 90; /* 90% */
softs->ipf_sync_queue_high_wm = SYNCLOG_SZ * 100 / 90; /* 90% */ softs->ipf_sync_queue_high_wm = SYNCLOG_SZ * 100 / 90; /* 90% */
return softs; return(softs);
} }
@ -178,28 +178,28 @@ ipf_sync_soft_init(ipf_main_softc_t *softc, void *arg)
KMALLOCS(softs->synclog, synclogent_t *, KMALLOCS(softs->synclog, synclogent_t *,
softs->ipf_sync_log_sz * sizeof(*softs->synclog)); softs->ipf_sync_log_sz * sizeof(*softs->synclog));
if (softs->synclog == NULL) if (softs->synclog == NULL)
return -1; return(-1);
bzero((char *)softs->synclog, bzero((char *)softs->synclog,
softs->ipf_sync_log_sz * sizeof(*softs->synclog)); softs->ipf_sync_log_sz * sizeof(*softs->synclog));
KMALLOCS(softs->syncupd, syncupdent_t *, KMALLOCS(softs->syncupd, syncupdent_t *,
softs->ipf_sync_log_sz * sizeof(*softs->syncupd)); softs->ipf_sync_log_sz * sizeof(*softs->syncupd));
if (softs->syncupd == NULL) if (softs->syncupd == NULL)
return -2; return(-2);
bzero((char *)softs->syncupd, bzero((char *)softs->syncupd,
softs->ipf_sync_log_sz * sizeof(*softs->syncupd)); softs->ipf_sync_log_sz * sizeof(*softs->syncupd));
KMALLOCS(softs->syncstatetab, synclist_t **, KMALLOCS(softs->syncstatetab, synclist_t **,
softs->ipf_sync_state_tab_sz * sizeof(*softs->syncstatetab)); softs->ipf_sync_state_tab_sz * sizeof(*softs->syncstatetab));
if (softs->syncstatetab == NULL) if (softs->syncstatetab == NULL)
return -3; return(-3);
bzero((char *)softs->syncstatetab, bzero((char *)softs->syncstatetab,
softs->ipf_sync_state_tab_sz * sizeof(*softs->syncstatetab)); softs->ipf_sync_state_tab_sz * sizeof(*softs->syncstatetab));
KMALLOCS(softs->syncnattab, synclist_t **, KMALLOCS(softs->syncnattab, synclist_t **,
softs->ipf_sync_nat_tab_sz * sizeof(*softs->syncnattab)); softs->ipf_sync_nat_tab_sz * sizeof(*softs->syncnattab));
if (softs->syncnattab == NULL) if (softs->syncnattab == NULL)
return -3; return(-3);
bzero((char *)softs->syncnattab, bzero((char *)softs->syncnattab,
softs->ipf_sync_nat_tab_sz * sizeof(*softs->syncnattab)); softs->ipf_sync_nat_tab_sz * sizeof(*softs->syncnattab));
@ -223,7 +223,7 @@ ipf_sync_soft_init(ipf_main_softc_t *softc, void *arg)
softs->ipf_sync_inited = 1; softs->ipf_sync_inited = 1;
return 0; return(0);
} }
@ -277,7 +277,7 @@ ipf_sync_soft_fini(ipf_main_softc_t *softc, void *arg)
softs->ipf_sync_inited = 0; softs->ipf_sync_inited = 0;
} }
return 0; return(0);
} }
void void
@ -437,7 +437,7 @@ ipf_sync_write(ipf_main_softc_t *softc, struct uio *uio)
if (softs->ipf_sync_debug > 2) if (softs->ipf_sync_debug > 2)
printf("uiomove(header) failed: %d\n", printf("uiomove(header) failed: %d\n",
err); err);
return err; return(err);
} }
/* convert to host order */ /* convert to host order */
@ -456,7 +456,7 @@ ipf_sync_write(ipf_main_softc_t *softc, struct uio *uio)
printf("uiomove(header) invalid %s\n", printf("uiomove(header) invalid %s\n",
"magic"); "magic");
IPFERROR(110001); IPFERROR(110001);
return EINVAL; return(EINVAL);
} }
if (sh.sm_v != 4 && sh.sm_v != 6) { if (sh.sm_v != 4 && sh.sm_v != 6) {
@ -464,7 +464,7 @@ ipf_sync_write(ipf_main_softc_t *softc, struct uio *uio)
printf("uiomove(header) invalid %s\n", printf("uiomove(header) invalid %s\n",
"protocol"); "protocol");
IPFERROR(110002); IPFERROR(110002);
return EINVAL; return(EINVAL);
} }
if (sh.sm_cmd > SMC_MAXCMD) { if (sh.sm_cmd > SMC_MAXCMD) {
@ -472,7 +472,7 @@ ipf_sync_write(ipf_main_softc_t *softc, struct uio *uio)
printf("uiomove(header) invalid %s\n", printf("uiomove(header) invalid %s\n",
"command"); "command");
IPFERROR(110003); IPFERROR(110003);
return EINVAL; return(EINVAL);
} }
@ -481,7 +481,7 @@ ipf_sync_write(ipf_main_softc_t *softc, struct uio *uio)
printf("uiomove(header) invalid %s\n", printf("uiomove(header) invalid %s\n",
"table"); "table");
IPFERROR(110004); IPFERROR(110004);
return EINVAL; return(EINVAL);
} }
} else { } else {
@ -489,7 +489,7 @@ ipf_sync_write(ipf_main_softc_t *softc, struct uio *uio)
if (softs->ipf_sync_debug > 2) if (softs->ipf_sync_debug > 2)
printf("uiomove(header) insufficient data"); printf("uiomove(header) insufficient data");
IPFERROR(110005); IPFERROR(110005);
return EAGAIN; return(EAGAIN);
} }
@ -504,7 +504,7 @@ ipf_sync_write(ipf_main_softc_t *softc, struct uio *uio)
printf("uiomove(data zero length %s\n", printf("uiomove(data zero length %s\n",
"not supported"); "not supported");
IPFERROR(110006); IPFERROR(110006);
return EINVAL; return(EINVAL);
} }
if (uio->uio_resid >= sh.sm_len) { if (uio->uio_resid >= sh.sm_len) {
@ -515,7 +515,7 @@ ipf_sync_write(ipf_main_softc_t *softc, struct uio *uio)
if (softs->ipf_sync_debug > 2) if (softs->ipf_sync_debug > 2)
printf("uiomove(data) failed: %d\n", printf("uiomove(data) failed: %d\n",
err); err);
return err; return(err);
} }
if (softs->ipf_sync_debug > 7) if (softs->ipf_sync_debug > 7)
@ -537,12 +537,12 @@ ipf_sync_write(ipf_main_softc_t *softc, struct uio *uio)
"insufficient data, need", "insufficient data, need",
sh.sm_len, (int)uio->uio_resid); sh.sm_len, (int)uio->uio_resid);
IPFERROR(110007); IPFERROR(110007);
return EAGAIN; return(EAGAIN);
} }
} }
/* no more data */ /* no more data */
return 0; return(0);
} }
@ -565,7 +565,7 @@ ipf_sync_read(ipf_main_softc_t *softc, struct uio *uio)
if ((uio->uio_resid & 3) || (uio->uio_resid < 8)) { if ((uio->uio_resid & 3) || (uio->uio_resid < 8)) {
IPFERROR(110008); IPFERROR(110008);
return EINVAL; return(EINVAL);
} }
# if defined(__NetBSD__) || defined(__FreeBSD__) # if defined(__NetBSD__) || defined(__FreeBSD__)
@ -580,14 +580,14 @@ ipf_sync_read(ipf_main_softc_t *softc, struct uio *uio)
if (!cv_wait_sig(&softs->ipslwait, &softs->ipsl_mutex.ipf_lk)) { if (!cv_wait_sig(&softs->ipslwait, &softs->ipsl_mutex.ipf_lk)) {
MUTEX_EXIT(&softs->ipsl_mutex); MUTEX_EXIT(&softs->ipsl_mutex);
IPFERROR(110009); IPFERROR(110009);
return EINTR; return(EINTR);
} }
# else # else
MUTEX_EXIT(&softs->ipsl_mutex); MUTEX_EXIT(&softs->ipsl_mutex);
err = SLEEP(&softs->sl_tail, "ipl sleep"); err = SLEEP(&softs->sl_tail, "ipl sleep");
if (err) { if (err) {
IPFERROR(110012); IPFERROR(110012);
return EINTR; return(EINTR);
} }
MUTEX_ENTER(&softs->ipsl_mutex); MUTEX_ENTER(&softs->ipsl_mutex);
# endif /* SOLARIS */ # endif /* SOLARIS */
@ -622,7 +622,7 @@ ipf_sync_read(ipf_main_softc_t *softc, struct uio *uio)
softs->su_tail = softs->su_idx = 0; softs->su_tail = softs->su_idx = 0;
MUTEX_EXIT(&softs->ipsl_mutex); MUTEX_EXIT(&softs->ipsl_mutex);
goterror: goterror:
return err; return(err);
} }
@ -794,7 +794,7 @@ ipf_sync_state(ipf_main_softc_t *softc, synchdr_t *sp, void *data)
printf("[%d] Update completed with error %d\n", printf("[%d] Update completed with error %d\n",
sp->sm_num, err); sp->sm_num, err);
return err; return(err);
} }
@ -951,7 +951,7 @@ ipf_sync_nat(ipf_main_softc_t *softc, synchdr_t *sp, void *data)
} }
RWLOCK_EXIT(&softs->ipf_syncnat); RWLOCK_EXIT(&softs->ipf_syncnat);
return err; return(err);
} }
@ -975,10 +975,10 @@ ipf_sync_new(ipf_main_softc_t *softc, int tab, fr_info_t *fin, void *ptr)
u_int hv, sz; u_int hv, sz;
if (softs->sl_idx == softs->ipf_sync_log_sz) if (softs->sl_idx == softs->ipf_sync_log_sz)
return NULL; return(NULL);
KMALLOC(sl, synclist_t *); KMALLOC(sl, synclist_t *);
if (sl == NULL) if (sl == NULL)
return NULL; return(NULL);
MUTEX_ENTER(&softs->ipf_syncadd); MUTEX_ENTER(&softs->ipf_syncadd);
/* /*
@ -1083,7 +1083,7 @@ ipf_sync_new(ipf_main_softc_t *softc, int tab, fr_info_t *fin, void *ptr)
MUTEX_EXIT(&softs->ipf_syncadd); MUTEX_EXIT(&softs->ipf_syncadd);
ipf_sync_wakeup(softc); ipf_sync_wakeup(softc);
return sl; return(sl);
} }
@ -1210,7 +1210,7 @@ ipf_sync_flush_table(ipf_sync_softc_t *softs, int tabsize, synclist_t **table)
} }
} }
return items; return(items);
} }
@ -1289,7 +1289,7 @@ ipf_sync_ioctl(ipf_main_softc_t *softc, caddr_t data, ioctlcmd_t cmd,
break; break;
} }
return error; return(error);
} }
@ -1305,8 +1305,8 @@ int
ipf_sync_canread(void *arg) ipf_sync_canread(void *arg)
{ {
ipf_sync_softc_t *softs = arg; ipf_sync_softc_t *softs = arg;
return !((softs->sl_tail == softs->sl_idx) && return (!((softs->sl_tail == softs->sl_idx) &&
(softs->su_tail == softs->su_idx)); (softs->su_tail == softs->su_idx)));
} }
@ -1322,7 +1322,7 @@ ipf_sync_canread(void *arg)
int int
ipf_sync_canwrite(void *arg) ipf_sync_canwrite(void *arg)
{ {
return 1; return(1);
} }

View File

@ -89,7 +89,7 @@ ipf_p_tftp_soft_create(ipf_main_softc_t *softc)
KMALLOC(softt, ipf_tftp_softc_t *); KMALLOC(softt, ipf_tftp_softc_t *);
if (softt == NULL) if (softt == NULL)
return NULL; return(NULL);
bzero((char *)softt, sizeof(*softt)); bzero((char *)softt, sizeof(*softt));
@ -98,16 +98,16 @@ ipf_p_tftp_soft_create(ipf_main_softc_t *softc)
ipf_tftp_tuneables); ipf_tftp_tuneables);
if (softt->ipf_p_tftp_tune == NULL) { if (softt->ipf_p_tftp_tune == NULL) {
ipf_p_tftp_soft_destroy(softc, softt); ipf_p_tftp_soft_destroy(softc, softt);
return NULL; return(NULL);
} }
if (ipf_tune_array_link(softc, softt->ipf_p_tftp_tune) == -1) { if (ipf_tune_array_link(softc, softt->ipf_p_tftp_tune) == -1) {
ipf_p_tftp_soft_destroy(softc, softt); ipf_p_tftp_soft_destroy(softc, softt);
return NULL; return(NULL);
} }
softt->ipf_p_tftp_readonly = 1; softt->ipf_p_tftp_readonly = 1;
return softt; return(softt);
} }
@ -133,8 +133,8 @@ ipf_p_tftp_out(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
fin->fin_flx |= FI_NOWILD; fin->fin_flx |= FI_NOWILD;
if (nat->nat_dir == NAT_OUTBOUND) if (nat->nat_dir == NAT_OUTBOUND)
return ipf_p_tftp_client(softt, fin, aps, nat); return(ipf_p_tftp_client(softt, fin, aps, nat));
return ipf_p_tftp_server(softt, fin, aps, nat); return(ipf_p_tftp_server(softt, fin, aps, nat));
} }
@ -145,8 +145,8 @@ ipf_p_tftp_in(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
fin->fin_flx |= FI_NOWILD; fin->fin_flx |= FI_NOWILD;
if (nat->nat_dir == NAT_INBOUND) if (nat->nat_dir == NAT_INBOUND)
return ipf_p_tftp_client(softt, fin, aps, nat); return(ipf_p_tftp_client(softt, fin, aps, nat));
return ipf_p_tftp_server(softt, fin, aps, nat); return(ipf_p_tftp_server(softt, fin, aps, nat));
} }
@ -166,11 +166,11 @@ ipf_p_tftp_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
KMALLOC(ti, tftpinfo_t *); KMALLOC(ti, tftpinfo_t *);
if (ti == NULL) if (ti == NULL)
return -1; return(-1);
KMALLOCS(ipn, ipnat_t *, size); KMALLOCS(ipn, ipnat_t *, size);
if (ipn == NULL) { if (ipn == NULL) {
KFREE(ti); KFREE(ti);
return -1; return(-1);
} }
aps->aps_data = ti; aps->aps_data = ti;
@ -242,7 +242,7 @@ ipf_p_tftp_new(void *arg, fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ti->ti_lastcmd = 0; ti->ti_lastcmd = 0;
return 0; return(0);
} }
@ -394,7 +394,7 @@ ipf_p_tftp_backchannel(fr_info_t *fin, ap_session_t *aps, nat_t *nat)
ip6->ip6_dst = sw2ip6.in6; ip6->ip6_dst = sw2ip6.in6;
#endif #endif
} }
return 0; return(0);
} }
@ -409,7 +409,7 @@ ipf_p_tftp_client(ipf_tftp_softc_t *softt, fr_info_t *fin, ap_session_t *aps,
int len; int len;
if (fin->fin_dlen < 4) if (fin->fin_dlen < 4)
return 0; return(0);
ti = aps->aps_data; ti = aps->aps_data;
msg = fin->fin_dp; msg = fin->fin_dp;
@ -436,12 +436,12 @@ ipf_p_tftp_client(ipf_tftp_softc_t *softt, fr_info_t *fin, ap_session_t *aps,
ipf_p_tftp_backchannel(fin, aps, nat); ipf_p_tftp_backchannel(fin, aps, nat);
break; break;
default : default :
return -1; return(-1);
} }
ti = aps->aps_data; ti = aps->aps_data;
ti->ti_lastcmd = opcode; ti->ti_lastcmd = opcode;
return 0; return(0);
} }
@ -455,7 +455,7 @@ ipf_p_tftp_server(ipf_tftp_softc_t *softt, fr_info_t *fin, ap_session_t *aps,
u_char *msg; u_char *msg;
if (fin->fin_dlen < 4) if (fin->fin_dlen < 4)
return 0; return(0);
ti = aps->aps_data; ti = aps->aps_data;
msg = fin->fin_dp; msg = fin->fin_dp;
@ -474,9 +474,9 @@ ipf_p_tftp_server(ipf_tftp_softc_t *softt, fr_info_t *fin, ap_session_t *aps,
break; break;
default : default :
return -1; return(-1);
} }
ti->ti_lastcmd = opcode; ti->ti_lastcmd = opcode;
return 0; return(0);
} }

View File

@ -283,7 +283,7 @@ colour: \
if (color == C_BLACK) \ if (color == C_BLACK) \
deleteblack(head, parent, node); \ deleteblack(head, parent, node); \
head->count--; \ head->count--; \
return old; \ return(old); \
} \ } \
\ \
void \ void \
@ -350,8 +350,8 @@ _n##_rb_search(struct _n##_rb_head *head, void *key) \
node = node->_f.right; \ node = node->_f.right; \
} \ } \
if (node == &_n##_rb_zero || match != 0) \ if (node == &_n##_rb_zero || match != 0) \
return (NULL); \ return(NULL); \
return (node); \ return(node); \
} }
#define RBI_DELETE(_n, _h, _v) _n##_rb_delete(_h, _v) #define RBI_DELETE(_n, _h, _v) _n##_rb_delete(_h, _v)

View File

@ -197,7 +197,7 @@ ipfilter_modevent(module_t mod, int type, void *unused)
error = EINVAL; error = EINVAL;
break; break;
} }
return error; return(error);
} }
@ -252,10 +252,10 @@ ipf_modload(void)
int i, j, error; int i, j, error;
if (ipf_load_all() != 0) if (ipf_load_all() != 0)
return EIO; return(EIO);
if (ipf_fbsd_sysctl_create() != 0) { if (ipf_fbsd_sysctl_create() != 0) {
return EIO; return(EIO);
} }
for (i = 0; i < IPL_LOGSIZE; i++) for (i = 0; i < IPL_LOGSIZE; i++)
@ -274,10 +274,10 @@ ipf_modload(void)
error = ipf_pfil_hook(); error = ipf_pfil_hook();
if (error != 0) if (error != 0)
return error; return(error);
ipf_event_reg(); ipf_event_reg();
return 0; return(0);
} }
static void static void
@ -315,7 +315,7 @@ ipf_modunload(void)
error = ipf_pfil_unhook(); error = ipf_pfil_unhook();
if (error != 0) if (error != 0)
return error; return(error);
for (i = 0; ipf_devfiles[i]; i++) { for (i = 0; ipf_devfiles[i]; i++) {
if (ipf_devs[i] != NULL) if (ipf_devs[i] != NULL)
@ -326,7 +326,7 @@ ipf_modunload(void)
printf("%s unloaded\n", ipfilter_version); printf("%s unloaded\n", ipfilter_version);
return (0); return(0);
} }
@ -367,7 +367,7 @@ sysctl_ipf_int ( SYSCTL_HANDLER_ARGS )
} }
sysctl_error: sysctl_error:
return (error); return(error);
} }
/* /*
@ -382,7 +382,7 @@ sysctl_ipf_int_nat ( SYSCTL_HANDLER_ARGS )
nat_softc = V_ipfmain.ipf_nat_soft; nat_softc = V_ipfmain.ipf_nat_soft;
arg1 = (void *)((uintptr_t)nat_softc + arg2); arg1 = (void *)((uintptr_t)nat_softc + arg2);
return (sysctl_ipf_int(oidp, arg1, 0, req)); return(sysctl_ipf_int(oidp, arg1, 0, req));
} }
static int static int
@ -393,7 +393,7 @@ sysctl_ipf_int_state ( SYSCTL_HANDLER_ARGS )
state_softc = V_ipfmain.ipf_state_soft; state_softc = V_ipfmain.ipf_state_soft;
arg1 = (void *)((uintptr_t)state_softc + arg2); arg1 = (void *)((uintptr_t)state_softc + arg2);
return (sysctl_ipf_int(oidp, arg1, 0, req)); return(sysctl_ipf_int(oidp, arg1, 0, req));
} }
static int static int
@ -404,7 +404,7 @@ sysctl_ipf_int_auth ( SYSCTL_HANDLER_ARGS )
auth_softc = V_ipfmain.ipf_auth_soft; auth_softc = V_ipfmain.ipf_auth_soft;
arg1 = (void *)((uintptr_t)auth_softc + arg2); arg1 = (void *)((uintptr_t)auth_softc + arg2);
return (sysctl_ipf_int(oidp, arg1, 0, req)); return(sysctl_ipf_int(oidp, arg1, 0, req));
} }
static int static int
@ -415,7 +415,7 @@ sysctl_ipf_int_frag ( SYSCTL_HANDLER_ARGS )
frag_softc = V_ipfmain.ipf_frag_soft; frag_softc = V_ipfmain.ipf_frag_soft;
arg1 = (void *)((uintptr_t)frag_softc + arg2); arg1 = (void *)((uintptr_t)frag_softc + arg2);
return (sysctl_ipf_int(oidp, arg1, 0, req)); return(sysctl_ipf_int(oidp, arg1, 0, req));
} }
#endif #endif
@ -431,7 +431,7 @@ ipfpoll(dev_t dev, int events, struct proc *td)
int revents; int revents;
if (unit < 0 || unit > IPL_LOGMAX) if (unit < 0 || unit > IPL_LOGMAX)
return 0; return(0);
revents = 0; revents = 0;
@ -466,7 +466,7 @@ ipfpoll(dev_t dev, int events, struct proc *td)
selrecord(td, &V_ipfmain.ipf_selwait[unit]); selrecord(td, &V_ipfmain.ipf_selwait[unit]);
CURVNET_RESTORE(); CURVNET_RESTORE();
return revents; return(revents);
} }
@ -504,7 +504,7 @@ ipfopen(dev_t dev, int flags)
break; break;
} }
} }
return error; return(error);
} }
@ -521,7 +521,7 @@ ipfclose(dev_t dev, int flags)
unit = ENXIO; unit = ENXIO;
else else
unit = 0; unit = 0;
return unit; return(unit);
} }
/* /*
@ -543,18 +543,18 @@ static int ipfread(dev, uio, ioflag)
int unit = GET_MINOR(dev); int unit = GET_MINOR(dev);
if (unit < 0) if (unit < 0)
return ENXIO; return(ENXIO);
CURVNET_SET(TD_TO_VNET(curthread)); CURVNET_SET(TD_TO_VNET(curthread));
if (V_ipfmain.ipf_running < 1) { if (V_ipfmain.ipf_running < 1) {
CURVNET_RESTORE(); CURVNET_RESTORE();
return EIO; return(EIO);
} }
if (unit == IPL_LOGSYNC) { if (unit == IPL_LOGSYNC) {
error = ipf_sync_read(&V_ipfmain, uio); error = ipf_sync_read(&V_ipfmain, uio);
CURVNET_RESTORE(); CURVNET_RESTORE();
return error; return(error);
} }
#ifdef IPFILTER_LOG #ifdef IPFILTER_LOG
@ -563,7 +563,7 @@ static int ipfread(dev, uio, ioflag)
error = ENXIO; error = ENXIO;
#endif #endif
CURVNET_RESTORE(); CURVNET_RESTORE();
return error; return(error);
} }
@ -587,15 +587,15 @@ static int ipfwrite(dev, uio, ioflag)
CURVNET_SET(TD_TO_VNET(curthread)); CURVNET_SET(TD_TO_VNET(curthread));
if (V_ipfmain.ipf_running < 1) { if (V_ipfmain.ipf_running < 1) {
CURVNET_RESTORE(); CURVNET_RESTORE();
return EIO; return(EIO);
} }
if (GET_MINOR(dev) == IPL_LOGSYNC) { if (GET_MINOR(dev) == IPL_LOGSYNC) {
error = ipf_sync_write(&V_ipfmain, uio); error = ipf_sync_write(&V_ipfmain, uio);
CURVNET_RESTORE(); CURVNET_RESTORE();
return error; return(error);
} }
return ENXIO; return(ENXIO);
} }
static int static int
@ -628,7 +628,7 @@ ipf_fbsd_sysctl_create(void)
NULL, offsetof(ipf_auth_softc_t, ipf_auth_defaultage), ""); NULL, offsetof(ipf_auth_softc_t, ipf_auth_defaultage), "");
SYSCTL_DYN_IPF_FRAG(_net_inet_ipf, OID_AUTO, "fr_ipfrttl", CTLFLAG_RW, SYSCTL_DYN_IPF_FRAG(_net_inet_ipf, OID_AUTO, "fr_ipfrttl", CTLFLAG_RW,
NULL, offsetof(ipf_frag_softc_t, ipfr_ttl), ""); NULL, offsetof(ipf_frag_softc_t, ipfr_ttl), "");
return 0; return(0);
} }
static int static int
@ -638,5 +638,5 @@ ipf_fbsd_sysctl_destroy(void)
printf("sysctl_ctx_free failed"); printf("sysctl_ctx_free failed");
return(ENOTEMPTY); return(ENOTEMPTY);
} }
return 0; return(0);
} }

View File

@ -78,7 +78,7 @@ count_mask_bits(addrfamily_t *mask, u_32_t **lastp)
count++; count++;
} }
return count; return(count);
} }
@ -155,7 +155,7 @@ ipf_rx_find_addr(ipf_rdx_node_t *tree, u_32_t *addr)
} }
} }
return (cur); return(cur);
} }
@ -201,7 +201,7 @@ ipf_rx_match(ipf_rdx_head_t *head, addrfamily_t *addr)
if ((*key & *mask) != *data) if ((*key & *mask) != *data)
break; break;
if ((end == key) && (cur->root == 0)) if ((end == key) && (cur->root == 0))
return (cur); /* Equal keys */ return(cur); /* Equal keys */
} }
prev = node->parent; prev = node->parent;
key = (u_32_t *)addr; key = (u_32_t *)addr;
@ -220,12 +220,12 @@ ipf_rx_match(ipf_rdx_head_t *head, addrfamily_t *addr)
for (i = ADF_OFF >> 2; i <= node->offset; i++) { for (i = ADF_OFF >> 2; i <= node->offset; i++) {
if ((key[i] & masknode->mask[i]) == if ((key[i] & masknode->mask[i]) ==
cur->addrkey[i]) cur->addrkey[i])
return (cur); return(cur);
} }
} }
} }
return NULL; return(NULL);
} }
@ -250,31 +250,31 @@ ipf_rx_lookup(ipf_rdx_head_t *head, addrfamily_t *addr, addrfamily_t *mask)
found = ipf_rx_find_addr(head->root, (u_32_t *)addr); found = ipf_rx_find_addr(head->root, (u_32_t *)addr);
if (found->root == 1) if (found->root == 1)
return NULL; return(NULL);
/* /*
* It is possible to find a matching address in the tree but for the * It is possible to find a matching address in the tree but for the
* netmask to not match. If the netmask does not match and there is * netmask to not match. If the netmask does not match and there is
* no list of alternatives present at dupkey, return a failure. * no list of alternatives present at dupkey, return a failure.
*/ */
count = count_mask_bits(mask, NULL); count = count_mask_bits(mask, NULL);
if (count != found->maskbitcount && found->dupkey == NULL) if (count != found->maskbitcount && found->dupkey == NULL)
return (NULL); return(NULL);
akey = (u_32_t *)addr; akey = (u_32_t *)addr;
if ((found->addrkey[found->offset] & found->maskkey[found->offset]) != if ((found->addrkey[found->offset] & found->maskkey[found->offset]) !=
akey[found->offset]) akey[found->offset])
return NULL; return(NULL);
if (found->dupkey != NULL) { if (found->dupkey != NULL) {
node = found; node = found;
while (node != NULL && node->maskbitcount != count) while (node != NULL && node->maskbitcount != count)
node = node->dupkey; node = node->dupkey;
if (node == NULL) if (node == NULL)
return (NULL); return(NULL);
found = node; found = node;
} }
return found; return(found);
} }
@ -347,7 +347,7 @@ ipf_rx_insert(ipf_rdx_head_t *head, ipf_rdx_node_t *nodes, int *dup)
break; break;
if (end == data) { if (end == data) {
*dup = 1; *dup = 1;
return (node); /* Equal keys */ return(node); /* Equal keys */
} }
*dup = 0; *dup = 0;
@ -416,7 +416,7 @@ ipf_rx_insert(ipf_rdx_head_t *head, ipf_rdx_node_t *nodes, int *dup)
KMALLOC(mask, ipf_rdx_mask_t *); KMALLOC(mask, ipf_rdx_mask_t *);
if (mask == NULL) if (mask == NULL)
return NULL; return(NULL);
bzero(mask, sizeof(*mask)); bzero(mask, sizeof(*mask));
mask->next = NULL; mask->next = NULL;
mask->node = &nodes[0]; mask->node = &nodes[0];
@ -467,7 +467,7 @@ ipf_rx_insert(ipf_rdx_head_t *head, ipf_rdx_node_t *nodes, int *dup)
} }
} }
} }
return (&nodes[0]); return(&nodes[0]);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -504,7 +504,7 @@ ipf_rx_addroute(ipf_rdx_head_t *head, addrfamily_t *addr, addrfamily_t *mask,
buildnodes(addr, mask, nodes); buildnodes(addr, mask, nodes);
x = ipf_rx_insert(head, nodes, &dup); x = ipf_rx_insert(head, nodes, &dup);
if (x == NULL) if (x == NULL)
return NULL; return(NULL);
if (dup == 1) { if (dup == 1) {
node = &nodes[0]; node = &nodes[0];
@ -521,12 +521,12 @@ ipf_rx_addroute(ipf_rdx_head_t *head, addrfamily_t *addr, addrfamily_t *mask,
} }
/* /*
* Is it a complete duplicate? If so, return NULL and * Is it a complete duplicate? If so, return NULL and
* fail the insert. Otherwise, insert it into the list * fail the insert. Otherwise, insert it into the list
* of netmasks active for this key. * of netmasks active for this key.
*/ */
if ((x != NULL) && (x->maskbitcount == node->maskbitcount)) if ((x != NULL) && (x->maskbitcount == node->maskbitcount))
return (NULL); return(NULL);
if (prev != NULL) { if (prev != NULL) {
nodes[0].dupkey = x; nodes[0].dupkey = x;
@ -546,7 +546,7 @@ ipf_rx_addroute(ipf_rdx_head_t *head, addrfamily_t *addr, addrfamily_t *mask,
} }
} }
return &nodes[0]; return(&nodes[0]);
} }
@ -577,9 +577,9 @@ ipf_rx_delete(ipf_rdx_head_t *head, addrfamily_t *addr, addrfamily_t *mask)
found = ipf_rx_find_addr(head->root, (u_32_t *)addr); found = ipf_rx_find_addr(head->root, (u_32_t *)addr);
if (found == NULL) if (found == NULL)
return NULL; return(NULL);
if (found->root == 1) if (found->root == 1)
return NULL; return(NULL);
count = count_mask_bits(mask, NULL); count = count_mask_bits(mask, NULL);
parent = found->parent; parent = found->parent;
if (found->dupkey != NULL) { if (found->dupkey != NULL) {
@ -587,7 +587,7 @@ ipf_rx_delete(ipf_rdx_head_t *head, addrfamily_t *addr, addrfamily_t *mask)
while (node != NULL && node->maskbitcount != count) while (node != NULL && node->maskbitcount != count)
node = node->dupkey; node = node->dupkey;
if (node == NULL) if (node == NULL)
return (NULL); return(NULL);
if (node != found) { if (node != found) {
/* /*
* Remove from the dupkey list. Here, "parent" is * Remove from the dupkey list. Here, "parent" is
@ -618,7 +618,7 @@ ipf_rx_delete(ipf_rdx_head_t *head, addrfamily_t *addr, addrfamily_t *mask)
} }
} else { } else {
if (count != found->maskbitcount) if (count != found->maskbitcount)
return (NULL); return(NULL);
/* /*
* Remove the node from the tree and reconnect the subtree * Remove the node from the tree and reconnect the subtree
* below. * below.
@ -725,7 +725,7 @@ ipf_rx_delete(ipf_rdx_head_t *head, addrfamily_t *addr, addrfamily_t *mask)
} }
} }
return (found); return(found);
} }
@ -796,7 +796,7 @@ ipf_rx_inithead(radix_softc_t *softr, ipf_rdx_head_t **headp)
KMALLOC(ptr, ipf_rdx_head_t *); KMALLOC(ptr, ipf_rdx_head_t *);
*headp = ptr; *headp = ptr;
if (ptr == NULL) if (ptr == NULL)
return -1; return(-1);
bzero(ptr, sizeof(*ptr)); bzero(ptr, sizeof(*ptr));
node = ptr->nodes; node = ptr->nodes;
ptr->root = node + 1; ptr->root = node + 1;
@ -829,7 +829,7 @@ ipf_rx_inithead(radix_softc_t *softr, ipf_rdx_head_t **headp)
ptr->lookup = ipf_rx_lookup; ptr->lookup = ipf_rx_lookup;
ptr->matchaddr = ipf_rx_match; ptr->matchaddr = ipf_rx_match;
ptr->walktree = ipf_rx_walktree; ptr->walktree = ipf_rx_walktree;
return 0; return(0);
} }
@ -860,17 +860,17 @@ ipf_rx_create(void)
KMALLOC(softr, radix_softc_t *); KMALLOC(softr, radix_softc_t *);
if (softr == NULL) if (softr == NULL)
return NULL; return(NULL);
bzero((char *)softr, sizeof(*softr)); bzero((char *)softr, sizeof(*softr));
KMALLOCS(softr->zeros, u_char *, 3 * sizeof(addrfamily_t)); KMALLOCS(softr->zeros, u_char *, 3 * sizeof(addrfamily_t));
if (softr->zeros == NULL) { if (softr->zeros == NULL) {
KFREE(softr); KFREE(softr);
return (NULL); return(NULL);
} }
softr->ones = softr->zeros + sizeof(addrfamily_t); softr->ones = softr->zeros + sizeof(addrfamily_t);
return softr; return(softr);
} }
@ -887,7 +887,7 @@ ipf_rx_init(void *ctx)
memset(softr->zeros, 0, 3 * sizeof(addrfamily_t)); memset(softr->zeros, 0, 3 * sizeof(addrfamily_t));
memset(softr->ones, 0xff, sizeof(addrfamily_t)); memset(softr->ones, 0xff, sizeof(addrfamily_t));
return (0); return(0);
} }
@ -1027,7 +1027,7 @@ addrname(addrfamily_t *ap)
bzero((char *)name, sizeof(name)); bzero((char *)name, sizeof(name));
txt = inet_ntop(ap->adf_family, &ap->adf_addr, name, txt = inet_ntop(ap->adf_family, &ap->adf_addr, name,
sizeof(name)); sizeof(name));
return txt; return(txt);
} }
@ -1262,7 +1262,7 @@ main(int argc, char *argv[])
ipf_rx_walktree(rnh, ipf_rx_freenode, rnh); ipf_rx_walktree(rnh, ipf_rx_freenode, rnh);
return 0; return(0);
} }
@ -1443,7 +1443,7 @@ randomize(int *pnitems)
order[i] = choice; order[i] = choice;
} }
return order; return(order);
} }