ipfilter userland: Style(9) requires a space after return

Reported by:    jrtc27
Fixes:          2582ae5740181e0d2bab10003d66ae91c9b56329
MFC after:      1 month
This commit is contained in:
Cy Schubert 2022-01-03 18:49:18 -08:00
parent 701301511f
commit 44bc301921
105 changed files with 778 additions and 778 deletions

View File

@ -26,15 +26,15 @@ int genmask(family, msk, mskp)
#ifdef USE_INET6
case AF_INET6 :
if (inet_pton(AF_INET6, msk, &mskp->in4) != 1)
return(-1);
return (-1);
break;
#endif
case AF_INET :
if (inet_aton(msk, &mskp->in4) == 0)
return(-1);
return (-1);
break;
default :
return(-1);
return (-1);
/*NOTREACHED*/
}
} else {
@ -47,12 +47,12 @@ int genmask(family, msk, mskp)
{
case AF_INET6 :
if ((*endptr != '\0') || (bits < 0) || (bits > 128))
return(-1);
return (-1);
fill6bits(bits, mskp->i6);
break;
case AF_INET :
if (*endptr != '\0' || bits > 32 || bits < 0)
return(-1);
return (-1);
if (bits == 0)
addr = 0;
else
@ -60,9 +60,9 @@ int genmask(family, msk, mskp)
mskp->in4.s_addr = addr;
break;
default :
return(-1);
return (-1);
/*NOTREACHED*/
}
}
return(0);
return (0);
}

View File

@ -69,11 +69,11 @@ yygetc(int docont)
c = yytext[yypos++];
if (c == '\n')
yylineNum++;
return(c);
return (c);
}
if (yypos == YYBUFSIZ)
return(TOOLONG);
return (TOOLONG);
if (pos >= string_start && pos <= string_end) {
c = string_val[pos - string_start];
@ -94,7 +94,7 @@ yygetc(int docont)
yylast = yypos;
yytext[yypos] = '\0';
return(c);
return (c);
}
@ -118,8 +118,8 @@ yyswallow(int last)
if (c != EOF)
yyunputc(c);
if (c == last)
return(0);
return(-1);
return (0);
return (-1);
}
@ -131,7 +131,7 @@ yytexttochar(void)
for (i = 0; i < yypos; i++)
yychars[i] = (char)(yytext[i] & 0xff);
yychars[i] = '\0';
return(yychars);
return (yychars);
}
@ -171,7 +171,7 @@ yytexttostr(int offset, int max)
str[i - offset] = (char)(yytext[i] & 0xff);
str[i - offset] = '\0';
}
return(str);
return (str);
}
@ -242,7 +242,7 @@ nextchar:
lnext = 0;
if ((isbuilding == 0) && !ISALNUM(c)) {
prior = c;
return(c);
return (c);
}
goto nextchar;
}
@ -333,7 +333,7 @@ nextchar:
if (yydebug)
fprintf(stderr, "reset at EOF\n");
prior = 0;
return(0);
return (0);
}
if (strchr("=,/;{}()@", c) != NULL) {
@ -599,7 +599,7 @@ done:
if (rval == YY_NUMBER)
priornum = yylval.num;
prior = rval;
return(rval);
return (rval);
}
@ -609,12 +609,12 @@ static wordtab_t *yyfindkey(key)
wordtab_t *w;
if (yywordtab == NULL)
return(NULL);
return (NULL);
for (w = yywordtab; w->w_word != 0; w++)
if (strcasecmp(key, w->w_word) == 0)
return(w);
return(NULL);
return (w);
return (NULL);
}
@ -624,12 +624,12 @@ yykeytostr(int num)
wordtab_t *w;
if (yywordtab == NULL)
return("<unknown>");
return ("<unknown>");
for (w = yywordtab; w->w_word; w++)
if (w->w_value == num)
return(w->w_word);
return("<unknown>");
return (w->w_word);
return ("<unknown>");
}
@ -640,7 +640,7 @@ yysettab(wordtab_t *words)
save = yywordtab;
yywordtab = words;
return(save);
return (save);
}

View File

@ -111,7 +111,7 @@ static int m_xhalf(mb_t *, int, int *);
(_k) -= len; \
(_m) = (_m)->m_next; \
if ((_m) == 0) \
return(0); \
return (0); \
len = M_LEN(m); \
} \
}
@ -129,7 +129,7 @@ m_xword(m, k, err)
cp = MTOD(m, u_char *) + k;
if (len - k >= 4) {
*err = 0;
return(EXTRACT_LONG(cp));
return (EXTRACT_LONG(cp));
}
m0 = m->m_next;
if (m0 == NULL || M_LEN(m0) + len - k < 4)
@ -139,17 +139,17 @@ m_xword(m, k, err)
switch (len - k) {
case 1:
return(cp[0] << 24) | (np[0] << 16) | (np[1] << 8) | np[2];
return (cp[0] << 24) | (np[0] << 16) | (np[1] << 8) | np[2];
case 2:
return(cp[0] << 24) | (cp[1] << 16) | (np[0] << 8) | np[1];
return (cp[0] << 24) | (cp[1] << 16) | (np[0] << 8) | np[1];
default:
return(cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | np[0];
return (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | np[0];
}
bad:
*err = 1;
return(0);
return (0);
}
static int
@ -165,16 +165,16 @@ m_xhalf(m, k, err)
cp = MTOD(m, u_char *) + k;
if (len - k >= 2) {
*err = 0;
return(EXTRACT_SHORT(cp));
return (EXTRACT_SHORT(cp));
}
m0 = m->m_next;
if (m0 == NULL)
goto bad;
*err = 0;
return(cp[0] << 8) | MTOD(m0, u_char *)[0];
return (cp[0] << 8) | MTOD(m0, u_char *)[0];
bad:
*err = 1;
return(0);
return (0);
}
/*
@ -209,7 +209,7 @@ bpf_filter(pc, p, wirelen, buflen)
/*
* No filter means accept all.
*/
return(u_int)-1;
return (u_int)-1;
A = 0;
X = 0;
--pc;
@ -218,21 +218,21 @@ bpf_filter(pc, p, wirelen, buflen)
switch (pc->code) {
default:
return(0);
return (0);
case BPF_RET|BPF_K:
return(u_int)pc->k;
return (u_int)pc->k;
case BPF_RET|BPF_A:
return(u_int)A;
return (u_int)A;
case BPF_LD|BPF_W|BPF_ABS:
k = pc->k;
if (k + sizeof(int32) > buflen) {
if (m == NULL)
return(0);
return (0);
A = m_xword(m, k, &merr);
if (merr != 0)
return(0);
return (0);
continue;
}
A = EXTRACT_LONG(&p[k]);
@ -242,10 +242,10 @@ bpf_filter(pc, p, wirelen, buflen)
k = pc->k;
if (k + sizeof(short) > buflen) {
if (m == NULL)
return(0);
return (0);
A = m_xhalf(m, k, &merr);
if (merr != 0)
return(0);
return (0);
continue;
}
A = EXTRACT_SHORT(&p[k]);
@ -255,7 +255,7 @@ bpf_filter(pc, p, wirelen, buflen)
k = pc->k;
if (k >= buflen) {
if (m == NULL)
return(0);
return (0);
n = m;
MINDEX(len, n, k);
A = MTOD(n, u_char *)[k];
@ -276,10 +276,10 @@ bpf_filter(pc, p, wirelen, buflen)
k = X + pc->k;
if (k + sizeof(int32) > buflen) {
if (m == NULL)
return(0);
return (0);
A = m_xword(m, k, &merr);
if (merr != 0)
return(0);
return (0);
continue;
}
A = EXTRACT_LONG(&p[k]);
@ -289,10 +289,10 @@ bpf_filter(pc, p, wirelen, buflen)
k = X + pc->k;
if (k + sizeof(short) > buflen) {
if (m == NULL)
return(0);
return (0);
A = m_xhalf(m, k, &merr);
if (merr != 0)
return(0);
return (0);
continue;
}
A = EXTRACT_SHORT(&p[k]);
@ -302,7 +302,7 @@ bpf_filter(pc, p, wirelen, buflen)
k = X + pc->k;
if (k >= buflen) {
if (m == NULL)
return(0);
return (0);
n = m;
MINDEX(len, n, k);
A = MTOD(n, u_char *)[k];
@ -315,7 +315,7 @@ bpf_filter(pc, p, wirelen, buflen)
k = pc->k;
if (k >= buflen) {
if (m == NULL)
return(0);
return (0);
n = m;
MINDEX(len, n, k);
X = (MTOD(n, char *)[k] & 0xf) << 2;
@ -398,7 +398,7 @@ bpf_filter(pc, p, wirelen, buflen)
case BPF_ALU|BPF_DIV|BPF_X:
if (X == 0)
return(0);
return (0);
A /= X;
continue;
@ -486,10 +486,10 @@ bpf_validate(f, len)
const struct bpf_insn *p;
if (len == 0)
return(1);
return (1);
if (len < 1 || len > BPF_MAXINSNS)
return(0);
return (0);
for (i = 0; i < len; ++i) {
p = &f[i];
@ -511,23 +511,23 @@ bpf_validate(f, len)
*/
#if 0
if (p->k >= bpf_maxbufsize)
return(0);
return (0);
#endif
break;
case BPF_MEM:
if (p->k >= BPF_MEMWORDS)
return(0);
return (0);
break;
case BPF_LEN:
break;
default:
return(0);
return (0);
}
break;
case BPF_ST:
case BPF_STX:
if (p->k >= BPF_MEMWORDS)
return(0);
return (0);
break;
case BPF_ALU:
switch (BPF_OP(p->code)) {
@ -544,9 +544,9 @@ bpf_validate(f, len)
* Check for constant division by 0.
*/
if (BPF_RVAL(p->code) == BPF_K && p->k == 0)
return(0);
return (0);
default:
return(0);
return (0);
}
break;
case BPF_JMP:
@ -570,17 +570,17 @@ bpf_validate(f, len)
switch (BPF_OP(p->code)) {
case BPF_JA:
if (from + p->k < from || from + p->k >= len)
return(0);
return (0);
break;
case BPF_JEQ:
case BPF_JGT:
case BPF_JGE:
case BPF_JSET:
if (from + p->jt >= len || from + p->jf >= len)
return(0);
return (0);
break;
default:
return(0);
return (0);
}
break;
case BPF_RET:
@ -588,8 +588,8 @@ bpf_validate(f, len)
case BPF_MISC:
break;
default:
return(0);
return (0);
}
}
return(BPF_CLASS(f[len - 1].code) == BPF_RET);
return (BPF_CLASS(f[len - 1].code) == BPF_RET);
}

View File

@ -165,7 +165,7 @@ main(int argc, char *argv[])
if (fd != -1)
(void) close(fd);
return(exitstatus);
return (exitstatus);
/* NOTREACHED */
}
@ -174,11 +174,11 @@ static int
opendevice(char *ipfdev, int check)
{
if (opts & OPT_DONOTHING)
return(-2);
return (-2);
if (check && checkrev(ipfname) == -1) {
fprintf(stderr, "User/kernel version check failed\n");
return(-2);
return (-2);
}
if (!ipfdev)
@ -188,7 +188,7 @@ opendevice(char *ipfdev, int check)
if ((fd = open(ipfdev, O_RDWR)) == -1)
if ((fd = open(ipfdev, O_RDONLY)) == -1)
ipferror(fd, "open device");
return(fd);
return (fd);
}
@ -208,9 +208,9 @@ get_flags(void)
if ((opendevice(ipfname, 1) != -2) &&
(ioctl(fd, SIOCGETFF, &i) == -1)) {
ipferror(fd, "SIOCGETFF");
return(0);
return (0);
}
return(i);
return (i);
}
@ -256,7 +256,7 @@ ipf_interceptadd(int fd, ioctlfunc_t ioctlfunc, void *ptr)
if (ipf_addrule(fd, ioctlfunc, ptr) != 0)
exitstatus = 1;
return(0);
return (0);
}
@ -527,13 +527,13 @@ showversion(void)
if ((vfd = open(ipfname, O_RDONLY)) == -1) {
perror("open device");
return(1);
return (1);
}
if (ioctl(vfd, SIOCGETFS, &ipfo)) {
ipferror(vfd, "ioctl(SIOCGETFS)");
close(vfd);
return(1);
return (1);
}
close(vfd);
flags = get_flags();
@ -574,5 +574,5 @@ showversion(void)
printf("Active list: %d\n", fio.f_active);
printf("Feature mask: %#x\n", fio.f_features);
return(0);
return (0);
}

View File

@ -249,9 +249,9 @@ int intcmp(c1, c2)
const mc_t *i1 = (const mc_t *)c1, *i2 = (const mc_t *)c2;
if (i1->n == i2->n) {
return(i1->c - i2->c);
return (i1->c - i2->c);
}
return(i2->n - i1->n);
return (i2->n - i1->n);
}
@ -414,10 +414,10 @@ int ipfrule_add()\n\
fprintf(cfile, "\
err = ipfrule_add_%s_%s();\n\
if (err != 0)\n\
return(err);\n",
return (err);\n",
(g->fg_flags & FR_INQUE) ? "in" : "out", g->fg_name);
fprintf(cfile, "\
return(0);\n");
return (0);\n");
fprintf(cfile, "}\n\
\n");
@ -430,10 +430,10 @@ int ipfrule_remove()\n\
fprintf(cfile, "\
err = ipfrule_remove_%s_%s();\n\
if (err != 0)\n\
return(err);\n",
return (err);\n",
(g->fg_flags & FR_INQUE) ? "in" : "out", g->fg_name);
fprintf(cfile, "\
return(0);\n");
return (0);\n");
fprintf(cfile, "}\n");
}
@ -467,7 +467,7 @@ static void emitGroup(num, dir, v, fr, group, incount, outcount)
fprintf(fp, "}\n");
}
if (openfunc == 1) {
fprintf(fp, "\treturn(fr);\n}\n");
fprintf(fp, "\treturn (fr);\n}\n");
openfunc = 0;
if (n != NULL) {
free(n);
@ -488,7 +488,7 @@ static void emitGroup(num, dir, v, fr, group, incount, outcount)
fprintf(fp, "}\n");
}
if (openfunc == 1) {
fprintf(fp, "\treturn(fr);\n}\n");
fprintf(fp, "\treturn (fr);\n}\n");
openfunc = 0;
}
}
@ -941,7 +941,7 @@ static void emitGroup(num, dir, v, fr, group, incount, outcount)
indent(fp, in);
if (fr->fr_flags & FR_QUICK) {
fprintf(fp, "return((frentry_t *)&%s_rule_%s_%d);\n",
fprintf(fp, "return ((frentry_t *)&%s_rule_%s_%d);\n",
fr->fr_flags & FR_INQUE ? "in" : "out",
FR_NAME(fr, fr_group), num);
} else {
@ -1328,7 +1328,7 @@ int ipfrule_add_%s_%s()\n", instr, group);
err = frrequest(&ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp,\n\
ipfmain.ipf_active, 0);\n",
instr, group);
fprintf(fp, "\treturn(err);\n}\n");
fprintf(fp, "\treturn (err);\n}\n");
fprintf(fp, "\n\n\
int ipfrule_remove_%s_%s()\n", instr, group);
@ -1365,8 +1365,8 @@ int ipfrule_remove_%s_%s()\n", instr, group);
instr, group, instr, group, instr, group);
fprintf(fp, "\
if (err)\n\
return(err);\n\
return (err);\n\
\n\n");
fprintf(fp, "\treturn(err);\n}\n");
fprintf(fp, "\treturn (err);\n}\n");
}

View File

@ -142,7 +142,7 @@ int changestateif(char *ifs, char *fname)
}
close(fd);
return(0);
return (0);
}
@ -198,7 +198,7 @@ int changenatif(char *ifs, char *fname)
}
close(fd);
return(0);
return (0);
}
@ -286,9 +286,9 @@ int main(int argc, char *argv[])
if (!filename || ns < 0)
usage();
if (ns == 0)
return(changenatif(ifs, filename));
return (changenatif(ifs, filename));
else
return(changestateif(ifs, filename));
return (changestateif(ifs, filename));
}
if ((ns >= 0) || (lock >= 0)) {
@ -327,7 +327,7 @@ int main(int argc, char *argv[])
}
}
}
return(err);
return (err);
}
@ -336,7 +336,7 @@ int opendevice(char *ipfdev)
int fd = -1;
if (opts & OPT_DONOTHING)
return(-2);
return (-2);
if (!ipfdev)
ipfdev = IPL_NAME;
@ -344,7 +344,7 @@ int opendevice(char *ipfdev)
if ((fd = open(ipfdev, O_RDWR)) == -1)
if ((fd = open(ipfdev, O_RDONLY)) == -1)
perror("open device");
return(fd);
return (fd);
}
@ -361,12 +361,12 @@ int setlock(int fd, int lock)
if (!(opts & OPT_DONOTHING)) {
if (ioctl(fd, SIOCSTLCK, &lock) == -1) {
perror("SIOCSTLCK");
return(1);
return (1);
}
if (opts & OPT_VERBOSE)
printf("Lock now %s\n", lock ? "on" : "off");
}
return(0);
return (0);
}
@ -383,7 +383,7 @@ int writestate(int fd, char *file)
if (wfd == -1) {
fprintf(stderr, "%s ", file);
perror("state:open");
return(1);
return (1);
}
ipsp = &ips;
@ -404,19 +404,19 @@ int writestate(int fd, char *file)
break;
perror("state:SIOCSTGET");
close(wfd);
return(1);
return (1);
}
if (opts & OPT_VERBOSE)
printf("Got state next %p\n", ips.ips_next);
if (write(wfd, ipsp, sizeof(ips)) != sizeof(ips)) {
perror("state:write");
close(wfd);
return(1);
return (1);
}
} while (ips.ips_next != NULL);
close(wfd);
return(0);
return (0);
}
@ -433,7 +433,7 @@ int readstate(int fd, char *file)
if (sfd == -1) {
fprintf(stderr, "%s ", file);
perror("open");
return(1);
return (1);
}
bzero((char *)&ips, sizeof(ips));
@ -522,7 +522,7 @@ int readstate(int fd, char *file)
free(is);
}
return(0);
return (0);
freeipshead:
while ((is = ipshead) != NULL) {
@ -531,7 +531,7 @@ freeipshead:
}
if (sfd != -1)
close(sfd);
return(1);
return (1);
}
@ -556,7 +556,7 @@ int readnat(int fd, char *file)
if (nfd == -1) {
fprintf(stderr, "%s ", file);
perror("nat:open");
return(1);
return (1);
}
bzero((char *)&ipn, sizeof(ipn));
@ -652,7 +652,7 @@ int readnat(int fd, char *file)
if (ioctl(fd, SIOCSTPUT, &obj)) {
fprintf(stderr, "in=%p:", in);
perror("SIOCSTPUT");
return(1);
return (1);
}
if (nat->nat_flags & SI_NEWFR) {
@ -667,7 +667,7 @@ int readnat(int fd, char *file)
free(in);
}
return(0);
return (0);
freenathead:
while ((in = ipnhead) != NULL) {
@ -676,7 +676,7 @@ freenathead:
}
if (nfd != -1)
close(nfd);
return(1);
return (1);
}
@ -694,7 +694,7 @@ int writenat(int fd, char *file)
if (nfd == -1) {
fprintf(stderr, "%s ", file);
perror("nat:open");
return(1);
return (1);
}
obj.ipfo_rev = IPFILTER_VERSION;
@ -710,7 +710,7 @@ int writenat(int fd, char *file)
close(nfd);
if (ipnp != NULL)
free(ipnp);
return(1);
return (1);
}
if (opts & OPT_VERBOSE)
@ -740,7 +740,7 @@ int writenat(int fd, char *file)
perror("nat:SIOCSTGET");
close(nfd);
free(ipnp);
return(1);
return (1);
}
if (opts & OPT_VERBOSE)
@ -750,7 +750,7 @@ int writenat(int fd, char *file)
perror("nat:write");
close(nfd);
free(ipnp);
return(1);
return (1);
}
next = ipnp->ipn_next;
} while (ipnp && next);
@ -758,7 +758,7 @@ int writenat(int fd, char *file)
free(ipnp);
close(nfd);
return(0);
return (0);
}
@ -772,15 +772,15 @@ int writeall(char *dirname)
if (chdir(dirname)) {
fprintf(stderr, "IPF_SAVEDIR=%s: ", dirname);
perror("chdir(IPF_SAVEDIR)");
return(1);
return (1);
}
fd = opendevice(NULL);
if (fd == -1)
return(1);
return (1);
if (setlock(fd, 1)) {
close(fd);
return(1);
return (1);
}
devfd = opendevice(IPSTATE_NAME);
@ -799,16 +799,16 @@ int writeall(char *dirname)
if (setlock(fd, 0)) {
close(fd);
return(1);
return (1);
}
close(fd);
return(0);
return (0);
bad:
setlock(fd, 0);
close(fd);
return(1);
return (1);
}
@ -821,35 +821,35 @@ int readall(char *dirname)
if (chdir(dirname)) {
perror("chdir(IPF_SAVEDIR)");
return(1);
return (1);
}
fd = opendevice(NULL);
if (fd == -1)
return(1);
return (1);
if (setlock(fd, 1)) {
close(fd);
return(1);
return (1);
}
devfd = opendevice(IPSTATE_NAME);
if (devfd == -1)
return(1);
return (1);
if (readstate(devfd, NULL))
return(1);
return (1);
close(devfd);
devfd = opendevice(IPNAT_NAME);
if (devfd == -1)
return(1);
return (1);
if (readnat(devfd, NULL))
return(1);
return (1);
close(devfd);
if (setlock(fd, 0)) {
close(fd);
return(1);
return (1);
}
return(0);
return (0);
}

View File

@ -443,7 +443,7 @@ int main(int argc, char *argv[])
else
showstats(fiop, frf);
return(0);
return (0);
}
@ -807,7 +807,7 @@ printlivelist( struct friostat *fiop, int out, int set, frentry_t *fp,
ipferror(ipf_fd, "ioctl(SIOCIPFITER)");
num = IPFGENITER_IPF;
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &num);
return(rules);
return (rules);
}
if (bcmp(fp, &zero, sizeof(zero)) == 0)
break;
@ -891,7 +891,7 @@ printlivelist( struct friostat *fiop, int out, int set, frentry_t *fp,
num = IPFGENITER_IPF;
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &num);
return(rules);
return (rules);
}
@ -1941,17 +1941,17 @@ static char *getip(int v, i6addr_t *addr)
#endif
if (v == 0)
return("any");
return ("any");
if (v == 4)
return(inet_ntoa(addr->in4));
return (inet_ntoa(addr->in4));
#ifdef USE_INET6
(void) inet_ntop(AF_INET6, &addr->in6, hostbuf, sizeof(hostbuf) - 1);
hostbuf[MAXHOSTNAMELEN] = '\0';
return(hostbuf);
return (hostbuf);
#else
return("IPv6");
return ("IPv6");
#endif
}
@ -1973,7 +1973,7 @@ static char *ttl_to_string(long int ttl)
snprintf(ttlbuf, sizeof(ttlbuf), "%2d:%02d:%02d", hours, minutes, seconds);
else
snprintf(ttlbuf, sizeof(ttlbuf), "%2d:%02d", minutes, seconds);
return(ttlbuf);
return (ttlbuf);
}
@ -1984,10 +1984,10 @@ static int sort_pkts(const void *a, const void *b)
register const statetop_t *bp = b;
if (ap->st_pkts == bp->st_pkts)
return(0);
return (0);
else if (ap->st_pkts < bp->st_pkts)
return(1);
return(-1);
return (1);
return (-1);
}
@ -1997,10 +1997,10 @@ static int sort_bytes(const void *a, const void *b)
register const statetop_t *bp = b;
if (ap->st_bytes == bp->st_bytes)
return(0);
return (0);
else if (ap->st_bytes < bp->st_bytes)
return(1);
return(-1);
return (1);
return (-1);
}
@ -2010,10 +2010,10 @@ static int sort_p(const void *a, const void *b)
register const statetop_t *bp = b;
if (ap->st_p == bp->st_p)
return(0);
return (0);
else if (ap->st_p < bp->st_p)
return(1);
return(-1);
return (1);
return (-1);
}
@ -2023,10 +2023,10 @@ static int sort_ttl(const void *a, const void *b)
register const statetop_t *bp = b;
if (ap->st_age == bp->st_age)
return(0);
return (0);
else if (ap->st_age < bp->st_age)
return(1);
return(-1);
return (1);
return (-1);
}
static int sort_srcip(const void *a, const void *b)
@ -2037,20 +2037,20 @@ static int sort_srcip(const void *a, const void *b)
#ifdef USE_INET6
if (use_inet6 && !use_inet4) {
if (IP6_EQ(&ap->st_src, &bp->st_src))
return(0);
return (0);
else if (IP6_GT(&ap->st_src, &bp->st_src))
return(1);
return (1);
} else
#endif
{
if (ntohl(ap->st_src.in4.s_addr) ==
ntohl(bp->st_src.in4.s_addr))
return(0);
return (0);
else if (ntohl(ap->st_src.in4.s_addr) >
ntohl(bp->st_src.in4.s_addr))
return(1);
return (1);
}
return(-1);
return (-1);
}
static int sort_srcpt(const void *a, const void *b)
@ -2059,10 +2059,10 @@ static int sort_srcpt(const void *a, const void *b)
register const statetop_t *bp = b;
if (htons(ap->st_sport) == htons(bp->st_sport))
return(0);
return (0);
else if (htons(ap->st_sport) > htons(bp->st_sport))
return(1);
return(-1);
return (1);
return (-1);
}
static int sort_dstip(const void *a, const void *b)
@ -2073,20 +2073,20 @@ static int sort_dstip(const void *a, const void *b)
#ifdef USE_INET6
if (use_inet6 && !use_inet4) {
if (IP6_EQ(&ap->st_dst, &bp->st_dst))
return(0);
return (0);
else if (IP6_GT(&ap->st_dst, &bp->st_dst))
return(1);
return (1);
} else
#endif
{
if (ntohl(ap->st_dst.in4.s_addr) ==
ntohl(bp->st_dst.in4.s_addr))
return(0);
return (0);
else if (ntohl(ap->st_dst.in4.s_addr) >
ntohl(bp->st_dst.in4.s_addr))
return(1);
return (1);
}
return(-1);
return (-1);
}
static int sort_dstpt(const void *a, const void *b)
@ -2095,10 +2095,10 @@ static int sort_dstpt(const void *a, const void *b)
register const statetop_t *bp = b;
if (htons(ap->st_dport) == htons(bp->st_dport))
return(0);
return (0);
else if (htons(ap->st_dport) > htons(bp->st_dport))
return(1);
return(-1);
return (1);
return (-1);
}
#endif
@ -2121,16 +2121,16 @@ ipstate_t *fetchstate(ipstate_t *src, ipstate_t *dst)
state.igi_data = dst;
if (ioctl(state_fd, SIOCGENITER, &obj) != 0)
return(NULL);
return (NULL);
if (dst->is_next == NULL) {
int n = IPFGENITER_STATE;
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &n);
}
} else {
if (kmemcpy((char *)dst, (u_long)src, sizeof(*dst)))
return(NULL);
return (NULL);
}
return(dst);
return (dst);
}
@ -2149,8 +2149,8 @@ static int fetchfrag( int fd, int type, ipfr_t *frp)
frag.igi_data = frp;
if (ioctl(fd, SIOCGENITER, &obj))
return(EFAULT);
return(0);
return (EFAULT);
return (0);
}
@ -2295,7 +2295,7 @@ static int state_matcharray(ipstate_t *stp, int *array)
break;
}
return(rv);
return (rv);
}

View File

@ -38,7 +38,7 @@ int
ipfattach(softc)
ipf_main_softc_t *softc;
{
return(0);
return (0);
}
@ -46,7 +46,7 @@ int
ipfdetach(softc)
ipf_main_softc_t *softc;
{
return(0);
return (0);
}
@ -71,10 +71,10 @@ ipfioctl(softc, dev, cmd, data, mode)
error = ipf_ioctlswitch(softc, unit, data, cmd, mode, uid, NULL);
if (error != -1) {
SPL_X(s);
return(error);
return (error);
}
SPL_X(s);
return(error);
return (error);
}
@ -115,7 +115,7 @@ no_output(ifp, m, s, rt)
struct mbuf *m;
struct sockaddr *s;
{
return(0);
return (0);
}
@ -143,11 +143,11 @@ write_output(ifp, m, s, rt)
fd = open(fname, O_WRONLY|O_APPEND);
if (fd == -1) {
perror("open");
return(-1);
return (-1);
}
write(fd, (char *)ip, ntohs(ip->ip_len));
close(fd);
return(0);
return (0);
}
@ -217,7 +217,7 @@ get_unit(name, family)
defined(__FreeBSD__)
if (!*name)
return(NULL);
return (NULL);
if (name == NULL)
name = "anon0";
@ -230,7 +230,7 @@ get_unit(name, family)
if (!strcmp(name, ifp->if_xname)) {
if (addr != NULL)
ipf_setifpaddr(ifp, addr);
return(ifp);
return (ifp);
}
}
#else
@ -248,7 +248,7 @@ get_unit(name, family)
if (!strcmp(name, ifname)) {
if (addr != NULL)
ipf_setifpaddr(ifp, addr);
return(ifp);
return (ifp);
}
}
#endif
@ -256,12 +256,12 @@ get_unit(name, family)
if (!ifneta) {
ifneta = (struct ifnet **)malloc(sizeof(ifp) * 2);
if (!ifneta)
return(NULL);
return (NULL);
ifneta[1] = NULL;
ifneta[0] = (struct ifnet *)calloc(1, sizeof(*ifp));
if (!ifneta[0]) {
free(ifneta);
return(NULL);
return (NULL);
}
nifs = 1;
} else {
@ -272,13 +272,13 @@ get_unit(name, family)
if (!ifneta) {
free(old_ifneta);
nifs = 0;
return(NULL);
return (NULL);
}
ifneta[nifs] = NULL;
ifneta[nifs - 1] = (struct ifnet *)malloc(sizeof(*ifp));
if (!ifneta[nifs - 1]) {
nifs--;
return(NULL);
return (NULL);
}
}
ifp = ifneta[nifs - 1];
@ -314,7 +314,7 @@ get_unit(name, family)
ipf_setifpaddr(ifp, addr);
}
return(ifp);
return (ifp);
}
@ -332,7 +332,7 @@ get_ifname(ifp)
else
strcpy(ifname, ifp->if_name);
#endif
return(ifname);
return (ifname);
}
@ -398,7 +398,7 @@ ipf_fastroute(m, mpp, fin, fdp)
ifp = fdp->fd_ptr;
if (ifp == NULL)
return(0; /* no routing table out here */);
return (0; /* no routing table out here */);
if (fin->fin_out == 0) {
fin->fin_ifp = ifp;
@ -433,7 +433,7 @@ ipf_fastroute(m, mpp, fin, fdp)
done:
fin->fin_ifp = sifp;
fin->fin_out = sout;
return(error);
return (error);
}
@ -442,7 +442,7 @@ ipf_send_reset(fin)
fr_info_t *fin;
{
ipfkverbose("- TCP RST sent\n");
return(0);
return (0);
}
@ -453,7 +453,7 @@ ipf_send_icmp_err(type, fin, dst)
int dst;
{
ipfkverbose("- ICMP unreachable sent\n");
return(0);
return (0);
}
@ -510,9 +510,9 @@ ipfuiomove(buf, len, rwflag, uio)
ioc++;
}
if (left > 0)
return(EFAULT);
return (EFAULT);
}
return(0);
return (0);
}
@ -552,7 +552,7 @@ ipf_newisn(fin)
*/
iss_seq_off += 0x00010000;
newiss += iss_seq_off;
return(newiss);
return (newiss);
}
@ -582,7 +582,7 @@ ipf_nextipid(fin)
id = ipid++;
MUTEX_EXIT(&softc->ipf_rw);
return(id);
return (id);
}
@ -592,13 +592,13 @@ ipf_checkv4sum(fin)
{
if (fin->fin_flx & FI_SHORT)
return(1);
return (1);
if (ipf_checkl4sum(fin) == -1) {
fin->fin_flx |= FI_BAD;
return(-1);
return (-1);
}
return(0);
return (0);
}
@ -608,13 +608,13 @@ ipf_checkv6sum(fin)
fr_info_t *fin;
{
if (fin->fin_flx & FI_SHORT)
return(1);
return (1);
if (ipf_checkl4sum(fin) == -1) {
fin->fin_flx |= FI_BAD;
return(-1);
return (-1);
}
return(0);
return (0);
}
#endif
@ -632,7 +632,7 @@ copyoutptr(softc, src, dst, size)
bcopy(dst, (char *)&ca, sizeof(ca));
bcopy(src, ca, size);
return(0);
return (0);
}
@ -648,7 +648,7 @@ copyinptr(src, dst, size)
bcopy(src, (char *)&ca, sizeof(ca));
bcopy(ca, dst, size);
return(0);
return (0);
}
#endif
@ -679,7 +679,7 @@ ipf_ifpaddr(softc, v, atype, ifptr, inp, inpmask)
sin = (struct sockaddr_in *)&ifa->ifa_addr;
return(ipf_ifpfillv4addr(atype, sin, &mask,
return (ipf_ifpfillv4addr(atype, sin, &mask,
&inp->in4, &inpmask->in4));
}
#ifdef USE_INET6
@ -691,12 +691,12 @@ ipf_ifpaddr(softc, v, atype, ifptr, inp, inpmask)
((i6addr_t *)&mask.sin6_addr)->i6[1] = 0xffffffff;
((i6addr_t *)&mask.sin6_addr)->i6[2] = 0xffffffff;
((i6addr_t *)&mask.sin6_addr)->i6[3] = 0xffffffff;
return(ipf_ifpfillv6addr(atype, sin6, &mask,
return (ipf_ifpfillv6addr(atype, sin6, &mask,
inp, inpmask));
}
#endif
}
return(0);
return (0);
}
@ -744,7 +744,7 @@ ipf_random()
number ^= last;
break;
}
return(number);
return (number);
}
@ -752,7 +752,7 @@ int
ipf_verifysrc(fin)
fr_info_t *fin;
{
return(1);
return (1);
}
@ -763,7 +763,7 @@ ipf_inject(fin, m)
{
FREE_MB_T(m);
return(0);
return (0);
}
@ -788,7 +788,7 @@ ipf_pcksum(fin, hlen, sum)
sum = (sum & 0xffff) + (sum >> 16);
sum2 = (u_short)(~sum & 0xffff);
return(sum2);
return (sum2);
}
@ -799,7 +799,7 @@ ipf_pullup(m, fin, plen)
int plen;
{
if (M_LEN(m) >= plen)
return(fin->fin_ip);
return (fin->fin_ip);
/*
* Fake ipf_pullup failing
@ -808,5 +808,5 @@ ipf_pullup(m, fin, plen)
*fin->fin_mp = NULL;
fin->fin_m = NULL;
fin->fin_ip = NULL;
return(NULL);
return (NULL);
}

View File

@ -143,7 +143,7 @@ main(int argc, char *argv[])
case 'N' :
if (ipnat_parsefile(-1, ipnat_addrule, ipnattestioctl,
optarg) == -1)
return(-1);
return (-1);
loaded = 1;
opts |= OPT_NAT;
break;
@ -152,13 +152,13 @@ main(int argc, char *argv[])
break;
case 'P' :
if (ippool_parsefile(-1, optarg, ipooltestioctl) == -1)
return(-1);
return (-1);
loaded = 1;
break;
case 'r' :
if (ipf_parsefile(-1, ipf_addrule, iocfunctions,
optarg) == -1)
return(-1);
return (-1);
loaded = 1;
break;
case 'S' :
@ -325,7 +325,7 @@ main(int argc, char *argv[])
fflush(stdout);
abort();
}
return(0);
return (0);
}
@ -346,9 +346,9 @@ int ipftestioctl(int dev, ioctlcmd_t cmd, ...)
(u_int)cmd, data, i, softc->ipf_interror);
if (i != 0) {
errno = i;
return(-1);
return (-1);
}
return(0);
return (0);
}
@ -370,9 +370,9 @@ ipnattestioctl(int dev, ioctlcmd_t cmd, ...)
(u_int)cmd, data, i);
if (i != 0) {
errno = i;
return(-1);
return (-1);
}
return(0);
return (0);
}
@ -394,9 +394,9 @@ ipstatetestioctl(int dev, ioctlcmd_t cmd, ...)
(u_int)cmd, data, i);
if (i != 0) {
errno = i;
return(-1);
return (-1);
}
return(0);
return (0);
}
@ -418,9 +418,9 @@ ipauthtestioctl(int dev, ioctlcmd_t cmd, ...)
(u_int)cmd, data, i);
if (i != 0) {
errno = i;
return(-1);
return (-1);
}
return(0);
return (0);
}
@ -442,9 +442,9 @@ ipscantestioctl(int dev, ioctlcmd_t cmd, ...)
(u_int)cmd, data, i);
if (i != 0) {
errno = i;
return(-1);
return (-1);
}
return(0);
return (0);
}
@ -466,9 +466,9 @@ ipsynctestioctl(int dev, ioctlcmd_t cmd, ...)
(u_int)cmd, data, i);
if (i != 0) {
errno = i;
return(-1);
return (-1);
}
return(0);
return (0);
}
@ -490,9 +490,9 @@ ipooltestioctl(int dev, ioctlcmd_t cmd, ...)
(u_int)cmd, data, i, softc->ipf_interror);
if (i != 0) {
errno = i;
return(-1);
return (-1);
}
return(0);
return (0);
}
@ -500,7 +500,7 @@ int
kmemcpy(char *addr, long offset, int size)
{
bcopy((char *)offset, addr, size);
return(0);
return (0);
}
@ -513,7 +513,7 @@ kstrncpy(char *buf, long pos, int n)
while ((n > 0) && (*buf++ = *ptr++))
;
return(0);
return (0);
}

View File

@ -307,19 +307,19 @@ find_icmpsubtype(int type, icmp_subtype_t *table, size_t tablesz)
int i;
if (tablesz < 2)
return(NULL);
return (NULL);
if ((type < 0) || (type > table[tablesz - 2].ist_val))
return(NULL);
return (NULL);
i = type;
if (table[type].ist_val == type)
return(table + type);
return (table + type);
for (i = 0, ist = table; ist->ist_val != -2; i++, ist++)
if (ist->ist_val == type)
return(ist);
return(NULL);
return (ist);
return (NULL);
}
@ -330,19 +330,19 @@ find_icmptype(int type, icmp_type_t *table, size_t tablesz)
int i;
if (tablesz < 2)
return(NULL);
return (NULL);
if ((type < 0) || (type > table[tablesz - 2].it_val))
return(NULL);
return (NULL);
i = type;
if (table[type].it_val == type)
return(table + type);
return (table + type);
for (i = 0, it = table; it->it_val != -2; i++, it++)
if (it->it_val == type)
return(it);
return(NULL);
return (it);
return (NULL);
}
@ -447,7 +447,7 @@ getlocalproto(u_int p)
sprintf(pnum, "%u", p);
s = pnum;
}
return(s);
return (s);
}
@ -461,11 +461,11 @@ read_log(int fd, int *lenp, char *buf, int bufsize)
nr = read(fd, buf, bufsize);
if (!nr)
return(2);
return (2);
if ((nr < 0) && (errno != EINTR))
return(-1);
return (-1);
*lenp = nr;
return(0);
return (0);
}
@ -482,7 +482,7 @@ portlocalname(res, proto, port)
port &= 0xffff;
sprintf(pname, "%u", port);
if (!res || (ipmonopts & IPMON_PORTNUM))
return(pname);
return (pname);
s = NULL;
if (!strcmp(proto, "tcp"))
s = tcp_ports[port];
@ -490,7 +490,7 @@ portlocalname(res, proto, port)
s = udp_ports[port];
if (s == NULL)
s = pname;
return(s);
return (s);
}
@ -521,7 +521,7 @@ icmpname(u_int type, u_int code)
else
sprintf(name + strlen(name), "%d", code);
return(name);
return (name);
}
static char *
@ -551,7 +551,7 @@ icmpname6(u_int type, u_int code)
else
sprintf(name + strlen(name), "%d", code);
return(name);
return (name);
}
@ -624,7 +624,7 @@ get_tm(time_t sec)
t = sec;
tm = localtime(&t);
return(tm);
return (tm);
}
static void
@ -1717,7 +1717,7 @@ main(int argc, char *argv[])
unload_config();
return(0);
return (0);
/* NOTREACHED */
}
@ -1775,11 +1775,11 @@ read_loginfo(config_t *conf)
n = select(conf->maxfd + 1, &fdr, NULL, NULL, NULL);
if (n == 0)
return(1);
return (1);
if (n == -1) {
if (errno == EINTR)
return(1);
return(-1);
return (1);
return (-1);
}
for (i = 0, nr = 0; i < 3; i++) {
@ -1792,7 +1792,7 @@ read_loginfo(config_t *conf)
if (l->regular) {
tr = (lseek(l->fd, 0, SEEK_CUR) < l->size);
if (!tr && !(ipmonopts & IPMON_TAIL))
return(0);
return (0);
}
n = 0;
@ -1828,13 +1828,13 @@ read_loginfo(config_t *conf)
else {
ipferror(l->fd, "read");
}
return(0);
return (0);
case 1 :
if (ipmonopts & IPMON_SYSLOG)
syslog(LOG_CRIT, "aborting logging\n");
else if (conf->log != NULL)
fprintf(conf->log, "aborting logging\n");
return(0);
return (0);
case 2 :
break;
case 0 :
@ -1851,5 +1851,5 @@ read_loginfo(config_t *conf)
if (!nr && (ipmonopts & IPMON_TAIL))
sleep(1);
return(1);
return (1);
}

View File

@ -221,11 +221,11 @@ main(int argc, char *argv[])
if (opts & (OPT_FLUSH|OPT_CLEAR))
flushtable(fd, opts, natfilter);
if (file) {
return(ipnat_parsefile(fd, ipnat_addrule, ioctl, file));
return (ipnat_parsefile(fd, ipnat_addrule, ioctl, file));
}
if (opts & (OPT_LIST|OPT_STAT))
dostats(fd, nsp, opts, 1, natfilter);
return(0);
return (0);
}
@ -829,5 +829,5 @@ nat_matcharray(nat_t *nat, int *array)
break;
}
return(rv);
return (rv);
}

View File

@ -122,7 +122,7 @@ main(int argc, char *argv[])
if (err != 0)
exit(1);
return(0);
return (0);
}
@ -161,23 +161,23 @@ poolnodecommand(int remove, int argc, char *argv[])
if (ipset == 1) {
fprintf(stderr,
"cannot set role after ip address\n");
return(-1);
return (-1);
}
role = getrole(optarg);
if (role == IPL_LOGNONE)
return(-1);
return (-1);
break;
case 't' :
if (ipset == 1) {
fprintf(stderr,
"cannot set type after ip address\n");
return(-1);
return (-1);
}
type = gettype(optarg, NULL);
switch (type) {
case IPLT_NONE :
fprintf(stderr, "unknown type '%s'\n", optarg);
return(-1);
return (-1);
case IPLT_HASH :
ptr = &hnode;
break;
@ -191,7 +191,7 @@ poolnodecommand(int remove, int argc, char *argv[])
ttl = atoi(optarg);
if (ttl < 0) {
fprintf(stderr, "cannot set negative ttl\n");
return(-1);
return (-1);
}
} else {
usage(argv[0]);
@ -218,12 +218,12 @@ poolnodecommand(int remove, int argc, char *argv[])
if (ipset == 0) {
fprintf(stderr, "no IP address given with -i\n");
return(-1);
return (-1);
}
if (poolname == NULL) {
fprintf(stderr, "poolname not given with add/remove node\n");
return(-1);
return (-1);
}
switch (type) {
@ -242,7 +242,7 @@ poolnodecommand(int remove, int argc, char *argv[])
default :
break;
}
return(err);
return (err);
}
@ -279,7 +279,7 @@ poolcommand(int remove, int argc, char *argv[])
role = getrole(optarg);
if (role == IPL_LOGNONE) {
fprintf(stderr, "unknown role '%s'\n", optarg);
return(-1);
return (-1);
}
break;
case 'S' :
@ -308,7 +308,7 @@ poolcommand(int remove, int argc, char *argv[])
if (poolname == NULL) {
fprintf(stderr, "poolname not given with add/remove pool\n");
return(-1);
return (-1);
}
if (type == IPLT_NONE && remove == 0) {
@ -318,7 +318,7 @@ poolcommand(int remove, int argc, char *argv[])
} else {
fprintf(stderr, "unknown type '%s'\n", typearg);
}
return(-1);
return (-1);
}
if (type == IPLT_HASH || (type == IPLT_NONE && remove == 1)) {
@ -363,7 +363,7 @@ poolcommand(int remove, int argc, char *argv[])
break;
}
}
return(err);
return (err);
}
@ -381,7 +381,7 @@ loadpoolfile(int argc, char *argv[], char *infile)
break;
case 'f' :
if (loadpoolfile(argc, argv, optarg) != 0)
return(-1);
return (-1);
break;
case 'n' :
opts |= OPT_DONOTHING|OPT_DONTOPEN;
@ -412,8 +412,8 @@ loadpoolfile(int argc, char *argv[], char *infile)
}
if (ippool_parsefile(fd, infile, ioctl) != 0)
return(-1);
return(0);
return (-1);
return (0);
}
@ -441,7 +441,7 @@ poolstats(int argc, char *argv[])
role = getrole(optarg);
if (role == IPL_LOGNONE) {
fprintf(stderr, "unknown role '%s'\n", optarg);
return(-1);
return (-1);
}
break;
case 't' :
@ -449,7 +449,7 @@ poolstats(int argc, char *argv[])
if (type != IPLT_POOL) {
fprintf(stderr,
"-s not supported for this type yet\n");
return(-1);
return (-1);
}
break;
case 'v' :
@ -482,7 +482,7 @@ poolstats(int argc, char *argv[])
c = ioctl(fd, SIOCLOOKUPSTAT, &op);
if (c == -1) {
ipferror(fd, "ioctl(S0IOCLOOKUPSTAT)");
return(-1);
return (-1);
}
printf("%lu\taddress pools\n", plstat.ipls_pools);
printf("%lu\taddress pool nodes\n", plstat.ipls_nodes);
@ -497,7 +497,7 @@ poolstats(int argc, char *argv[])
c = ioctl(fd, SIOCLOOKUPSTAT, &op);
if (c == -1) {
ipferror(fd, "ioctl(SIOCLOOKUPSTAT)");
return(-1);
return (-1);
}
printf("%lu\thash tables\n", htstat.iphs_numtables);
printf("%lu\thash table nodes\n", htstat.iphs_numnodes);
@ -514,7 +514,7 @@ poolstats(int argc, char *argv[])
c = ioctl(fd, SIOCLOOKUPSTAT, &op);
if (c == -1) {
ipferror(fd, "ioctl(SIOCLOOKUPSTAT)");
return(-1);
return (-1);
}
printf("%u\tdestination lists\n",
dlstat.ipls_numlists);
@ -528,7 +528,7 @@ poolstats(int argc, char *argv[])
dlstat.ipls_numderefnodes);
}
}
return(0);
return (0);
}
@ -552,14 +552,14 @@ poolflush(int argc, char *argv[])
role = getrole(optarg);
if (role == IPL_LOGNONE) {
fprintf(stderr, "unknown role '%s'\n", optarg);
return(-1);
return (-1);
}
break;
case 't' :
type = gettype(optarg, NULL);
if (type == IPLT_NONE) {
fprintf(stderr, "unknown type '%s'\n", optarg);
return(-1);
return (-1);
}
break;
case 'v' :
@ -599,7 +599,7 @@ poolflush(int argc, char *argv[])
printf("%u object%s flushed\n", flush.iplf_count,
(flush.iplf_count == 1) ? "" : "s");
return(0);
return (0);
}
@ -630,7 +630,7 @@ getrole(char *rolename)
role = IPL_LOGNONE;
}
return(role);
return (role);
}
@ -652,7 +652,7 @@ gettype(char *typename, u_int *minor)
} else {
type = IPLT_NONE;
}
return(type);
return (type);
}
@ -691,7 +691,7 @@ poollist(int argc, char *argv[])
role = getrole(optarg);
if (role == IPL_LOGNONE) {
fprintf(stderr, "unknown role '%s'\n", optarg);
return(-1);
return (-1);
}
break;
#if 0
@ -708,7 +708,7 @@ poollist(int argc, char *argv[])
type = gettype(optarg, NULL);
if (type == IPLT_NONE) {
fprintf(stderr, "unknown type '%s'\n", optarg);
return(-1);
return (-1);
}
break;
case 'v' :
@ -744,7 +744,7 @@ poollist(int argc, char *argv[])
poollist_live(role, poolname, type, fd);
else
poollist_dead(role, poolname, type, kernel, core);
return(0);
return (0);
}
@ -1044,7 +1044,7 @@ setnodeaddr(int type, int role, void *ptr, char *arg)
mask.s_addr = 0xffffffff;
else if (strchr(s, '.') == NULL) {
if (ntomask(AF_INET, atoi(s + 1), &mask.s_addr) != 0)
return(-1);
return (-1);
} else {
mask.s_addr = inet_addr(s + 1);
}
@ -1110,5 +1110,5 @@ setnodeaddr(int type, int role, void *ptr, char *arg)
#endif
}
return(0);
return (0);
}

View File

@ -46,13 +46,13 @@ int resolve(char *host, char *address)
if (!(hp = gethostbyname(host)))
{
fprintf(stderr, "unknown host: %s\n", host);
return(-1);
return (-1);
}
bcopy((char *)hp->h_addr, (char *)address, 4);
return(0);
return (0);
}
bcopy((char*)&add, address, 4);
return(0);
return (0);
}
@ -67,11 +67,11 @@ int arp(char *addr, char *eaddr)
#ifdef IPSEND
if (arp_getipv4(addr, ether) == 0)
return(0);
return (0);
#endif
if (!addr)
return(-1);
return (-1);
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
@ -109,8 +109,8 @@ int arp(char *addr, char *eaddr)
sizeof(struct in_addr)))
{
bcopy(LLADDR(sdl), eaddr, sdl->sdl_alen);
return(0);
return (0);
}
}
return(-1);
return (-1);
}

View File

@ -45,13 +45,13 @@ int resolve(char *host, char *address)
if (!(hp = gethostbyname(host)))
{
fprintf(stderr, "unknown host: %s\n", host);
return(-1);
return (-1);
}
bcopy((char *)hp->h_addr, (char *)address, 4);
return(0);
return (0);
}
bcopy((char*)&add, address, 4);
return(0);
return (0);
}
/*
@ -72,11 +72,11 @@ int arp(ip, ether)
#ifdef IPSEND
if (arp_getipv4(ip, ether) == 0)
return(0);
return (0);
#endif
if (!bcmp(ipsave, ip, 4)) {
bcopy(ethersave, ether, 6);
return(0);
return (0);
}
fd = -1;
bzero((char *)&ar, sizeof(ar));
@ -95,7 +95,7 @@ int arp(ip, ether)
if ((sfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
{
perror("arp: socket");
return(-1);
return (-1);
}
tryagain:
if (ioctl(sfd, SIOCGARP, (caddr_t)&ar) == -1)
@ -116,19 +116,19 @@ tryagain:
fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr));
if (errno != ENXIO)
perror("SIOCGARP");
return(-1);
return (-1);
}
if ((ar.arp_ha.sa_data[0] == 0) && (ar.arp_ha.sa_data[1] == 0) &&
(ar.arp_ha.sa_data[2] == 0) && (ar.arp_ha.sa_data[3] == 0) &&
(ar.arp_ha.sa_data[4] == 0) && (ar.arp_ha.sa_data[5] == 0)) {
fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr));
return(-1);
return (-1);
}
bcopy(ar.arp_ha.sa_data, ether, 6);
savearp:
bcopy(ether, ethersave, 6);
bcopy(ip, ipsave, 4);
return(0);
return (0);
}

View File

@ -26,7 +26,7 @@ typedef unsigned long ulong;
#include <string.h>
#include "dltest.h"
#define CASERET(s) case s: return("s")
#define CASERET(s) case s: return ("s")
char *dlprim();
char *dlstate();
@ -1056,7 +1056,7 @@ stringtoaddr(char *sp, char *addr)
p = NULL;
}
return(n);
return (n);
}
@ -1068,7 +1068,7 @@ hexnibble(char c)
'a', 'b', 'c', 'd', 'e', 'f'
};
return(hextab[c & 0x0f]);
return (hextab[c & 0x0f]);
}
char*
@ -1106,7 +1106,7 @@ dlprim(u_long prim)
CASERET(DL_RESET_CON);
default:
(void) snprintf(primbuf, sizeof(primbuf), "unknown primitive 0x%x", prim);
return(primbuf);
return (primbuf);
}
}
@ -1140,7 +1140,7 @@ dlstate(u_long state)
CASERET(DL_SUBS_BIND_PND);
default:
(void) snprintf(statebuf, sizeof(statebuf), "unknown state 0x%x", state);
return(statebuf);
return (statebuf);
}
}
@ -1181,7 +1181,7 @@ dlerrno(u_long errno)
default:
(void) snprintf(errnobuf, sizeof(errnobuf), "unknown dlpi errno 0x%x", errno);
return(errnobuf);
return (errnobuf);
}
}
@ -1196,7 +1196,7 @@ dlpromisclevel(u_long level)
CASERET(DL_PROMISC_MULTI);
default:
(void) snprintf(levelbuf, sizeof(levelbuf), "unknown promisc level 0x%x", level);
return(levelbuf);
return (levelbuf);
}
}
@ -1212,7 +1212,7 @@ dlservicemode(u_long servicemode)
default:
(void) snprintf(servicemodebuf, sizeof(servicemodebuf),
"unknown provider service mode 0x%x", servicemode);
return(servicemodebuf);
return (servicemodebuf);
}
}
@ -1226,7 +1226,7 @@ dlstyle(long style)
CASERET(DL_STYLE2);
default:
(void) snprintf(stylebuf, sizeof(stylebuf), "unknown provider style 0x%x", style);
return(stylebuf);
return (stylebuf);
}
}
@ -1246,7 +1246,7 @@ dlmactype(u_long media)
CASERET(DL_CTCA);
default:
(void) snprintf(mediabuf, sizeof(mediabuf), "unknown media type 0x%x", media);
return(mediabuf);
return (mediabuf);
}
}
@ -1277,7 +1277,7 @@ strioctl(int fd, int cmd, int timout, int len, char *dp)
rc = ioctl(fd, I_STR, &sioc);
if (rc < 0)
return(rc);
return (rc);
else
return(sioc.ic_len);
return (sioc.ic_len);
}

View File

@ -41,7 +41,7 @@ chksum(u_short *buf, int len)
sum += *buf++;
sum = (sum>>16) + (sum & 0xffff);
sum += (sum >>16);
return(~sum);
return (~sum);
}
@ -67,12 +67,12 @@ send_ether(int nfd, char *buf, int len, struct in_addr gwip)
else if (arp((char *)&gwip, (char *) &eh->ether_dhost) == -1)
{
perror("arp");
return(-2);
return (-2);
}
eh->ether_type = htons(ETHERTYPE_IP);
last_gw.s_addr = gwip.s_addr;
err = sendip(nfd, s, sizeof(*eh) + len);
return(err);
return (err);
}
@ -95,7 +95,7 @@ send_ip(int nfd, int mtu, ip_t *ip, struct in_addr gwip, int frag)
if (!ipbuf)
{
perror("malloc failed");
return(-2);
return (-2);
}
}
@ -109,7 +109,7 @@ send_ip(int nfd, int mtu, ip_t *ip, struct in_addr gwip, int frag)
else if (arp((char *)&gwip, (char *) &eh->ether_dhost) == -1)
{
perror("arp");
return(-2);
return (-2);
}
bcopy((char *) &eh->ether_dhost, last_arp, sizeof(last_arp));
eh->ether_type = htons(ETHERTYPE_IP);
@ -159,7 +159,7 @@ send_ip(int nfd, int mtu, ip_t *ip, struct in_addr gwip, int frag)
fprintf(stderr, "mtu (%d) < ip header size (%d) + 8\n",
mtu, hlen);
fprintf(stderr, "can't fragment data\n");
return(-2);
return (-2);
}
ol = (IP_HL(ip) << 2) - sizeof(*ip);
for (i = 0, s = (char*)(ip + 1); ol > 0; )
@ -229,7 +229,7 @@ send_ip(int nfd, int mtu, ip_t *ip, struct in_addr gwip, int frag)
}
bcopy((char *)&ipsv, (char *)ip, sizeof(*ip));
return(err);
return (err);
}
@ -280,7 +280,7 @@ send_tcp(int nfd, int mtu, ip_t *ip, struct in_addr gwip)
t2->th_sum = chksum((u_short *)ip2, thlen + sizeof(ip_t));
bcopy((char *)t2, (char *)ip + hlen, thlen);
return(send_ip(nfd, mtu, ip, gwip, 1));
return (send_ip(nfd, mtu, ip, gwip, 1));
}
@ -310,7 +310,7 @@ send_udp(int nfd, int mtu, ip_t *ip, struct in_addr gwip)
bcopy((char *)&ti->ti_sport,
(char *)ip + (IP_HL(ip) << 2), sizeof(udphdr_t));
return(send_ip(nfd, mtu, ip, gwip, 1));
return (send_ip(nfd, mtu, ip, gwip, 1));
}
@ -327,7 +327,7 @@ send_icmp(int nfd, int mtu, ip_t *ip, in_addr gwip)
ic->icmp_cksum = 0;
ic->icmp_cksum = chksum((u_short *)ic, sizeof(struct icmp));
return(send_ip(nfd, mtu, ip, gwip, 1));
return (send_ip(nfd, mtu, ip, gwip, 1));
}

View File

@ -128,5 +128,5 @@ main(int argc, char **argv)
printf("Gateway: %s\n", inet_ntoa(gwip));
printf("mtu: %d\n", mtu);
return(ip_resend(dev, mtu, ipr, gwip, resend));
return (ip_resend(dev, mtu, ipr, gwip, resend));
}

View File

@ -128,8 +128,8 @@ send_packets(char *dev, int mtu, ip_t *ip, struct in_addr gwip)
wfd = initdevice(dev, 5);
if (wfd == -1)
return(-1);
return(send_packet(wfd, mtu, ip, gwip));
return (-1);
return (send_packet(wfd, mtu, ip, gwip));
}
void
@ -213,7 +213,7 @@ main(int argc, char **argv)
exit(1);
}
iplang(langfile);
return(0);
return (0);
case 'P' :
{
struct protoent *p;
@ -405,7 +405,7 @@ main(int argc, char **argv)
}
#ifdef DOSOCKET
if (ip->ip_p == IPPROTO_TCP && tcp->th_dport)
return(do_socket(dev, mtu, ip, gwip));
return (do_socket(dev, mtu, ip, gwip));
#endif
return(send_packets(dev, mtu, ip, gwip));
return (send_packets(dev, mtu, ip, gwip));
}

View File

@ -66,9 +66,9 @@ u_short ipseclevel(slevel)
if (!so->on_name) {
fprintf(stderr, "no such security level: %s\n", slevel);
return(0);
return (0);
}
return(so->on_value);
return (so->on_value);
}
@ -83,7 +83,7 @@ addipopt(char *op, struct ipopt_names *io, int len, char *class)
if ((len + io->on_siz) > 48) {
fprintf(stderr, "options too long\n");
return(0);
return (0);
}
len += io->on_siz;
*op++ = io->on_value;
@ -136,7 +136,7 @@ addipopt(char *op, struct ipopt_names *io, int len, char *class)
else
op += io->on_siz - 3;
}
return(len - olen);
return (len - olen);
}
@ -166,7 +166,7 @@ buildopts(char *cp, char *op, int len)
}
if (!io->on_name) {
fprintf(stderr, "unknown IP option name %s\n", s);
return(0);
return (0);
}
}
@ -188,5 +188,5 @@ buildopts(char *cp, char *op, int len)
}
}
}
return(len);
return (len);
}

View File

@ -192,5 +192,5 @@ main(int argc, char **argv)
ip_test7(dev, mtu, (ip_t *)ti, gwip, pointtest);
break;
}
return(0);
return (0);
}

View File

@ -74,7 +74,7 @@ ip_resend(char *dev, int mtu, struct ipread *r, struct in_addr gwip,
mb_t mb;
if (wfd == -1)
return(-1);
return (-1);
if (datain)
fd = (*r->r_open)(datain);
@ -89,7 +89,7 @@ ip_resend(char *dev, int mtu, struct ipread *r, struct in_addr gwip,
if(!eh)
{
perror("malloc failed");
return(-2);
return (-2);
}
bzero((char *) &eh->ether_shost, sizeof(eh->ether_shost));
@ -97,7 +97,7 @@ ip_resend(char *dev, int mtu, struct ipread *r, struct in_addr gwip,
{
perror("arp");
free(eh);
return(-2);
return (-2);
}
while ((i = (*r->r_readip)(&mb, NULL, NULL)) > 0)
@ -134,5 +134,5 @@ ip_resend(char *dev, int mtu, struct ipread *r, struct in_addr gwip,
}
(*r->r_close)();
free(eh);
return(0);
return (0);
}

View File

@ -65,7 +65,7 @@ initdevice(char *device, int tout)
if ((fd = open(bpfname, O_RDWR)) < 0)
{
fprintf(stderr, "no bpf devices available as /dev/bpfxx\n");
return(-1);
return (-1);
}
#else
char bpfname[16];
@ -80,14 +80,14 @@ initdevice(char *device, int tout)
if (i == 16)
{
fprintf(stderr, "no bpf devices available as /dev/bpfxx\n");
return(-1);
return (-1);
}
#endif
if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0)
{
perror("BIOCVERSION");
return(-1);
return (-1);
}
if (bv.bv_major != BPF_MAJOR_VERSION ||
bv.bv_minor < BPF_MINOR_VERSION)
@ -96,7 +96,7 @@ initdevice(char *device, int tout)
bv.bv_major, bv.bv_minor);
fprintf(stderr, "current version: %d.%d\n",
BPF_MAJOR_VERSION, BPF_MINOR_VERSION);
return(-1);
return (-1);
}
(void) strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
@ -128,7 +128,7 @@ initdevice(char *device, int tout)
}
(void) ioctl(fd, BIOCFLUSH, 0);
return(fd);
return (fd);
}
@ -141,8 +141,8 @@ sendip(int fd, char *pkt, int len)
if (write(fd, pkt, len) == -1)
{
perror("send");
return(-1);
return (-1);
}
return(len);
return (len);
}

View File

@ -119,7 +119,7 @@ initdevice(char *device, int tout)
exit(-1);
}
#endif
return(fd);
return (fd);
}
@ -154,13 +154,13 @@ sendip(int fd, char *pkt, int len)
if (putmsg(fd, cp, dp, pri) == -1)
{
perror("putmsg");
return(-1);
return (-1);
}
if (ioctl(fd, I_FLUSH, FLUSHW) == -1)
{
perror("I_FLUSHW");
return(-1);
return (-1);
}
return(len);
return (len);
}

View File

@ -106,7 +106,7 @@ initdevice(char *device, int tout)
perror(ifr.ifr_name);
exit(1);
}
return(fd);
return (fd);
}
@ -125,7 +125,7 @@ sendip(int fd, char *pkt, int len)
* For ethernet, need at least 802.3 header and IP header.
*/
if (len < (sizeof(sa->sa_data) + sizeof(struct ip)))
return(-1);
return (-1);
/*
* to avoid any output processing for IP, say we're not.
*/
@ -148,13 +148,13 @@ sendip(int fd, char *pkt, int len)
if (putmsg(fd, cp, dp, 0) == -1)
{
perror("putmsg");
return(-1);
return (-1);
}
if (ioctl(fd, I_FLUSH, FLUSHW) == -1)
{
perror("I_FLUSH");
return(-1);
return (-1);
}
return(len);
return (len);
}

View File

@ -111,14 +111,14 @@ kmemcpy(char *buf, void *pos, int n)
if (lseek(kfd, offset, SEEK_SET) == -1)
{
perror("lseek");
return(-1);
return (-1);
}
if (read(kfd, buf, n) == -1)
{
perror("read");
return(-1);
return (-1);
}
return(n);
return (n);
}
struct nlist names[4] = {
@ -145,9 +145,9 @@ kinfo_proc *getproc(void)
if (sysctl(mib, 4, &kp, &n, NULL, 0) == -1)
{
perror("sysctl");
return(NULL);
return (NULL);
}
return(&kp);
return (&kp);
}
@ -162,18 +162,18 @@ find_tcp(int tfd, struct tcpiphdr *ti)
struct file *f, **o;
if (!(p = getproc()))
return(NULL);
return (NULL);
fd = (struct filedesc *)malloc(sizeof(*fd));
if (fd == NULL)
return(NULL);
return (NULL);
#if defined( __FreeBSD__)
if (KMCPY(fd, p->ki_fd, sizeof(*fd)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx) failed\n",
(u_long)p, (u_long)p->ki_fd);
free(fd);
return(NULL);
return (NULL);
}
#else
if (KMCPY(fd, p->kp_proc.p_fd, sizeof(*fd)) == -1)
@ -181,7 +181,7 @@ find_tcp(int tfd, struct tcpiphdr *ti)
fprintf(stderr, "read(%#lx,%#lx) failed\n",
(u_long)p, (u_long)p->kp_proc.p_fd);
free(fd);
return(NULL);
return (NULL);
}
#endif
@ -229,7 +229,7 @@ find_tcp(int tfd, struct tcpiphdr *ti)
(u_long)i->inp_ppcb, (u_long)t, (u_long)sizeof(*t));
goto finderror;
}
return(struct tcpcb *)i->inp_ppcb;
return (struct tcpcb *)i->inp_ppcb;
finderror:
if (o != NULL)
@ -242,7 +242,7 @@ finderror:
free(i);
if (t != NULL)
free(t);
return(NULL);
return (NULL);
}
int
@ -259,13 +259,13 @@ do_socket(char *dev, int mtu, struct tcpiphdr *ti, struct in_addr gwip)
if (fd == -1)
{
perror("socket");
return(-1);
return (-1);
}
if (fcntl(fd, F_SETFL, FNDELAY) == -1)
{
perror("fcntl");
return(-1);
return (-1);
}
bzero((char *)&lsin, sizeof(lsin));
@ -275,7 +275,7 @@ do_socket(char *dev, int mtu, struct tcpiphdr *ti, struct in_addr gwip)
if (bind(fd, (struct sockaddr *)&lsin, sizeof(lsin)) == -1)
{
perror("bind");
return(-1);
return (-1);
}
len = sizeof(lsin);
(void) getsockname(fd, (struct sockaddr *)&lsin, &len);
@ -284,10 +284,10 @@ do_socket(char *dev, int mtu, struct tcpiphdr *ti, struct in_addr gwip)
nfd = initdevice(dev, 1);
if (nfd == -1)
return(-1);
return (-1);
if (!(t = find_tcp(fd, ti)))
return(-1);
return (-1);
bzero((char *)&rsin, sizeof(rsin));
rsin.sin_family = AF_INET;
@ -298,7 +298,7 @@ do_socket(char *dev, int mtu, struct tcpiphdr *ti, struct in_addr gwip)
errno != EINPROGRESS)
{
perror("connect");
return(-1);
return (-1);
}
KMCPY(&tcb, t, sizeof(tcb));
ti->ti_win = tcb.rcv_adv;
@ -306,9 +306,9 @@ do_socket(char *dev, int mtu, struct tcpiphdr *ti, struct in_addr gwip)
ti->ti_ack = tcb.rcv_nxt;
if (send_tcp(nfd, mtu, (ip_t *)ti, gwip) == -1)
return(-1);
return (-1);
(void)write(fd, "Hello World\n", 12);
sleep(2);
close(fd);
return(0);
return (0);
}

View File

@ -47,13 +47,13 @@ initdevice(char *device, int tout)
if ((fd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
{
perror("socket(AF_INET, SOCK_RAW, IPPROTO_RAW)");
return(-1);
return (-1);
}
if (ioctl(fd, SIOCGIFADDR, &ifr) == -1)
{
perror("ioctl SIOCGIFADDR");
return(-1);
return (-1);
}
bzero((char *)&s, sizeof(s));
@ -61,7 +61,7 @@ initdevice(char *device, int tout)
bcopy(&ifr.ifr_addr, s.sa_data, 4);
if (bind(fd, &s, sizeof(s)) == -1)
perror("bind");
return(fd);
return (fd);
}
@ -83,8 +83,8 @@ int sendip(int fd, char *pkt, int len)
if (sendto(fd, pkt, len, 0, &sin, sizeof(sin)) == -1)
{
perror("send");
return(-1);
return (-1);
}
return(len);
return (len);
}

View File

@ -22,7 +22,7 @@ addipopt(char *op, struct ipopt_names *io, int len, char *class)
if ((len + io->on_siz) > 48) {
fprintf(stderr, "options too long\n");
return(0);
return (0);
}
len += io->on_siz;
*op++ = io->on_value;
@ -58,5 +58,5 @@ addipopt(char *op, struct ipopt_names *io, int len, char *class)
if (opts & OPT_DEBUG)
fprintf(stderr, "bo: %s %d %#x: %d\n",
io->on_name, io->on_value, io->on_bit, len);
return(len - olen);
return (len - olen);
}

View File

@ -24,12 +24,12 @@ alist_new(int family, char *host)
family = AF_INET;
}
if (family != AF_INET && family != AF_INET6)
return(NULL);
return (NULL);
al = calloc(1, sizeof(*al));
if (al == NULL) {
fprintf(stderr, "alist_new out of memory\n");
return(NULL);
return (NULL);
}
while (ISSPACE(*host))
@ -86,8 +86,8 @@ alist_new(int family, char *host)
al->al_family = family;
if (slash != NULL)
*slash = '/';
return(al);
return (al);
bad:
free(al);
return(NULL);
return (NULL);
}

View File

@ -15,9 +15,9 @@ allocmbt(size_t len)
m = (mb_t *)malloc(sizeof(mb_t));
if (m == NULL)
return(NULL);
return (NULL);
m->mb_len = len;
m->mb_next = NULL;
m->mb_data = (char *)m->mb_buf;
return(m);
return (m);
}

View File

@ -14,6 +14,6 @@ int
bcopywrap(void *from, void *to, size_t size)
{
bcopy((caddr_t)from, (caddr_t)to, size);
return(0);
return (0);
}

View File

@ -36,7 +36,7 @@ buildopts(char *cp, char *op, int len)
}
if (!io->on_name) {
fprintf(stderr, "unknown IP option name %s\n", s);
return(0);
return (0);
}
}
while ((len & 3) != 3) {
@ -45,5 +45,5 @@ buildopts(char *cp, char *op, int len)
}
*op++ = IPOPT_EOL;
len++;
return(len);
return (len);
}

View File

@ -29,18 +29,18 @@ checkrev(char *ipfname)
if ((vfd == -1) && ((vfd = open(ipfname, O_RDONLY)) == -1)) {
perror("open device");
return(-1);
return (-1);
}
if (ioctl(vfd, SIOCGETFS, &obj)) {
ipferror(vfd, "ioctl(SIOCGETFS)");
close(vfd);
vfd = -1;
return(-1);
return (-1);
}
if (strncmp(IPL_VERSION, fio.f_version, sizeof(fio.f_version))) {
return(-1);
return (-1);
}
return(0);
return (0);
}

View File

@ -25,24 +25,24 @@ connecttcp(char *server, int port)
if (ISDIGIT(*server)) {
if (inet_aton(server, &sin.sin_addr) == -1) {
return(-1);
return (-1);
}
} else {
host = gethostbyname(server);
if (host == NULL)
return(-1);
return (-1);
memcpy(&sin.sin_addr, host->h_addr_list[0],
sizeof(sin.sin_addr));
}
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd == -1)
return(-1);
return (-1);
if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
close(fd);
return(-1);
return (-1);
}
return(fd);
return (fd);
}

View File

@ -35,6 +35,6 @@ count4bits(u_int ip)
ipn++;
}
if (ipn == ip)
return(cnt);
return(-1);
return (cnt);
return (-1);
}

View File

@ -25,5 +25,5 @@ count6bits(u_32_t *msk)
if (j & 0x80000000)
i++;
}
return(i);
return (i);
}

View File

@ -15,10 +15,10 @@ dupmbt(mb_t *orig)
m = (mb_t *)malloc(sizeof(mb_t));
if (m == NULL)
return(NULL);
return (NULL);
m->mb_len = orig->mb_len;
m->mb_next = NULL;
m->mb_data = (char *)m->mb_buf + (orig->mb_data - (char *)orig->mb_buf);
bcopy(orig->mb_data, m->mb_data, m->mb_len);
return(m);
return (m);
}

View File

@ -82,13 +82,13 @@ fac_toname(int facpri)
j = fac >> 3;
if (j < (sizeof(facs)/sizeof(facs[0]))) {
if (facs[j].value == fac)
return(facs[j].name);
return (facs[j].name);
}
for (i = 0; facs[i].name; i++)
if (fac == facs[i].value)
return(facs[i].name);
return (facs[i].name);
return(NULL);
return (NULL);
}
@ -102,8 +102,8 @@ fac_findname(char *name)
for (i = 0; facs[i].name; i++)
if (!strcmp(facs[i].name, name))
return(facs[i].value);
return(-1);
return (facs[i].value);
return (-1);
}
@ -126,8 +126,8 @@ pri_findname(char *name)
for (i = 0; pris[i].name; i++)
if (!strcmp(pris[i].name, name))
return(pris[i].value);
return(-1);
return (pris[i].value);
return (-1);
}
@ -141,9 +141,9 @@ pri_toname(int facpri)
pri = facpri & LOG_PRIMASK;
if (pris[pri].value == pri)
return(pris[pri].name);
return (pris[pri].name);
for (i = 0; pris[i].name; i++)
if (pri == pris[i].value)
return(pris[i].name);
return(NULL);
return (pris[i].name);
return (NULL);
}

View File

@ -4,10 +4,10 @@ const char *
familyname(int family)
{
if (family == AF_INET)
return("inet");
return ("inet");
#ifdef USE_INET6
if (family == AF_INET6)
return("inet6");
return ("inet6");
#endif
return("unknown");
return ("unknown");
}

View File

@ -18,7 +18,7 @@ findword(wordtab_t *words, char *name)
if (!strcmp(name, w->w_word))
break;
if (w->w_word == NULL)
return(NULL);
return (NULL);
return(w);
return (w);
}

View File

@ -5,11 +5,11 @@ ftov(int version)
{
#ifdef USE_INET6
if (version == AF_INET6)
return(6);
return (6);
#endif
if (version == AF_INET)
return(4);
return (4);
if (version == AF_UNSPEC)
return(0);
return(-1);
return (0);
return (-1);
}

View File

@ -30,7 +30,7 @@ gethost(int family, char *name, i6addr_t *hostp)
hostp->i6[3] = htonl(0xfedcba98);
}
#endif
return(0);
return (0);
}
if (!strcmp(name, "<thishost>"))
@ -43,14 +43,14 @@ gethost(int family, char *name, i6addr_t *hostp)
(h->h_length == sizeof(addr))) {
bcopy(h->h_addr, (char *)&addr, sizeof(addr));
hostp->in4.s_addr = addr;
return(0);
return (0);
}
}
n = getnetbyname(name);
if (n != NULL) {
hostp->in4.s_addr = htonl(n->n_net & 0xffffffff);
return(0);
return (0);
}
}
#ifdef USE_INET6
@ -66,9 +66,9 @@ gethost(int family, char *name, i6addr_t *hostp)
sin6 = (struct sockaddr_in6 *)res->ai_addr;
hostp->in6 = sin6->sin6_addr;
freeaddrinfo(res);
return(0);
return (0);
}
}
#endif
return(-1);
return (-1);
}

View File

@ -15,14 +15,14 @@ geticmptype(int family, char *name)
for (i = icmptypelist; i->it_name != NULL; i++) {
if (!strcmp(name, i->it_name)) {
if (family == AF_INET)
return(i->it_v4);
return (i->it_v4);
#ifdef USE_INET6
if (family == AF_INET6)
return(i->it_v6);
return (i->it_v6);
#endif
return(-1);
return (-1);
}
}
return(-1);
return (-1);
}

View File

@ -27,28 +27,28 @@ getifname(struct ifnet *ptr)
qif_t qif;
if ((void *)ptr == (void *)-1)
return("!");
return ("!");
if (ptr == NULL)
return("-");
return ("-");
if (kmemcpy((char *)&qif, (u_long)ptr, sizeof(qif)) == -1)
return("X");
return ("X");
ifname = strdup(qif.qf_name);
if ((ifname != NULL) && (*ifname == '\0')) {
free(ifname);
return("!");
return ("!");
}
return(ifname);
return (ifname);
#else
struct ifnet netif;
if ((void *)ptr == (void *)-1)
return("!");
return ("!");
if (ptr == NULL)
return("-");
return ("-");
if (kmemcpy((char *)&netif, (u_long)ptr, sizeof(netif)) == -1)
return("X");
return(strdup(netif.if_xname));
return ("X");
return (strdup(netif.if_xname));
#endif
}

View File

@ -25,7 +25,7 @@ getnattype(nat_t *nat)
char *which;
if (!nat)
return("???");
return ("???");
switch (nat->nat_redir)
{
@ -65,5 +65,5 @@ getnattype(nat_t *nat)
which = unknownbuf;
break;
}
return(which);
return (which);
}

View File

@ -22,17 +22,17 @@ getport(frentry_t *fr, char *name, u_short *port, char *proto)
s = getservbyname(name, proto);
if (s != NULL) {
*port = s->s_port;
return(0);
return (0);
}
if (ISDIGIT(*name)) {
int portval = atoi(name);
if (portval < 0 || portval > 65535)
return(-1);
return (-1);
*port = htons((u_short)portval);
return(0);
return (0);
}
return(-1);
return (-1);
}
/*
@ -51,15 +51,15 @@ getport(frentry_t *fr, char *name, u_short *port, char *proto)
s = getservbyname(name, "udp");
if (s != NULL) {
if (p1 != s->s_port)
return(-1);
return (-1);
}
if ((p1 == 0) && (s == NULL))
return(-1);
return (-1);
if (p1)
*port = p1;
else
*port = s->s_port;
return(0);
return (0);
}
if ((fr->fr_flx & FI_TCPUDP) != 0) {
@ -69,20 +69,20 @@ getport(frentry_t *fr, char *name, u_short *port, char *proto)
*/
s = getservbyname(name, "tcp");
if (s == NULL)
return(-1);
return (-1);
p1 = s->s_port;
s = getservbyname(name, "udp");
if (s == NULL || s->s_port != p1)
return(-1);
return (-1);
*port = p1;
return(0);
return (0);
}
p = getprotobynumber(fr->fr_proto);
s = getservbyname(name, p ? p->p_name : NULL);
if (s != NULL) {
*port = s->s_port;
return(0);
return (0);
}
return(-1);
return (-1);
}

View File

@ -23,17 +23,17 @@ getportproto(char *name, int proto)
for (s = name; *s != '\0'; s++)
if (!ISDIGIT(*s))
return(-1);
return (-1);
number = atoi(name);
if (number < 0 || number > 65535)
return(-1);
return(htons(number));
return (-1);
return (htons(number));
}
p = getprotobynumber(proto);
s = getservbyname(name, p ? p->p_name : NULL);
if (s != NULL)
return(s->s_port);
return(-1);
return (s->s_port);
return (-1);
}

View File

@ -23,13 +23,13 @@ getproto(char *name)
if (!ISDIGIT(*s))
break;
if (*s == '\0')
return(atoi(name));
return (atoi(name));
if (!strcasecmp(name, "ip"))
return(0);
return (0);
p = getprotobyname(name);
if (p != NULL)
return(p->p_proto);
return(-1);
return (p->p_proto);
return (-1);
}

View File

@ -19,5 +19,5 @@ getsumd(u_32_t sum)
snprintf(sumdbuf, sizeof(sumdbuf), "hw(%#0x)", sum & 0xffff);
else
snprintf(sumdbuf, sizeof(sumdbuf), "%#0x", sum);
return(sumdbuf);
return (sumdbuf);
}

View File

@ -23,7 +23,7 @@ hostname(int family, void *ip)
if (family == AF_INET) {
ipa.s_addr = *(u_32_t *)ip;
if (ipa.s_addr == htonl(0xfedcba98))
return("test.host.dots");
return ("test.host.dots");
}
if ((opts & OPT_NORESOLVE) == 0) {
@ -33,7 +33,7 @@ hostname(int family, void *ip)
*hp->h_name != '\0') {
strncpy(hostbuf, hp->h_name, sizeof(hostbuf));
hostbuf[sizeof(hostbuf) - 1] = '\0';
return(hostbuf);
return (hostbuf);
}
np = getnetbyaddr(ipa.s_addr, AF_INET);
@ -41,19 +41,19 @@ hostname(int family, void *ip)
*np->n_name != '\0') {
strncpy(hostbuf, np->n_name, sizeof(hostbuf));
hostbuf[sizeof(hostbuf) - 1] = '\0';
return(hostbuf);
return (hostbuf);
}
}
}
if (family == AF_INET) {
return(inet_ntoa(ipa));
return (inet_ntoa(ipa));
}
#ifdef USE_INET6
(void) inet_ntop(AF_INET6, ip, hostbuf, sizeof(hostbuf) - 1);
hostbuf[MAXHOSTNAMELEN] = '\0';
return(hostbuf);
return (hostbuf);
#else
return("IPv6");
return ("IPv6");
#endif
}

View File

@ -13,16 +13,16 @@ icmptypename(int family, int type)
icmptype_t *i;
if ((type < 0) || (type > 255))
return(NULL);
return (NULL);
for (i = icmptypelist; i->it_name != NULL; i++) {
if ((family == AF_INET) && (i->it_v4 == type))
return(i->it_name);
return (i->it_name);
#ifdef USE_INET6
if ((family == AF_INET6) && (i->it_v6 == type))
return(i->it_name);
return (i->it_name);
#endif
}
return(NULL);
return (NULL);
}

View File

@ -108,7 +108,7 @@ inet_aton(register const char *cp, struct in_addr *addr)
* 0x=hex, 0=octal, isdigit=decimal.
*/
if (!ISDIGIT(c))
return(0);
return (0);
val = 0; base = 10;
if (c == '0') {
c = *++cp;
@ -136,7 +136,7 @@ inet_aton(register const char *cp, struct in_addr *addr)
* a.b (with b treated as 24 bits)
*/
if (pp >= parts + 3)
return(0);
return (0);
*pp++ = val;
c = *++cp;
} else
@ -146,7 +146,7 @@ inet_aton(register const char *cp, struct in_addr *addr)
* Check for trailing characters.
*/
if (c != '\0' && (!ISASCII(c) || !ISSPACE(c)))
return(0);
return (0);
/*
* Concoct the address according to
* the number of parts specified.
@ -155,32 +155,32 @@ inet_aton(register const char *cp, struct in_addr *addr)
switch (n) {
case 0:
return(0); /* initial nondigit */
return (0); /* initial nondigit */
case 1: /* a -- 32 bits */
break;
case 2: /* a.b -- 8.24 bits */
if (val > 0xffffff)
return(0);
return (0);
val |= parts[0] << 24;
break;
case 3: /* a.b.c -- 8.8.16 bits */
if (val > 0xffff)
return(0);
return (0);
val |= (parts[0] << 24) | (parts[1] << 16);
break;
case 4: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff)
return(0);
return (0);
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
}
if (addr)
addr->s_addr = htonl(val);
return(1);
return (1);
}
/* these are compatibility routines, not needed on recent BSD releases */
@ -195,7 +195,7 @@ inet_addr(const char *cp)
struct in_addr val;
if (inet_aton(cp, &val))
return(val.s_addr);
return(0xffffffff);
return (val.s_addr);
return (0xffffffff);
}
#endif

View File

@ -530,7 +530,7 @@ find_error(int errnum)
while (step != 0) {
ie = ipf_errors + l + step;
if (ie->iee_number == errnum)
return(ie);
return (ie);
step = l + step;
if (ie->iee_number > errnum)
r = step;
@ -539,7 +539,7 @@ find_error(int errnum)
step = (r - l) / 2;;
}
return(NULL);
return (NULL);
}
char *
@ -553,12 +553,12 @@ ipf_geterror(int fd, ioctlfunc_t *func)
ie = find_error(errnum);
if (ie != NULL)
return(ie->iee_text);
return (ie->iee_text);
snprintf(text, sizeof(text), "unknown error %d", errnum);
} else {
snprintf(text, sizeof(text), "retrieving error number failed (%d)", errno);
}
return(text);
return (text);
}
@ -571,8 +571,8 @@ ipf_strerror(int errnum)
ie = find_error(errnum);
if (ie != NULL)
return(ie->iee_text);
return (ie->iee_text);
snprintf(text, sizeof(text), "unknown error %d", errnum);
return(text);
return (text);
}

View File

@ -24,7 +24,7 @@ ipf_perror_fd( int fd, ioctlfunc_t iocfunc, char *string)
errno = save;
fprintf(stderr, "%d:", realerr);
ipf_perror(realerr, string);
return(realerr ? realerr : save);
return (realerr ? realerr : save);
}

View File

@ -32,7 +32,7 @@ hex_open(char *fname)
{
if (tfp && tfd != -1) {
rewind(tfp);
return(tfd);
return (tfd);
}
if (!strcmp(fname, "-")) {
@ -43,7 +43,7 @@ hex_open(char *fname)
if (tfd != -1)
tfp = fdopen(tfd, "r");
}
return(tfd);
return (tfd);
}
@ -53,7 +53,7 @@ hex_close(void)
int cfd = tfd;
tfd = -1;
return(close(cfd));
return (close(cfd));
}
@ -79,7 +79,7 @@ hex_readip(mb_t *mb, char **ifn, int *dir)
if ((s = strchr(line, '\n'))) {
if (s == line) {
mb->mb_len = (char *)ip - buf;
return(mb->mb_len);
return (mb->mb_len);
}
*s = '\0';
}
@ -147,8 +147,8 @@ hex_readip(mb_t *mb, char **ifn, int *dir)
}
}
if (feof(tfp))
return(0);
return(-1);
return (0);
return (-1);
}
@ -178,5 +178,5 @@ static char
} else
break;
}
return(dst);
return (dst);
}

View File

@ -85,20 +85,20 @@ ipcap_open(char *fname)
int fd, i;
if (pfd != -1)
return(pfd);
return (pfd);
if (!strcmp(fname, "-"))
fd = 0;
else if ((fd = open(fname, O_RDONLY)) == -1)
return(-1);
return (-1);
if (read(fd, (char *)&ph, sizeof(ph)) != sizeof(ph))
return(-2);
return (-2);
if (ph.id != 0xa1b2c3d4) {
if (SWAPLONG(ph.id) != 0xa1b2c3d4) {
(void) close(fd);
return(-2);
return (-2);
}
swapped = 1;
iswap_hdr(&ph);
@ -112,7 +112,7 @@ ipcap_open(char *fname)
if (llcp == NULL) {
(void) close(fd);
return(-2);
return (-2);
}
pfd = fd;
@ -120,14 +120,14 @@ ipcap_open(char *fname)
printf("\tid: %08x version: %d.%d type: %d snap %d\n",
ph.id, ph.major, ph.minor, ph.type, ph.snaplen);
return(fd);
return (fd);
}
static int
ipcap_close(void)
{
return(close(pfd));
return (close(pfd));
}
@ -145,7 +145,7 @@ ipcap_read_rec(packetheader_t *rec)
while (n > 0) {
i = read(pfd, (char *)rec, sizeof(*rec));
if (i <= 0)
return(-2);
return (-2);
n -= i;
}
@ -158,11 +158,11 @@ ipcap_read_rec(packetheader_t *rec)
p = rec->caplen;
n = MIN(p, rec->wirelen);
if (!n || n < 0)
return(-3);
return (-3);
if (p < 0 || p > 65536)
return(-4);
return(p);
return (-4);
return (p);
}
@ -179,7 +179,7 @@ ipcap_read(char *buf, int cnt)
int i, n;
if ((i = ipcap_read_rec(&rec)) <= 0)
return(i);
return (i);
if (!bufp)
bufp = malloc(i);
@ -187,11 +187,11 @@ ipcap_read(char *buf, int cnt)
bufp = realloc(bufp, i);
if (read(pfd, bufp, i) != i)
return(-2);
return (-2);
n = MIN(i, cnt);
bcopy(bufp, buf, n);
return(n);
return (n);
}
#endif
@ -220,7 +220,7 @@ ipcap_readip(mb_t *mb, char **ifn, int *dir)
/* do { */
if ((i = ipcap_read_rec(&rec)) <= 0)
return(i);
return (i);
if (!bufp)
bufp = malloc(i);
@ -231,7 +231,7 @@ ipcap_readip(mb_t *mb, char **ifn, int *dir)
for (j = i, n = 0; j > 0; ) {
n = read(pfd, s, j);
if (n <= 0)
return(-2);
return (-2);
j -= n;
s += n;
}
@ -245,5 +245,5 @@ ipcap_readip(mb_t *mb, char **ifn, int *dir)
n = MIN(i, cnt);
bcopy(s, buf, n);
mb->mb_len = n;
return(n);
return (n);
}

View File

@ -51,16 +51,16 @@ tx_hostnum(char *host, int *resolved)
*resolved = 0;
if (!strcasecmp("any", host))
return(0L);
return (0L);
if (ISDIGIT(*host))
return(inet_addr(host));
return (inet_addr(host));
if (gethost(AF_INET, host, &ipa) == -1) {
*resolved = -1;
fprintf(stderr, "can't resolve hostname: %s\n", host);
return(0);
return (0);
}
return(ipa.in4.s_addr);
return (ipa.in4.s_addr);
}
@ -74,12 +74,12 @@ tx_portnum(char *name)
struct servent *sp;
if (ISDIGIT(*name))
return(u_short)atoi(name);
return (u_short)atoi(name);
sp = getservbyname(name, tx_proto);
if (sp)
return(ntohs(sp->s_port));
return (ntohs(sp->s_port));
(void) fprintf(stderr, "unknown service \"%s\".\n", name);
return(0);
return (0);
}
@ -88,7 +88,7 @@ text_open(char *fname)
{
if (tfp && tfd != -1) {
rewind(tfp);
return(tfd);
return (tfd);
}
if (!strcmp(fname, "-")) {
@ -99,7 +99,7 @@ text_open(char *fname)
if (tfd != -1)
tfp = fdopen(tfd, "r");
}
return(tfd);
return (tfd);
}
@ -109,7 +109,7 @@ text_close(void)
int cfd = tfd;
tfd = -1;
return(close(cfd));
return (close(cfd));
}
@ -149,12 +149,12 @@ text_readip(mb_t *mb, char **ifn, int *dir)
} else {
mb->mb_len = ntohs(ip->ip_len);
}
return(mb->mb_len);
return (mb->mb_len);
}
}
if (feof(tfp))
return(0);
return(-1);
return (0);
return (-1);
}
static int
@ -179,32 +179,32 @@ parseline(char *line, ip_t *ip, char **ifn, int *out)
cpp = cps;
if (!*cpp)
return(1);
return (1);
c = **cpp;
if (!ISALPHA(c) || (TOLOWER(c) != 'o' && TOLOWER(c) != 'i')) {
fprintf(stderr, "bad direction \"%s\"\n", *cpp);
return(1);
return (1);
}
#ifdef USE_INET6
if (!strcasecmp(*cpp, "out6") || !strcasecmp(*cpp, "in6")) {
return(parseipv6(cpp, (ip6_t *)ip, ifn, out));
return (parseipv6(cpp, (ip6_t *)ip, ifn, out));
}
#endif
*out = (TOLOWER(c) == 'o') ? 1 : 0;
cpp++;
if (!*cpp)
return(1);
return (1);
if (!strcasecmp(*cpp, "on")) {
cpp++;
if (!*cpp)
return(1);
return (1);
*ifn = strdup(*cpp++);
if (!*cpp)
return(1);
return (1);
}
c = **cpp;
@ -232,14 +232,14 @@ parseline(char *line, ip_t *ip, char **ifn, int *out)
ip->ip_p = IPPROTO_IP;
if (!*cpp)
return(1);
return (1);
if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) {
char *last;
last = strchr(*cpp, ',');
if (!last) {
fprintf(stderr, "tcp/udp with no source port\n");
return(1);
return (1);
}
*last++ = '\0';
tcp->th_sport = htons(tx_portnum(last));
@ -251,7 +251,7 @@ parseline(char *line, ip_t *ip, char **ifn, int *out)
ip->ip_src.s_addr = tx_hostnum(*cpp, &r);
cpp++;
if (!*cpp)
return(1);
return (1);
if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) {
char *last;
@ -259,7 +259,7 @@ parseline(char *line, ip_t *ip, char **ifn, int *out)
last = strchr(*cpp, ',');
if (!last) {
fprintf(stderr, "tcp/udp with no destination port\n");
return(1);
return (1);
}
*last++ = '\0';
tcp->th_dport = htons(tx_portnum(last));
@ -327,7 +327,7 @@ parseline(char *line, ip_t *ip, char **ifn, int *out)
bcopy((char *)ic, ((char *)ip) + (IP_HL(ip) << 2),
sizeof(*ic));
ip->ip_len = htons(ip->ip_len);
return(0);
return (0);
}
@ -346,15 +346,15 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
*out = (**cpp == 'o') ? 1 : 0;
cpp++;
if (!*cpp)
return(1);
return (1);
if (!strcasecmp(*cpp, "on")) {
cpp++;
if (!*cpp)
return(1);
return (1);
*ifn = strdup(*cpp++);
if (!*cpp)
return(1);
return (1);
}
if (!strcasecmp(*cpp, "tcp")) {
@ -376,7 +376,7 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
ip6->ip6_nxt = IPPROTO_IPV6;
if (!*cpp)
return(1);
return (1);
switch (ip6->ip6_nxt)
{
@ -399,7 +399,7 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
last = strchr(*cpp, ',');
if (!last) {
fprintf(stderr, "tcp/udp with no source port\n");
return(1);
return (1);
}
*last++ = '\0';
tcp->th_sport = htons(tx_portnum(last));
@ -411,12 +411,12 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
if (inet_pton(AF_INET6, *cpp, &ip6->ip6_src) != 1) {
fprintf(stderr, "cannot parse source address '%s'\n", *cpp);
return(1);
return (1);
}
cpp++;
if (!*cpp)
return(1);
return (1);
if (ip6->ip6_nxt == IPPROTO_TCP || ip6->ip6_nxt == IPPROTO_UDP) {
char *last;
@ -424,7 +424,7 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
last = strchr(*cpp, ',');
if (!last) {
fprintf(stderr, "tcp/udp with no destination port\n");
return(1);
return (1);
}
*last++ = '\0';
tcp->th_dport = htons(tx_portnum(last));
@ -433,7 +433,7 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
if (inet_pton(AF_INET6, *cpp, &ip6->ip6_dst) != 1) {
fprintf(stderr, "cannot parse destination address '%s'\n",
*cpp);
return(1);
return (1);
}
cpp++;
@ -495,6 +495,6 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
ip6->ip6_plen++;
}
ip6->ip6_plen = htons(ip6->ip6_plen);
return(0);
return (0);
}
#endif

View File

@ -30,7 +30,7 @@ seclevel(char *slevel)
struct ipopt_names *so;
if (slevel == NULL || *slevel == '\0')
return(0);
return (0);
for (so = secclass; so->on_name; so++)
if (!strcasecmp(slevel, so->on_name))
@ -38,9 +38,9 @@ seclevel(char *slevel)
if (!so->on_name) {
fprintf(stderr, "no such security level: '%s'\n", slevel);
return(0);
return (0);
}
return(u_char)so->on_value;
return (u_char)so->on_value;
}
@ -55,7 +55,7 @@ secbit(int class)
if (!so->on_name) {
fprintf(stderr, "no such security class: %d.\n", class);
return(0);
return (0);
}
return(u_char)so->on_bit;
return (u_char)so->on_bit;
}

View File

@ -47,9 +47,9 @@ openkmem(char *kern, char *core)
if (kvm_f == NULL)
{
perror("openkmem:open");
return(-1);
return (-1);
}
return(kvm_f != NULL);
return (kvm_f != NULL);
}
int
@ -58,18 +58,18 @@ kmemcpy(register char *buf, long pos, register int n)
register int r;
if (!n)
return(0);
return (0);
if (kvm_f == NULL)
if (openkmem(NULL, NULL) == -1)
return(-1);
return (-1);
while ((r = kvm_read(kvm_f, pos, buf, n)) < n)
if (r <= 0)
{
fprintf(stderr, "pos=0x%lx ", (u_long)pos);
perror("kmemcpy:read");
return(-1);
return (-1);
}
else
{
@ -77,7 +77,7 @@ kmemcpy(register char *buf, long pos, register int n)
pos += r;
n -= r;
}
return(0);
return (0);
}
int
@ -86,11 +86,11 @@ kstrncpy(register char *buf, long pos, register int n)
register int r;
if (!n)
return(0);
return (0);
if (kvm_f == NULL)
if (openkmem(NULL, NULL) == -1)
return(-1);
return (-1);
while (n > 0)
{
@ -99,7 +99,7 @@ kstrncpy(register char *buf, long pos, register int n)
{
fprintf(stderr, "pos=0x%lx ", (u_long)pos);
perror("kmemcpy:read");
return(-1);
return (-1);
}
else
{
@ -110,5 +110,5 @@ kstrncpy(register char *buf, long pos, register int n)
n--;
}
}
return(0);
return (0);
}

View File

@ -17,6 +17,6 @@ kmemcpywrap(void *from, void *to, size_t size)
int ret;
ret = kmemcpy((caddr_t)to, (u_long)from, size);
return(ret);
return (ret);
}

View File

@ -27,12 +27,12 @@ kvatoname(ipfunc_t func, ioctlfunc_t iocfunc)
if ((opts & OPT_DONTOPEN) == 0) {
fd = open(IPL_NAME, O_RDONLY);
if (fd == -1)
return(NULL);
return (NULL);
}
(void) (*iocfunc)(fd, SIOCFUNCL, &res);
if (fd >= 0)
close(fd);
strncpy(funcname, res.ipfu_name, sizeof(funcname));
funcname[sizeof(funcname) - 1] = '\0';
return(funcname);
return (funcname);
}

View File

@ -21,10 +21,10 @@ load_dstlist(ippool_dst_t *dst, ioctlfunc_t iocfunc, ipf_dstnode_t *nodes)
ippool_dst_t dest;
if (dst->ipld_name[0] == '\0')
return(-1);
return (-1);
if (pool_open() == -1)
return(-1);
return (-1);
op.iplo_unit = dst->ipld_unit;
op.iplo_type = IPLT_DSTLIST;
@ -41,7 +41,7 @@ load_dstlist(ippool_dst_t *dst, ioctlfunc_t iocfunc, ipf_dstnode_t *nodes)
if ((opts & OPT_REMOVE) == 0) {
if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op))
if ((opts & OPT_DONOTHING) == 0) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"add destination list table"));
}
}
@ -58,9 +58,9 @@ load_dstlist(ippool_dst_t *dst, ioctlfunc_t iocfunc, ipf_dstnode_t *nodes)
if ((opts & OPT_REMOVE) != 0) {
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
if ((opts & OPT_DONOTHING) == 0) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"delete destination list table"));
}
}
return(0);
return (0);
}

View File

@ -23,11 +23,11 @@ load_dstlistnode(int role, char *name, ipf_dstnode_t *node,
int err;
if (pool_open() == -1)
return(-1);
return (-1);
dst = calloc(1, sizeof(*dst) + node->ipfd_dest.fd_name);
if (dst == NULL)
return(-1);
return (-1);
op.iplo_unit = role;
op.iplo_type = IPLT_DSTLIST;
@ -59,9 +59,9 @@ load_dstlistnode(int role, char *name, ipf_dstnode_t *node,
char msg[80];
(void) snprintf(msg, sizeof(msg), "%s lookup node", what);
return(ipf_perror_fd(pool_fd(), iocfunc, msg));
return (ipf_perror_fd(pool_fd(), iocfunc, msg));
}
}
return(0);
return (0);
}

View File

@ -20,7 +20,7 @@ load_file(char *filename)
fp = fopen(filename + 7, "r");
if (fp == NULL) {
fprintf(stderr, "load_file cannot open '%s'\n", filename);
return(NULL);
return (NULL);
}
a = NULL;
@ -40,7 +40,7 @@ load_file(char *filename)
linenum, filename);
fclose(fp);
alist_free(rtop);
return(NULL);
return (NULL);
}
/*
@ -92,5 +92,5 @@ load_file(char *filename)
}
fclose(fp);
return(rtop);
return (rtop);
}

View File

@ -25,7 +25,7 @@ load_hash(iphtable_t *iphp, iphtent_t *list, ioctlfunc_t iocfunc)
int n;
if (pool_open() == -1)
return(-1);
return (-1);
for (n = 0, a = list; a != NULL; a = a->ipe_next)
n++;
@ -59,7 +59,7 @@ load_hash(iphtable_t *iphp, iphtent_t *list, ioctlfunc_t iocfunc)
if ((opts & OPT_REMOVE) == 0) {
if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op))
if ((opts & OPT_DONOTHING) == 0) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"add lookup hash table"));
}
}
@ -71,7 +71,7 @@ load_hash(iphtable_t *iphp, iphtent_t *list, ioctlfunc_t iocfunc)
iph.iph_table = calloc(size, sizeof(*iph.iph_table));
if (iph.iph_table == NULL) {
perror("calloc(size, sizeof(*iph.iph_table))");
return(-1);
return (-1);
}
iph.iph_list = list;
printhash(&iph, bcopywrap, iph.iph_name, opts, NULL);
@ -92,9 +92,9 @@ load_hash(iphtable_t *iphp, iphtent_t *list, ioctlfunc_t iocfunc)
if ((opts & OPT_REMOVE) != 0) {
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
if ((opts & OPT_DONOTHING) == 0) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"delete lookup hash table"));
}
}
return(0);
return (0);
}

View File

@ -25,7 +25,7 @@ load_hashnode(int unit, char *name, iphtent_t *node, int ttl,
int err;
if (pool_open() == -1)
return(-1);
return (-1);
op.iplo_type = IPLT_HASH;
op.iplo_unit = unit;
@ -57,7 +57,7 @@ load_hashnode(int unit, char *name, iphtent_t *node, int ttl,
char msg[80];
snprintf(msg, sizeof(msg), "%s node from lookup hash table", what);
return(ipf_perror_fd(pool_fd(), iocfunc, msg));
return (ipf_perror_fd(pool_fd(), iocfunc, msg));
}
return(0);
return (0);
}

View File

@ -42,7 +42,7 @@ load_http(char *url)
if (strlen(url) > MAX_URL_LEN) {
fprintf(stderr, "load_http has a URL > %d bytes?!\n",
MAX_URL_LEN);
return(NULL);
return (NULL);
}
fd = -1;
@ -67,7 +67,7 @@ load_http(char *url)
if (t == NULL) {
fprintf(stderr, "load_http has a malformed URL '%s'\n", url);
free(myurl);
return(NULL);
return (NULL);
}
*t++ = '\0';
@ -77,7 +77,7 @@ load_http(char *url)
if (strlen(s) + strlen(buffer) + 10 > sizeof(buffer)) {
fprintf(stderr, "load_http has a malformed URL '%s'\n", url);
free(myurl);
return(NULL);
return (NULL);
}
u = strchr(s, '@');
@ -204,5 +204,5 @@ done:
free(myurl);
if (fd != -1)
close(fd);
return(rtop);
return (rtop);
}

View File

@ -23,7 +23,7 @@ load_pool(ip_pool_t *plp, ioctlfunc_t iocfunc)
ip_pool_t pool;
if (pool_open() == -1)
return(-1);
return (-1);
op.iplo_unit = plp->ipo_unit;
op.iplo_type = IPLT_POOL;
@ -40,7 +40,7 @@ load_pool(ip_pool_t *plp, ioctlfunc_t iocfunc)
if ((opts & OPT_REMOVE) == 0) {
if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op)) {
if ((opts & OPT_DONOTHING) == 0) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"add lookup table"));
}
}
@ -62,9 +62,9 @@ load_pool(ip_pool_t *plp, ioctlfunc_t iocfunc)
if ((opts & OPT_REMOVE) != 0) {
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
if ((opts & OPT_DONOTHING) == 0) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"delete lookup table"));
}
}
return(0);
return (0);
}

View File

@ -25,7 +25,7 @@ load_poolnode(int role, char *name, ip_pool_node_t *node, int ttl,
int err;
if (pool_open() == -1)
return(-1);
return (-1);
op.iplo_unit = role;
op.iplo_type = IPLT_POOL;
@ -58,9 +58,9 @@ load_poolnode(int role, char *name, ip_pool_node_t *node, int ttl,
snprintf(msg, sizeof(msg), "%s pool node(%s/", what,
inet_ntoa(pn.ipn_addr.adf_addr.in4));
strcat(msg, inet_ntoa(pn.ipn_mask.adf_addr.in4));
return(ipf_perror_fd(pool_fd(), iocfunc, msg));
return (ipf_perror_fd(pool_fd(), iocfunc, msg));
}
}
return(0);
return (0);
}

View File

@ -27,5 +27,5 @@ load_url(char *url)
hosts = load_http(url);
}
return(hosts);
return (hosts);
}

View File

@ -15,5 +15,5 @@ size_t msgdsize(mb_t *orig)
for (m = orig; m != NULL; m = m->mb_next)
sz += m->mb_len;
return(sz);
return (sz);
}

View File

@ -26,12 +26,12 @@ nametokva(char *name, ioctlfunc_t iocfunc)
if ((opts & OPT_DONTOPEN) == 0) {
fd = open(IPL_NAME, O_RDONLY);
if (fd == -1)
return(NULL);
return (NULL);
}
(void) (*iocfunc)(fd, SIOCFUNCL, &res);
if (fd >= 0)
close(fd);
if (res.ipfu_addr == NULL)
res.ipfu_addr = (ipfunc_t)-1;
return(res.ipfu_addr);
return (res.ipfu_addr);
}

View File

@ -16,13 +16,13 @@ ntomask(int family, int nbits, u_32_t *ap)
u_32_t mask;
if (nbits < 0)
return(-1);
return (-1);
switch (family)
{
case AF_INET :
if (nbits > 32 || use_inet6 == 1)
return(-1);
return (-1);
if (nbits == 0) {
mask = 0;
} else {
@ -35,12 +35,12 @@ ntomask(int family, int nbits, u_32_t *ap)
case 0 :
case AF_INET6 :
if ((nbits > 128) || (use_inet6 == -1))
return(-1);
return (-1);
fill6bits(nbits, ap);
break;
default :
return(-1);
return (-1);
}
return(0);
return (0);
}

View File

@ -29,7 +29,7 @@ optname(char ***cp, u_short *sp, int linenum)
if (!io->on_name) {
fprintf(stderr, "%d: unknown IP option name %s\n",
linenum, s);
return(0);
return (0);
}
if (!strcasecmp(s, "sec-class"))
sec = 1;
@ -38,7 +38,7 @@ optname(char ***cp, u_short *sp, int linenum)
if (sec && !*(*cp + 1)) {
fprintf(stderr, "%d: missing security level after sec-class\n",
linenum);
return(0);
return (0);
}
if (sec) {
@ -53,11 +53,11 @@ optname(char ***cp, u_short *sp, int linenum)
fprintf(stderr,
"%d: no such security level: %s\n",
linenum, s);
return(0);
return (0);
}
}
if (smsk)
*sp = smsk;
}
return(msk);
return (msk);
}

View File

@ -17,8 +17,8 @@ getoptbyname(char *optname)
for (io = ionames; io->on_name; io++)
if (!strcasecmp(optname, io->on_name))
return(io->on_bit);
return(-1);
return (io->on_bit);
return (-1);
}
@ -29,6 +29,6 @@ getoptbyvalue(int optval)
for (io = ionames; io->on_name; io++)
if (io->on_value == optval)
return(io->on_bit);
return(-1);
return (io->on_bit);
return (-1);
}

View File

@ -47,5 +47,5 @@ wordtab_t *parsefields(wordtab_t *table, char *arg)
fields[num].w_value = 0;
}
return(fields);
return (fields);
}

View File

@ -268,7 +268,7 @@ parseipfexpr(char *line, char **errorptr)
oplist[0] = asize + 2;
oplist[asize + 1] = IPF_EXP_END;
return(oplist);
return (oplist);
parseerror:
if (errorptr != NULL)
@ -277,5 +277,5 @@ parseerror:
free(oplist);
if (temp != NULL)
free(temp);
return(NULL);
return (NULL);
}

View File

@ -19,7 +19,7 @@ parsewhoisline(char *line, addrfamily_t *addrp, addrfamily_t *maskp)
char *s = NULL;
if (line == NULL)
return(-1);
return (-1);
while (*src != '\0') {
s = strchr(src, '(');
@ -33,7 +33,7 @@ parsewhoisline(char *line, addrfamily_t *addrp, addrfamily_t *maskp)
}
if (s == NULL)
return(-1);
return (-1);
memset(addrp, 0x00, sizeof(*maskp));
memset(maskp, 0x00, sizeof(*maskp));
@ -44,20 +44,20 @@ parsewhoisline(char *line, addrfamily_t *addrp, addrfamily_t *maskp)
s = strchr(s, ')');
if (s == NULL || *++s != ' ')
return(-1);
return (-1);
/*
* Parse the IPv6
*/
if (inet_pton(AF_INET6, s, &a61.in6) != 1)
return(-1);
return (-1);
s = strchr(s, ' ');
if (s == NULL || strncmp(s, " - ", 3))
return(-1);
return (-1);
s += 3;
if (inet_pton(AF_INET6, s, &a62) != 1)
return(-1);
return (-1);
addrp->adf_addr = a61;
addrp->adf_family = AF_INET6;
@ -74,37 +74,37 @@ parsewhoisline(char *line, addrfamily_t *addrp, addrfamily_t *maskp)
* then we can't add it into a pool.
*/
if (count6bits(maskp->adf_addr.i6) == -1)
return(-1);
return (-1);
maskp->adf_family = AF_INET6;
maskp->adf_len = addrp->adf_len;
if (IP6_MASKNEQ(&addrp->adf_addr.in6, &maskp->adf_addr.in6,
&addrp->adf_addr.in6)) {
return(-1);
return (-1);
}
return(0);
return (0);
#else
return(-1);
return (-1);
#endif
}
s = strchr(s, ')');
if (s == NULL || *++s != ' ')
return(-1);
return (-1);
s++;
if (inet_aton(s, &a1) != 1)
return(-1);
return (-1);
s = strchr(s, ' ');
if (s == NULL || strncmp(s, " - ", 3))
return(-1);
return (-1);
s += 3;
if (inet_aton(s, &a2) != 1)
return(-1);
return (-1);
addrp->adf_addr.in4 = a1;
addrp->adf_family = AF_INET;
@ -117,13 +117,13 @@ parsewhoisline(char *line, addrfamily_t *addrp, addrfamily_t *maskp)
* we can't add it into a pool.
*/
if (count4bits(maskp->adf_addr.in4.s_addr) == -1)
return(-1);
return (-1);
maskp->adf_family = AF_INET;
maskp->adf_len = addrp->adf_len;
bzero((char *)maskp + maskp->adf_len, sizeof(*maskp) - maskp->adf_len);
if ((addrp->adf_addr.in4.s_addr & maskp->adf_addr.in4.s_addr) !=
addrp->adf_addr.in4.s_addr)
return(-1);
return(0);
return (-1);
return (0);
}

View File

@ -20,11 +20,11 @@ pool_open(void)
{
if ((opts & OPT_DONTOPEN) != 0)
return(0);
return (0);
if (poolfd == -1)
poolfd = open(IPLOOKUP_NAME, O_RDWR);
return(poolfd);
return (poolfd);
}
int
@ -33,7 +33,7 @@ pool_ioctl(iocfunc, cmd, ptr)
ioctlcmd_t cmd;
void *ptr;
{
return(*iocfunc)(poolfd, cmd, ptr);
return (*iocfunc)(poolfd, cmd, ptr);
}
@ -49,5 +49,5 @@ pool_close(void)
int
pool_fd(void)
{
return(poolfd);
return (poolfd);
}

View File

@ -28,16 +28,16 @@ portname(int pr, int port)
NULL : sv1;
}
if (sv)
return(buf);
return (buf);
} else if ((pr != -2) && (p = getprotobynumber(pr))) {
if ((sv = getservbyport(htons(port), p->p_name))) {
strncpy(buf, sv->s_name, sizeof(buf)-1);
buf[sizeof(buf)-1] = '\0';
return(buf);
return (buf);
}
}
}
(void) snprintf(buf, sizeof(buf), "%d", port);
return(buf);
return (buf);
}

View File

@ -12,5 +12,5 @@ int prependmbt( fr_info_t *fin, mb_t *m)
{
m->mb_next = *fin->fin_mp;
*fin->fin_mp = m;
return(0);
return (0);
}

View File

@ -23,15 +23,15 @@ printdstl_live( ippool_dst_t *d, int fd, char *name, int opts,
ipfobj_t obj;
if ((name != NULL) && strncmp(name, d->ipld_name, FR_GROUPLEN))
return(d->ipld_next);
return (d->ipld_next);
entry = calloc(1, sizeof(*entry) + 64);
if (entry == NULL)
return(d->ipld_next);
return (d->ipld_next);
zero = calloc(1, sizeof(*zero) + 64);
if (zero == NULL) {
free(entry);
return(d->ipld_next);
return (d->ipld_next);
}
if (fields == NULL)
@ -76,5 +76,5 @@ printdstl_live( ippool_dst_t *d, int fd, char *name, int opts,
if ((opts & OPT_DEBUG) == 0)
PRINTF(" };\n");
return(d->ipld_next);
return (d->ipld_next);
}

View File

@ -15,10 +15,10 @@ printdstlist( ippool_dst_t *pp, copyfunc_t copyfunc, char *name, int opts,
ippool_dst_t dst;
if ((*copyfunc)(pp, &dst, sizeof(dst)))
return(NULL);
return (NULL);
if ((name != NULL) && strncmp(name, dst.ipld_name, FR_GROUPLEN))
return(dst.ipld_next);
return (dst.ipld_next);
if (fields == NULL)
printdstlistdata(&dst, opts);
@ -39,7 +39,7 @@ printdstlist( ippool_dst_t *pp, copyfunc_t copyfunc, char *name, int opts,
break;
if ((*copyfunc)(node, n, node->ipfd_size)) {
free(n);
return(NULL);
return (NULL);
}
node = printdstlistnode(n, bcopywrap, opts, fields);
@ -51,5 +51,5 @@ printdstlist( ippool_dst_t *pp, copyfunc_t copyfunc, char *name, int opts,
if ((opts & OPT_DEBUG) == 0)
PRINTF(" };\n");
return(dst.ipld_next);
return (dst.ipld_next);
}

View File

@ -19,13 +19,13 @@ printdstlistnode(ipf_dstnode_t *inp, copyfunc_t copyfunc, int opts,
#endif
if ((*copyfunc)(inp, &node, sizeof(node)))
return(NULL);
return (NULL);
np = calloc(1, node.ipfd_size);
if (np == NULL)
return(node.ipfd_next);
return (node.ipfd_next);
if ((*copyfunc)(inp, np, node.ipfd_size))
return(NULL);
return (NULL);
if (fields != NULL) {
for (i = 0; fields[i].w_value != 0; i++) {
@ -71,5 +71,5 @@ printdstlistnode(ipf_dstnode_t *inp, copyfunc_t copyfunc, int opts,
np->ipfd_names, np->ipfd_uid);
}
free(np);
return(node.ipfd_next);
return (node.ipfd_next);
}

View File

@ -19,10 +19,10 @@ printhash( iphtable_t *hp, copyfunc_t copyfunc, char *name, int opts,
size_t sz;
if ((*copyfunc)((char *)hp, (char *)&iph, sizeof(iph)))
return(NULL);
return (NULL);
if ((name != NULL) && strncmp(name, iph.iph_name, FR_GROUPLEN))
return(iph.iph_next);
return (iph.iph_next);
if (fields == NULL)
printhashdata(hp, opts);
@ -36,7 +36,7 @@ printhash( iphtable_t *hp, copyfunc_t copyfunc, char *name, int opts,
sz = iph.iph_size * sizeof(*table);
table = malloc(sz);
if ((*copyfunc)((char *)iph.iph_table, (char *)table, sz))
return(NULL);
return (NULL);
for (printed = 0, ipep = iph.iph_list; ipep != NULL; ) {
ipep = printhashnode(&iph, ipep, copyfunc, opts, fields);
@ -50,5 +50,5 @@ printhash( iphtable_t *hp, copyfunc_t copyfunc, char *name, int opts,
if ((opts & OPT_DEBUG) == 0)
PRINTF(" };\n");
return(iph.iph_next);
return (iph.iph_next);
}

View File

@ -18,7 +18,7 @@ printhash_live(iphtable_t *hp, int fd, char *name, int opts, wordtab_t *fields)
ipfobj_t obj;
if ((name != NULL) && strncmp(name, hp->iph_name, FR_GROUPLEN))
return(hp->iph_next);
return (hp->iph_next);
if (fields == NULL)
printhashdata(hp, opts);
@ -61,5 +61,5 @@ printhash_live(iphtable_t *hp, int fd, char *name, int opts, wordtab_t *fields)
if ((opts & OPT_DEBUG) == 0)
PRINTF(" };\n");
return(hp->iph_next);
return (hp->iph_next);
}

View File

@ -18,7 +18,7 @@ printhashnode(iphtable_t *iph, iphtent_t *ipep, copyfunc_t copyfunc, int opts,
int i;
if ((*copyfunc)(ipep, &ipe, sizeof(ipe)))
return(NULL);
return (NULL);
hv = IPE_V4_HASH_FN(ipe.ipe_addr.i6[0], ipe.ipe_mask.i6[0],
iph->iph_size);
@ -90,5 +90,5 @@ printhashnode(iphtable_t *iph, iphtent_t *ipep, copyfunc_t copyfunc, int opts,
}
ipep = ipe.ipe_next;
return(ipep);
return (ipep);
}

View File

@ -17,10 +17,10 @@ printpool(ip_pool_t *pp, copyfunc_t copyfunc, char *name, int opts,
ip_pool_t ipp;
if ((*copyfunc)(pp, &ipp, sizeof(ipp)))
return(NULL);
return (NULL);
if ((name != NULL) && strncmp(name, ipp.ipo_name, FR_GROUPLEN))
return(ipp.ipo_next);
return (ipp.ipo_next);
printpooldata(&ipp, opts);
@ -57,5 +57,5 @@ printpool(ip_pool_t *pp, copyfunc_t copyfunc, char *name, int opts,
if ((opts & OPT_DEBUG) == 0)
PRINTF(" };\n");
return(ipp.ipo_next);
return (ipp.ipo_next);
}

View File

@ -19,7 +19,7 @@ printpool_live(ip_pool_t *pool, int fd, char *name, int opts,
ipfobj_t obj;
if ((name != NULL) && strncmp(name, pool->ipo_name, FR_GROUPLEN))
return(pool->ipo_next);
return (pool->ipo_next);
if (fields == NULL)
printpooldata(pool, opts);
@ -63,5 +63,5 @@ printpool_live(ip_pool_t *pool, int fd, char *name, int opts,
(void) ioctl(fd,SIOCIPFDELTOK, &iter.ili_key);
return(pool->ipo_next);
return (pool->ipo_next);
}

View File

@ -64,5 +64,5 @@ printpoolnode(ip_pool_node_t *np, int opts, wordtab_t *fields)
np->ipn_name, np->ipn_ref);
#endif
}
return(np->ipn_next);
return (np->ipn_next);
}

View File

@ -207,7 +207,7 @@ printstate(ipstate_t *sp, int opts, u_long now)
if (kmemcpy((char *)&ipsync, (u_long)sp->is_sync,
sizeof(ipsync))) {
PRINTF("status could not be retrieved\n");
return(NULL);
return (NULL);
}
PRINTF("idx %d num %d v %d pr %d rev %d\n",
@ -217,5 +217,5 @@ printstate(ipstate_t *sp, int opts, u_long now)
PRINTF("not synchronized\n");
}
return(sp->is_next);
return (sp->is_next);
}

View File

@ -22,7 +22,7 @@ remove_hash(iphtable_t *iphp, ioctlfunc_t iocfunc)
iphtable_t iph;
if (pool_open() == -1)
return(-1);
return (-1);
op.iplo_type = IPLT_HASH;
op.iplo_unit = iphp->iph_unit;
@ -40,9 +40,9 @@ remove_hash(iphtable_t *iphp, ioctlfunc_t iocfunc)
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op)) {
if ((opts & OPT_DONOTHING) == 0) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"remove lookup hash table"));
}
}
return(0);
return (0);
}

View File

@ -22,7 +22,7 @@ remove_hashnode(int unit, char *name, iphtent_t *node, ioctlfunc_t iocfunc)
iphtent_t ipe;
if (pool_open() == -1)
return(-1);
return (-1);
op.iplo_type = IPLT_HASH;
op.iplo_unit = unit;
@ -44,9 +44,9 @@ remove_hashnode(int unit, char *name, iphtent_t *node, ioctlfunc_t iocfunc)
if (pool_ioctl(iocfunc, SIOCLOOKUPDELNODE, &op)) {
if (!(opts & OPT_DONOTHING)) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"remove lookup hash node"));
}
}
return(0);
return (0);
}

View File

@ -22,7 +22,7 @@ remove_pool(ip_pool_t *poolp, ioctlfunc_t iocfunc)
ip_pool_t pool;
if (pool_open() == -1)
return(-1);
return (-1);
op.iplo_type = IPLT_POOL;
op.iplo_unit = poolp->ipo_unit;
@ -37,9 +37,9 @@ remove_pool(ip_pool_t *poolp, ioctlfunc_t iocfunc)
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op)) {
if ((opts & OPT_DONOTHING) == 0) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"delete lookup pool"));
}
}
return(0);
return (0);
}

View File

@ -23,7 +23,7 @@ remove_poolnode(int unit, char *name, ip_pool_node_t *node,
iplookupop_t op;
if (pool_open() == -1)
return(-1);
return (-1);
op.iplo_unit = unit;
op.iplo_type = IPLT_POOL;
@ -42,10 +42,10 @@ remove_poolnode(int unit, char *name, ip_pool_node_t *node,
if (pool_ioctl(iocfunc, SIOCLOOKUPDELNODE, &op)) {
if ((opts & OPT_DONOTHING) == 0) {
return(ipf_perror_fd(pool_fd(), iocfunc,
return (ipf_perror_fd(pool_fd(), iocfunc,
"remove lookup pool node"));
}
}
return(0);
return (0);
}

View File

@ -33,10 +33,10 @@ execute_parse(char **strings)
} else {
free(ctx);
return(NULL);
return (NULL);
}
return(ctx);
return (ctx);
}
@ -71,6 +71,6 @@ execute_send(void *ctx, ipmon_msg_t *msg)
fwrite(msg->imm_msg, msg->imm_msglen, 1, fp);
pclose(fp);
}
return(0);
return (0);
}

View File

@ -33,7 +33,7 @@ file_parse(char **strings)
ctx = calloc(1, sizeof(*ctx));
if (ctx == NULL)
return(NULL);
return (NULL);
if (strings[0] != NULL && strings[0][0] != '\0') {
ctx->ref = 1;
@ -53,7 +53,7 @@ file_parse(char **strings)
ctx = NULL;
}
return(ctx);
return (ctx);
}
@ -63,10 +63,10 @@ file_match(void *ctx1, void *ctx2)
file_opts_t *f1 = ctx1, *f2 = ctx2;
if (f1->raw != f2->raw)
return(1);
return (1);
if (strcmp(f1->path, f2->path))
return(1);
return(0);
return (1);
return (0);
}
@ -76,7 +76,7 @@ file_dup(void *ctx)
file_opts_t *f = ctx;
f->ref++;
return(f);
return (f);
}
@ -118,6 +118,6 @@ file_send(void *ctx, ipmon_msg_t *msg)
} else {
fprintf(file->fp, "%s", msg->imm_msg);
}
return(0);
return (0);
}

View File

@ -33,7 +33,7 @@ nothing_parse(char **strings)
ctx = calloc(1, sizeof(void *));
return(ctx);
return (ctx);
}
@ -54,6 +54,6 @@ nothing_send(void *ctx, ipmon_msg_t *msg)
/*
* Do nothing
*/
return(0);
return (0);
}

View File

@ -33,7 +33,7 @@ syslog_parse(char **strings)
ctx = calloc(1, sizeof(*ctx));
if (ctx == NULL)
return(NULL);
return (NULL);
ctx->facpri = -1;
@ -51,7 +51,7 @@ syslog_parse(char **strings)
if (fac == -1) {
free(str);
free(ctx);
return(NULL);
return (NULL);
}
}
@ -60,7 +60,7 @@ syslog_parse(char **strings)
if (pri == -1) {
free(str);
free(ctx);
return(NULL);
return (NULL);
}
}
free(str);
@ -81,7 +81,7 @@ syslog_parse(char **strings)
}
}
return(ctx);
return (ctx);
}
@ -129,5 +129,5 @@ syslog_send(void *ctx, ipmon_msg_t *msg)
}
}
syslog(facpri, "%s", msg->imm_msg);
return(0);
return (0);
}

View File

@ -51,23 +51,23 @@ snmpv1_match(void *ctx1, void *ctx2)
snmpv1_opts_t *s1 = ctx1, *s2 = ctx2;
if (s1->v6 != s2->v6)
return(1);
return (1);
if (strcmp(s1->community, s2->community))
return(1);
return (1);
#ifdef USE_INET6
if (s1->v6 == 1) {
if (memcmp(&s1->sin6, &s2->sin6, sizeof(s1->sin6)))
return(1);
return (1);
} else
#endif
{
if (memcmp(&s1->sin, &s2->sin, sizeof(s1->sin)))
return(1);
return (1);
}
return(0);
return (0);
}
@ -77,7 +77,7 @@ snmpv1_dup(void *ctx)
snmpv1_opts_t *s = ctx;
s->ref++;
return(s);
return (s);
}
@ -110,16 +110,16 @@ snmpv1_parse(char **strings)
char *s;
if (strings[0] == NULL || strings[0][0] == '\0')
return(NULL);
return (NULL);
if (strchr(*strings, ' ') == NULL)
return(NULL);
return (NULL);
str = strdup(*strings);
ctx = calloc(1, sizeof(*ctx));
if (ctx == NULL)
return(NULL);
return (NULL);
ctx->fd = -1;
@ -132,7 +132,7 @@ snmpv1_parse(char **strings)
if (!*s) {
free(str);
free(ctx);
return(NULL);
return (NULL);
}
#ifdef USE_INET6
@ -147,7 +147,7 @@ snmpv1_parse(char **strings)
(struct sockaddr *)&ctx->sin,
sizeof(ctx->sin)) != 0) {
snmpv1_destroy(ctx);
return(NULL);
return (NULL);
}
}
}
@ -163,7 +163,7 @@ snmpv1_parse(char **strings)
(struct sockaddr *)&ctx->sin6,
sizeof(ctx->sin6)) != 0) {
snmpv1_destroy(ctx);
return(NULL);
return (NULL);
}
}
}
@ -178,7 +178,7 @@ snmpv1_parse(char **strings)
if (connect(ctx->fd, (struct sockaddr *)&ctx->sin,
sizeof(ctx->sin)) != 0) {
snmpv1_destroy(ctx);
return(NULL);
return (NULL);
}
}
}
@ -187,12 +187,12 @@ snmpv1_parse(char **strings)
if (result != 1) {
free(str);
free(ctx);
return(NULL);
return (NULL);
}
ctx->ref = 1;
return(ctx);
return (ctx);
}
@ -218,7 +218,7 @@ snmpv1_send(void *ctx, ipmon_msg_t *msg)
{
snmpv1_opts_t *v1 = ctx;
return(sendtrap_v1_0(v1->fd, v1->community,
return (sendtrap_v1_0(v1->fd, v1->community,
msg->imm_msg, msg->imm_msglen, msg->imm_when));
}
@ -232,7 +232,7 @@ writelength(u_char *buffer, u_int value)
if (value < 128) {
*buffer = value;
return(1);
return (1);
}
if (value > 0xffffff)
len = 4;
@ -247,7 +247,7 @@ writelength(u_char *buffer, u_int value)
bcopy((u_char *)&n + 4 - len, buffer + 1, len);
return(len + 1);
return (len + 1);
}
@ -259,7 +259,7 @@ writeint(u_char *buffer, int value)
if (value == 0) {
*buffer = 0;
return(1);
return (1);
}
if (n > 4194304) {
@ -276,7 +276,7 @@ writeint(u_char *buffer, int value)
}
*s++ = (u_char)n;
return(s - buffer);
return (s - buffer);
}
@ -303,7 +303,7 @@ maketrap_v1(char *community, u_char *buffer, int bufsize, u_char *msg,
basesize += strlen(community) + msglen;
if (basesize + 8 > bufsize)
return(0);
return (0);
memset(buffer, 0xff, bufsize);
*s++ = 0x30; /* Sequence */
@ -345,7 +345,7 @@ maketrap_v1(char *community, u_char *buffer, int bufsize, u_char *msg,
*s++ = 0x2;
n = writeint(s + 1, 6);
if (n == 0)
return(0);
return (0);
*s = n;
s += n + 1;
@ -353,7 +353,7 @@ maketrap_v1(char *community, u_char *buffer, int bufsize, u_char *msg,
*s++ = 0x2;
n = writeint(s + 1, 0);
if (n == 0)
return(0);
return (0);
*s = n;
s += n + 1;
@ -422,7 +422,7 @@ maketrap_v1(char *community, u_char *buffer, int bufsize, u_char *msg,
len = t - buffer - baselensz - 1;
writelength(buffer + 1, len); /* length of trap */
return(t - buffer);
return (t - buffer);
}
@ -436,8 +436,8 @@ sendtrap_v1_0(int fd, char *community, char *msg, int msglen, time_t when)
n = maketrap_v1(community, buffer, sizeof(buffer),
(u_char *)msg, msglen, 0, when);
if (n > 0) {
return(send(fd, buffer, n, 0));
return (send(fd, buffer, n, 0));
}
return(0);
return (0);
}

View File

@ -55,23 +55,23 @@ snmpv2_match(void *ctx1, void *ctx2)
snmpv2_opts_t *s1 = ctx1, *s2 = ctx2;
if (s1->v6 != s2->v6)
return(1);
return (1);
if (strcmp(s1->community, s2->community))
return(1);
return (1);
#ifdef USE_INET6
if (s1->v6 == 1) {
if (memcmp(&s1->sin6, &s2->sin6, sizeof(s1->sin6)))
return(1);
return (1);
} else
#endif
{
if (memcmp(&s1->sin, &s2->sin, sizeof(s1->sin)))
return(1);
return (1);
}
return(0);
return (0);
}
@ -81,7 +81,7 @@ snmpv2_dup(void *ctx)
snmpv2_opts_t *s = ctx;
s->ref++;
return(s);
return (s);
}
@ -114,16 +114,16 @@ snmpv2_parse(char **strings)
char *s;
if (strings[0] == NULL || strings[0][0] == '\0')
return(NULL);
return (NULL);
if (strchr(*strings, ' ') == NULL)
return(NULL);
return (NULL);
str = strdup(*strings);
ctx = calloc(1, sizeof(*ctx));
if (ctx == NULL) {
free(str);
return(NULL);
return (NULL);
}
ctx->fd = -1;
@ -137,7 +137,7 @@ snmpv2_parse(char **strings)
if (!*s) {
free(str);
free(ctx);
return(NULL);
return (NULL);
}
#ifdef USE_INET6
@ -152,7 +152,7 @@ snmpv2_parse(char **strings)
(struct sockaddr *)&ctx->sin,
sizeof(ctx->sin)) != 0) {
snmpv2_destroy(ctx);
return(NULL);
return (NULL);
}
}
}
@ -168,7 +168,7 @@ snmpv2_parse(char **strings)
(struct sockaddr *)&ctx->sin6,
sizeof(ctx->sin6)) != 0) {
snmpv2_destroy(ctx);
return(NULL);
return (NULL);
}
}
}
@ -183,7 +183,7 @@ snmpv2_parse(char **strings)
if (connect(ctx->fd, (struct sockaddr *)&ctx->sin,
sizeof(ctx->sin)) != 0) {
snmpv2_destroy(ctx);
return(NULL);
return (NULL);
}
}
}
@ -192,12 +192,12 @@ snmpv2_parse(char **strings)
if (result != 1) {
free(str);
free(ctx);
return(NULL);
return (NULL);
}
ctx->ref = 1;
return(ctx);
return (ctx);
}
@ -223,7 +223,7 @@ snmpv2_send(void *ctx, ipmon_msg_t *msg)
{
snmpv2_opts_t *v2 = ctx;
return(sendtrap_v2_0(v2->fd, v2->community,
return (sendtrap_v2_0(v2->fd, v2->community,
msg->imm_msg, msg->imm_msglen));
}
static int
@ -234,7 +234,7 @@ writelength(u_char *buffer, u_int value)
if (value < 128) {
*buffer = value;
return(1);
return (1);
}
if (value > 0xffffff)
len = 4;
@ -249,7 +249,7 @@ writelength(u_char *buffer, u_int value)
bcopy((u_char *)&n + 4 - len, buffer + 1, len);
return(len + 1);
return (len + 1);
}
@ -261,7 +261,7 @@ writeint(u_char *buffer, int value)
if (value == 0) {
*buffer = 0;
return(1);
return (1);
}
if (n > 4194304) {
@ -278,7 +278,7 @@ writeint(u_char *buffer, int value)
}
*s++ = (u_char)n;
return(s - buffer);
return (s - buffer);
}
@ -306,7 +306,7 @@ maketrap_v2(char *community, u_char *buffer, int bufsize, u_char *msg,
basesize += strlen(community) + msglen;
if (basesize + 8 > bufsize)
return(0);
return (0);
memset(buffer, 0xff, bufsize);
*s++ = 0x30; /* Sequence */
@ -423,7 +423,7 @@ maketrap_v2(char *community, u_char *buffer, int bufsize, u_char *msg,
len = t - buffer - baselensz - 1;
writelength(buffer + 1, len); /* length of trap */
return(t - buffer);
return (t - buffer);
}
@ -437,8 +437,8 @@ sendtrap_v2_0(int fd, char *community, char *msg, int msglen)
n = maketrap_v2(community, buffer, sizeof(buffer),
(u_char *)msg, msglen);
if (n > 0) {
return(send(fd, buffer, n, 0));
return (send(fd, buffer, n, 0));
}
return(0);
return (0);
}

Some files were not shown because too many files have changed in this diff Show More