ipfilter: Adjust userland returns to conform to style(9)
Adjust ipfilter's userland return statements to conform to style(9). MFC after: 1 month
This commit is contained in:
parent
8c82b37461
commit
2582ae5740
@ -26,15 +26,15 @@ int genmask(family, msk, mskp)
|
|||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
case AF_INET6 :
|
case AF_INET6 :
|
||||||
if (inet_pton(AF_INET6, msk, &mskp->in4) != 1)
|
if (inet_pton(AF_INET6, msk, &mskp->in4) != 1)
|
||||||
return -1;
|
return(-1);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case AF_INET :
|
case AF_INET :
|
||||||
if (inet_aton(msk, &mskp->in4) == 0)
|
if (inet_aton(msk, &mskp->in4) == 0)
|
||||||
return -1;
|
return(-1);
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
return -1;
|
return(-1);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -47,12 +47,12 @@ int genmask(family, msk, mskp)
|
|||||||
{
|
{
|
||||||
case AF_INET6 :
|
case AF_INET6 :
|
||||||
if ((*endptr != '\0') || (bits < 0) || (bits > 128))
|
if ((*endptr != '\0') || (bits < 0) || (bits > 128))
|
||||||
return -1;
|
return(-1);
|
||||||
fill6bits(bits, mskp->i6);
|
fill6bits(bits, mskp->i6);
|
||||||
break;
|
break;
|
||||||
case AF_INET :
|
case AF_INET :
|
||||||
if (*endptr != '\0' || bits > 32 || bits < 0)
|
if (*endptr != '\0' || bits > 32 || bits < 0)
|
||||||
return -1;
|
return(-1);
|
||||||
if (bits == 0)
|
if (bits == 0)
|
||||||
addr = 0;
|
addr = 0;
|
||||||
else
|
else
|
||||||
@ -60,9 +60,9 @@ int genmask(family, msk, mskp)
|
|||||||
mskp->in4.s_addr = addr;
|
mskp->in4.s_addr = addr;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
return -1;
|
return(-1);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -1712,7 +1712,7 @@ ipv4_16:
|
|||||||
YY_NUMBER '.' YY_NUMBER
|
YY_NUMBER '.' YY_NUMBER
|
||||||
{ if ($1 > 255 || $3 > 255) {
|
{ if ($1 > 255 || $3 > 255) {
|
||||||
yyerror("Invalid octet string for IP address");
|
yyerror("Invalid octet string for IP address");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
$$.s_addr = ($1 << 24) | ($3 << 16);
|
$$.s_addr = ($1 << 24) | ($3 << 16);
|
||||||
$$.s_addr = htonl($$.s_addr);
|
$$.s_addr = htonl($$.s_addr);
|
||||||
@ -1723,7 +1723,7 @@ ipv4_24:
|
|||||||
ipv4_16 '.' YY_NUMBER
|
ipv4_16 '.' YY_NUMBER
|
||||||
{ if ($3 > 255) {
|
{ if ($3 > 255) {
|
||||||
yyerror("Invalid octet string for IP address");
|
yyerror("Invalid octet string for IP address");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
$$.s_addr |= htonl($3 << 8);
|
$$.s_addr |= htonl($3 << 8);
|
||||||
}
|
}
|
||||||
@ -1732,7 +1732,7 @@ ipv4_24:
|
|||||||
ipv4: ipv4_24 '.' YY_NUMBER
|
ipv4: ipv4_24 '.' YY_NUMBER
|
||||||
{ if ($3 > 255) {
|
{ if ($3 > 255) {
|
||||||
yyerror("Invalid octet string for IP address");
|
yyerror("Invalid octet string for IP address");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
$$.s_addr |= htonl($3);
|
$$.s_addr |= htonl($3);
|
||||||
}
|
}
|
||||||
@ -2003,7 +2003,7 @@ ipf_parsefile(int fd, addfunc_t addfunc, ioctlfunc_t *iocfuncs, char *filename)
|
|||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
fprintf(stderr, "fopen(%s) failed: %s\n", filename,
|
fprintf(stderr, "fopen(%s) failed: %s\n", filename,
|
||||||
STRERROR(errno));
|
STRERROR(errno));
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
@ -2012,7 +2012,7 @@ ipf_parsefile(int fd, addfunc_t addfunc, ioctlfunc_t *iocfuncs, char *filename)
|
|||||||
;
|
;
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2028,14 +2028,14 @@ ipf_parsesome(int fd, addfunc_t addfunc, ioctlfunc_t *iocfuncs, FILE *fp)
|
|||||||
ipfaddfunc = addfunc;
|
ipfaddfunc = addfunc;
|
||||||
|
|
||||||
if (feof(fp))
|
if (feof(fp))
|
||||||
return 0;
|
return(0);
|
||||||
i = fgetc(fp);
|
i = fgetc(fp);
|
||||||
if (i == EOF)
|
if (i == EOF)
|
||||||
return 0;
|
return(0);
|
||||||
if (ungetc(i, fp) == 0)
|
if (ungetc(i, fp) == 0)
|
||||||
return 0;
|
return(0);
|
||||||
if (feof(fp))
|
if (feof(fp))
|
||||||
return 0;
|
return(0);
|
||||||
s = getenv("YYDEBUG");
|
s = getenv("YYDEBUG");
|
||||||
if (s != NULL)
|
if (s != NULL)
|
||||||
yydebug = atoi(s);
|
yydebug = atoi(s);
|
||||||
@ -2044,7 +2044,7 @@ ipf_parsesome(int fd, addfunc_t addfunc, ioctlfunc_t *iocfuncs, FILE *fp)
|
|||||||
|
|
||||||
yyin = fp;
|
yyin = fp;
|
||||||
yyparse();
|
yyparse();
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2121,7 +2121,7 @@ addrule(void)
|
|||||||
for (f1 = frc; count > 0; count--, f1 = f1->fr_next) {
|
for (f1 = frc; count > 0; count--, f1 = f1->fr_next) {
|
||||||
f->fr_next = allocfr();
|
f->fr_next = allocfr();
|
||||||
if (f->fr_next == NULL)
|
if (f->fr_next == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
f->fr_next->fr_pnext = &f->fr_next;
|
f->fr_next->fr_pnext = &f->fr_next;
|
||||||
added++;
|
added++;
|
||||||
f = f->fr_next;
|
f = f->fr_next;
|
||||||
@ -2133,7 +2133,7 @@ addrule(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return f2->fr_next;
|
return(f2->fr_next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2152,15 +2152,15 @@ lookuphost(char *name, i6addr_t *addrp)
|
|||||||
if (strcmp(name, fr->fr_names + fr->fr_ifnames[i]) == 0) {
|
if (strcmp(name, fr->fr_names + fr->fr_ifnames[i]) == 0) {
|
||||||
ifpflag = FRI_DYNAMIC;
|
ifpflag = FRI_DYNAMIC;
|
||||||
dynamic = addname(&fr, name);
|
dynamic = addname(&fr, name);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gethost(AF_INET, name, addrp) == -1) {
|
if (gethost(AF_INET, name, addrp) == -1) {
|
||||||
fprintf(stderr, "unknown name \"%s\"\n", name);
|
fprintf(stderr, "unknown name \"%s\"\n", name);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2274,10 +2274,10 @@ newalist(alist_t *ptr)
|
|||||||
|
|
||||||
al = malloc(sizeof(*al));
|
al = malloc(sizeof(*al));
|
||||||
if (al == NULL)
|
if (al == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
al->al_not = 0;
|
al->al_not = 0;
|
||||||
al->al_next = ptr;
|
al->al_next = ptr;
|
||||||
return al;
|
return(al);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2290,10 +2290,10 @@ makepool(alist_t *list)
|
|||||||
int num;
|
int num;
|
||||||
|
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
top = calloc(1, sizeof(*top));
|
top = calloc(1, sizeof(*top));
|
||||||
if (top == NULL)
|
if (top == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
for (n = top, a = list; (n != NULL) && (a != NULL); a = a->al_next) {
|
for (n = top, a = list; (n != NULL) && (a != NULL); a = a->al_next) {
|
||||||
if (use_inet6 == 1) {
|
if (use_inet6 == 1) {
|
||||||
@ -2334,7 +2334,7 @@ makepool(alist_t *list)
|
|||||||
top = n->ipn_next;
|
top = n->ipn_next;
|
||||||
free(n);
|
free(n);
|
||||||
}
|
}
|
||||||
return num;
|
return(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2347,10 +2347,10 @@ makehash(alist_t *list)
|
|||||||
int num;
|
int num;
|
||||||
|
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
top = calloc(1, sizeof(*top));
|
top = calloc(1, sizeof(*top));
|
||||||
if (top == NULL)
|
if (top == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
for (n = top, a = list; (n != NULL) && (a != NULL); a = a->al_next) {
|
for (n = top, a = list; (n != NULL) && (a != NULL); a = a->al_next) {
|
||||||
if (a->al_family == AF_INET6) {
|
if (a->al_family == AF_INET6) {
|
||||||
@ -2383,7 +2383,7 @@ makehash(alist_t *list)
|
|||||||
top = n->ipe_next;
|
top = n->ipe_next;
|
||||||
free(n);
|
free(n);
|
||||||
}
|
}
|
||||||
return num;
|
return(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2395,7 +2395,7 @@ ipf_addrule(int fd, ioctlfunc_t ioctlfunc, void *ptr)
|
|||||||
ipfobj_t obj;
|
ipfobj_t obj;
|
||||||
|
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
fr = ptr;
|
fr = ptr;
|
||||||
add = 0;
|
add = 0;
|
||||||
@ -2442,7 +2442,7 @@ ipf_addrule(int fd, ioctlfunc_t ioctlfunc, void *ptr)
|
|||||||
|
|
||||||
snprintf(msg, sizeof(msg), "%d:ioctl(zero rule)",
|
snprintf(msg, sizeof(msg), "%d:ioctl(zero rule)",
|
||||||
fr->fr_flineno);
|
fr->fr_flineno);
|
||||||
return ipf_perror_fd(fd, ioctlfunc, msg);
|
return(ipf_perror_fd(fd, ioctlfunc, msg));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef USE_QUAD_T
|
#ifdef USE_QUAD_T
|
||||||
@ -2462,7 +2462,7 @@ ipf_addrule(int fd, ioctlfunc_t ioctlfunc, void *ptr)
|
|||||||
|
|
||||||
snprintf(msg, sizeof(msg), "%d:ioctl(delete rule)",
|
snprintf(msg, sizeof(msg), "%d:ioctl(delete rule)",
|
||||||
fr->fr_flineno);
|
fr->fr_flineno);
|
||||||
return ipf_perror_fd(fd, ioctlfunc, msg);
|
return(ipf_perror_fd(fd, ioctlfunc, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2472,11 +2472,11 @@ ipf_addrule(int fd, ioctlfunc_t ioctlfunc, void *ptr)
|
|||||||
|
|
||||||
snprintf(msg, sizeof(msg), "%d:ioctl(add/insert rule)",
|
snprintf(msg, sizeof(msg), "%d:ioctl(add/insert rule)",
|
||||||
fr->fr_flineno);
|
fr->fr_flineno);
|
||||||
return ipf_perror_fd(fd, ioctlfunc, msg);
|
return(ipf_perror_fd(fd, ioctlfunc, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2609,7 +2609,7 @@ addname(frentry_t **frp, char *name)
|
|||||||
frc = f;
|
frc = f;
|
||||||
*frp = f;
|
*frp = f;
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return -1;
|
return(-1);
|
||||||
if (f->fr_pnext != NULL)
|
if (f->fr_pnext != NULL)
|
||||||
*f->fr_pnext = f;
|
*f->fr_pnext = f;
|
||||||
f->fr_size += nlen;
|
f->fr_size += nlen;
|
||||||
@ -2617,7 +2617,7 @@ addname(frentry_t **frp, char *name)
|
|||||||
f->fr_namelen += nlen;
|
f->fr_namelen += nlen;
|
||||||
strcpy(f->fr_names + pos, name);
|
strcpy(f->fr_names + pos, name);
|
||||||
f->fr_names[f->fr_namelen] = '\0';
|
f->fr_names[f->fr_namelen] = '\0';
|
||||||
return pos;
|
return(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2641,7 +2641,7 @@ allocfr(void)
|
|||||||
fr->fr_rif.fd_name = -1;
|
fr->fr_rif.fd_name = -1;
|
||||||
fr->fr_dif.fd_name = -1;
|
fr->fr_dif.fd_name = -1;
|
||||||
}
|
}
|
||||||
return fr;
|
return(fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,11 +69,11 @@ yygetc(int docont)
|
|||||||
c = yytext[yypos++];
|
c = yytext[yypos++];
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
yylineNum++;
|
yylineNum++;
|
||||||
return c;
|
return(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yypos == YYBUFSIZ)
|
if (yypos == YYBUFSIZ)
|
||||||
return TOOLONG;
|
return(TOOLONG);
|
||||||
|
|
||||||
if (pos >= string_start && pos <= string_end) {
|
if (pos >= string_start && pos <= string_end) {
|
||||||
c = string_val[pos - string_start];
|
c = string_val[pos - string_start];
|
||||||
@ -94,7 +94,7 @@ yygetc(int docont)
|
|||||||
yylast = yypos;
|
yylast = yypos;
|
||||||
yytext[yypos] = '\0';
|
yytext[yypos] = '\0';
|
||||||
|
|
||||||
return c;
|
return(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -118,8 +118,8 @@ yyswallow(int last)
|
|||||||
if (c != EOF)
|
if (c != EOF)
|
||||||
yyunputc(c);
|
yyunputc(c);
|
||||||
if (c == last)
|
if (c == last)
|
||||||
return 0;
|
return(0);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ yytexttochar(void)
|
|||||||
for (i = 0; i < yypos; i++)
|
for (i = 0; i < yypos; i++)
|
||||||
yychars[i] = (char)(yytext[i] & 0xff);
|
yychars[i] = (char)(yytext[i] & 0xff);
|
||||||
yychars[i] = '\0';
|
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] = (char)(yytext[i] & 0xff);
|
||||||
str[i - offset] = '\0';
|
str[i - offset] = '\0';
|
||||||
}
|
}
|
||||||
return str;
|
return(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ yylex(void)
|
|||||||
lnext = 0;
|
lnext = 0;
|
||||||
if ((isbuilding == 0) && !ISALNUM(c)) {
|
if ((isbuilding == 0) && !ISALNUM(c)) {
|
||||||
prior = c;
|
prior = c;
|
||||||
return c;
|
return(c);
|
||||||
}
|
}
|
||||||
goto nextchar;
|
goto nextchar;
|
||||||
}
|
}
|
||||||
@ -333,7 +333,7 @@ yylex(void)
|
|||||||
if (yydebug)
|
if (yydebug)
|
||||||
fprintf(stderr, "reset at EOF\n");
|
fprintf(stderr, "reset at EOF\n");
|
||||||
prior = 0;
|
prior = 0;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strchr("=,/;{}()@", c) != NULL) {
|
if (strchr("=,/;{}()@", c) != NULL) {
|
||||||
@ -599,7 +599,7 @@ yylex(void)
|
|||||||
if (rval == YY_NUMBER)
|
if (rval == YY_NUMBER)
|
||||||
priornum = yylval.num;
|
priornum = yylval.num;
|
||||||
prior = rval;
|
prior = rval;
|
||||||
return rval;
|
return(rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -609,12 +609,12 @@ static wordtab_t *yyfindkey(key)
|
|||||||
wordtab_t *w;
|
wordtab_t *w;
|
||||||
|
|
||||||
if (yywordtab == NULL)
|
if (yywordtab == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
for (w = yywordtab; w->w_word != 0; w++)
|
for (w = yywordtab; w->w_word != 0; w++)
|
||||||
if (strcasecmp(key, w->w_word) == 0)
|
if (strcasecmp(key, w->w_word) == 0)
|
||||||
return w;
|
return(w);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -624,12 +624,12 @@ yykeytostr(int num)
|
|||||||
wordtab_t *w;
|
wordtab_t *w;
|
||||||
|
|
||||||
if (yywordtab == NULL)
|
if (yywordtab == NULL)
|
||||||
return "<unknown>";
|
return("<unknown>");
|
||||||
|
|
||||||
for (w = yywordtab; w->w_word; w++)
|
for (w = yywordtab; w->w_word; w++)
|
||||||
if (w->w_value == num)
|
if (w->w_value == num)
|
||||||
return w->w_word;
|
return(w->w_word);
|
||||||
return "<unknown>";
|
return("<unknown>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -640,7 +640,7 @@ yysettab(wordtab_t *words)
|
|||||||
|
|
||||||
save = yywordtab;
|
save = yywordtab;
|
||||||
yywordtab = words;
|
yywordtab = words;
|
||||||
return save;
|
return(save);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ static int m_xhalf(mb_t *, int, int *);
|
|||||||
(_k) -= len; \
|
(_k) -= len; \
|
||||||
(_m) = (_m)->m_next; \
|
(_m) = (_m)->m_next; \
|
||||||
if ((_m) == 0) \
|
if ((_m) == 0) \
|
||||||
return 0; \
|
return(0); \
|
||||||
len = M_LEN(m); \
|
len = M_LEN(m); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ m_xword(m, k, err)
|
|||||||
cp = MTOD(m, u_char *) + k;
|
cp = MTOD(m, u_char *) + k;
|
||||||
if (len - k >= 4) {
|
if (len - k >= 4) {
|
||||||
*err = 0;
|
*err = 0;
|
||||||
return EXTRACT_LONG(cp);
|
return(EXTRACT_LONG(cp));
|
||||||
}
|
}
|
||||||
m0 = m->m_next;
|
m0 = m->m_next;
|
||||||
if (m0 == NULL || M_LEN(m0) + len - k < 4)
|
if (m0 == NULL || M_LEN(m0) + len - k < 4)
|
||||||
@ -139,17 +139,17 @@ m_xword(m, k, err)
|
|||||||
switch (len - k) {
|
switch (len - k) {
|
||||||
|
|
||||||
case 1:
|
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:
|
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:
|
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:
|
bad:
|
||||||
*err = 1;
|
*err = 1;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -165,16 +165,16 @@ m_xhalf(m, k, err)
|
|||||||
cp = MTOD(m, u_char *) + k;
|
cp = MTOD(m, u_char *) + k;
|
||||||
if (len - k >= 2) {
|
if (len - k >= 2) {
|
||||||
*err = 0;
|
*err = 0;
|
||||||
return EXTRACT_SHORT(cp);
|
return(EXTRACT_SHORT(cp));
|
||||||
}
|
}
|
||||||
m0 = m->m_next;
|
m0 = m->m_next;
|
||||||
if (m0 == NULL)
|
if (m0 == NULL)
|
||||||
goto bad;
|
goto bad;
|
||||||
*err = 0;
|
*err = 0;
|
||||||
return (cp[0] << 8) | MTOD(m0, u_char *)[0];
|
return(cp[0] << 8) | MTOD(m0, u_char *)[0];
|
||||||
bad:
|
bad:
|
||||||
*err = 1;
|
*err = 1;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -209,7 +209,7 @@ bpf_filter(pc, p, wirelen, buflen)
|
|||||||
/*
|
/*
|
||||||
* No filter means accept all.
|
* No filter means accept all.
|
||||||
*/
|
*/
|
||||||
return (u_int)-1;
|
return(u_int)-1;
|
||||||
A = 0;
|
A = 0;
|
||||||
X = 0;
|
X = 0;
|
||||||
--pc;
|
--pc;
|
||||||
@ -218,21 +218,21 @@ bpf_filter(pc, p, wirelen, buflen)
|
|||||||
switch (pc->code) {
|
switch (pc->code) {
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return(0);
|
||||||
case BPF_RET|BPF_K:
|
case BPF_RET|BPF_K:
|
||||||
return (u_int)pc->k;
|
return(u_int)pc->k;
|
||||||
|
|
||||||
case BPF_RET|BPF_A:
|
case BPF_RET|BPF_A:
|
||||||
return (u_int)A;
|
return(u_int)A;
|
||||||
|
|
||||||
case BPF_LD|BPF_W|BPF_ABS:
|
case BPF_LD|BPF_W|BPF_ABS:
|
||||||
k = pc->k;
|
k = pc->k;
|
||||||
if (k + sizeof(int32) > buflen) {
|
if (k + sizeof(int32) > buflen) {
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
A = m_xword(m, k, &merr);
|
A = m_xword(m, k, &merr);
|
||||||
if (merr != 0)
|
if (merr != 0)
|
||||||
return 0;
|
return(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
A = EXTRACT_LONG(&p[k]);
|
A = EXTRACT_LONG(&p[k]);
|
||||||
@ -242,10 +242,10 @@ bpf_filter(pc, p, wirelen, buflen)
|
|||||||
k = pc->k;
|
k = pc->k;
|
||||||
if (k + sizeof(short) > buflen) {
|
if (k + sizeof(short) > buflen) {
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
A = m_xhalf(m, k, &merr);
|
A = m_xhalf(m, k, &merr);
|
||||||
if (merr != 0)
|
if (merr != 0)
|
||||||
return 0;
|
return(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
A = EXTRACT_SHORT(&p[k]);
|
A = EXTRACT_SHORT(&p[k]);
|
||||||
@ -255,7 +255,7 @@ bpf_filter(pc, p, wirelen, buflen)
|
|||||||
k = pc->k;
|
k = pc->k;
|
||||||
if (k >= buflen) {
|
if (k >= buflen) {
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
n = m;
|
n = m;
|
||||||
MINDEX(len, n, k);
|
MINDEX(len, n, k);
|
||||||
A = MTOD(n, u_char *)[k];
|
A = MTOD(n, u_char *)[k];
|
||||||
@ -276,10 +276,10 @@ bpf_filter(pc, p, wirelen, buflen)
|
|||||||
k = X + pc->k;
|
k = X + pc->k;
|
||||||
if (k + sizeof(int32) > buflen) {
|
if (k + sizeof(int32) > buflen) {
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
A = m_xword(m, k, &merr);
|
A = m_xword(m, k, &merr);
|
||||||
if (merr != 0)
|
if (merr != 0)
|
||||||
return 0;
|
return(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
A = EXTRACT_LONG(&p[k]);
|
A = EXTRACT_LONG(&p[k]);
|
||||||
@ -289,10 +289,10 @@ bpf_filter(pc, p, wirelen, buflen)
|
|||||||
k = X + pc->k;
|
k = X + pc->k;
|
||||||
if (k + sizeof(short) > buflen) {
|
if (k + sizeof(short) > buflen) {
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
A = m_xhalf(m, k, &merr);
|
A = m_xhalf(m, k, &merr);
|
||||||
if (merr != 0)
|
if (merr != 0)
|
||||||
return 0;
|
return(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
A = EXTRACT_SHORT(&p[k]);
|
A = EXTRACT_SHORT(&p[k]);
|
||||||
@ -302,7 +302,7 @@ bpf_filter(pc, p, wirelen, buflen)
|
|||||||
k = X + pc->k;
|
k = X + pc->k;
|
||||||
if (k >= buflen) {
|
if (k >= buflen) {
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
n = m;
|
n = m;
|
||||||
MINDEX(len, n, k);
|
MINDEX(len, n, k);
|
||||||
A = MTOD(n, u_char *)[k];
|
A = MTOD(n, u_char *)[k];
|
||||||
@ -315,7 +315,7 @@ bpf_filter(pc, p, wirelen, buflen)
|
|||||||
k = pc->k;
|
k = pc->k;
|
||||||
if (k >= buflen) {
|
if (k >= buflen) {
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return 0;
|
return(0);
|
||||||
n = m;
|
n = m;
|
||||||
MINDEX(len, n, k);
|
MINDEX(len, n, k);
|
||||||
X = (MTOD(n, char *)[k] & 0xf) << 2;
|
X = (MTOD(n, char *)[k] & 0xf) << 2;
|
||||||
@ -398,7 +398,7 @@ bpf_filter(pc, p, wirelen, buflen)
|
|||||||
|
|
||||||
case BPF_ALU|BPF_DIV|BPF_X:
|
case BPF_ALU|BPF_DIV|BPF_X:
|
||||||
if (X == 0)
|
if (X == 0)
|
||||||
return 0;
|
return(0);
|
||||||
A /= X;
|
A /= X;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -486,10 +486,10 @@ bpf_validate(f, len)
|
|||||||
const struct bpf_insn *p;
|
const struct bpf_insn *p;
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return 1;
|
return(1);
|
||||||
|
|
||||||
if (len < 1 || len > BPF_MAXINSNS)
|
if (len < 1 || len > BPF_MAXINSNS)
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
p = &f[i];
|
p = &f[i];
|
||||||
@ -511,23 +511,23 @@ bpf_validate(f, len)
|
|||||||
*/
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
if (p->k >= bpf_maxbufsize)
|
if (p->k >= bpf_maxbufsize)
|
||||||
return 0;
|
return(0);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case BPF_MEM:
|
case BPF_MEM:
|
||||||
if (p->k >= BPF_MEMWORDS)
|
if (p->k >= BPF_MEMWORDS)
|
||||||
return 0;
|
return(0);
|
||||||
break;
|
break;
|
||||||
case BPF_LEN:
|
case BPF_LEN:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BPF_ST:
|
case BPF_ST:
|
||||||
case BPF_STX:
|
case BPF_STX:
|
||||||
if (p->k >= BPF_MEMWORDS)
|
if (p->k >= BPF_MEMWORDS)
|
||||||
return 0;
|
return(0);
|
||||||
break;
|
break;
|
||||||
case BPF_ALU:
|
case BPF_ALU:
|
||||||
switch (BPF_OP(p->code)) {
|
switch (BPF_OP(p->code)) {
|
||||||
@ -544,9 +544,9 @@ bpf_validate(f, len)
|
|||||||
* Check for constant division by 0.
|
* Check for constant division by 0.
|
||||||
*/
|
*/
|
||||||
if (BPF_RVAL(p->code) == BPF_K && p->k == 0)
|
if (BPF_RVAL(p->code) == BPF_K && p->k == 0)
|
||||||
return 0;
|
return(0);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BPF_JMP:
|
case BPF_JMP:
|
||||||
@ -570,17 +570,17 @@ bpf_validate(f, len)
|
|||||||
switch (BPF_OP(p->code)) {
|
switch (BPF_OP(p->code)) {
|
||||||
case BPF_JA:
|
case BPF_JA:
|
||||||
if (from + p->k < from || from + p->k >= len)
|
if (from + p->k < from || from + p->k >= len)
|
||||||
return 0;
|
return(0);
|
||||||
break;
|
break;
|
||||||
case BPF_JEQ:
|
case BPF_JEQ:
|
||||||
case BPF_JGT:
|
case BPF_JGT:
|
||||||
case BPF_JGE:
|
case BPF_JGE:
|
||||||
case BPF_JSET:
|
case BPF_JSET:
|
||||||
if (from + p->jt >= len || from + p->jf >= len)
|
if (from + p->jt >= len || from + p->jf >= len)
|
||||||
return 0;
|
return(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BPF_RET:
|
case BPF_RET:
|
||||||
@ -588,8 +588,8 @@ bpf_validate(f, len)
|
|||||||
case BPF_MISC:
|
case BPF_MISC:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BPF_CLASS(f[len - 1].code) == BPF_RET;
|
return(BPF_CLASS(f[len - 1].code) == BPF_RET);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ typedef struct frentry {
|
|||||||
u_short fr_skip; /* # of rules to skip */
|
u_short fr_skip; /* # of rules to skip */
|
||||||
u_short fr_loglevel; /* syslog log facility + priority */
|
u_short fr_loglevel; /* syslog log facility + priority */
|
||||||
int (*fr_func)(int, ip_t *, fr_info_t *));
|
int (*fr_func)(int, ip_t *, fr_info_t *));
|
||||||
char fr_icode; /* return ICMP code */
|
( char fr_icode; /* return ICMP code */);
|
||||||
char fr_ifname[IFNAMSIZ];
|
char fr_ifname[IFNAMSIZ];
|
||||||
#ifdef BSD
|
#ifdef BSD
|
||||||
char fr_oifname[IFNAMSIZ];
|
char fr_oifname[IFNAMSIZ];
|
||||||
@ -118,8 +118,8 @@ Flags which are recognised in fr_flags:
|
|||||||
FR_LOGP 0x000012 /* Log-pass */
|
FR_LOGP 0x000012 /* Log-pass */
|
||||||
FR_LOGBODY 0x000020 /* log the body of packets too */
|
FR_LOGBODY 0x000020 /* log the body of packets too */
|
||||||
FR_LOGFIRST 0x000040 /* log only the first packet to match */
|
FR_LOGFIRST 0x000040 /* log only the first packet to match */
|
||||||
FR_RETRST 0x000080 /* return a TCP RST packet if blocked */
|
( FR_RETRST 0x000080 /* return a TCP RST packet if blocked */);
|
||||||
FR_RETICMP 0x000100 /* return an ICMP packet if blocked */
|
( FR_RETICMP 0x000100 /* return an ICMP packet if blocked */);
|
||||||
FR_FAKEICMP 0x00180 /* Return ICMP unreachable with fake source */
|
FR_FAKEICMP 0x00180 /* Return ICMP unreachable with fake source */
|
||||||
FR_NOMATCH 0x000200 /* no match occured */
|
FR_NOMATCH 0x000200 /* no match occured */
|
||||||
FR_ACCOUNT 0x000400 /* count packet bytes */
|
FR_ACCOUNT 0x000400 /* count packet bytes */
|
||||||
@ -210,7 +210,7 @@ struct filterstats {
|
|||||||
u_long fr_npkl; /* packets unmatched and logged */
|
u_long fr_npkl; /* packets unmatched and logged */
|
||||||
u_long fr_pkl; /* packets logged */
|
u_long fr_pkl; /* packets logged */
|
||||||
u_long fr_skip; /* packets to be logged but buffer full */
|
u_long fr_skip; /* packets to be logged but buffer full */
|
||||||
u_long fr_ret; /* packets for which a return is sent */
|
( u_long fr_ret; /* packets for which a return is sent */);
|
||||||
u_long fr_acct; /* packets for which counting was performed */
|
u_long fr_acct; /* packets for which counting was performed */
|
||||||
u_long fr_bnfr; /* bad attempts to allocate fragment state */
|
u_long fr_bnfr; /* bad attempts to allocate fragment state */
|
||||||
u_long fr_nfr; /* new fragment state kept */
|
u_long fr_nfr; /* new fragment state kept */
|
||||||
|
@ -108,7 +108,7 @@ auth
|
|||||||
rules cause the matching packet to be queued up for processing by a
|
rules cause the matching packet to be queued up for processing by a
|
||||||
user space program. The user space program is responsible for making
|
user space program. The user space program is responsible for making
|
||||||
an ioctl system call to collect the information about the queued
|
an ioctl system call to collect the information about the queued
|
||||||
packet and another ioctl system call to return the verdict (block,
|
packet( and another ioctl system call to return the verdict (block,);
|
||||||
pass, etc) on what to do with the packet. In the event that the queue
|
pass, etc) on what to do with the packet. In the event that the queue
|
||||||
becomes full, the packets will end up being dropped.
|
becomes full, the packets will end up being dropped.
|
||||||
.HP
|
.HP
|
||||||
@ -224,7 +224,7 @@ To address this problem, a block rule can be qualified in two ways.
|
|||||||
The first of these is specific to TCP and instructs IPFilter to send back
|
The first of these is specific to TCP and instructs IPFilter to send back
|
||||||
a reset (RST) packet. This packet indicates to the remote system that the
|
a reset (RST) packet. This packet indicates to the remote system that the
|
||||||
packet it sent has been rejected and that it shouldn't make any further
|
packet it sent has been rejected and that it shouldn't make any further
|
||||||
attempts to send packets to that port. Telling IPFilter to return a TCP
|
attempts( to send packets to that port. Telling IPFilter to return a TCP);
|
||||||
RST packet in response to something that has been received is achieved
|
RST packet in response to something that has been received is achieved
|
||||||
with the return-rst keyword like this:
|
with the return-rst keyword like this:
|
||||||
.PP
|
.PP
|
||||||
@ -240,18 +240,18 @@ For all of the other protocols handled by the IP protocol suite, to send
|
|||||||
back an error indicating that the received packet was dropped requires
|
back an error indicating that the received packet was dropped requires
|
||||||
sending back an ICMP error packet. Whilst these can also be used for TCP,
|
sending back an ICMP error packet. Whilst these can also be used for TCP,
|
||||||
the sending host may not treat the received ICMP error as a hard error
|
the sending host may not treat the received ICMP error as a hard error
|
||||||
in the same way as it does the TCP RST packet. To return an ICMP error
|
in( the same way as it does the TCP RST packet. To return an ICMP error);
|
||||||
it is necessary to place return-icmp after the block keyword like this:
|
it is necessary to place return-icmp after the block keyword like this:
|
||||||
.PP
|
.PP
|
||||||
.nf
|
.nf
|
||||||
block return-icmp in proto udp from any to 192.168.0.1/24
|
block return-icmp in proto udp from any to 192.168.0.1/24
|
||||||
.fi
|
.fi
|
||||||
.PP
|
.PP
|
||||||
When electing to return an ICMP error packet, it is also possible to
|
When( electing to return an ICMP error packet, it is also possible to);
|
||||||
select what type of ICMP error is returned. Whilst the full compliment
|
select what type of ICMP error is returned. Whilst the full compliment
|
||||||
of ICMP unreachable codes can be used by specifying a number instead of
|
of ICMP unreachable codes can be used by specifying a number instead of
|
||||||
the string below, only the following should be used in conjunction with
|
the string below, only the following should be used in conjunction with
|
||||||
return-icmp. Which return code to use is a choice to be made when
|
return-icmp.( Which return code to use is a choice to be made when);
|
||||||
weighing up the pro's and con's. Using some of the codes may make it
|
weighing up the pro's and con's. Using some of the codes may make it
|
||||||
more obvious that a firewall is being used rather than just the host
|
more obvious that a firewall is being used rather than just the host
|
||||||
not responding.
|
not responding.
|
||||||
|
@ -174,11 +174,11 @@ static int
|
|||||||
opendevice(char *ipfdev, int check)
|
opendevice(char *ipfdev, int check)
|
||||||
{
|
{
|
||||||
if (opts & OPT_DONOTHING)
|
if (opts & OPT_DONOTHING)
|
||||||
return -2;
|
return(-2);
|
||||||
|
|
||||||
if (check && checkrev(ipfname) == -1) {
|
if (check && checkrev(ipfname) == -1) {
|
||||||
fprintf(stderr, "User/kernel version check failed\n");
|
fprintf(stderr, "User/kernel version check failed\n");
|
||||||
return -2;
|
return(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ipfdev)
|
if (!ipfdev)
|
||||||
@ -188,7 +188,7 @@ opendevice(char *ipfdev, int check)
|
|||||||
if ((fd = open(ipfdev, O_RDWR)) == -1)
|
if ((fd = open(ipfdev, O_RDWR)) == -1)
|
||||||
if ((fd = open(ipfdev, O_RDONLY)) == -1)
|
if ((fd = open(ipfdev, O_RDONLY)) == -1)
|
||||||
ipferror(fd, "open device");
|
ipferror(fd, "open device");
|
||||||
return fd;
|
return(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -208,9 +208,9 @@ get_flags(void)
|
|||||||
if ((opendevice(ipfname, 1) != -2) &&
|
if ((opendevice(ipfname, 1) != -2) &&
|
||||||
(ioctl(fd, SIOCGETFF, &i) == -1)) {
|
(ioctl(fd, SIOCGETFF, &i) == -1)) {
|
||||||
ipferror(fd, "SIOCGETFF");
|
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)
|
if (ipf_addrule(fd, ioctlfunc, ptr) != 0)
|
||||||
exitstatus = 1;
|
exitstatus = 1;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -527,13 +527,13 @@ showversion(void)
|
|||||||
|
|
||||||
if ((vfd = open(ipfname, O_RDONLY)) == -1) {
|
if ((vfd = open(ipfname, O_RDONLY)) == -1) {
|
||||||
perror("open device");
|
perror("open device");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(vfd, SIOCGETFS, &ipfo)) {
|
if (ioctl(vfd, SIOCGETFS, &ipfo)) {
|
||||||
ipferror(vfd, "ioctl(SIOCGETFS)");
|
ipferror(vfd, "ioctl(SIOCGETFS)");
|
||||||
close(vfd);
|
close(vfd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
close(vfd);
|
close(vfd);
|
||||||
flags = get_flags();
|
flags = get_flags();
|
||||||
@ -574,5 +574,5 @@ showversion(void)
|
|||||||
printf("Active list: %d\n", fio.f_active);
|
printf("Active list: %d\n", fio.f_active);
|
||||||
printf("Feature mask: %#x\n", fio.f_features);
|
printf("Feature mask: %#x\n", fio.f_features);
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,8 @@ static FILE *cfile = NULL;
|
|||||||
* This is called once per filter rule being loaded to emit data structures
|
* This is called once per filter rule being loaded to emit data structures
|
||||||
* required.
|
* required.
|
||||||
*/
|
*/
|
||||||
void
|
void printc(fr)
|
||||||
printc(frentry_t *fr)
|
frentry_t *fr;
|
||||||
{
|
{
|
||||||
u_long *ulp;
|
u_long *ulp;
|
||||||
char *and;
|
char *and;
|
||||||
@ -162,8 +162,9 @@ printc(frentry_t *fr)
|
|||||||
static frgroup_t *groups = NULL;
|
static frgroup_t *groups = NULL;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void addrule(fp, fr)
|
||||||
addrule(FILE *fp, frentry_t *fr)
|
FILE *fp;
|
||||||
|
frentry_t *fr;
|
||||||
{
|
{
|
||||||
frentry_t *f, **fpp;
|
frentry_t *f, **fpp;
|
||||||
frgroup_t *g;
|
frgroup_t *g;
|
||||||
@ -242,27 +243,30 @@ static u_long ipf%s_rule_data_%s_%u[] = {\n",
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int intcmp(c1, c2)
|
||||||
intcmp(const void *c1, const void *c2)
|
const void *c1, *c2;
|
||||||
{
|
{
|
||||||
const mc_t *i1 = (const mc_t *)c1, *i2 = (const mc_t *)c2;
|
const mc_t *i1 = (const mc_t *)c1, *i2 = (const mc_t *)c2;
|
||||||
|
|
||||||
if (i1->n == i2->n) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void indent(fp, in)
|
||||||
indent(FILE *fp, int in)
|
FILE *fp;
|
||||||
|
int in;
|
||||||
{
|
{
|
||||||
for (; in; in--)
|
for (; in; in--)
|
||||||
fputc('\t', fp);
|
fputc('\t', fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void printeq(fp, var, m, max, v)
|
||||||
printeq(FILE *fp, char *var, int m, int max, int v)
|
FILE *fp;
|
||||||
|
char *var;
|
||||||
|
int m, max, v;
|
||||||
{
|
{
|
||||||
if (m == max)
|
if (m == max)
|
||||||
fprintf(fp, "%s == %#x) {\n", var, v);
|
fprintf(fp, "%s == %#x) {\n", var, v);
|
||||||
@ -276,8 +280,10 @@ printeq(FILE *fp, char *var, int m, int max, int v)
|
|||||||
* m - netmask
|
* m - netmask
|
||||||
* v - required address
|
* v - required address
|
||||||
*/
|
*/
|
||||||
static void
|
static void printipeq(fp, var, fl, m, v)
|
||||||
printipeq(FILE *fp, char *var, int fl, int m, int v)
|
FILE *fp;
|
||||||
|
char *var;
|
||||||
|
int fl, m, v;
|
||||||
{
|
{
|
||||||
if (m == 0xffffffff)
|
if (m == 0xffffffff)
|
||||||
fprintf(fp, "%s ", var);
|
fprintf(fp, "%s ", var);
|
||||||
@ -288,8 +294,10 @@ printipeq(FILE *fp, char *var, int fl, int m, int v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void emit(num, dir, v, fr)
|
||||||
emit(int num, int dir, void *v, frentry_t *fr)
|
int num, dir;
|
||||||
|
void *v;
|
||||||
|
frentry_t *fr;
|
||||||
{
|
{
|
||||||
u_int incnt, outcnt;
|
u_int incnt, outcnt;
|
||||||
frgroup_t *g;
|
frgroup_t *g;
|
||||||
@ -338,8 +346,9 @@ emit(int num, int dir, void *v, frentry_t *fr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void emitheader(grp, incount, outcount)
|
||||||
emitheader(frgroup_t *grp, u_int incount, u_int outcount)
|
frgroup_t *grp;
|
||||||
|
u_int incount, outcount;
|
||||||
{
|
{
|
||||||
static FILE *fph = NULL;
|
static FILE *fph = NULL;
|
||||||
frgroup_t *g;
|
frgroup_t *g;
|
||||||
@ -392,8 +401,7 @@ extern int ipfrule_remove_out_%s(void));\n",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void emittail()
|
||||||
emittail(void)
|
|
||||||
{
|
{
|
||||||
frgroup_t *g;
|
frgroup_t *g;
|
||||||
|
|
||||||
@ -406,10 +414,10 @@ int ipfrule_add()\n\
|
|||||||
fprintf(cfile, "\
|
fprintf(cfile, "\
|
||||||
err = ipfrule_add_%s_%s();\n\
|
err = ipfrule_add_%s_%s();\n\
|
||||||
if (err != 0)\n\
|
if (err != 0)\n\
|
||||||
return err;\n",
|
return(err);\n",
|
||||||
(g->fg_flags & FR_INQUE) ? "in" : "out", g->fg_name);
|
(g->fg_flags & FR_INQUE) ? "in" : "out", g->fg_name);
|
||||||
fprintf(cfile, "\
|
fprintf(cfile, "\
|
||||||
return 0;\n");
|
return(0);\n");
|
||||||
fprintf(cfile, "}\n\
|
fprintf(cfile, "}\n\
|
||||||
\n");
|
\n");
|
||||||
|
|
||||||
@ -422,17 +430,20 @@ int ipfrule_remove()\n\
|
|||||||
fprintf(cfile, "\
|
fprintf(cfile, "\
|
||||||
err = ipfrule_remove_%s_%s();\n\
|
err = ipfrule_remove_%s_%s();\n\
|
||||||
if (err != 0)\n\
|
if (err != 0)\n\
|
||||||
return err;\n",
|
return(err);\n",
|
||||||
(g->fg_flags & FR_INQUE) ? "in" : "out", g->fg_name);
|
(g->fg_flags & FR_INQUE) ? "in" : "out", g->fg_name);
|
||||||
fprintf(cfile, "\
|
fprintf(cfile, "\
|
||||||
return 0;\n");
|
return(0);\n");
|
||||||
fprintf(cfile, "}\n");
|
fprintf(cfile, "}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void emitGroup(num, dir, v, fr, group, incount, outcount)
|
||||||
emitGroup(int num, int dir, void *v, frentry_t *fr, char *group,
|
int num, dir;
|
||||||
u_int incount, u_int outcount)
|
void *v;
|
||||||
|
frentry_t *fr;
|
||||||
|
char *group;
|
||||||
|
u_int incount, outcount;
|
||||||
{
|
{
|
||||||
static FILE *fp = NULL;
|
static FILE *fp = NULL;
|
||||||
static int header[2] = { 0, 0 };
|
static int header[2] = { 0, 0 };
|
||||||
@ -456,7 +467,7 @@ emitGroup(int num, int dir, void *v, frentry_t *fr, char *group,
|
|||||||
fprintf(fp, "}\n");
|
fprintf(fp, "}\n");
|
||||||
}
|
}
|
||||||
if (openfunc == 1) {
|
if (openfunc == 1) {
|
||||||
fprintf(fp, "\treturn fr;\n}\n");
|
fprintf(fp, "\treturn(fr);\n}\n");
|
||||||
openfunc = 0;
|
openfunc = 0;
|
||||||
if (n != NULL) {
|
if (n != NULL) {
|
||||||
free(n);
|
free(n);
|
||||||
@ -477,7 +488,7 @@ emitGroup(int num, int dir, void *v, frentry_t *fr, char *group,
|
|||||||
fprintf(fp, "}\n");
|
fprintf(fp, "}\n");
|
||||||
}
|
}
|
||||||
if (openfunc == 1) {
|
if (openfunc == 1) {
|
||||||
fprintf(fp, "\treturn fr;\n}\n");
|
fprintf(fp, "\treturn(fr);\n}\n");
|
||||||
openfunc = 0;
|
openfunc = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -930,7 +941,7 @@ emitGroup(int num, int dir, void *v, frentry_t *fr, char *group,
|
|||||||
|
|
||||||
indent(fp, in);
|
indent(fp, in);
|
||||||
if (fr->fr_flags & FR_QUICK) {
|
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->fr_flags & FR_INQUE ? "in" : "out",
|
||||||
FR_NAME(fr, fr_group), num);
|
FR_NAME(fr, fr_group), num);
|
||||||
} else {
|
} else {
|
||||||
@ -945,8 +956,8 @@ emitGroup(int num, int dir, void *v, frentry_t *fr, char *group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void printC(dir)
|
||||||
printC(int dir)
|
int dir;
|
||||||
{
|
{
|
||||||
static mc_t *m = NULL;
|
static mc_t *m = NULL;
|
||||||
frgroup_t *g;
|
frgroup_t *g;
|
||||||
@ -968,8 +979,11 @@ printC(int dir)
|
|||||||
/*
|
/*
|
||||||
* Now print out code to implement all of the rules.
|
* Now print out code to implement all of the rules.
|
||||||
*/
|
*/
|
||||||
static void
|
static void printCgroup(dir, top, m, group)
|
||||||
printCgroup(int dir, frentry_t *top, mc_t *m, char *group)
|
int dir;
|
||||||
|
frentry_t *top;
|
||||||
|
mc_t *m;
|
||||||
|
char *group;
|
||||||
{
|
{
|
||||||
frentry_t *fr, *fr1;
|
frentry_t *fr, *fr1;
|
||||||
int i, n, rn;
|
int i, n, rn;
|
||||||
@ -1215,8 +1229,11 @@ printCgroup(int dir, frentry_t *top, mc_t *m, char *group)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void printhooks(fp, in, out, grp)
|
||||||
printhooks(FILE *fp, int in, int out, frgroup_t *grp)
|
FILE *fp;
|
||||||
|
int in;
|
||||||
|
int out;
|
||||||
|
frgroup_t *grp;
|
||||||
{
|
{
|
||||||
frentry_t *fr;
|
frentry_t *fr;
|
||||||
char *group;
|
char *group;
|
||||||
@ -1311,7 +1328,7 @@ int ipfrule_add_%s_%s()\n", instr, group);
|
|||||||
err = frrequest(&ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp,\n\
|
err = frrequest(&ipfmain, IPL_LOGIPF, SIOCADDFR, (caddr_t)fp,\n\
|
||||||
ipfmain.ipf_active, 0);\n",
|
ipfmain.ipf_active, 0);\n",
|
||||||
instr, group);
|
instr, group);
|
||||||
fprintf(fp, "\treturn err;\n}\n");
|
fprintf(fp, "\treturn(err);\n}\n");
|
||||||
|
|
||||||
fprintf(fp, "\n\n\
|
fprintf(fp, "\n\n\
|
||||||
int ipfrule_remove_%s_%s()\n", instr, group);
|
int ipfrule_remove_%s_%s()\n", instr, group);
|
||||||
@ -1348,8 +1365,8 @@ int ipfrule_remove_%s_%s()\n", instr, group);
|
|||||||
instr, group, instr, group, instr, group);
|
instr, group, instr, group, instr, group);
|
||||||
fprintf(fp, "\
|
fprintf(fp, "\
|
||||||
if (err)\n\
|
if (err)\n\
|
||||||
return err;\n\
|
return(err);\n\
|
||||||
\n\n");
|
\n\n");
|
||||||
|
|
||||||
fprintf(fp, "\treturn err;\n}\n");
|
fprintf(fp, "\treturn(err);\n}\n");
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ The ioctls which are for use with logging and don't affect the filter are:
|
|||||||
The SIOCIPFFB ioctl flushes the log buffer and returns the number of bytes
|
The SIOCIPFFB ioctl flushes the log buffer and returns the number of bytes
|
||||||
flushed. FIONREAD returns the number of bytes currently used for storing
|
flushed. FIONREAD returns the number of bytes currently used for storing
|
||||||
log data. If IPFILTER_LOG is not defined when compiling, SIOCIPFFB is not
|
log data. If IPFILTER_LOG is not defined when compiling, SIOCIPFFB is not
|
||||||
available and FIONREAD will return but not do anything.
|
available( and FIONREAD will return but not do anything.);
|
||||||
.PP
|
.PP
|
||||||
There is currently no support for non-blocking IO with this device, meaning
|
There is currently no support for non-blocking IO with this device, meaning
|
||||||
all read operations should be considered blocking in nature (if there is no
|
all read operations should be considered blocking in nature (if there is no
|
||||||
|
@ -142,7 +142,7 @@ int changestateif(char *ifs, char *fname)
|
|||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ int changenatif(char *ifs, char *fname)
|
|||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -286,9 +286,9 @@ int main(int argc, char *argv[])
|
|||||||
if (!filename || ns < 0)
|
if (!filename || ns < 0)
|
||||||
usage();
|
usage();
|
||||||
if (ns == 0)
|
if (ns == 0)
|
||||||
return changenatif(ifs, filename);
|
return(changenatif(ifs, filename));
|
||||||
else
|
else
|
||||||
return changestateif(ifs, filename);
|
return(changestateif(ifs, filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ns >= 0) || (lock >= 0)) {
|
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;
|
int fd = -1;
|
||||||
|
|
||||||
if (opts & OPT_DONOTHING)
|
if (opts & OPT_DONOTHING)
|
||||||
return -2;
|
return(-2);
|
||||||
|
|
||||||
if (!ipfdev)
|
if (!ipfdev)
|
||||||
ipfdev = IPL_NAME;
|
ipfdev = IPL_NAME;
|
||||||
@ -344,7 +344,7 @@ int opendevice(char *ipfdev)
|
|||||||
if ((fd = open(ipfdev, O_RDWR)) == -1)
|
if ((fd = open(ipfdev, O_RDWR)) == -1)
|
||||||
if ((fd = open(ipfdev, O_RDONLY)) == -1)
|
if ((fd = open(ipfdev, O_RDONLY)) == -1)
|
||||||
perror("open device");
|
perror("open device");
|
||||||
return fd;
|
return(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -361,12 +361,12 @@ int setlock(int fd, int lock)
|
|||||||
if (!(opts & OPT_DONOTHING)) {
|
if (!(opts & OPT_DONOTHING)) {
|
||||||
if (ioctl(fd, SIOCSTLCK, &lock) == -1) {
|
if (ioctl(fd, SIOCSTLCK, &lock) == -1) {
|
||||||
perror("SIOCSTLCK");
|
perror("SIOCSTLCK");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
if (opts & OPT_VERBOSE)
|
if (opts & OPT_VERBOSE)
|
||||||
printf("Lock now %s\n", lock ? "on" : "off");
|
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) {
|
if (wfd == -1) {
|
||||||
fprintf(stderr, "%s ", file);
|
fprintf(stderr, "%s ", file);
|
||||||
perror("state:open");
|
perror("state:open");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipsp = &ips;
|
ipsp = &ips;
|
||||||
@ -404,19 +404,19 @@ int writestate(int fd, char *file)
|
|||||||
break;
|
break;
|
||||||
perror("state:SIOCSTGET");
|
perror("state:SIOCSTGET");
|
||||||
close(wfd);
|
close(wfd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
if (opts & OPT_VERBOSE)
|
if (opts & OPT_VERBOSE)
|
||||||
printf("Got state next %p\n", ips.ips_next);
|
printf("Got state next %p\n", ips.ips_next);
|
||||||
if (write(wfd, ipsp, sizeof(ips)) != sizeof(ips)) {
|
if (write(wfd, ipsp, sizeof(ips)) != sizeof(ips)) {
|
||||||
perror("state:write");
|
perror("state:write");
|
||||||
close(wfd);
|
close(wfd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
} while (ips.ips_next != NULL);
|
} while (ips.ips_next != NULL);
|
||||||
close(wfd);
|
close(wfd);
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -433,7 +433,7 @@ int readstate(int fd, char *file)
|
|||||||
if (sfd == -1) {
|
if (sfd == -1) {
|
||||||
fprintf(stderr, "%s ", file);
|
fprintf(stderr, "%s ", file);
|
||||||
perror("open");
|
perror("open");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bzero((char *)&ips, sizeof(ips));
|
bzero((char *)&ips, sizeof(ips));
|
||||||
@ -522,7 +522,7 @@ int readstate(int fd, char *file)
|
|||||||
free(is);
|
free(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
freeipshead:
|
freeipshead:
|
||||||
while ((is = ipshead) != NULL) {
|
while ((is = ipshead) != NULL) {
|
||||||
@ -531,7 +531,7 @@ int readstate(int fd, char *file)
|
|||||||
}
|
}
|
||||||
if (sfd != -1)
|
if (sfd != -1)
|
||||||
close(sfd);
|
close(sfd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -556,7 +556,7 @@ int readnat(int fd, char *file)
|
|||||||
if (nfd == -1) {
|
if (nfd == -1) {
|
||||||
fprintf(stderr, "%s ", file);
|
fprintf(stderr, "%s ", file);
|
||||||
perror("nat:open");
|
perror("nat:open");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bzero((char *)&ipn, sizeof(ipn));
|
bzero((char *)&ipn, sizeof(ipn));
|
||||||
@ -652,7 +652,7 @@ int readnat(int fd, char *file)
|
|||||||
if (ioctl(fd, SIOCSTPUT, &obj)) {
|
if (ioctl(fd, SIOCSTPUT, &obj)) {
|
||||||
fprintf(stderr, "in=%p:", in);
|
fprintf(stderr, "in=%p:", in);
|
||||||
perror("SIOCSTPUT");
|
perror("SIOCSTPUT");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nat->nat_flags & SI_NEWFR) {
|
if (nat->nat_flags & SI_NEWFR) {
|
||||||
@ -667,7 +667,7 @@ int readnat(int fd, char *file)
|
|||||||
free(in);
|
free(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
freenathead:
|
freenathead:
|
||||||
while ((in = ipnhead) != NULL) {
|
while ((in = ipnhead) != NULL) {
|
||||||
@ -676,7 +676,7 @@ int readnat(int fd, char *file)
|
|||||||
}
|
}
|
||||||
if (nfd != -1)
|
if (nfd != -1)
|
||||||
close(nfd);
|
close(nfd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -694,7 +694,7 @@ int writenat(int fd, char *file)
|
|||||||
if (nfd == -1) {
|
if (nfd == -1) {
|
||||||
fprintf(stderr, "%s ", file);
|
fprintf(stderr, "%s ", file);
|
||||||
perror("nat:open");
|
perror("nat:open");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.ipfo_rev = IPFILTER_VERSION;
|
obj.ipfo_rev = IPFILTER_VERSION;
|
||||||
@ -710,7 +710,7 @@ int writenat(int fd, char *file)
|
|||||||
close(nfd);
|
close(nfd);
|
||||||
if (ipnp != NULL)
|
if (ipnp != NULL)
|
||||||
free(ipnp);
|
free(ipnp);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts & OPT_VERBOSE)
|
if (opts & OPT_VERBOSE)
|
||||||
@ -740,7 +740,7 @@ int writenat(int fd, char *file)
|
|||||||
perror("nat:SIOCSTGET");
|
perror("nat:SIOCSTGET");
|
||||||
close(nfd);
|
close(nfd);
|
||||||
free(ipnp);
|
free(ipnp);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts & OPT_VERBOSE)
|
if (opts & OPT_VERBOSE)
|
||||||
@ -750,7 +750,7 @@ int writenat(int fd, char *file)
|
|||||||
perror("nat:write");
|
perror("nat:write");
|
||||||
close(nfd);
|
close(nfd);
|
||||||
free(ipnp);
|
free(ipnp);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
next = ipnp->ipn_next;
|
next = ipnp->ipn_next;
|
||||||
} while (ipnp && next);
|
} while (ipnp && next);
|
||||||
@ -758,7 +758,7 @@ int writenat(int fd, char *file)
|
|||||||
free(ipnp);
|
free(ipnp);
|
||||||
close(nfd);
|
close(nfd);
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -772,15 +772,15 @@ int writeall(char *dirname)
|
|||||||
if (chdir(dirname)) {
|
if (chdir(dirname)) {
|
||||||
fprintf(stderr, "IPF_SAVEDIR=%s: ", dirname);
|
fprintf(stderr, "IPF_SAVEDIR=%s: ", dirname);
|
||||||
perror("chdir(IPF_SAVEDIR)");
|
perror("chdir(IPF_SAVEDIR)");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = opendevice(NULL);
|
fd = opendevice(NULL);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return 1;
|
return(1);
|
||||||
if (setlock(fd, 1)) {
|
if (setlock(fd, 1)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
devfd = opendevice(IPSTATE_NAME);
|
devfd = opendevice(IPSTATE_NAME);
|
||||||
@ -799,16 +799,16 @@ int writeall(char *dirname)
|
|||||||
|
|
||||||
if (setlock(fd, 0)) {
|
if (setlock(fd, 0)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
setlock(fd, 0);
|
setlock(fd, 0);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -821,35 +821,35 @@ int readall(char *dirname)
|
|||||||
|
|
||||||
if (chdir(dirname)) {
|
if (chdir(dirname)) {
|
||||||
perror("chdir(IPF_SAVEDIR)");
|
perror("chdir(IPF_SAVEDIR)");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = opendevice(NULL);
|
fd = opendevice(NULL);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return 1;
|
return(1);
|
||||||
if (setlock(fd, 1)) {
|
if (setlock(fd, 1)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
devfd = opendevice(IPSTATE_NAME);
|
devfd = opendevice(IPSTATE_NAME);
|
||||||
if (devfd == -1)
|
if (devfd == -1)
|
||||||
return 1;
|
return(1);
|
||||||
if (readstate(devfd, NULL))
|
if (readstate(devfd, NULL))
|
||||||
return 1;
|
return(1);
|
||||||
close(devfd);
|
close(devfd);
|
||||||
|
|
||||||
devfd = opendevice(IPNAT_NAME);
|
devfd = opendevice(IPNAT_NAME);
|
||||||
if (devfd == -1)
|
if (devfd == -1)
|
||||||
return 1;
|
return(1);
|
||||||
if (readnat(devfd, NULL))
|
if (readnat(devfd, NULL))
|
||||||
return 1;
|
return(1);
|
||||||
close(devfd);
|
close(devfd);
|
||||||
|
|
||||||
if (setlock(fd, 0)) {
|
if (setlock(fd, 0)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
showstats(fiop, frf);
|
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)");
|
ipferror(ipf_fd, "ioctl(SIOCIPFITER)");
|
||||||
num = IPFGENITER_IPF;
|
num = IPFGENITER_IPF;
|
||||||
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &num);
|
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &num);
|
||||||
return rules;
|
return(rules);
|
||||||
}
|
}
|
||||||
if (bcmp(fp, &zero, sizeof(zero)) == 0)
|
if (bcmp(fp, &zero, sizeof(zero)) == 0)
|
||||||
break;
|
break;
|
||||||
@ -891,7 +891,7 @@ printlivelist( struct friostat *fiop, int out, int set, frentry_t *fp,
|
|||||||
num = IPFGENITER_IPF;
|
num = IPFGENITER_IPF;
|
||||||
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &num);
|
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &num);
|
||||||
|
|
||||||
return rules;
|
return(rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1941,17 +1941,17 @@ static char *getip(int v, i6addr_t *addr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (v == 0)
|
if (v == 0)
|
||||||
return ("any");
|
return("any");
|
||||||
|
|
||||||
if (v == 4)
|
if (v == 4)
|
||||||
return inet_ntoa(addr->in4);
|
return(inet_ntoa(addr->in4));
|
||||||
|
|
||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
(void) inet_ntop(AF_INET6, &addr->in6, hostbuf, sizeof(hostbuf) - 1);
|
(void) inet_ntop(AF_INET6, &addr->in6, hostbuf, sizeof(hostbuf) - 1);
|
||||||
hostbuf[MAXHOSTNAMELEN] = '\0';
|
hostbuf[MAXHOSTNAMELEN] = '\0';
|
||||||
return hostbuf;
|
return(hostbuf);
|
||||||
#else
|
#else
|
||||||
return "IPv6";
|
return("IPv6");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1973,7 +1973,7 @@ static char *ttl_to_string(long int ttl)
|
|||||||
snprintf(ttlbuf, sizeof(ttlbuf), "%2d:%02d:%02d", hours, minutes, seconds);
|
snprintf(ttlbuf, sizeof(ttlbuf), "%2d:%02d:%02d", hours, minutes, seconds);
|
||||||
else
|
else
|
||||||
snprintf(ttlbuf, sizeof(ttlbuf), "%2d:%02d", minutes, seconds);
|
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;
|
register const statetop_t *bp = b;
|
||||||
|
|
||||||
if (ap->st_pkts == bp->st_pkts)
|
if (ap->st_pkts == bp->st_pkts)
|
||||||
return 0;
|
return(0);
|
||||||
else if (ap->st_pkts < bp->st_pkts)
|
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;
|
register const statetop_t *bp = b;
|
||||||
|
|
||||||
if (ap->st_bytes == bp->st_bytes)
|
if (ap->st_bytes == bp->st_bytes)
|
||||||
return 0;
|
return(0);
|
||||||
else if (ap->st_bytes < bp->st_bytes)
|
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;
|
register const statetop_t *bp = b;
|
||||||
|
|
||||||
if (ap->st_p == bp->st_p)
|
if (ap->st_p == bp->st_p)
|
||||||
return 0;
|
return(0);
|
||||||
else if (ap->st_p < bp->st_p)
|
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;
|
register const statetop_t *bp = b;
|
||||||
|
|
||||||
if (ap->st_age == bp->st_age)
|
if (ap->st_age == bp->st_age)
|
||||||
return 0;
|
return(0);
|
||||||
else if (ap->st_age < bp->st_age)
|
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)
|
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
|
#ifdef USE_INET6
|
||||||
if (use_inet6 && !use_inet4) {
|
if (use_inet6 && !use_inet4) {
|
||||||
if (IP6_EQ(&ap->st_src, &bp->st_src))
|
if (IP6_EQ(&ap->st_src, &bp->st_src))
|
||||||
return 0;
|
return(0);
|
||||||
else if (IP6_GT(&ap->st_src, &bp->st_src))
|
else if (IP6_GT(&ap->st_src, &bp->st_src))
|
||||||
return 1;
|
return(1);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (ntohl(ap->st_src.in4.s_addr) ==
|
if (ntohl(ap->st_src.in4.s_addr) ==
|
||||||
ntohl(bp->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) >
|
else if (ntohl(ap->st_src.in4.s_addr) >
|
||||||
ntohl(bp->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)
|
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;
|
register const statetop_t *bp = b;
|
||||||
|
|
||||||
if (htons(ap->st_sport) == htons(bp->st_sport))
|
if (htons(ap->st_sport) == htons(bp->st_sport))
|
||||||
return 0;
|
return(0);
|
||||||
else if (htons(ap->st_sport) > htons(bp->st_sport))
|
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)
|
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
|
#ifdef USE_INET6
|
||||||
if (use_inet6 && !use_inet4) {
|
if (use_inet6 && !use_inet4) {
|
||||||
if (IP6_EQ(&ap->st_dst, &bp->st_dst))
|
if (IP6_EQ(&ap->st_dst, &bp->st_dst))
|
||||||
return 0;
|
return(0);
|
||||||
else if (IP6_GT(&ap->st_dst, &bp->st_dst))
|
else if (IP6_GT(&ap->st_dst, &bp->st_dst))
|
||||||
return 1;
|
return(1);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (ntohl(ap->st_dst.in4.s_addr) ==
|
if (ntohl(ap->st_dst.in4.s_addr) ==
|
||||||
ntohl(bp->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) >
|
else if (ntohl(ap->st_dst.in4.s_addr) >
|
||||||
ntohl(bp->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)
|
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;
|
register const statetop_t *bp = b;
|
||||||
|
|
||||||
if (htons(ap->st_dport) == htons(bp->st_dport))
|
if (htons(ap->st_dport) == htons(bp->st_dport))
|
||||||
return 0;
|
return(0);
|
||||||
else if (htons(ap->st_dport) > htons(bp->st_dport))
|
else if (htons(ap->st_dport) > htons(bp->st_dport))
|
||||||
return 1;
|
return(1);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -2121,16 +2121,16 @@ ipstate_t *fetchstate(ipstate_t *src, ipstate_t *dst)
|
|||||||
state.igi_data = dst;
|
state.igi_data = dst;
|
||||||
|
|
||||||
if (ioctl(state_fd, SIOCGENITER, &obj) != 0)
|
if (ioctl(state_fd, SIOCGENITER, &obj) != 0)
|
||||||
return NULL;
|
return(NULL);
|
||||||
if (dst->is_next == NULL) {
|
if (dst->is_next == NULL) {
|
||||||
int n = IPFGENITER_STATE;
|
int n = IPFGENITER_STATE;
|
||||||
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &n);
|
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &n);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (kmemcpy((char *)dst, (u_long)src, sizeof(*dst)))
|
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;
|
frag.igi_data = frp;
|
||||||
|
|
||||||
if (ioctl(fd, SIOCGENITER, &obj))
|
if (ioctl(fd, SIOCGENITER, &obj))
|
||||||
return EFAULT;
|
return(EFAULT);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2295,7 +2295,7 @@ static int state_matcharray(ipstate_t *stp, int *array)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return(rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ int
|
|||||||
ipfattach(softc)
|
ipfattach(softc)
|
||||||
ipf_main_softc_t *softc;
|
ipf_main_softc_t *softc;
|
||||||
{
|
{
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ int
|
|||||||
ipfdetach(softc)
|
ipfdetach(softc)
|
||||||
ipf_main_softc_t *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);
|
error = ipf_ioctlswitch(softc, unit, data, cmd, mode, uid, NULL);
|
||||||
if (error != -1) {
|
if (error != -1) {
|
||||||
SPL_X(s);
|
SPL_X(s);
|
||||||
return error;
|
return(error);
|
||||||
}
|
}
|
||||||
SPL_X(s);
|
SPL_X(s);
|
||||||
return error;
|
return(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ no_output(ifp, m, s, rt)
|
|||||||
struct mbuf *m;
|
struct mbuf *m;
|
||||||
struct sockaddr *s;
|
struct sockaddr *s;
|
||||||
{
|
{
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -143,11 +143,11 @@ write_output(ifp, m, s, rt)
|
|||||||
fd = open(fname, O_WRONLY|O_APPEND);
|
fd = open(fname, O_WRONLY|O_APPEND);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
perror("open");
|
perror("open");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
write(fd, (char *)ip, ntohs(ip->ip_len));
|
write(fd, (char *)ip, ntohs(ip->ip_len));
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ get_unit(name, family)
|
|||||||
defined(__FreeBSD__)
|
defined(__FreeBSD__)
|
||||||
|
|
||||||
if (!*name)
|
if (!*name)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = "anon0";
|
name = "anon0";
|
||||||
@ -230,7 +230,7 @@ get_unit(name, family)
|
|||||||
if (!strcmp(name, ifp->if_xname)) {
|
if (!strcmp(name, ifp->if_xname)) {
|
||||||
if (addr != NULL)
|
if (addr != NULL)
|
||||||
ipf_setifpaddr(ifp, addr);
|
ipf_setifpaddr(ifp, addr);
|
||||||
return ifp;
|
return(ifp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -248,7 +248,7 @@ get_unit(name, family)
|
|||||||
if (!strcmp(name, ifname)) {
|
if (!strcmp(name, ifname)) {
|
||||||
if (addr != NULL)
|
if (addr != NULL)
|
||||||
ipf_setifpaddr(ifp, addr);
|
ipf_setifpaddr(ifp, addr);
|
||||||
return ifp;
|
return(ifp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -256,12 +256,12 @@ get_unit(name, family)
|
|||||||
if (!ifneta) {
|
if (!ifneta) {
|
||||||
ifneta = (struct ifnet **)malloc(sizeof(ifp) * 2);
|
ifneta = (struct ifnet **)malloc(sizeof(ifp) * 2);
|
||||||
if (!ifneta)
|
if (!ifneta)
|
||||||
return NULL;
|
return(NULL);
|
||||||
ifneta[1] = NULL;
|
ifneta[1] = NULL;
|
||||||
ifneta[0] = (struct ifnet *)calloc(1, sizeof(*ifp));
|
ifneta[0] = (struct ifnet *)calloc(1, sizeof(*ifp));
|
||||||
if (!ifneta[0]) {
|
if (!ifneta[0]) {
|
||||||
free(ifneta);
|
free(ifneta);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
nifs = 1;
|
nifs = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -272,13 +272,13 @@ get_unit(name, family)
|
|||||||
if (!ifneta) {
|
if (!ifneta) {
|
||||||
free(old_ifneta);
|
free(old_ifneta);
|
||||||
nifs = 0;
|
nifs = 0;
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
ifneta[nifs] = NULL;
|
ifneta[nifs] = NULL;
|
||||||
ifneta[nifs - 1] = (struct ifnet *)malloc(sizeof(*ifp));
|
ifneta[nifs - 1] = (struct ifnet *)malloc(sizeof(*ifp));
|
||||||
if (!ifneta[nifs - 1]) {
|
if (!ifneta[nifs - 1]) {
|
||||||
nifs--;
|
nifs--;
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifp = ifneta[nifs - 1];
|
ifp = ifneta[nifs - 1];
|
||||||
@ -314,7 +314,7 @@ get_unit(name, family)
|
|||||||
ipf_setifpaddr(ifp, addr);
|
ipf_setifpaddr(ifp, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ifp;
|
return(ifp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ get_ifname(ifp)
|
|||||||
else
|
else
|
||||||
strcpy(ifname, ifp->if_name);
|
strcpy(ifname, ifp->if_name);
|
||||||
#endif
|
#endif
|
||||||
return ifname;
|
return(ifname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ ipf_fastroute(m, mpp, fin, fdp)
|
|||||||
ifp = fdp->fd_ptr;
|
ifp = fdp->fd_ptr;
|
||||||
|
|
||||||
if (ifp == NULL)
|
if (ifp == NULL)
|
||||||
return 0; /* no routing table out here */
|
return(0; /* no routing table out here */);
|
||||||
|
|
||||||
if (fin->fin_out == 0) {
|
if (fin->fin_out == 0) {
|
||||||
fin->fin_ifp = ifp;
|
fin->fin_ifp = ifp;
|
||||||
@ -433,7 +433,7 @@ ipf_fastroute(m, mpp, fin, fdp)
|
|||||||
done:
|
done:
|
||||||
fin->fin_ifp = sifp;
|
fin->fin_ifp = sifp;
|
||||||
fin->fin_out = sout;
|
fin->fin_out = sout;
|
||||||
return error;
|
return(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ ipf_send_reset(fin)
|
|||||||
fr_info_t *fin;
|
fr_info_t *fin;
|
||||||
{
|
{
|
||||||
ipfkverbose("- TCP RST sent\n");
|
ipfkverbose("- TCP RST sent\n");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ ipf_send_icmp_err(type, fin, dst)
|
|||||||
int dst;
|
int dst;
|
||||||
{
|
{
|
||||||
ipfkverbose("- ICMP unreachable sent\n");
|
ipfkverbose("- ICMP unreachable sent\n");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -510,9 +510,9 @@ ipfuiomove(buf, len, rwflag, uio)
|
|||||||
ioc++;
|
ioc++;
|
||||||
}
|
}
|
||||||
if (left > 0)
|
if (left > 0)
|
||||||
return EFAULT;
|
return(EFAULT);
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -552,7 +552,7 @@ ipf_newisn(fin)
|
|||||||
*/
|
*/
|
||||||
iss_seq_off += 0x00010000;
|
iss_seq_off += 0x00010000;
|
||||||
newiss += iss_seq_off;
|
newiss += iss_seq_off;
|
||||||
return newiss;
|
return(newiss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -582,7 +582,7 @@ ipf_nextipid(fin)
|
|||||||
id = ipid++;
|
id = ipid++;
|
||||||
MUTEX_EXIT(&softc->ipf_rw);
|
MUTEX_EXIT(&softc->ipf_rw);
|
||||||
|
|
||||||
return id;
|
return(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -592,13 +592,13 @@ ipf_checkv4sum(fin)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (fin->fin_flx & FI_SHORT)
|
if (fin->fin_flx & FI_SHORT)
|
||||||
return 1;
|
return(1);
|
||||||
|
|
||||||
if (ipf_checkl4sum(fin) == -1) {
|
if (ipf_checkl4sum(fin) == -1) {
|
||||||
fin->fin_flx |= FI_BAD;
|
fin->fin_flx |= FI_BAD;
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -608,13 +608,13 @@ ipf_checkv6sum(fin)
|
|||||||
fr_info_t *fin;
|
fr_info_t *fin;
|
||||||
{
|
{
|
||||||
if (fin->fin_flx & FI_SHORT)
|
if (fin->fin_flx & FI_SHORT)
|
||||||
return 1;
|
return(1);
|
||||||
|
|
||||||
if (ipf_checkl4sum(fin) == -1) {
|
if (ipf_checkl4sum(fin) == -1) {
|
||||||
fin->fin_flx |= FI_BAD;
|
fin->fin_flx |= FI_BAD;
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ copyoutptr(softc, src, dst, size)
|
|||||||
|
|
||||||
bcopy(dst, (char *)&ca, sizeof(ca));
|
bcopy(dst, (char *)&ca, sizeof(ca));
|
||||||
bcopy(src, ca, size);
|
bcopy(src, ca, size);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -648,13 +648,13 @@ copyinptr(src, dst, size)
|
|||||||
|
|
||||||
bcopy(src, (char *)&ca, sizeof(ca));
|
bcopy(src, (char *)&ca, sizeof(ca));
|
||||||
bcopy(ca, dst, size);
|
bcopy(ca, dst, size);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return the first IP Address associated with an interface
|
* return the first IP Address associated with an interface
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ipf_ifpaddr(softc, v, atype, ifptr, inp, inpmask)
|
ipf_ifpaddr(softc, v, atype, ifptr, inp, inpmask)
|
||||||
@ -679,8 +679,8 @@ ipf_ifpaddr(softc, v, atype, ifptr, inp, inpmask)
|
|||||||
|
|
||||||
sin = (struct sockaddr_in *)&ifa->ifa_addr;
|
sin = (struct sockaddr_in *)&ifa->ifa_addr;
|
||||||
|
|
||||||
return ipf_ifpfillv4addr(atype, sin, &mask,
|
return(ipf_ifpfillv4addr(atype, sin, &mask,
|
||||||
&inp->in4, &inpmask->in4);
|
&inp->in4, &inpmask->in4));
|
||||||
}
|
}
|
||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
if (v == 6) {
|
if (v == 6) {
|
||||||
@ -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[1] = 0xffffffff;
|
||||||
((i6addr_t *)&mask.sin6_addr)->i6[2] = 0xffffffff;
|
((i6addr_t *)&mask.sin6_addr)->i6[2] = 0xffffffff;
|
||||||
((i6addr_t *)&mask.sin6_addr)->i6[3] = 0xffffffff;
|
((i6addr_t *)&mask.sin6_addr)->i6[3] = 0xffffffff;
|
||||||
return ipf_ifpfillv6addr(atype, sin6, &mask,
|
return(ipf_ifpfillv6addr(atype, sin6, &mask,
|
||||||
inp, inpmask);
|
inp, inpmask));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -744,7 +744,7 @@ ipf_random()
|
|||||||
number ^= last;
|
number ^= last;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return number;
|
return(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -752,7 +752,7 @@ int
|
|||||||
ipf_verifysrc(fin)
|
ipf_verifysrc(fin)
|
||||||
fr_info_t *fin;
|
fr_info_t *fin;
|
||||||
{
|
{
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -763,7 +763,7 @@ ipf_inject(fin, m)
|
|||||||
{
|
{
|
||||||
FREE_MB_T(m);
|
FREE_MB_T(m);
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -788,7 +788,7 @@ ipf_pcksum(fin, hlen, sum)
|
|||||||
sum = (sum & 0xffff) + (sum >> 16);
|
sum = (sum & 0xffff) + (sum >> 16);
|
||||||
sum2 = (u_short)(~sum & 0xffff);
|
sum2 = (u_short)(~sum & 0xffff);
|
||||||
|
|
||||||
return sum2;
|
return(sum2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -799,7 +799,7 @@ ipf_pullup(m, fin, plen)
|
|||||||
int plen;
|
int plen;
|
||||||
{
|
{
|
||||||
if (M_LEN(m) >= plen)
|
if (M_LEN(m) >= plen)
|
||||||
return fin->fin_ip;
|
return(fin->fin_ip);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fake ipf_pullup failing
|
* Fake ipf_pullup failing
|
||||||
@ -808,5 +808,5 @@ ipf_pullup(m, fin, plen)
|
|||||||
*fin->fin_mp = NULL;
|
*fin->fin_mp = NULL;
|
||||||
fin->fin_m = NULL;
|
fin->fin_m = NULL;
|
||||||
fin->fin_ip = NULL;
|
fin->fin_ip = NULL;
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ in providing a secure IP environment.
|
|||||||
\fBipftest\fP will parse any standard ruleset for use with \fBipf\fP,
|
\fBipftest\fP will parse any standard ruleset for use with \fBipf\fP,
|
||||||
\fBipnat\fP and/or \fBippool\fP
|
\fBipnat\fP and/or \fBippool\fP
|
||||||
and apply input, returning output as to the result. However, \fBipftest\fP
|
and apply input, returning output as to the result. However, \fBipftest\fP
|
||||||
will return one of three values for packets passed through the filter:
|
will( return one of three values for packets passed through the filter:);
|
||||||
pass, block or nomatch. This is intended to give the operator a better
|
pass, block or nomatch. This is intended to give the operator a better
|
||||||
idea of what is happening with packets passing through their filter
|
idea of what is happening with packets passing through their filter
|
||||||
ruleset.
|
ruleset.
|
||||||
|
@ -143,7 +143,7 @@ main(int argc, char *argv[])
|
|||||||
case 'N' :
|
case 'N' :
|
||||||
if (ipnat_parsefile(-1, ipnat_addrule, ipnattestioctl,
|
if (ipnat_parsefile(-1, ipnat_addrule, ipnattestioctl,
|
||||||
optarg) == -1)
|
optarg) == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
loaded = 1;
|
loaded = 1;
|
||||||
opts |= OPT_NAT;
|
opts |= OPT_NAT;
|
||||||
break;
|
break;
|
||||||
@ -152,13 +152,13 @@ main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'P' :
|
case 'P' :
|
||||||
if (ippool_parsefile(-1, optarg, ipooltestioctl) == -1)
|
if (ippool_parsefile(-1, optarg, ipooltestioctl) == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
loaded = 1;
|
loaded = 1;
|
||||||
break;
|
break;
|
||||||
case 'r' :
|
case 'r' :
|
||||||
if (ipf_parsefile(-1, ipf_addrule, iocfunctions,
|
if (ipf_parsefile(-1, ipf_addrule, iocfunctions,
|
||||||
optarg) == -1)
|
optarg) == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
loaded = 1;
|
loaded = 1;
|
||||||
break;
|
break;
|
||||||
case 'S' :
|
case 'S' :
|
||||||
@ -256,7 +256,7 @@ main(int argc, char *argv[])
|
|||||||
(void)printf("block return-icmp-as-dest");
|
(void)printf("block return-icmp-as-dest");
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
(void)printf("recognised return %#x\n", i);
|
(void)printf("recognised( return %#x\n", i));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ main(int argc, char *argv[])
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -346,9 +346,9 @@ int ipftestioctl(int dev, ioctlcmd_t cmd, ...)
|
|||||||
(u_int)cmd, data, i, softc->ipf_interror);
|
(u_int)cmd, data, i, softc->ipf_interror);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
errno = i;
|
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);
|
(u_int)cmd, data, i);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
errno = i;
|
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);
|
(u_int)cmd, data, i);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
errno = i;
|
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);
|
(u_int)cmd, data, i);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
errno = i;
|
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);
|
(u_int)cmd, data, i);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
errno = i;
|
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);
|
(u_int)cmd, data, i);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
errno = i;
|
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);
|
(u_int)cmd, data, i, softc->ipf_interror);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
errno = i;
|
errno = i;
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ int
|
|||||||
kmemcpy(char *addr, long offset, int size)
|
kmemcpy(char *addr, long offset, int size)
|
||||||
{
|
{
|
||||||
bcopy((char *)offset, addr, 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++))
|
while ((n > 0) && (*buf++ = *ptr++))
|
||||||
;
|
;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,15 +166,15 @@ white [ \t\r]+
|
|||||||
%%
|
%%
|
||||||
{white} ;
|
{white} ;
|
||||||
\n { lineNum++; swallow(); }
|
\n { lineNum++; swallow(); }
|
||||||
\{ { push_proto(); return next_item('{'); }
|
\{ {( push_proto(); return next_item('{'); });
|
||||||
\} { pop_proto(); return next_item('}'); }
|
\} {( pop_proto(); return next_item('}'); });
|
||||||
; { return next_item(';'); }
|
; {( return next_item(';'); });
|
||||||
[0-9]+ { return next_item(IL_NUMBER); }
|
[0-9]+ {( return next_item(IL_NUMBER); });
|
||||||
[0-9a-fA-F] { return next_item(IL_HEXDIGIT); }
|
[0-9a-fA-F] {( return next_item(IL_HEXDIGIT); });
|
||||||
: { return next_item(IL_COLON); }
|
: {( return next_item(IL_COLON); });
|
||||||
#[^\n]* { return next_item(IL_COMMENT); }
|
#[^\n]* {( return next_item(IL_COMMENT); });
|
||||||
[^ \{\}\n\t;:{}]* { return next_item(IL_TOKEN); }
|
[^( \{\}\n\t;:{}]* { return next_item(IL_TOKEN); });
|
||||||
\"[^\"]*\" { return next_item(IL_TOKEN); }
|
\"[^\"]*\" {( return next_item(IL_TOKEN); });
|
||||||
%%
|
%%
|
||||||
void yyerror(msg)
|
void yyerror(msg)
|
||||||
char *msg;
|
char *msg;
|
||||||
@ -214,7 +214,7 @@ int save_token(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
yylval.str = strdup((char *)yytext);
|
yylval.str = strdup((char *)yytext);
|
||||||
return IL_TOKEN;
|
return(IL_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -226,20 +226,20 @@ int next_item(int nstate)
|
|||||||
printf("text=[%s] id=%d next=%d\n", yytext, nstate, next);
|
printf("text=[%s] id=%d next=%d\n", yytext, nstate, next);
|
||||||
if (next == IL_TOKEN) {
|
if (next == IL_TOKEN) {
|
||||||
next = -1;
|
next = -1;
|
||||||
return save_token();
|
return(save_token());
|
||||||
}
|
}
|
||||||
token++;
|
token++;
|
||||||
|
|
||||||
for (wt = words; wt->word; wt++)
|
for (wt = words; wt->word; wt++)
|
||||||
if (!strcasecmp(wt->word, (char *)yytext))
|
if (!strcasecmp(wt->word, (char *)yytext))
|
||||||
return next_state(wt->state, wt->next);
|
return(next_state(wt->state, wt->next));
|
||||||
if (opts & OPT_DEBUG)
|
if (opts & OPT_DEBUG)
|
||||||
printf("unknown keyword=[%s]\n", yytext);
|
printf("unknown keyword=[%s]\n", yytext);
|
||||||
next = -1;
|
next = -1;
|
||||||
if (nstate == IL_NUMBER)
|
if (nstate == IL_NUMBER)
|
||||||
yylval.num = atoi((char *)yytext);
|
yylval.num = atoi((char *)yytext);
|
||||||
token++;
|
token++;
|
||||||
return nstate;
|
return(nstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ int next_state(int nstate, int fornext)
|
|||||||
nstate = IL_UDPLEN;
|
nstate = IL_UDPLEN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return nstate;
|
return(nstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -600,7 +600,7 @@ char *arg;
|
|||||||
bcopy(hp->h_addr, &in.s_addr, sizeof(struct in_addr));
|
bcopy(hp->h_addr, &in.s_addr, sizeof(struct in_addr));
|
||||||
else
|
else
|
||||||
in.s_addr = inet_addr(arg);
|
in.s_addr = inet_addr(arg);
|
||||||
return in;
|
return(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -610,8 +610,8 @@ char *pr, *name;
|
|||||||
struct servent *sp;
|
struct servent *sp;
|
||||||
|
|
||||||
if (!(sp = getservbyname(name, pr)))
|
if (!(sp = getservbyname(name, pr)))
|
||||||
return htons(atoi(name));
|
return(htons(atoi(name)));
|
||||||
return sp->s_port;
|
return(sp->s_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -629,7 +629,7 @@ struct ether_addr *geteaddr(char *arg, struct ether_addr *buf)
|
|||||||
bcopy(e->ether_addr_octet, buf->ether_addr_octet,
|
bcopy(e->ether_addr_octet, buf->ether_addr_octet,
|
||||||
sizeof(e->ether_addr_octet));
|
sizeof(e->ether_addr_octet));
|
||||||
# endif
|
# endif
|
||||||
return e;
|
return(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -669,7 +669,7 @@ void *new_header(int type)
|
|||||||
else if (aip->ah_p == IPPROTO_UDP)
|
else if (aip->ah_p == IPPROTO_UDP)
|
||||||
aip->ah_udp->uh_ulen += sz;
|
aip->ah_udp->uh_ulen += sz;
|
||||||
}
|
}
|
||||||
return (void *)canip->ah_data;
|
return(void *)canip->ah_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1371,9 +1371,9 @@ int arp_getipv4(char *ip, char *addr)
|
|||||||
for (a = arplist; a; a = a->arp_next)
|
for (a = arplist; a; a = a->arp_next)
|
||||||
if (!bcmp(ip, (char *)&a->arp_addr, 4)) {
|
if (!bcmp(ip, (char *)&a->arp_addr, 4)) {
|
||||||
bcopy((char *)&a->arp_eaddr, addr, 6);
|
bcopy((char *)&a->arp_eaddr, addr, 6);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1742,7 +1742,7 @@ u_short c_chksum(u_short *buf, u_int len, u_long init)
|
|||||||
sum += *buf++;
|
sum += *buf++;
|
||||||
sum = (sum>>16) + (sum & 0xffff);
|
sum = (sum>>16) + (sum & 0xffff);
|
||||||
sum += (sum >>16);
|
sum += (sum >>16);
|
||||||
return (~sum);
|
return(~sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1753,5 +1753,5 @@ u_long p_chksum(u_short *buf, u_int len)
|
|||||||
|
|
||||||
for(; nwords > 0; nwords--)
|
for(; nwords > 0; nwords--)
|
||||||
sum += *buf++;
|
sum += *buf++;
|
||||||
return sum;
|
return(sum);
|
||||||
}
|
}
|
||||||
|
@ -307,19 +307,19 @@ find_icmpsubtype(int type, icmp_subtype_t *table, size_t tablesz)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (tablesz < 2)
|
if (tablesz < 2)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
if ((type < 0) || (type > table[tablesz - 2].ist_val))
|
if ((type < 0) || (type > table[tablesz - 2].ist_val))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
i = type;
|
i = type;
|
||||||
if (table[type].ist_val == type)
|
if (table[type].ist_val == type)
|
||||||
return table + type;
|
return(table + type);
|
||||||
|
|
||||||
for (i = 0, ist = table; ist->ist_val != -2; i++, ist++)
|
for (i = 0, ist = table; ist->ist_val != -2; i++, ist++)
|
||||||
if (ist->ist_val == type)
|
if (ist->ist_val == type)
|
||||||
return ist;
|
return(ist);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -330,19 +330,19 @@ find_icmptype(int type, icmp_type_t *table, size_t tablesz)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (tablesz < 2)
|
if (tablesz < 2)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
if ((type < 0) || (type > table[tablesz - 2].it_val))
|
if ((type < 0) || (type > table[tablesz - 2].it_val))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
i = type;
|
i = type;
|
||||||
if (table[type].it_val == type)
|
if (table[type].it_val == type)
|
||||||
return table + type;
|
return(table + type);
|
||||||
|
|
||||||
for (i = 0, it = table; it->it_val != -2; i++, it++)
|
for (i = 0, it = table; it->it_val != -2; i++, it++)
|
||||||
if (it->it_val == type)
|
if (it->it_val == type)
|
||||||
return it;
|
return(it);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ getlocalproto(u_int p)
|
|||||||
sprintf(pnum, "%u", p);
|
sprintf(pnum, "%u", p);
|
||||||
s = pnum;
|
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);
|
nr = read(fd, buf, bufsize);
|
||||||
if (!nr)
|
if (!nr)
|
||||||
return 2;
|
return(2);
|
||||||
if ((nr < 0) && (errno != EINTR))
|
if ((nr < 0) && (errno != EINTR))
|
||||||
return -1;
|
return(-1);
|
||||||
*lenp = nr;
|
*lenp = nr;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -482,7 +482,7 @@ portlocalname(res, proto, port)
|
|||||||
port &= 0xffff;
|
port &= 0xffff;
|
||||||
sprintf(pname, "%u", port);
|
sprintf(pname, "%u", port);
|
||||||
if (!res || (ipmonopts & IPMON_PORTNUM))
|
if (!res || (ipmonopts & IPMON_PORTNUM))
|
||||||
return pname;
|
return(pname);
|
||||||
s = NULL;
|
s = NULL;
|
||||||
if (!strcmp(proto, "tcp"))
|
if (!strcmp(proto, "tcp"))
|
||||||
s = tcp_ports[port];
|
s = tcp_ports[port];
|
||||||
@ -490,7 +490,7 @@ portlocalname(res, proto, port)
|
|||||||
s = udp_ports[port];
|
s = udp_ports[port];
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
s = pname;
|
s = pname;
|
||||||
return s;
|
return(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -521,7 +521,7 @@ icmpname(u_int type, u_int code)
|
|||||||
else
|
else
|
||||||
sprintf(name + strlen(name), "%d", code);
|
sprintf(name + strlen(name), "%d", code);
|
||||||
|
|
||||||
return name;
|
return(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@ -551,7 +551,7 @@ icmpname6(u_int type, u_int code)
|
|||||||
else
|
else
|
||||||
sprintf(name + strlen(name), "%d", code);
|
sprintf(name + strlen(name), "%d", code);
|
||||||
|
|
||||||
return name;
|
return(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -624,7 +624,7 @@ get_tm(time_t sec)
|
|||||||
|
|
||||||
t = sec;
|
t = sec;
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
return tm;
|
return(tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1775,11 +1775,11 @@ read_loginfo(config_t *conf)
|
|||||||
|
|
||||||
n = select(conf->maxfd + 1, &fdr, NULL, NULL, NULL);
|
n = select(conf->maxfd + 1, &fdr, NULL, NULL, NULL);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return 1;
|
return(1);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
return 1;
|
return(1);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, nr = 0; i < 3; i++) {
|
for (i = 0, nr = 0; i < 3; i++) {
|
||||||
@ -1792,7 +1792,7 @@ read_loginfo(config_t *conf)
|
|||||||
if (l->regular) {
|
if (l->regular) {
|
||||||
tr = (lseek(l->fd, 0, SEEK_CUR) < l->size);
|
tr = (lseek(l->fd, 0, SEEK_CUR) < l->size);
|
||||||
if (!tr && !(ipmonopts & IPMON_TAIL))
|
if (!tr && !(ipmonopts & IPMON_TAIL))
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
@ -1828,13 +1828,13 @@ read_loginfo(config_t *conf)
|
|||||||
else {
|
else {
|
||||||
ipferror(l->fd, "read");
|
ipferror(l->fd, "read");
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
case 1 :
|
case 1 :
|
||||||
if (ipmonopts & IPMON_SYSLOG)
|
if (ipmonopts & IPMON_SYSLOG)
|
||||||
syslog(LOG_CRIT, "aborting logging\n");
|
syslog(LOG_CRIT, "aborting logging\n");
|
||||||
else if (conf->log != NULL)
|
else if (conf->log != NULL)
|
||||||
fprintf(conf->log, "aborting logging\n");
|
fprintf(conf->log, "aborting logging\n");
|
||||||
return 0;
|
return(0);
|
||||||
case 2 :
|
case 2 :
|
||||||
break;
|
break;
|
||||||
case 0 :
|
case 0 :
|
||||||
@ -1851,5 +1851,5 @@ read_loginfo(config_t *conf)
|
|||||||
if (!nr && (ipmonopts & IPMON_TAIL))
|
if (!nr && (ipmonopts & IPMON_TAIL))
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ typeopt:
|
|||||||
ipv4: YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER
|
ipv4: YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER
|
||||||
{ if ($1 > 255 || $3 > 255 || $5 > 255 || $7 > 255) {
|
{ if ($1 > 255 || $3 > 255 || $5 > 255 || $7 > 255) {
|
||||||
yyerror("Invalid octet string for IP address");
|
yyerror("Invalid octet string for IP address");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
$$.s_addr = ($1 << 24) | ($3 << 16) | ($5 << 8) | $7;
|
$$.s_addr = ($1 << 24) | ($3 << 16) | ($5 << 8) | $7;
|
||||||
$$.s_addr = htonl($$.s_addr);
|
$$.s_addr = htonl($$.s_addr);
|
||||||
@ -311,7 +311,7 @@ new_opt(int type)
|
|||||||
o->o_line = yylineNum;
|
o->o_line = yylineNum;
|
||||||
o->o_logfac = -1;
|
o->o_logfac = -1;
|
||||||
o->o_logpri = -1;
|
o->o_logpri = -1;
|
||||||
return o;
|
return(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -620,7 +620,7 @@ check_action(char *buf, char *log, int opts, int lvl)
|
|||||||
(*d->ipmd_store)(d->ipmd_token, &msg);
|
(*d->ipmd_store)(d->ipmd_token, &msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return matched;
|
return(matched);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -665,13 +665,13 @@ load_config(char *file)
|
|||||||
fp = fopen(file, "r");
|
fp = fopen(file, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
perror("load_config:fopen:");
|
perror("load_config:fopen:");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
yyin = fp;
|
yyin = fp;
|
||||||
while (!feof(fp))
|
while (!feof(fp))
|
||||||
yyparse();
|
yyparse();
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -749,15 +749,15 @@ add_doing(ipmon_saver_t *saver)
|
|||||||
ipmon_saver_int_t *it;
|
ipmon_saver_int_t *it;
|
||||||
|
|
||||||
if (find_doing(saver->ims_name) == IPM_DOING)
|
if (find_doing(saver->ims_name) == IPM_DOING)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
it = calloc(1, sizeof(*it));
|
it = calloc(1, sizeof(*it));
|
||||||
if (it == NULL)
|
if (it == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
it->imsi_stor = saver;
|
it->imsi_stor = saver;
|
||||||
it->imsi_next = saverlist;
|
it->imsi_next = saverlist;
|
||||||
saverlist = it;
|
saverlist = it;
|
||||||
return it;
|
return(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -768,9 +768,9 @@ find_doing(char *string)
|
|||||||
|
|
||||||
for (it = saverlist; it != NULL; it = it->imsi_next) {
|
for (it = saverlist; it != NULL; it = it->imsi_next) {
|
||||||
if (!strcmp(it->imsi_stor->ims_name, string))
|
if (!strcmp(it->imsi_stor->ims_name, string))
|
||||||
return IPM_DOING;
|
return(IPM_DOING);
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -785,7 +785,7 @@ build_doing(char *target, char *options)
|
|||||||
|
|
||||||
d = calloc(1, sizeof(*d));
|
d = calloc(1, sizeof(*d));
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
for (it = saverlist; it != NULL; it = it->imsi_next) {
|
for (it = saverlist; it != NULL; it = it->imsi_next) {
|
||||||
if (!strcmp(it->imsi_stor->ims_name, target))
|
if (!strcmp(it->imsi_stor->ims_name, target))
|
||||||
@ -793,7 +793,7 @@ build_doing(char *target, char *options)
|
|||||||
}
|
}
|
||||||
if (it == NULL) {
|
if (it == NULL) {
|
||||||
free(d);
|
free(d);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
strarray[0] = options;
|
strarray[0] = options;
|
||||||
@ -802,7 +802,7 @@ build_doing(char *target, char *options)
|
|||||||
d->ipmd_token = (*it->imsi_stor->ims_parse)(strarray);
|
d->ipmd_token = (*it->imsi_stor->ims_parse)(strarray);
|
||||||
if (d->ipmd_token == NULL) {
|
if (d->ipmd_token == NULL) {
|
||||||
free(d);
|
free(d);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
save = it->imsi_stor;
|
save = it->imsi_stor;
|
||||||
@ -827,7 +827,7 @@ build_doing(char *target, char *options)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return d;
|
return(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -974,11 +974,11 @@ install_saver(char *name, char *path)
|
|||||||
char nbuf[80];
|
char nbuf[80];
|
||||||
|
|
||||||
if (find_doing(name) == IPM_DOING)
|
if (find_doing(name) == IPM_DOING)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
isi = calloc(1, sizeof(*isi));
|
isi = calloc(1, sizeof(*isi));
|
||||||
if (isi == NULL)
|
if (isi == NULL)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
is = calloc(1, sizeof(*is));
|
is = calloc(1, sizeof(*is));
|
||||||
if (is == NULL)
|
if (is == NULL)
|
||||||
@ -1026,7 +1026,7 @@ install_saver(char *name, char *path)
|
|||||||
isi->imsi_next = saverlist;
|
isi->imsi_next = saverlist;
|
||||||
saverlist = isi;
|
saverlist = isi;
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
loaderror:
|
loaderror:
|
||||||
if (isi->imsi_handle != NULL)
|
if (isi->imsi_handle != NULL)
|
||||||
@ -1034,5 +1034,5 @@ loaderror:
|
|||||||
free(isi);
|
free(isi);
|
||||||
if (is != NULL)
|
if (is != NULL)
|
||||||
free(is);
|
free(is);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -252,8 +252,8 @@ are always in the
|
|||||||
.I inbound
|
.I inbound
|
||||||
,
|
,
|
||||||
.I outbound
|
.I outbound
|
||||||
order. In this case, hme0 would be the return interface and le0 would be
|
order.( In this case, hme0 would be the return interface and le0 would be);
|
||||||
the outgoing interface. If you wish to allow return packets on any
|
the( outgoing interface. If you wish to allow return packets on any);
|
||||||
interface, the correct syntax to use would be:
|
interface, the correct syntax to use would be:
|
||||||
.nf
|
.nf
|
||||||
|
|
||||||
|
@ -221,11 +221,11 @@ main(int argc, char *argv[])
|
|||||||
if (opts & (OPT_FLUSH|OPT_CLEAR))
|
if (opts & (OPT_FLUSH|OPT_CLEAR))
|
||||||
flushtable(fd, opts, natfilter);
|
flushtable(fd, opts, natfilter);
|
||||||
if (file) {
|
if (file) {
|
||||||
return ipnat_parsefile(fd, ipnat_addrule, ioctl, file);
|
return(ipnat_parsefile(fd, ipnat_addrule, ioctl, file));
|
||||||
}
|
}
|
||||||
if (opts & (OPT_LIST|OPT_STAT))
|
if (opts & (OPT_LIST|OPT_STAT))
|
||||||
dostats(fd, nsp, opts, 1, natfilter);
|
dostats(fd, nsp, opts, 1, natfilter);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -829,5 +829,5 @@ nat_matcharray(nat_t *nat, int *array)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return(rv);
|
||||||
}
|
}
|
||||||
|
@ -1213,7 +1213,7 @@ ipaddr: ipv4 { $$ = $1; }
|
|||||||
ipv4: YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER
|
ipv4: YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER
|
||||||
{ if ($1 > 255 || $3 > 255 || $5 > 255 || $7 > 255) {
|
{ if ($1 > 255 || $3 > 255 || $5 > 255 || $7 > 255) {
|
||||||
yyerror("Invalid octet string for IP address");
|
yyerror("Invalid octet string for IP address");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
bzero((char *)&$$, sizeof($$));
|
bzero((char *)&$$, sizeof($$));
|
||||||
$$.a.in4.s_addr = ($1 << 24) | ($3 << 16) | ($5 << 8) | $7;
|
$$.a.in4.s_addr = ($1 << 24) | ($3 << 16) | ($5 << 8) | $7;
|
||||||
@ -1316,7 +1316,7 @@ ipnat_parsefile(int fd, addfunc_t addfunc, ioctlfunc_t ioctlfunc,
|
|||||||
if (!fp) {
|
if (!fp) {
|
||||||
FPRINTF(stderr, "fopen(%s) failed: %s\n", filename,
|
FPRINTF(stderr, "fopen(%s) failed: %s\n", filename,
|
||||||
STRERROR(errno));
|
STRERROR(errno));
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
@ -1329,7 +1329,7 @@ ipnat_parsefile(int fd, addfunc_t addfunc, ioctlfunc_t ioctlfunc,
|
|||||||
rval = 0;
|
rval = 0;
|
||||||
else if (rval != 0)
|
else if (rval != 0)
|
||||||
rval = 1;
|
rval = 1;
|
||||||
return rval;
|
return(rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1346,14 +1346,14 @@ ipnat_parsesome(int fd, addfunc_t addfunc, ioctlfunc_t ioctlfunc,
|
|||||||
natioctlfunc = ioctlfunc;
|
natioctlfunc = ioctlfunc;
|
||||||
|
|
||||||
if (feof(fp))
|
if (feof(fp))
|
||||||
return -1;
|
return(-1);
|
||||||
i = fgetc(fp);
|
i = fgetc(fp);
|
||||||
if (i == EOF)
|
if (i == EOF)
|
||||||
return -1;
|
return(-1);
|
||||||
if (ungetc(i, fp) == EOF)
|
if (ungetc(i, fp) == EOF)
|
||||||
return -1;
|
return(-1);
|
||||||
if (feof(fp))
|
if (feof(fp))
|
||||||
return -1;
|
return(-1);
|
||||||
s = getenv("YYDEBUG");
|
s = getenv("YYDEBUG");
|
||||||
if (s)
|
if (s)
|
||||||
yydebug = atoi(s);
|
yydebug = atoi(s);
|
||||||
@ -1362,7 +1362,7 @@ ipnat_parsesome(int fd, addfunc_t addfunc, ioctlfunc_t ioctlfunc,
|
|||||||
|
|
||||||
yyin = fp;
|
yyin = fp;
|
||||||
yyparse();
|
yyparse();
|
||||||
return parser_error;
|
return(parser_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1499,7 +1499,7 @@ ipnat_addrule(int fd, ioctlfunc_t ioctlfunc, void *ptr)
|
|||||||
|
|
||||||
snprintf(msg, sizeof(msg), "%d:ioctl(zero nat rule)",
|
snprintf(msg, sizeof(msg), "%d:ioctl(zero nat rule)",
|
||||||
ipn->in_flineno);
|
ipn->in_flineno);
|
||||||
return ipf_perror_fd(fd, ioctlfunc, msg);
|
return(ipf_perror_fd(fd, ioctlfunc, msg));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PRINTF("hits %lu ", ipn->in_hits);
|
PRINTF("hits %lu ", ipn->in_hits);
|
||||||
@ -1519,7 +1519,7 @@ ipnat_addrule(int fd, ioctlfunc_t ioctlfunc, void *ptr)
|
|||||||
|
|
||||||
snprintf(msg, sizeof(msg), "%d:ioctl(delete nat rule)",
|
snprintf(msg, sizeof(msg), "%d:ioctl(delete nat rule)",
|
||||||
ipn->in_flineno);
|
ipn->in_flineno);
|
||||||
return ipf_perror_fd(fd, ioctlfunc, msg);
|
return(ipf_perror_fd(fd, ioctlfunc, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1534,11 +1534,11 @@ ipnat_addrule(int fd, ioctlfunc_t ioctlfunc, void *ptr)
|
|||||||
snprintf(msg + strlen_msg, sizeof(msg) -strlen_msg, "(line %d)",
|
snprintf(msg + strlen_msg, sizeof(msg) -strlen_msg, "(line %d)",
|
||||||
ipn->in_flineno);
|
ipn->in_flineno);
|
||||||
}
|
}
|
||||||
return ipf_perror_fd(fd, ioctlfunc, msg);
|
return(ipf_perror_fd(fd, ioctlfunc, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1606,7 +1606,7 @@ proxy_dns_add_pass(char *prefix, char *name)
|
|||||||
strcat(n->na_name, name);
|
strcat(n->na_name, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1626,7 +1626,7 @@ proxy_dns_add_block(char *prefix, char *name)
|
|||||||
}
|
}
|
||||||
n->na_value = 1;
|
n->na_value = 1;
|
||||||
}
|
}
|
||||||
return n;
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1734,7 +1734,7 @@ addname(ipnat_t **np, char *name)
|
|||||||
nattop = n;
|
nattop = n;
|
||||||
*np = n;
|
*np = n;
|
||||||
if (n == NULL)
|
if (n == NULL)
|
||||||
return -1;
|
return(-1);
|
||||||
if (n->in_pnext != NULL)
|
if (n->in_pnext != NULL)
|
||||||
*n->in_pnext = n;
|
*n->in_pnext = n;
|
||||||
n->in_size += nlen;
|
n->in_size += nlen;
|
||||||
@ -1742,5 +1742,5 @@ addname(ipnat_t **np, char *name)
|
|||||||
n->in_namelen += nlen;
|
n->in_namelen += nlen;
|
||||||
strcpy(n->in_names + pos, name);
|
strcpy(n->in_names + pos, name);
|
||||||
n->in_names[n->in_namelen] = '\0';
|
n->in_names[n->in_namelen] = '\0';
|
||||||
return pos;
|
return(pos);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -161,23 +161,23 @@ poolnodecommand(int remove, int argc, char *argv[])
|
|||||||
if (ipset == 1) {
|
if (ipset == 1) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"cannot set role after ip address\n");
|
"cannot set role after ip address\n");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
role = getrole(optarg);
|
role = getrole(optarg);
|
||||||
if (role == IPL_LOGNONE)
|
if (role == IPL_LOGNONE)
|
||||||
return -1;
|
return(-1);
|
||||||
break;
|
break;
|
||||||
case 't' :
|
case 't' :
|
||||||
if (ipset == 1) {
|
if (ipset == 1) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"cannot set type after ip address\n");
|
"cannot set type after ip address\n");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
type = gettype(optarg, NULL);
|
type = gettype(optarg, NULL);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case IPLT_NONE :
|
case IPLT_NONE :
|
||||||
fprintf(stderr, "unknown type '%s'\n", optarg);
|
fprintf(stderr, "unknown type '%s'\n", optarg);
|
||||||
return -1;
|
return(-1);
|
||||||
case IPLT_HASH :
|
case IPLT_HASH :
|
||||||
ptr = &hnode;
|
ptr = &hnode;
|
||||||
break;
|
break;
|
||||||
@ -191,7 +191,7 @@ poolnodecommand(int remove, int argc, char *argv[])
|
|||||||
ttl = atoi(optarg);
|
ttl = atoi(optarg);
|
||||||
if (ttl < 0) {
|
if (ttl < 0) {
|
||||||
fprintf(stderr, "cannot set negative ttl\n");
|
fprintf(stderr, "cannot set negative ttl\n");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
@ -218,12 +218,12 @@ poolnodecommand(int remove, int argc, char *argv[])
|
|||||||
|
|
||||||
if (ipset == 0) {
|
if (ipset == 0) {
|
||||||
fprintf(stderr, "no IP address given with -i\n");
|
fprintf(stderr, "no IP address given with -i\n");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (poolname == NULL) {
|
if (poolname == NULL) {
|
||||||
fprintf(stderr, "poolname not given with add/remove node\n");
|
fprintf(stderr, "poolname not given with add/remove node\n");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -242,7 +242,7 @@ poolnodecommand(int remove, int argc, char *argv[])
|
|||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return err;
|
return(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ poolcommand(int remove, int argc, char *argv[])
|
|||||||
role = getrole(optarg);
|
role = getrole(optarg);
|
||||||
if (role == IPL_LOGNONE) {
|
if (role == IPL_LOGNONE) {
|
||||||
fprintf(stderr, "unknown role '%s'\n", optarg);
|
fprintf(stderr, "unknown role '%s'\n", optarg);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'S' :
|
case 'S' :
|
||||||
@ -308,7 +308,7 @@ poolcommand(int remove, int argc, char *argv[])
|
|||||||
|
|
||||||
if (poolname == NULL) {
|
if (poolname == NULL) {
|
||||||
fprintf(stderr, "poolname not given with add/remove pool\n");
|
fprintf(stderr, "poolname not given with add/remove pool\n");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == IPLT_NONE && remove == 0) {
|
if (type == IPLT_NONE && remove == 0) {
|
||||||
@ -318,7 +318,7 @@ poolcommand(int remove, int argc, char *argv[])
|
|||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "unknown type '%s'\n", typearg);
|
fprintf(stderr, "unknown type '%s'\n", typearg);
|
||||||
}
|
}
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == IPLT_HASH || (type == IPLT_NONE && remove == 1)) {
|
if (type == IPLT_HASH || (type == IPLT_NONE && remove == 1)) {
|
||||||
@ -363,7 +363,7 @@ poolcommand(int remove, int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err;
|
return(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -412,8 +412,8 @@ loadpoolfile(int argc, char *argv[], char *infile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ippool_parsefile(fd, infile, ioctl) != 0)
|
if (ippool_parsefile(fd, infile, ioctl) != 0)
|
||||||
return -1;
|
return(-1);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ poolstats(int argc, char *argv[])
|
|||||||
role = getrole(optarg);
|
role = getrole(optarg);
|
||||||
if (role == IPL_LOGNONE) {
|
if (role == IPL_LOGNONE) {
|
||||||
fprintf(stderr, "unknown role '%s'\n", optarg);
|
fprintf(stderr, "unknown role '%s'\n", optarg);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 't' :
|
case 't' :
|
||||||
@ -449,7 +449,7 @@ poolstats(int argc, char *argv[])
|
|||||||
if (type != IPLT_POOL) {
|
if (type != IPLT_POOL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"-s not supported for this type yet\n");
|
"-s not supported for this type yet\n");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'v' :
|
case 'v' :
|
||||||
@ -482,7 +482,7 @@ poolstats(int argc, char *argv[])
|
|||||||
c = ioctl(fd, SIOCLOOKUPSTAT, &op);
|
c = ioctl(fd, SIOCLOOKUPSTAT, &op);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
ipferror(fd, "ioctl(S0IOCLOOKUPSTAT)");
|
ipferror(fd, "ioctl(S0IOCLOOKUPSTAT)");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
printf("%lu\taddress pools\n", plstat.ipls_pools);
|
printf("%lu\taddress pools\n", plstat.ipls_pools);
|
||||||
printf("%lu\taddress pool nodes\n", plstat.ipls_nodes);
|
printf("%lu\taddress pool nodes\n", plstat.ipls_nodes);
|
||||||
@ -497,7 +497,7 @@ poolstats(int argc, char *argv[])
|
|||||||
c = ioctl(fd, SIOCLOOKUPSTAT, &op);
|
c = ioctl(fd, SIOCLOOKUPSTAT, &op);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
ipferror(fd, "ioctl(SIOCLOOKUPSTAT)");
|
ipferror(fd, "ioctl(SIOCLOOKUPSTAT)");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
printf("%lu\thash tables\n", htstat.iphs_numtables);
|
printf("%lu\thash tables\n", htstat.iphs_numtables);
|
||||||
printf("%lu\thash table nodes\n", htstat.iphs_numnodes);
|
printf("%lu\thash table nodes\n", htstat.iphs_numnodes);
|
||||||
@ -514,7 +514,7 @@ poolstats(int argc, char *argv[])
|
|||||||
c = ioctl(fd, SIOCLOOKUPSTAT, &op);
|
c = ioctl(fd, SIOCLOOKUPSTAT, &op);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
ipferror(fd, "ioctl(SIOCLOOKUPSTAT)");
|
ipferror(fd, "ioctl(SIOCLOOKUPSTAT)");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
printf("%u\tdestination lists\n",
|
printf("%u\tdestination lists\n",
|
||||||
dlstat.ipls_numlists);
|
dlstat.ipls_numlists);
|
||||||
@ -528,7 +528,7 @@ poolstats(int argc, char *argv[])
|
|||||||
dlstat.ipls_numderefnodes);
|
dlstat.ipls_numderefnodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -552,14 +552,14 @@ poolflush(int argc, char *argv[])
|
|||||||
role = getrole(optarg);
|
role = getrole(optarg);
|
||||||
if (role == IPL_LOGNONE) {
|
if (role == IPL_LOGNONE) {
|
||||||
fprintf(stderr, "unknown role '%s'\n", optarg);
|
fprintf(stderr, "unknown role '%s'\n", optarg);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 't' :
|
case 't' :
|
||||||
type = gettype(optarg, NULL);
|
type = gettype(optarg, NULL);
|
||||||
if (type == IPLT_NONE) {
|
if (type == IPLT_NONE) {
|
||||||
fprintf(stderr, "unknown type '%s'\n", optarg);
|
fprintf(stderr, "unknown type '%s'\n", optarg);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'v' :
|
case 'v' :
|
||||||
@ -599,7 +599,7 @@ poolflush(int argc, char *argv[])
|
|||||||
printf("%u object%s flushed\n", flush.iplf_count,
|
printf("%u object%s flushed\n", flush.iplf_count,
|
||||||
(flush.iplf_count == 1) ? "" : "s");
|
(flush.iplf_count == 1) ? "" : "s");
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -630,7 +630,7 @@ getrole(char *rolename)
|
|||||||
role = IPL_LOGNONE;
|
role = IPL_LOGNONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return role;
|
return(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ gettype(char *typename, u_int *minor)
|
|||||||
} else {
|
} else {
|
||||||
type = IPLT_NONE;
|
type = IPLT_NONE;
|
||||||
}
|
}
|
||||||
return type;
|
return(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ poollist(int argc, char *argv[])
|
|||||||
role = getrole(optarg);
|
role = getrole(optarg);
|
||||||
if (role == IPL_LOGNONE) {
|
if (role == IPL_LOGNONE) {
|
||||||
fprintf(stderr, "unknown role '%s'\n", optarg);
|
fprintf(stderr, "unknown role '%s'\n", optarg);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
@ -708,7 +708,7 @@ poollist(int argc, char *argv[])
|
|||||||
type = gettype(optarg, NULL);
|
type = gettype(optarg, NULL);
|
||||||
if (type == IPLT_NONE) {
|
if (type == IPLT_NONE) {
|
||||||
fprintf(stderr, "unknown type '%s'\n", optarg);
|
fprintf(stderr, "unknown type '%s'\n", optarg);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'v' :
|
case 'v' :
|
||||||
@ -744,7 +744,7 @@ poollist(int argc, char *argv[])
|
|||||||
poollist_live(role, poolname, type, fd);
|
poollist_live(role, poolname, type, fd);
|
||||||
else
|
else
|
||||||
poollist_dead(role, poolname, type, kernel, core);
|
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;
|
mask.s_addr = 0xffffffff;
|
||||||
else if (strchr(s, '.') == NULL) {
|
else if (strchr(s, '.') == NULL) {
|
||||||
if (ntomask(AF_INET, atoi(s + 1), &mask.s_addr) != 0)
|
if (ntomask(AF_INET, atoi(s + 1), &mask.s_addr) != 0)
|
||||||
return -1;
|
return(-1);
|
||||||
} else {
|
} else {
|
||||||
mask.s_addr = inet_addr(s + 1);
|
mask.s_addr = inet_addr(s + 1);
|
||||||
}
|
}
|
||||||
@ -1110,5 +1110,5 @@ setnodeaddr(int type, int role, void *ptr, char *arg)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ seed: IPT_SEED '=' YY_NUMBER { ipht.iph_seed = $3; }
|
|||||||
ipv4: YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER
|
ipv4: YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER '.' YY_NUMBER
|
||||||
{ if ($1 > 255 || $3 > 255 || $5 > 255 || $7 > 255) {
|
{ if ($1 > 255 || $3 > 255 || $5 > 255 || $7 > 255) {
|
||||||
yyerror("Invalid octet string for IP address");
|
yyerror("Invalid octet string for IP address");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
$$.s_addr = ($1 << 24) | ($3 << 16) | ($5 << 8) | $7;
|
$$.s_addr = ($1 << 24) | ($3 << 16) | ($5 << 8) | $7;
|
||||||
$$.s_addr = htonl($$.s_addr);
|
$$.s_addr = htonl($$.s_addr);
|
||||||
@ -629,7 +629,7 @@ ippool_parsefile(int fd, char *filename, ioctlfunc_t iocfunc)
|
|||||||
if (!fp) {
|
if (!fp) {
|
||||||
fprintf(stderr, "fopen(%s) failed: %s\n", filename,
|
fprintf(stderr, "fopen(%s) failed: %s\n", filename,
|
||||||
STRERROR(errno));
|
STRERROR(errno));
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
@ -638,7 +638,7 @@ ippool_parsefile(int fd, char *filename, ioctlfunc_t iocfunc)
|
|||||||
;
|
;
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -651,14 +651,14 @@ ippool_parsesome(int fd, FILE *fp, ioctlfunc_t iocfunc)
|
|||||||
poolioctl = iocfunc;
|
poolioctl = iocfunc;
|
||||||
|
|
||||||
if (feof(fp))
|
if (feof(fp))
|
||||||
return 0;
|
return(0);
|
||||||
i = fgetc(fp);
|
i = fgetc(fp);
|
||||||
if (i == EOF)
|
if (i == EOF)
|
||||||
return 0;
|
return(0);
|
||||||
if (ungetc(i, fp) == EOF)
|
if (ungetc(i, fp) == EOF)
|
||||||
return 0;
|
return(0);
|
||||||
if (feof(fp))
|
if (feof(fp))
|
||||||
return 0;
|
return(0);
|
||||||
s = getenv("YYDEBUG");
|
s = getenv("YYDEBUG");
|
||||||
if (s)
|
if (s)
|
||||||
yydebug = atoi(s);
|
yydebug = atoi(s);
|
||||||
@ -667,7 +667,7 @@ ippool_parsesome(int fd, FILE *fp, ioctlfunc_t iocfunc)
|
|||||||
|
|
||||||
yyin = fp;
|
yyin = fp;
|
||||||
yyparse();
|
yyparse();
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -684,7 +684,7 @@ add_htablehosts(char *url)
|
|||||||
|
|
||||||
hlist = calloc(1, sizeof(*hlist));
|
hlist = calloc(1, sizeof(*hlist));
|
||||||
if (hlist == NULL)
|
if (hlist == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
if (gethost(hlist->al_family, url, &hlist->al_i6addr) == -1) {
|
if (gethost(hlist->al_family, url, &hlist->al_i6addr) == -1) {
|
||||||
yyerror("Unknown hostname");
|
yyerror("Unknown hostname");
|
||||||
@ -712,7 +712,7 @@ add_htablehosts(char *url)
|
|||||||
|
|
||||||
alist_free(hlist);
|
alist_free(hlist);
|
||||||
|
|
||||||
return htop;
|
return(htop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -729,7 +729,7 @@ add_poolhosts(char *url)
|
|||||||
|
|
||||||
hlist = calloc(1, sizeof(*hlist));
|
hlist = calloc(1, sizeof(*hlist));
|
||||||
if (hlist == NULL)
|
if (hlist == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
if (gethost(hlist->al_family, url, &hlist->al_i6addr) == -1) {
|
if (gethost(hlist->al_family, url, &hlist->al_i6addr) == -1) {
|
||||||
yyerror("Unknown hostname");
|
yyerror("Unknown hostname");
|
||||||
@ -766,7 +766,7 @@ add_poolhosts(char *url)
|
|||||||
|
|
||||||
alist_free(hlist);
|
alist_free(hlist);
|
||||||
|
|
||||||
return ptop;
|
return(ptop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -779,7 +779,7 @@ read_whoisfile(char *file)
|
|||||||
|
|
||||||
fp = fopen(file, "r");
|
fp = fopen(file, "r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
last = NULL;
|
last = NULL;
|
||||||
ntop = NULL;
|
ntop = NULL;
|
||||||
@ -800,7 +800,7 @@ read_whoisfile(char *file)
|
|||||||
last = ipn;
|
last = ipn;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return ntop;
|
return(ntop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ cram(char *dst, char *src)
|
|||||||
} else
|
} else
|
||||||
*u++ = c, i++;
|
*u++ = c, i++;
|
||||||
}
|
}
|
||||||
return i;
|
return(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ makepair(char *s1, char *s2)
|
|||||||
a = malloc(sizeof(char *) * 2);
|
a = malloc(sizeof(char *) * 2);
|
||||||
a[0] = s1;
|
a[0] = s1;
|
||||||
a[1] = s2;
|
a[1] = s2;
|
||||||
return a;
|
return(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ combine(int a1, int a2, int a3, int a4)
|
|||||||
a4 &= 0xff;
|
a4 &= 0xff;
|
||||||
in.s_addr |= a4;
|
in.s_addr |= a4;
|
||||||
in.s_addr = htonl(in.s_addr);
|
in.s_addr = htonl(in.s_addr);
|
||||||
return in;
|
return(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -443,9 +443,9 @@ gethostip(char *host)
|
|||||||
|
|
||||||
hp = gethostbyname(host);
|
hp = gethostbyname(host);
|
||||||
if (!hp)
|
if (!hp)
|
||||||
return in;
|
return(in);
|
||||||
bcopy(hp->h_addr, (char *)&in, sizeof(in));
|
bcopy(hp->h_addr, (char *)&in, sizeof(in));
|
||||||
return in;
|
return(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -456,8 +456,8 @@ getportnum(char *port)
|
|||||||
|
|
||||||
s = getservbyname(port, "tcp");
|
s = getservbyname(port, "tcp");
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return -1;
|
return(-1);
|
||||||
return s->s_port;
|
return(s->s_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,13 +46,13 @@ int resolve(char *host, char *address)
|
|||||||
if (!(hp = gethostbyname(host)))
|
if (!(hp = gethostbyname(host)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "unknown host: %s\n", host);
|
fprintf(stderr, "unknown host: %s\n", host);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
bcopy((char *)hp->h_addr, (char *)address, 4);
|
bcopy((char *)hp->h_addr, (char *)address, 4);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
bcopy((char*)&add, address, 4);
|
bcopy((char*)&add, address, 4);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,11 +67,11 @@ int arp(char *addr, char *eaddr)
|
|||||||
|
|
||||||
#ifdef IPSEND
|
#ifdef IPSEND
|
||||||
if (arp_getipv4(addr, ether) == 0)
|
if (arp_getipv4(addr, ether) == 0)
|
||||||
return 0;
|
return(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
mib[0] = CTL_NET;
|
mib[0] = CTL_NET;
|
||||||
mib[1] = PF_ROUTE;
|
mib[1] = PF_ROUTE;
|
||||||
@ -109,8 +109,8 @@ int arp(char *addr, char *eaddr)
|
|||||||
sizeof(struct in_addr)))
|
sizeof(struct in_addr)))
|
||||||
{
|
{
|
||||||
bcopy(LLADDR(sdl), eaddr, sdl->sdl_alen);
|
bcopy(LLADDR(sdl), eaddr, sdl->sdl_alen);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -45,13 +45,13 @@ int resolve(char *host, char *address)
|
|||||||
if (!(hp = gethostbyname(host)))
|
if (!(hp = gethostbyname(host)))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "unknown host: %s\n", host);
|
fprintf(stderr, "unknown host: %s\n", host);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
bcopy((char *)hp->h_addr, (char *)address, 4);
|
bcopy((char *)hp->h_addr, (char *)address, 4);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
bcopy((char*)&add, address, 4);
|
bcopy((char*)&add, address, 4);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -72,11 +72,11 @@ int arp(ip, ether)
|
|||||||
|
|
||||||
#ifdef IPSEND
|
#ifdef IPSEND
|
||||||
if (arp_getipv4(ip, ether) == 0)
|
if (arp_getipv4(ip, ether) == 0)
|
||||||
return 0;
|
return(0);
|
||||||
#endif
|
#endif
|
||||||
if (!bcmp(ipsave, ip, 4)) {
|
if (!bcmp(ipsave, ip, 4)) {
|
||||||
bcopy(ethersave, ether, 6);
|
bcopy(ethersave, ether, 6);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
fd = -1;
|
fd = -1;
|
||||||
bzero((char *)&ar, sizeof(ar));
|
bzero((char *)&ar, sizeof(ar));
|
||||||
@ -95,7 +95,7 @@ int arp(ip, ether)
|
|||||||
if ((sfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
if ((sfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||||
{
|
{
|
||||||
perror("arp: socket");
|
perror("arp: socket");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
tryagain:
|
tryagain:
|
||||||
if (ioctl(sfd, SIOCGARP, (caddr_t)&ar) == -1)
|
if (ioctl(sfd, SIOCGARP, (caddr_t)&ar) == -1)
|
||||||
@ -116,19 +116,19 @@ int arp(ip, ether)
|
|||||||
fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr));
|
fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr));
|
||||||
if (errno != ENXIO)
|
if (errno != ENXIO)
|
||||||
perror("SIOCGARP");
|
perror("SIOCGARP");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ar.arp_ha.sa_data[0] == 0) && (ar.arp_ha.sa_data[1] == 0) &&
|
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[2] == 0) && (ar.arp_ha.sa_data[3] == 0) &&
|
||||||
(ar.arp_ha.sa_data[4] == 0) && (ar.arp_ha.sa_data[5] == 0)) {
|
(ar.arp_ha.sa_data[4] == 0) && (ar.arp_ha.sa_data[5] == 0)) {
|
||||||
fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr));
|
fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr));
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bcopy(ar.arp_ha.sa_data, ether, 6);
|
bcopy(ar.arp_ha.sa_data, ether, 6);
|
||||||
savearp:
|
savearp:
|
||||||
bcopy(ether, ethersave, 6);
|
bcopy(ether, ethersave, 6);
|
||||||
bcopy(ip, ipsave, 4);
|
bcopy(ip, ipsave, 4);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ typedef unsigned long ulong;
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "dltest.h"
|
#include "dltest.h"
|
||||||
|
|
||||||
#define CASERET(s) case s: return ("s")
|
#define CASERET(s) case s: return("s")
|
||||||
|
|
||||||
char *dlprim();
|
char *dlprim();
|
||||||
char *dlstate();
|
char *dlstate();
|
||||||
@ -1056,7 +1056,7 @@ stringtoaddr(char *sp, char *addr)
|
|||||||
p = NULL;
|
p = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (n);
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1068,7 +1068,7 @@ hexnibble(char c)
|
|||||||
'a', 'b', 'c', 'd', 'e', 'f'
|
'a', 'b', 'c', 'd', 'e', 'f'
|
||||||
};
|
};
|
||||||
|
|
||||||
return (hextab[c & 0x0f]);
|
return(hextab[c & 0x0f]);
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
@ -1106,7 +1106,7 @@ dlprim(u_long prim)
|
|||||||
CASERET(DL_RESET_CON);
|
CASERET(DL_RESET_CON);
|
||||||
default:
|
default:
|
||||||
(void) snprintf(primbuf, sizeof(primbuf), "unknown primitive 0x%x", prim);
|
(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);
|
CASERET(DL_SUBS_BIND_PND);
|
||||||
default:
|
default:
|
||||||
(void) snprintf(statebuf, sizeof(statebuf), "unknown state 0x%x", state);
|
(void) snprintf(statebuf, sizeof(statebuf), "unknown state 0x%x", state);
|
||||||
return (statebuf);
|
return(statebuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,7 +1181,7 @@ dlerrno(u_long errno)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
(void) snprintf(errnobuf, sizeof(errnobuf), "unknown dlpi errno 0x%x", errno);
|
(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);
|
CASERET(DL_PROMISC_MULTI);
|
||||||
default:
|
default:
|
||||||
(void) snprintf(levelbuf, sizeof(levelbuf), "unknown promisc level 0x%x", level);
|
(void) snprintf(levelbuf, sizeof(levelbuf), "unknown promisc level 0x%x", level);
|
||||||
return (levelbuf);
|
return(levelbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1212,7 +1212,7 @@ dlservicemode(u_long servicemode)
|
|||||||
default:
|
default:
|
||||||
(void) snprintf(servicemodebuf, sizeof(servicemodebuf),
|
(void) snprintf(servicemodebuf, sizeof(servicemodebuf),
|
||||||
"unknown provider service mode 0x%x", servicemode);
|
"unknown provider service mode 0x%x", servicemode);
|
||||||
return (servicemodebuf);
|
return(servicemodebuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1226,7 +1226,7 @@ dlstyle(long style)
|
|||||||
CASERET(DL_STYLE2);
|
CASERET(DL_STYLE2);
|
||||||
default:
|
default:
|
||||||
(void) snprintf(stylebuf, sizeof(stylebuf), "unknown provider style 0x%x", style);
|
(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);
|
CASERET(DL_CTCA);
|
||||||
default:
|
default:
|
||||||
(void) snprintf(mediabuf, sizeof(mediabuf), "unknown media type 0x%x", media);
|
(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);
|
rc = ioctl(fd, I_STR, &sioc);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return (rc);
|
return(rc);
|
||||||
else
|
else
|
||||||
return (sioc.ic_len);
|
return(sioc.ic_len);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ chksum(u_short *buf, int len)
|
|||||||
sum += *buf++;
|
sum += *buf++;
|
||||||
sum = (sum>>16) + (sum & 0xffff);
|
sum = (sum>>16) + (sum & 0xffff);
|
||||||
sum += (sum >>16);
|
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)
|
else if (arp((char *)&gwip, (char *) &eh->ether_dhost) == -1)
|
||||||
{
|
{
|
||||||
perror("arp");
|
perror("arp");
|
||||||
return -2;
|
return(-2);
|
||||||
}
|
}
|
||||||
eh->ether_type = htons(ETHERTYPE_IP);
|
eh->ether_type = htons(ETHERTYPE_IP);
|
||||||
last_gw.s_addr = gwip.s_addr;
|
last_gw.s_addr = gwip.s_addr;
|
||||||
err = sendip(nfd, s, sizeof(*eh) + len);
|
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)
|
if (!ipbuf)
|
||||||
{
|
{
|
||||||
perror("malloc failed");
|
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)
|
else if (arp((char *)&gwip, (char *) &eh->ether_dhost) == -1)
|
||||||
{
|
{
|
||||||
perror("arp");
|
perror("arp");
|
||||||
return -2;
|
return(-2);
|
||||||
}
|
}
|
||||||
bcopy((char *) &eh->ether_dhost, last_arp, sizeof(last_arp));
|
bcopy((char *) &eh->ether_dhost, last_arp, sizeof(last_arp));
|
||||||
eh->ether_type = htons(ETHERTYPE_IP);
|
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",
|
fprintf(stderr, "mtu (%d) < ip header size (%d) + 8\n",
|
||||||
mtu, hlen);
|
mtu, hlen);
|
||||||
fprintf(stderr, "can't fragment data\n");
|
fprintf(stderr, "can't fragment data\n");
|
||||||
return -2;
|
return(-2);
|
||||||
}
|
}
|
||||||
ol = (IP_HL(ip) << 2) - sizeof(*ip);
|
ol = (IP_HL(ip) << 2) - sizeof(*ip);
|
||||||
for (i = 0, s = (char*)(ip + 1); ol > 0; )
|
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));
|
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));
|
t2->th_sum = chksum((u_short *)ip2, thlen + sizeof(ip_t));
|
||||||
|
|
||||||
bcopy((char *)t2, (char *)ip + hlen, thlen);
|
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,
|
bcopy((char *)&ti->ti_sport,
|
||||||
(char *)ip + (IP_HL(ip) << 2), sizeof(udphdr_t));
|
(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 = 0;
|
||||||
ic->icmp_cksum = chksum((u_short *)ic, sizeof(struct icmp));
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -340,12 +340,12 @@ send_packet(int nfd, int mtu, ip_t *ip, struct in_addr gwip)
|
|||||||
switch (ip->ip_p)
|
switch (ip->ip_p)
|
||||||
{
|
{
|
||||||
case IPPROTO_TCP :
|
case IPPROTO_TCP :
|
||||||
return send_tcp(nfd, mtu, ip, gwip);
|
( return send_tcp(nfd, mtu, ip, gwip));
|
||||||
case IPPROTO_UDP :
|
case IPPROTO_UDP :
|
||||||
return send_udp(nfd, mtu, ip, gwip);
|
( return send_udp(nfd, mtu, ip, gwip));
|
||||||
case IPPROTO_ICMP :
|
case IPPROTO_ICMP :
|
||||||
return send_icmp(nfd, mtu, ip, gwip);
|
( return send_icmp(nfd, mtu, ip, gwip));
|
||||||
default :
|
default :
|
||||||
return send_ip(nfd, mtu, ip, gwip, 1);
|
( return send_ip(nfd, mtu, ip, gwip, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,5 +128,5 @@ main(int argc, char **argv)
|
|||||||
printf("Gateway: %s\n", inet_ntoa(gwip));
|
printf("Gateway: %s\n", inet_ntoa(gwip));
|
||||||
printf("mtu: %d\n", mtu);
|
printf("mtu: %d\n", mtu);
|
||||||
|
|
||||||
return ip_resend(dev, mtu, ipr, gwip, resend);
|
return(ip_resend(dev, mtu, ipr, gwip, resend));
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,8 @@ send_packets(char *dev, int mtu, ip_t *ip, struct in_addr gwip)
|
|||||||
|
|
||||||
wfd = initdevice(dev, 5);
|
wfd = initdevice(dev, 5);
|
||||||
if (wfd == -1)
|
if (wfd == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
return send_packet(wfd, mtu, ip, gwip);
|
return(send_packet(wfd, mtu, ip, gwip));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -213,7 +213,7 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
iplang(langfile);
|
iplang(langfile);
|
||||||
return 0;
|
return(0);
|
||||||
case 'P' :
|
case 'P' :
|
||||||
{
|
{
|
||||||
struct protoent *p;
|
struct protoent *p;
|
||||||
@ -405,7 +405,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#ifdef DOSOCKET
|
#ifdef DOSOCKET
|
||||||
if (ip->ip_p == IPPROTO_TCP && tcp->th_dport)
|
if (ip->ip_p == IPPROTO_TCP && tcp->th_dport)
|
||||||
return do_socket(dev, mtu, ip, gwip);
|
return(do_socket(dev, mtu, ip, gwip));
|
||||||
#endif
|
#endif
|
||||||
return send_packets(dev, mtu, ip, gwip);
|
return(send_packets(dev, mtu, ip, gwip));
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,9 @@ u_short ipseclevel(slevel)
|
|||||||
|
|
||||||
if (!so->on_name) {
|
if (!so->on_name) {
|
||||||
fprintf(stderr, "no such security level: %s\n", slevel);
|
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) {
|
if ((len + io->on_siz) > 48) {
|
||||||
fprintf(stderr, "options too long\n");
|
fprintf(stderr, "options too long\n");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
len += io->on_siz;
|
len += io->on_siz;
|
||||||
*op++ = io->on_value;
|
*op++ = io->on_value;
|
||||||
@ -136,7 +136,7 @@ addipopt(char *op, struct ipopt_names *io, int len, char *class)
|
|||||||
else
|
else
|
||||||
op += io->on_siz - 3;
|
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) {
|
if (!io->on_name) {
|
||||||
fprintf(stderr, "unknown IP option name %s\n", s);
|
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);
|
||||||
}
|
}
|
||||||
|
@ -192,5 +192,5 @@ main(int argc, char **argv)
|
|||||||
ip_test7(dev, mtu, (ip_t *)ti, gwip, pointtest);
|
ip_test7(dev, mtu, (ip_t *)ti, gwip, pointtest);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ ip_resend(char *dev, int mtu, struct ipread *r, struct in_addr gwip,
|
|||||||
mb_t mb;
|
mb_t mb;
|
||||||
|
|
||||||
if (wfd == -1)
|
if (wfd == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
if (datain)
|
if (datain)
|
||||||
fd = (*r->r_open)(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)
|
if(!eh)
|
||||||
{
|
{
|
||||||
perror("malloc failed");
|
perror("malloc failed");
|
||||||
return -2;
|
return(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bzero((char *) &eh->ether_shost, sizeof(eh->ether_shost));
|
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");
|
perror("arp");
|
||||||
free(eh);
|
free(eh);
|
||||||
return -2;
|
return(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((i = (*r->r_readip)(&mb, NULL, NULL)) > 0)
|
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)();
|
(*r->r_close)();
|
||||||
free(eh);
|
free(eh);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ initdevice(char *device, int tout)
|
|||||||
if ((fd = open(bpfname, O_RDWR)) < 0)
|
if ((fd = open(bpfname, O_RDWR)) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "no bpf devices available as /dev/bpfxx\n");
|
fprintf(stderr, "no bpf devices available as /dev/bpfxx\n");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
char bpfname[16];
|
char bpfname[16];
|
||||||
@ -80,14 +80,14 @@ initdevice(char *device, int tout)
|
|||||||
if (i == 16)
|
if (i == 16)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "no bpf devices available as /dev/bpfxx\n");
|
fprintf(stderr, "no bpf devices available as /dev/bpfxx\n");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0)
|
if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0)
|
||||||
{
|
{
|
||||||
perror("BIOCVERSION");
|
perror("BIOCVERSION");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
if (bv.bv_major != BPF_MAJOR_VERSION ||
|
if (bv.bv_major != BPF_MAJOR_VERSION ||
|
||||||
bv.bv_minor < BPF_MINOR_VERSION)
|
bv.bv_minor < BPF_MINOR_VERSION)
|
||||||
@ -96,7 +96,7 @@ initdevice(char *device, int tout)
|
|||||||
bv.bv_major, bv.bv_minor);
|
bv.bv_major, bv.bv_minor);
|
||||||
fprintf(stderr, "current version: %d.%d\n",
|
fprintf(stderr, "current version: %d.%d\n",
|
||||||
BPF_MAJOR_VERSION, BPF_MINOR_VERSION);
|
BPF_MAJOR_VERSION, BPF_MINOR_VERSION);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
(void) strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
||||||
@ -128,7 +128,7 @@ initdevice(char *device, int tout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
(void) ioctl(fd, BIOCFLUSH, 0);
|
(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)
|
if (write(fd, pkt, len) == -1)
|
||||||
{
|
{
|
||||||
perror("send");
|
perror("send");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return(len);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ initdevice(char *device, int tout)
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return fd;
|
return(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -154,13 +154,13 @@ sendip(int fd, char *pkt, int len)
|
|||||||
if (putmsg(fd, cp, dp, pri) == -1)
|
if (putmsg(fd, cp, dp, pri) == -1)
|
||||||
{
|
{
|
||||||
perror("putmsg");
|
perror("putmsg");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
if (ioctl(fd, I_FLUSH, FLUSHW) == -1)
|
if (ioctl(fd, I_FLUSH, FLUSHW) == -1)
|
||||||
{
|
{
|
||||||
perror("I_FLUSHW");
|
perror("I_FLUSHW");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return len;
|
return(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ initdevice(char *device, int tout)
|
|||||||
perror(ifr.ifr_name);
|
perror(ifr.ifr_name);
|
||||||
exit(1);
|
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.
|
* For ethernet, need at least 802.3 header and IP header.
|
||||||
*/
|
*/
|
||||||
if (len < (sizeof(sa->sa_data) + sizeof(struct ip)))
|
if (len < (sizeof(sa->sa_data) + sizeof(struct ip)))
|
||||||
return -1;
|
return(-1);
|
||||||
/*
|
/*
|
||||||
* to avoid any output processing for IP, say we're not.
|
* 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)
|
if (putmsg(fd, cp, dp, 0) == -1)
|
||||||
{
|
{
|
||||||
perror("putmsg");
|
perror("putmsg");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fd, I_FLUSH, FLUSHW) == -1)
|
if (ioctl(fd, I_FLUSH, FLUSHW) == -1)
|
||||||
{
|
{
|
||||||
perror("I_FLUSH");
|
perror("I_FLUSH");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return len;
|
return(len);
|
||||||
}
|
}
|
||||||
|
@ -111,14 +111,14 @@ kmemcpy(char *buf, void *pos, int n)
|
|||||||
if (lseek(kfd, offset, SEEK_SET) == -1)
|
if (lseek(kfd, offset, SEEK_SET) == -1)
|
||||||
{
|
{
|
||||||
perror("lseek");
|
perror("lseek");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
if (read(kfd, buf, n) == -1)
|
if (read(kfd, buf, n) == -1)
|
||||||
{
|
{
|
||||||
perror("read");
|
perror("read");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return n;
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct nlist names[4] = {
|
struct nlist names[4] = {
|
||||||
@ -145,9 +145,9 @@ kinfo_proc *getproc(void)
|
|||||||
if (sysctl(mib, 4, &kp, &n, NULL, 0) == -1)
|
if (sysctl(mib, 4, &kp, &n, NULL, 0) == -1)
|
||||||
{
|
{
|
||||||
perror("sysctl");
|
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;
|
struct file *f, **o;
|
||||||
|
|
||||||
if (!(p = getproc()))
|
if (!(p = getproc()))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
fd = (struct filedesc *)malloc(sizeof(*fd));
|
fd = (struct filedesc *)malloc(sizeof(*fd));
|
||||||
if (fd == NULL)
|
if (fd == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
#if defined( __FreeBSD__)
|
#if defined( __FreeBSD__)
|
||||||
if (KMCPY(fd, p->ki_fd, sizeof(*fd)) == -1)
|
if (KMCPY(fd, p->ki_fd, sizeof(*fd)) == -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "read(%#lx,%#lx) failed\n",
|
fprintf(stderr, "read(%#lx,%#lx) failed\n",
|
||||||
(u_long)p, (u_long)p->ki_fd);
|
(u_long)p, (u_long)p->ki_fd);
|
||||||
free(fd);
|
free(fd);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (KMCPY(fd, p->kp_proc.p_fd, sizeof(*fd)) == -1)
|
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",
|
fprintf(stderr, "read(%#lx,%#lx) failed\n",
|
||||||
(u_long)p, (u_long)p->kp_proc.p_fd);
|
(u_long)p, (u_long)p->kp_proc.p_fd);
|
||||||
free(fd);
|
free(fd);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ find_tcp(int tfd, struct tcpiphdr *ti)
|
|||||||
(u_long)i->inp_ppcb, (u_long)t, (u_long)sizeof(*t));
|
(u_long)i->inp_ppcb, (u_long)t, (u_long)sizeof(*t));
|
||||||
goto finderror;
|
goto finderror;
|
||||||
}
|
}
|
||||||
return (struct tcpcb *)i->inp_ppcb;
|
return(struct tcpcb *)i->inp_ppcb;
|
||||||
|
|
||||||
finderror:
|
finderror:
|
||||||
if (o != NULL)
|
if (o != NULL)
|
||||||
@ -242,7 +242,7 @@ find_tcp(int tfd, struct tcpiphdr *ti)
|
|||||||
free(i);
|
free(i);
|
||||||
if (t != NULL)
|
if (t != NULL)
|
||||||
free(t);
|
free(t);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -259,13 +259,13 @@ do_socket(char *dev, int mtu, struct tcpiphdr *ti, struct in_addr gwip)
|
|||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
perror("socket");
|
perror("socket");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fcntl(fd, F_SETFL, FNDELAY) == -1)
|
if (fcntl(fd, F_SETFL, FNDELAY) == -1)
|
||||||
{
|
{
|
||||||
perror("fcntl");
|
perror("fcntl");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bzero((char *)&lsin, sizeof(lsin));
|
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)
|
if (bind(fd, (struct sockaddr *)&lsin, sizeof(lsin)) == -1)
|
||||||
{
|
{
|
||||||
perror("bind");
|
perror("bind");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
len = sizeof(lsin);
|
len = sizeof(lsin);
|
||||||
(void) getsockname(fd, (struct sockaddr *)&lsin, &len);
|
(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);
|
nfd = initdevice(dev, 1);
|
||||||
if (nfd == -1)
|
if (nfd == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
if (!(t = find_tcp(fd, ti)))
|
if (!(t = find_tcp(fd, ti)))
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
bzero((char *)&rsin, sizeof(rsin));
|
bzero((char *)&rsin, sizeof(rsin));
|
||||||
rsin.sin_family = AF_INET;
|
rsin.sin_family = AF_INET;
|
||||||
@ -298,7 +298,7 @@ do_socket(char *dev, int mtu, struct tcpiphdr *ti, struct in_addr gwip)
|
|||||||
errno != EINPROGRESS)
|
errno != EINPROGRESS)
|
||||||
{
|
{
|
||||||
perror("connect");
|
perror("connect");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
KMCPY(&tcb, t, sizeof(tcb));
|
KMCPY(&tcb, t, sizeof(tcb));
|
||||||
ti->ti_win = tcb.rcv_adv;
|
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;
|
ti->ti_ack = tcb.rcv_nxt;
|
||||||
|
|
||||||
if (send_tcp(nfd, mtu, (ip_t *)ti, gwip) == -1)
|
if (send_tcp(nfd, mtu, (ip_t *)ti, gwip) == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
(void)write(fd, "Hello World\n", 12);
|
(void)write(fd, "Hello World\n", 12);
|
||||||
sleep(2);
|
sleep(2);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -47,13 +47,13 @@ initdevice(char *device, int tout)
|
|||||||
if ((fd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
|
if ((fd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
|
||||||
{
|
{
|
||||||
perror("socket(AF_INET, SOCK_RAW, IPPROTO_RAW)");
|
perror("socket(AF_INET, SOCK_RAW, IPPROTO_RAW)");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fd, SIOCGIFADDR, &ifr) == -1)
|
if (ioctl(fd, SIOCGIFADDR, &ifr) == -1)
|
||||||
{
|
{
|
||||||
perror("ioctl SIOCGIFADDR");
|
perror("ioctl SIOCGIFADDR");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bzero((char *)&s, sizeof(s));
|
bzero((char *)&s, sizeof(s));
|
||||||
@ -61,7 +61,7 @@ initdevice(char *device, int tout)
|
|||||||
bcopy(&ifr.ifr_addr, s.sa_data, 4);
|
bcopy(&ifr.ifr_addr, s.sa_data, 4);
|
||||||
if (bind(fd, &s, sizeof(s)) == -1)
|
if (bind(fd, &s, sizeof(s)) == -1)
|
||||||
perror("bind");
|
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)
|
if (sendto(fd, pkt, len, 0, &sin, sizeof(sin)) == -1)
|
||||||
{
|
{
|
||||||
perror("send");
|
perror("send");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return(len);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ addipopt(char *op, struct ipopt_names *io, int len, char *class)
|
|||||||
|
|
||||||
if ((len + io->on_siz) > 48) {
|
if ((len + io->on_siz) > 48) {
|
||||||
fprintf(stderr, "options too long\n");
|
fprintf(stderr, "options too long\n");
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
len += io->on_siz;
|
len += io->on_siz;
|
||||||
*op++ = io->on_value;
|
*op++ = io->on_value;
|
||||||
@ -58,5 +58,5 @@ addipopt(char *op, struct ipopt_names *io, int len, char *class)
|
|||||||
if (opts & OPT_DEBUG)
|
if (opts & OPT_DEBUG)
|
||||||
fprintf(stderr, "bo: %s %d %#x: %d\n",
|
fprintf(stderr, "bo: %s %d %#x: %d\n",
|
||||||
io->on_name, io->on_value, io->on_bit, len);
|
io->on_name, io->on_value, io->on_bit, len);
|
||||||
return len - olen;
|
return(len - olen);
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,12 @@ alist_new(int family, char *host)
|
|||||||
family = AF_INET;
|
family = AF_INET;
|
||||||
}
|
}
|
||||||
if (family != AF_INET && family != AF_INET6)
|
if (family != AF_INET && family != AF_INET6)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
al = calloc(1, sizeof(*al));
|
al = calloc(1, sizeof(*al));
|
||||||
if (al == NULL) {
|
if (al == NULL) {
|
||||||
fprintf(stderr, "alist_new out of memory\n");
|
fprintf(stderr, "alist_new out of memory\n");
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ISSPACE(*host))
|
while (ISSPACE(*host))
|
||||||
@ -86,8 +86,8 @@ alist_new(int family, char *host)
|
|||||||
al->al_family = family;
|
al->al_family = family;
|
||||||
if (slash != NULL)
|
if (slash != NULL)
|
||||||
*slash = '/';
|
*slash = '/';
|
||||||
return al;
|
return(al);
|
||||||
bad:
|
bad:
|
||||||
free(al);
|
free(al);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ allocmbt(size_t len)
|
|||||||
|
|
||||||
m = (mb_t *)malloc(sizeof(mb_t));
|
m = (mb_t *)malloc(sizeof(mb_t));
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
m->mb_len = len;
|
m->mb_len = len;
|
||||||
m->mb_next = NULL;
|
m->mb_next = NULL;
|
||||||
m->mb_data = (char *)m->mb_buf;
|
m->mb_data = (char *)m->mb_buf;
|
||||||
return m;
|
return(m);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ int
|
|||||||
bcopywrap(void *from, void *to, size_t size)
|
bcopywrap(void *from, void *to, size_t size)
|
||||||
{
|
{
|
||||||
bcopy((caddr_t)from, (caddr_t)to, size);
|
bcopy((caddr_t)from, (caddr_t)to, size);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ buildopts(char *cp, char *op, int len)
|
|||||||
}
|
}
|
||||||
if (!io->on_name) {
|
if (!io->on_name) {
|
||||||
fprintf(stderr, "unknown IP option name %s\n", s);
|
fprintf(stderr, "unknown IP option name %s\n", s);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ((len & 3) != 3) {
|
while ((len & 3) != 3) {
|
||||||
@ -45,5 +45,5 @@ buildopts(char *cp, char *op, int len)
|
|||||||
}
|
}
|
||||||
*op++ = IPOPT_EOL;
|
*op++ = IPOPT_EOL;
|
||||||
len++;
|
len++;
|
||||||
return len;
|
return(len);
|
||||||
}
|
}
|
||||||
|
@ -29,18 +29,18 @@ checkrev(char *ipfname)
|
|||||||
|
|
||||||
if ((vfd == -1) && ((vfd = open(ipfname, O_RDONLY)) == -1)) {
|
if ((vfd == -1) && ((vfd = open(ipfname, O_RDONLY)) == -1)) {
|
||||||
perror("open device");
|
perror("open device");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(vfd, SIOCGETFS, &obj)) {
|
if (ioctl(vfd, SIOCGETFS, &obj)) {
|
||||||
ipferror(vfd, "ioctl(SIOCGETFS)");
|
ipferror(vfd, "ioctl(SIOCGETFS)");
|
||||||
close(vfd);
|
close(vfd);
|
||||||
vfd = -1;
|
vfd = -1;
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(IPL_VERSION, fio.f_version, sizeof(fio.f_version))) {
|
if (strncmp(IPL_VERSION, fio.f_version, sizeof(fio.f_version))) {
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -25,24 +25,24 @@ connecttcp(char *server, int port)
|
|||||||
|
|
||||||
if (ISDIGIT(*server)) {
|
if (ISDIGIT(*server)) {
|
||||||
if (inet_aton(server, &sin.sin_addr) == -1) {
|
if (inet_aton(server, &sin.sin_addr) == -1) {
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
host = gethostbyname(server);
|
host = gethostbyname(server);
|
||||||
if (host == NULL)
|
if (host == NULL)
|
||||||
return -1;
|
return(-1);
|
||||||
memcpy(&sin.sin_addr, host->h_addr_list[0],
|
memcpy(&sin.sin_addr, host->h_addr_list[0],
|
||||||
sizeof(sin.sin_addr));
|
sizeof(sin.sin_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = socket(AF_INET, SOCK_STREAM, 0);
|
fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
|
if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fd;
|
return(fd);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* count consecutive 1's in bit mask. If the mask generated by counting
|
* count consecutive 1's in bit mask. If the mask generated by counting
|
||||||
* consecutive 1's is different to that passed, return -1, else return #
|
* consecutive 1's is different to that passed, return -1, else return #
|
||||||
* of bits.
|
* of bits.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -35,6 +35,6 @@ count4bits(u_int ip)
|
|||||||
ipn++;
|
ipn++;
|
||||||
}
|
}
|
||||||
if (ipn == ip)
|
if (ipn == ip)
|
||||||
return cnt;
|
return(cnt);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -25,5 +25,5 @@ count6bits(u_32_t *msk)
|
|||||||
if (j & 0x80000000)
|
if (j & 0x80000000)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return i;
|
return(i);
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ dupmbt(mb_t *orig)
|
|||||||
|
|
||||||
m = (mb_t *)malloc(sizeof(mb_t));
|
m = (mb_t *)malloc(sizeof(mb_t));
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
m->mb_len = orig->mb_len;
|
m->mb_len = orig->mb_len;
|
||||||
m->mb_next = NULL;
|
m->mb_next = NULL;
|
||||||
m->mb_data = (char *)m->mb_buf + (orig->mb_data - (char *)orig->mb_buf);
|
m->mb_data = (char *)m->mb_buf + (orig->mb_data - (char *)orig->mb_buf);
|
||||||
bcopy(orig->mb_data, m->mb_data, m->mb_len);
|
bcopy(orig->mb_data, m->mb_data, m->mb_len);
|
||||||
return m;
|
return(m);
|
||||||
}
|
}
|
||||||
|
@ -82,13 +82,13 @@ fac_toname(int facpri)
|
|||||||
j = fac >> 3;
|
j = fac >> 3;
|
||||||
if (j < (sizeof(facs)/sizeof(facs[0]))) {
|
if (j < (sizeof(facs)/sizeof(facs[0]))) {
|
||||||
if (facs[j].value == fac)
|
if (facs[j].value == fac)
|
||||||
return facs[j].name;
|
return(facs[j].name);
|
||||||
}
|
}
|
||||||
for (i = 0; facs[i].name; i++)
|
for (i = 0; facs[i].name; i++)
|
||||||
if (fac == facs[i].value)
|
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++)
|
for (i = 0; facs[i].name; i++)
|
||||||
if (!strcmp(facs[i].name, name))
|
if (!strcmp(facs[i].name, name))
|
||||||
return facs[i].value;
|
return(facs[i].value);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -126,8 +126,8 @@ pri_findname(char *name)
|
|||||||
|
|
||||||
for (i = 0; pris[i].name; i++)
|
for (i = 0; pris[i].name; i++)
|
||||||
if (!strcmp(pris[i].name, name))
|
if (!strcmp(pris[i].name, name))
|
||||||
return pris[i].value;
|
return(pris[i].value);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,9 +141,9 @@ pri_toname(int facpri)
|
|||||||
|
|
||||||
pri = facpri & LOG_PRIMASK;
|
pri = facpri & LOG_PRIMASK;
|
||||||
if (pris[pri].value == pri)
|
if (pris[pri].value == pri)
|
||||||
return pris[pri].name;
|
return(pris[pri].name);
|
||||||
for (i = 0; pris[i].name; i++)
|
for (i = 0; pris[i].name; i++)
|
||||||
if (pri == pris[i].value)
|
if (pri == pris[i].value)
|
||||||
return pris[i].name;
|
return(pris[i].name);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ const char *
|
|||||||
familyname(int family)
|
familyname(int family)
|
||||||
{
|
{
|
||||||
if (family == AF_INET)
|
if (family == AF_INET)
|
||||||
return "inet";
|
return("inet");
|
||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
if (family == AF_INET6)
|
if (family == AF_INET6)
|
||||||
return "inet6";
|
return("inet6");
|
||||||
#endif
|
#endif
|
||||||
return "unknown";
|
return("unknown");
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ findword(wordtab_t *words, char *name)
|
|||||||
if (!strcmp(name, w->w_word))
|
if (!strcmp(name, w->w_word))
|
||||||
break;
|
break;
|
||||||
if (w->w_word == NULL)
|
if (w->w_word == NULL)
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
return w;
|
return(w);
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ ftov(int version)
|
|||||||
{
|
{
|
||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
if (version == AF_INET6)
|
if (version == AF_INET6)
|
||||||
return 6;
|
return(6);
|
||||||
#endif
|
#endif
|
||||||
if (version == AF_INET)
|
if (version == AF_INET)
|
||||||
return 4;
|
return(4);
|
||||||
if (version == AF_UNSPEC)
|
if (version == AF_UNSPEC)
|
||||||
return 0;
|
return(0);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ gethost(int family, char *name, i6addr_t *hostp)
|
|||||||
hostp->i6[3] = htonl(0xfedcba98);
|
hostp->i6[3] = htonl(0xfedcba98);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(name, "<thishost>"))
|
if (!strcmp(name, "<thishost>"))
|
||||||
@ -43,14 +43,14 @@ gethost(int family, char *name, i6addr_t *hostp)
|
|||||||
(h->h_length == sizeof(addr))) {
|
(h->h_length == sizeof(addr))) {
|
||||||
bcopy(h->h_addr, (char *)&addr, sizeof(addr));
|
bcopy(h->h_addr, (char *)&addr, sizeof(addr));
|
||||||
hostp->in4.s_addr = addr;
|
hostp->in4.s_addr = addr;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = getnetbyname(name);
|
n = getnetbyname(name);
|
||||||
if (n != NULL) {
|
if (n != NULL) {
|
||||||
hostp->in4.s_addr = htonl(n->n_net & 0xffffffff);
|
hostp->in4.s_addr = htonl(n->n_net & 0xffffffff);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
@ -66,9 +66,9 @@ gethost(int family, char *name, i6addr_t *hostp)
|
|||||||
sin6 = (struct sockaddr_in6 *)res->ai_addr;
|
sin6 = (struct sockaddr_in6 *)res->ai_addr;
|
||||||
hostp->in6 = sin6->sin6_addr;
|
hostp->in6 = sin6->sin6_addr;
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@ geticmptype(int family, char *name)
|
|||||||
for (i = icmptypelist; i->it_name != NULL; i++) {
|
for (i = icmptypelist; i->it_name != NULL; i++) {
|
||||||
if (!strcmp(name, i->it_name)) {
|
if (!strcmp(name, i->it_name)) {
|
||||||
if (family == AF_INET)
|
if (family == AF_INET)
|
||||||
return i->it_v4;
|
return(i->it_v4);
|
||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
if (family == AF_INET6)
|
if (family == AF_INET6)
|
||||||
return i->it_v6;
|
return(i->it_v6);
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "kmem.h"
|
#include "kmem.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given a pointer to an interface in the kernel, return a pointer to a
|
* Given a pointer to an interface in the kernel, return a pointer to a
|
||||||
* string which is the interface name.
|
* string which is the interface name.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
@ -27,28 +27,28 @@ getifname(struct ifnet *ptr)
|
|||||||
qif_t qif;
|
qif_t qif;
|
||||||
|
|
||||||
if ((void *)ptr == (void *)-1)
|
if ((void *)ptr == (void *)-1)
|
||||||
return "!";
|
return("!");
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return "-";
|
return("-");
|
||||||
|
|
||||||
if (kmemcpy((char *)&qif, (u_long)ptr, sizeof(qif)) == -1)
|
if (kmemcpy((char *)&qif, (u_long)ptr, sizeof(qif)) == -1)
|
||||||
return "X";
|
return("X");
|
||||||
ifname = strdup(qif.qf_name);
|
ifname = strdup(qif.qf_name);
|
||||||
if ((ifname != NULL) && (*ifname == '\0')) {
|
if ((ifname != NULL) && (*ifname == '\0')) {
|
||||||
free(ifname);
|
free(ifname);
|
||||||
return "!";
|
return("!");
|
||||||
}
|
}
|
||||||
return ifname;
|
return(ifname);
|
||||||
#else
|
#else
|
||||||
struct ifnet netif;
|
struct ifnet netif;
|
||||||
|
|
||||||
if ((void *)ptr == (void *)-1)
|
if ((void *)ptr == (void *)-1)
|
||||||
return "!";
|
return("!");
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return "-";
|
return("-");
|
||||||
|
|
||||||
if (kmemcpy((char *)&netif, (u_long)ptr, sizeof(netif)) == -1)
|
if (kmemcpy((char *)&netif, (u_long)ptr, sizeof(netif)) == -1)
|
||||||
return "X";
|
return("X");
|
||||||
return strdup(netif.if_xname);
|
return(strdup(netif.if_xname));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ getnattype(nat_t *nat)
|
|||||||
char *which;
|
char *which;
|
||||||
|
|
||||||
if (!nat)
|
if (!nat)
|
||||||
return "???";
|
return("???");
|
||||||
|
|
||||||
switch (nat->nat_redir)
|
switch (nat->nat_redir)
|
||||||
{
|
{
|
||||||
@ -65,5 +65,5 @@ getnattype(nat_t *nat)
|
|||||||
which = unknownbuf;
|
which = unknownbuf;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return which;
|
return(which);
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,17 @@ getport(frentry_t *fr, char *name, u_short *port, char *proto)
|
|||||||
s = getservbyname(name, proto);
|
s = getservbyname(name, proto);
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
*port = s->s_port;
|
*port = s->s_port;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ISDIGIT(*name)) {
|
if (ISDIGIT(*name)) {
|
||||||
int portval = atoi(name);
|
int portval = atoi(name);
|
||||||
if (portval < 0 || portval > 65535)
|
if (portval < 0 || portval > 65535)
|
||||||
return -1;
|
return(-1);
|
||||||
*port = htons((u_short)portval);
|
*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");
|
s = getservbyname(name, "udp");
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
if (p1 != s->s_port)
|
if (p1 != s->s_port)
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
if ((p1 == 0) && (s == NULL))
|
if ((p1 == 0) && (s == NULL))
|
||||||
return -1;
|
return(-1);
|
||||||
if (p1)
|
if (p1)
|
||||||
*port = p1;
|
*port = p1;
|
||||||
else
|
else
|
||||||
*port = s->s_port;
|
*port = s->s_port;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fr->fr_flx & FI_TCPUDP) != 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");
|
s = getservbyname(name, "tcp");
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return -1;
|
return(-1);
|
||||||
p1 = s->s_port;
|
p1 = s->s_port;
|
||||||
s = getservbyname(name, "udp");
|
s = getservbyname(name, "udp");
|
||||||
if (s == NULL || s->s_port != p1)
|
if (s == NULL || s->s_port != p1)
|
||||||
return -1;
|
return(-1);
|
||||||
*port = p1;
|
*port = p1;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
p = getprotobynumber(fr->fr_proto);
|
p = getprotobynumber(fr->fr_proto);
|
||||||
s = getservbyname(name, p ? p->p_name : NULL);
|
s = getservbyname(name, p ? p->p_name : NULL);
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
*port = s->s_port;
|
*port = s->s_port;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -23,17 +23,17 @@ getportproto(char *name, int proto)
|
|||||||
|
|
||||||
for (s = name; *s != '\0'; s++)
|
for (s = name; *s != '\0'; s++)
|
||||||
if (!ISDIGIT(*s))
|
if (!ISDIGIT(*s))
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
number = atoi(name);
|
number = atoi(name);
|
||||||
if (number < 0 || number > 65535)
|
if (number < 0 || number > 65535)
|
||||||
return -1;
|
return(-1);
|
||||||
return htons(number);
|
return(htons(number));
|
||||||
}
|
}
|
||||||
|
|
||||||
p = getprotobynumber(proto);
|
p = getprotobynumber(proto);
|
||||||
s = getservbyname(name, p ? p->p_name : NULL);
|
s = getservbyname(name, p ? p->p_name : NULL);
|
||||||
if (s != NULL)
|
if (s != NULL)
|
||||||
return s->s_port;
|
return(s->s_port);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,13 @@ getproto(char *name)
|
|||||||
if (!ISDIGIT(*s))
|
if (!ISDIGIT(*s))
|
||||||
break;
|
break;
|
||||||
if (*s == '\0')
|
if (*s == '\0')
|
||||||
return atoi(name);
|
return(atoi(name));
|
||||||
|
|
||||||
if (!strcasecmp(name, "ip"))
|
if (!strcasecmp(name, "ip"))
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
p = getprotobyname(name);
|
p = getprotobyname(name);
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
return p->p_proto;
|
return(p->p_proto);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,5 @@ getsumd(u_32_t sum)
|
|||||||
snprintf(sumdbuf, sizeof(sumdbuf), "hw(%#0x)", sum & 0xffff);
|
snprintf(sumdbuf, sizeof(sumdbuf), "hw(%#0x)", sum & 0xffff);
|
||||||
else
|
else
|
||||||
snprintf(sumdbuf, sizeof(sumdbuf), "%#0x", sum);
|
snprintf(sumdbuf, sizeof(sumdbuf), "%#0x", sum);
|
||||||
return sumdbuf;
|
return(sumdbuf);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ hostname(int family, void *ip)
|
|||||||
if (family == AF_INET) {
|
if (family == AF_INET) {
|
||||||
ipa.s_addr = *(u_32_t *)ip;
|
ipa.s_addr = *(u_32_t *)ip;
|
||||||
if (ipa.s_addr == htonl(0xfedcba98))
|
if (ipa.s_addr == htonl(0xfedcba98))
|
||||||
return ("test.host.dots");
|
return("test.host.dots");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((opts & OPT_NORESOLVE) == 0) {
|
if ((opts & OPT_NORESOLVE) == 0) {
|
||||||
@ -33,7 +33,7 @@ hostname(int family, void *ip)
|
|||||||
*hp->h_name != '\0') {
|
*hp->h_name != '\0') {
|
||||||
strncpy(hostbuf, hp->h_name, sizeof(hostbuf));
|
strncpy(hostbuf, hp->h_name, sizeof(hostbuf));
|
||||||
hostbuf[sizeof(hostbuf) - 1] = '\0';
|
hostbuf[sizeof(hostbuf) - 1] = '\0';
|
||||||
return (hostbuf);
|
return(hostbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
np = getnetbyaddr(ipa.s_addr, AF_INET);
|
np = getnetbyaddr(ipa.s_addr, AF_INET);
|
||||||
@ -41,19 +41,19 @@ hostname(int family, void *ip)
|
|||||||
*np->n_name != '\0') {
|
*np->n_name != '\0') {
|
||||||
strncpy(hostbuf, np->n_name, sizeof(hostbuf));
|
strncpy(hostbuf, np->n_name, sizeof(hostbuf));
|
||||||
hostbuf[sizeof(hostbuf) - 1] = '\0';
|
hostbuf[sizeof(hostbuf) - 1] = '\0';
|
||||||
return (hostbuf);
|
return(hostbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (family == AF_INET) {
|
if (family == AF_INET) {
|
||||||
return (inet_ntoa(ipa));
|
return(inet_ntoa(ipa));
|
||||||
}
|
}
|
||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
(void) inet_ntop(AF_INET6, ip, hostbuf, sizeof(hostbuf) - 1);
|
(void) inet_ntop(AF_INET6, ip, hostbuf, sizeof(hostbuf) - 1);
|
||||||
hostbuf[MAXHOSTNAMELEN] = '\0';
|
hostbuf[MAXHOSTNAMELEN] = '\0';
|
||||||
return (hostbuf);
|
return(hostbuf);
|
||||||
#else
|
#else
|
||||||
return ("IPv6");
|
return("IPv6");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,16 @@ icmptypename(int family, int type)
|
|||||||
icmptype_t *i;
|
icmptype_t *i;
|
||||||
|
|
||||||
if ((type < 0) || (type > 255))
|
if ((type < 0) || (type > 255))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
for (i = icmptypelist; i->it_name != NULL; i++) {
|
for (i = icmptypelist; i->it_name != NULL; i++) {
|
||||||
if ((family == AF_INET) && (i->it_v4 == type))
|
if ((family == AF_INET) && (i->it_v4 == type))
|
||||||
return i->it_name;
|
return(i->it_name);
|
||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
if ((family == AF_INET6) && (i->it_v6 == type))
|
if ((family == AF_INET6) && (i->it_v6 == type))
|
||||||
return i->it_name;
|
return(i->it_name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ int inet_aton(const char *, struct in_addr *);
|
|||||||
* Check whether "cp" is a valid ascii representation
|
* Check whether "cp" is a valid ascii representation
|
||||||
* of an Internet address and convert to a binary address.
|
* of an Internet address and convert to a binary address.
|
||||||
* Returns 1 if the address is valid, 0 if not.
|
* Returns 1 if the address is valid, 0 if not.
|
||||||
* This replaces inet_addr, the return value from which
|
* This replaces inet_addr, the return value from which
|
||||||
* cannot distinguish between failure and a local broadcast address.
|
* cannot distinguish between failure and a local broadcast address.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -108,7 +108,7 @@ inet_aton(register const char *cp, struct in_addr *addr)
|
|||||||
* 0x=hex, 0=octal, isdigit=decimal.
|
* 0x=hex, 0=octal, isdigit=decimal.
|
||||||
*/
|
*/
|
||||||
if (!ISDIGIT(c))
|
if (!ISDIGIT(c))
|
||||||
return (0);
|
return(0);
|
||||||
val = 0; base = 10;
|
val = 0; base = 10;
|
||||||
if (c == '0') {
|
if (c == '0') {
|
||||||
c = *++cp;
|
c = *++cp;
|
||||||
@ -136,7 +136,7 @@ inet_aton(register const char *cp, struct in_addr *addr)
|
|||||||
* a.b (with b treated as 24 bits)
|
* a.b (with b treated as 24 bits)
|
||||||
*/
|
*/
|
||||||
if (pp >= parts + 3)
|
if (pp >= parts + 3)
|
||||||
return (0);
|
return(0);
|
||||||
*pp++ = val;
|
*pp++ = val;
|
||||||
c = *++cp;
|
c = *++cp;
|
||||||
} else
|
} else
|
||||||
@ -146,7 +146,7 @@ inet_aton(register const char *cp, struct in_addr *addr)
|
|||||||
* Check for trailing characters.
|
* Check for trailing characters.
|
||||||
*/
|
*/
|
||||||
if (c != '\0' && (!ISASCII(c) || !ISSPACE(c)))
|
if (c != '\0' && (!ISASCII(c) || !ISSPACE(c)))
|
||||||
return (0);
|
return(0);
|
||||||
/*
|
/*
|
||||||
* Concoct the address according to
|
* Concoct the address according to
|
||||||
* the number of parts specified.
|
* the number of parts specified.
|
||||||
@ -155,32 +155,32 @@ inet_aton(register const char *cp, struct in_addr *addr)
|
|||||||
switch (n) {
|
switch (n) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
return (0); /* initial nondigit */
|
return(0); /* initial nondigit */
|
||||||
|
|
||||||
case 1: /* a -- 32 bits */
|
case 1: /* a -- 32 bits */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* a.b -- 8.24 bits */
|
case 2: /* a.b -- 8.24 bits */
|
||||||
if (val > 0xffffff)
|
if (val > 0xffffff)
|
||||||
return (0);
|
return(0);
|
||||||
val |= parts[0] << 24;
|
val |= parts[0] << 24;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: /* a.b.c -- 8.8.16 bits */
|
case 3: /* a.b.c -- 8.8.16 bits */
|
||||||
if (val > 0xffff)
|
if (val > 0xffff)
|
||||||
return (0);
|
return(0);
|
||||||
val |= (parts[0] << 24) | (parts[1] << 16);
|
val |= (parts[0] << 24) | (parts[1] << 16);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: /* a.b.c.d -- 8.8.8.8 bits */
|
case 4: /* a.b.c.d -- 8.8.8.8 bits */
|
||||||
if (val > 0xff)
|
if (val > 0xff)
|
||||||
return (0);
|
return(0);
|
||||||
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (addr)
|
if (addr)
|
||||||
addr->s_addr = htonl(val);
|
addr->s_addr = htonl(val);
|
||||||
return (1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* these are compatibility routines, not needed on recent BSD releases */
|
/* these are compatibility routines, not needed on recent BSD releases */
|
||||||
@ -195,7 +195,7 @@ inet_addr(const char *cp)
|
|||||||
struct in_addr val;
|
struct in_addr val;
|
||||||
|
|
||||||
if (inet_aton(cp, &val))
|
if (inet_aton(cp, &val))
|
||||||
return (val.s_addr);
|
return(val.s_addr);
|
||||||
return (0xffffffff);
|
return(0xffffffff);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -530,7 +530,7 @@ find_error(int errnum)
|
|||||||
while (step != 0) {
|
while (step != 0) {
|
||||||
ie = ipf_errors + l + step;
|
ie = ipf_errors + l + step;
|
||||||
if (ie->iee_number == errnum)
|
if (ie->iee_number == errnum)
|
||||||
return ie;
|
return(ie);
|
||||||
step = l + step;
|
step = l + step;
|
||||||
if (ie->iee_number > errnum)
|
if (ie->iee_number > errnum)
|
||||||
r = step;
|
r = step;
|
||||||
@ -539,7 +539,7 @@ find_error(int errnum)
|
|||||||
step = (r - l) / 2;;
|
step = (r - l) / 2;;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -553,12 +553,12 @@ ipf_geterror(int fd, ioctlfunc_t *func)
|
|||||||
|
|
||||||
ie = find_error(errnum);
|
ie = find_error(errnum);
|
||||||
if (ie != NULL)
|
if (ie != NULL)
|
||||||
return ie->iee_text;
|
return(ie->iee_text);
|
||||||
snprintf(text, sizeof(text), "unknown error %d", errnum);
|
snprintf(text, sizeof(text), "unknown error %d", errnum);
|
||||||
} else {
|
} else {
|
||||||
snprintf(text, sizeof(text), "retrieving error number failed (%d)", errno);
|
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);
|
ie = find_error(errnum);
|
||||||
if (ie != NULL)
|
if (ie != NULL)
|
||||||
return ie->iee_text;
|
return(ie->iee_text);
|
||||||
|
|
||||||
snprintf(text, sizeof(text), "unknown error %d", errnum);
|
snprintf(text, sizeof(text), "unknown error %d", errnum);
|
||||||
return text;
|
return(text);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ ipf_perror_fd( int fd, ioctlfunc_t iocfunc, char *string)
|
|||||||
errno = save;
|
errno = save;
|
||||||
fprintf(stderr, "%d:", realerr);
|
fprintf(stderr, "%d:", realerr);
|
||||||
ipf_perror(realerr, string);
|
ipf_perror(realerr, string);
|
||||||
return realerr ? realerr : save;
|
return(realerr ? realerr : save);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ hex_open(char *fname)
|
|||||||
{
|
{
|
||||||
if (tfp && tfd != -1) {
|
if (tfp && tfd != -1) {
|
||||||
rewind(tfp);
|
rewind(tfp);
|
||||||
return tfd;
|
return(tfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(fname, "-")) {
|
if (!strcmp(fname, "-")) {
|
||||||
@ -43,7 +43,7 @@ hex_open(char *fname)
|
|||||||
if (tfd != -1)
|
if (tfd != -1)
|
||||||
tfp = fdopen(tfd, "r");
|
tfp = fdopen(tfd, "r");
|
||||||
}
|
}
|
||||||
return tfd;
|
return(tfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ hex_close(void)
|
|||||||
int cfd = tfd;
|
int cfd = tfd;
|
||||||
|
|
||||||
tfd = -1;
|
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 = strchr(line, '\n'))) {
|
||||||
if (s == line) {
|
if (s == line) {
|
||||||
mb->mb_len = (char *)ip - buf;
|
mb->mb_len = (char *)ip - buf;
|
||||||
return mb->mb_len;
|
return(mb->mb_len);
|
||||||
}
|
}
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
}
|
}
|
||||||
@ -147,8 +147,8 @@ hex_readip(mb_t *mb, char **ifn, int *dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (feof(tfp))
|
if (feof(tfp))
|
||||||
return 0;
|
return(0);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -178,5 +178,5 @@ static char
|
|||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return dst;
|
return(dst);
|
||||||
}
|
}
|
||||||
|
@ -85,20 +85,20 @@ ipcap_open(char *fname)
|
|||||||
int fd, i;
|
int fd, i;
|
||||||
|
|
||||||
if (pfd != -1)
|
if (pfd != -1)
|
||||||
return pfd;
|
return(pfd);
|
||||||
|
|
||||||
if (!strcmp(fname, "-"))
|
if (!strcmp(fname, "-"))
|
||||||
fd = 0;
|
fd = 0;
|
||||||
else if ((fd = open(fname, O_RDONLY)) == -1)
|
else if ((fd = open(fname, O_RDONLY)) == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
if (read(fd, (char *)&ph, sizeof(ph)) != sizeof(ph))
|
if (read(fd, (char *)&ph, sizeof(ph)) != sizeof(ph))
|
||||||
return -2;
|
return(-2);
|
||||||
|
|
||||||
if (ph.id != 0xa1b2c3d4) {
|
if (ph.id != 0xa1b2c3d4) {
|
||||||
if (SWAPLONG(ph.id) != 0xa1b2c3d4) {
|
if (SWAPLONG(ph.id) != 0xa1b2c3d4) {
|
||||||
(void) close(fd);
|
(void) close(fd);
|
||||||
return -2;
|
return(-2);
|
||||||
}
|
}
|
||||||
swapped = 1;
|
swapped = 1;
|
||||||
iswap_hdr(&ph);
|
iswap_hdr(&ph);
|
||||||
@ -112,7 +112,7 @@ ipcap_open(char *fname)
|
|||||||
|
|
||||||
if (llcp == NULL) {
|
if (llcp == NULL) {
|
||||||
(void) close(fd);
|
(void) close(fd);
|
||||||
return -2;
|
return(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
pfd = fd;
|
pfd = fd;
|
||||||
@ -120,14 +120,14 @@ ipcap_open(char *fname)
|
|||||||
printf("\tid: %08x version: %d.%d type: %d snap %d\n",
|
printf("\tid: %08x version: %d.%d type: %d snap %d\n",
|
||||||
ph.id, ph.major, ph.minor, ph.type, ph.snaplen);
|
ph.id, ph.major, ph.minor, ph.type, ph.snaplen);
|
||||||
|
|
||||||
return fd;
|
return(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ipcap_close(void)
|
ipcap_close(void)
|
||||||
{
|
{
|
||||||
return close(pfd);
|
return(close(pfd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ ipcap_read_rec(packetheader_t *rec)
|
|||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
i = read(pfd, (char *)rec, sizeof(*rec));
|
i = read(pfd, (char *)rec, sizeof(*rec));
|
||||||
if (i <= 0)
|
if (i <= 0)
|
||||||
return -2;
|
return(-2);
|
||||||
n -= i;
|
n -= i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,11 +158,11 @@ ipcap_read_rec(packetheader_t *rec)
|
|||||||
p = rec->caplen;
|
p = rec->caplen;
|
||||||
n = MIN(p, rec->wirelen);
|
n = MIN(p, rec->wirelen);
|
||||||
if (!n || n < 0)
|
if (!n || n < 0)
|
||||||
return -3;
|
return(-3);
|
||||||
|
|
||||||
if (p < 0 || p > 65536)
|
if (p < 0 || p > 65536)
|
||||||
return -4;
|
return(-4);
|
||||||
return p;
|
return(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ ipcap_read(char *buf, int cnt)
|
|||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
if ((i = ipcap_read_rec(&rec)) <= 0)
|
if ((i = ipcap_read_rec(&rec)) <= 0)
|
||||||
return i;
|
return(i);
|
||||||
|
|
||||||
if (!bufp)
|
if (!bufp)
|
||||||
bufp = malloc(i);
|
bufp = malloc(i);
|
||||||
@ -187,17 +187,17 @@ ipcap_read(char *buf, int cnt)
|
|||||||
bufp = realloc(bufp, i);
|
bufp = realloc(bufp, i);
|
||||||
|
|
||||||
if (read(pfd, bufp, i) != i)
|
if (read(pfd, bufp, i) != i)
|
||||||
return -2;
|
return(-2);
|
||||||
|
|
||||||
n = MIN(i, cnt);
|
n = MIN(i, cnt);
|
||||||
bcopy(bufp, buf, n);
|
bcopy(bufp, buf, n);
|
||||||
return n;
|
return(n);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return only an IP packet read into buf
|
* return only an IP packet read into buf
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ipcap_readip(mb_t *mb, char **ifn, int *dir)
|
ipcap_readip(mb_t *mb, char **ifn, int *dir)
|
||||||
@ -220,7 +220,7 @@ ipcap_readip(mb_t *mb, char **ifn, int *dir)
|
|||||||
|
|
||||||
/* do { */
|
/* do { */
|
||||||
if ((i = ipcap_read_rec(&rec)) <= 0)
|
if ((i = ipcap_read_rec(&rec)) <= 0)
|
||||||
return i;
|
return(i);
|
||||||
|
|
||||||
if (!bufp)
|
if (!bufp)
|
||||||
bufp = malloc(i);
|
bufp = malloc(i);
|
||||||
@ -231,7 +231,7 @@ ipcap_readip(mb_t *mb, char **ifn, int *dir)
|
|||||||
for (j = i, n = 0; j > 0; ) {
|
for (j = i, n = 0; j > 0; ) {
|
||||||
n = read(pfd, s, j);
|
n = read(pfd, s, j);
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
return -2;
|
return(-2);
|
||||||
j -= n;
|
j -= n;
|
||||||
s += n;
|
s += n;
|
||||||
}
|
}
|
||||||
@ -245,5 +245,5 @@ ipcap_readip(mb_t *mb, char **ifn, int *dir)
|
|||||||
n = MIN(i, cnt);
|
n = MIN(i, cnt);
|
||||||
bcopy(s, buf, n);
|
bcopy(s, buf, n);
|
||||||
mb->mb_len = n;
|
mb->mb_len = n;
|
||||||
return n;
|
return(n);
|
||||||
}
|
}
|
||||||
|
@ -51,16 +51,16 @@ tx_hostnum(char *host, int *resolved)
|
|||||||
|
|
||||||
*resolved = 0;
|
*resolved = 0;
|
||||||
if (!strcasecmp("any", host))
|
if (!strcasecmp("any", host))
|
||||||
return 0L;
|
return(0L);
|
||||||
if (ISDIGIT(*host))
|
if (ISDIGIT(*host))
|
||||||
return inet_addr(host);
|
return(inet_addr(host));
|
||||||
|
|
||||||
if (gethost(AF_INET, host, &ipa) == -1) {
|
if (gethost(AF_INET, host, &ipa) == -1) {
|
||||||
*resolved = -1;
|
*resolved = -1;
|
||||||
fprintf(stderr, "can't resolve hostname: %s\n", host);
|
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;
|
struct servent *sp;
|
||||||
|
|
||||||
if (ISDIGIT(*name))
|
if (ISDIGIT(*name))
|
||||||
return (u_short)atoi(name);
|
return(u_short)atoi(name);
|
||||||
sp = getservbyname(name, tx_proto);
|
sp = getservbyname(name, tx_proto);
|
||||||
if (sp)
|
if (sp)
|
||||||
return ntohs(sp->s_port);
|
return(ntohs(sp->s_port));
|
||||||
(void) fprintf(stderr, "unknown service \"%s\".\n", name);
|
(void) fprintf(stderr, "unknown service \"%s\".\n", name);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ text_open(char *fname)
|
|||||||
{
|
{
|
||||||
if (tfp && tfd != -1) {
|
if (tfp && tfd != -1) {
|
||||||
rewind(tfp);
|
rewind(tfp);
|
||||||
return tfd;
|
return(tfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(fname, "-")) {
|
if (!strcmp(fname, "-")) {
|
||||||
@ -99,7 +99,7 @@ text_open(char *fname)
|
|||||||
if (tfd != -1)
|
if (tfd != -1)
|
||||||
tfp = fdopen(tfd, "r");
|
tfp = fdopen(tfd, "r");
|
||||||
}
|
}
|
||||||
return tfd;
|
return(tfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ text_close(void)
|
|||||||
int cfd = tfd;
|
int cfd = tfd;
|
||||||
|
|
||||||
tfd = -1;
|
tfd = -1;
|
||||||
return close(cfd);
|
return(close(cfd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,12 +149,12 @@ text_readip(mb_t *mb, char **ifn, int *dir)
|
|||||||
} else {
|
} else {
|
||||||
mb->mb_len = ntohs(ip->ip_len);
|
mb->mb_len = ntohs(ip->ip_len);
|
||||||
}
|
}
|
||||||
return mb->mb_len;
|
return(mb->mb_len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (feof(tfp))
|
if (feof(tfp))
|
||||||
return 0;
|
return(0);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -179,32 +179,32 @@ parseline(char *line, ip_t *ip, char **ifn, int *out)
|
|||||||
|
|
||||||
cpp = cps;
|
cpp = cps;
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
|
|
||||||
c = **cpp;
|
c = **cpp;
|
||||||
if (!ISALPHA(c) || (TOLOWER(c) != 'o' && TOLOWER(c) != 'i')) {
|
if (!ISALPHA(c) || (TOLOWER(c) != 'o' && TOLOWER(c) != 'i')) {
|
||||||
fprintf(stderr, "bad direction \"%s\"\n", *cpp);
|
fprintf(stderr, "bad direction \"%s\"\n", *cpp);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_INET6
|
#ifdef USE_INET6
|
||||||
if (!strcasecmp(*cpp, "out6") || !strcasecmp(*cpp, "in6")) {
|
if (!strcasecmp(*cpp, "out6") || !strcasecmp(*cpp, "in6")) {
|
||||||
return parseipv6(cpp, (ip6_t *)ip, ifn, out);
|
return(parseipv6(cpp, (ip6_t *)ip, ifn, out));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*out = (TOLOWER(c) == 'o') ? 1 : 0;
|
*out = (TOLOWER(c) == 'o') ? 1 : 0;
|
||||||
cpp++;
|
cpp++;
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
|
|
||||||
if (!strcasecmp(*cpp, "on")) {
|
if (!strcasecmp(*cpp, "on")) {
|
||||||
cpp++;
|
cpp++;
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
*ifn = strdup(*cpp++);
|
*ifn = strdup(*cpp++);
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = **cpp;
|
c = **cpp;
|
||||||
@ -232,14 +232,14 @@ parseline(char *line, ip_t *ip, char **ifn, int *out)
|
|||||||
ip->ip_p = IPPROTO_IP;
|
ip->ip_p = IPPROTO_IP;
|
||||||
|
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) {
|
if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) {
|
||||||
char *last;
|
char *last;
|
||||||
|
|
||||||
last = strchr(*cpp, ',');
|
last = strchr(*cpp, ',');
|
||||||
if (!last) {
|
if (!last) {
|
||||||
fprintf(stderr, "tcp/udp with no source port\n");
|
fprintf(stderr, "tcp/udp with no source port\n");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
*last++ = '\0';
|
*last++ = '\0';
|
||||||
tcp->th_sport = htons(tx_portnum(last));
|
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);
|
ip->ip_src.s_addr = tx_hostnum(*cpp, &r);
|
||||||
cpp++;
|
cpp++;
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
|
|
||||||
if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) {
|
if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) {
|
||||||
char *last;
|
char *last;
|
||||||
@ -259,7 +259,7 @@ parseline(char *line, ip_t *ip, char **ifn, int *out)
|
|||||||
last = strchr(*cpp, ',');
|
last = strchr(*cpp, ',');
|
||||||
if (!last) {
|
if (!last) {
|
||||||
fprintf(stderr, "tcp/udp with no destination port\n");
|
fprintf(stderr, "tcp/udp with no destination port\n");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
*last++ = '\0';
|
*last++ = '\0';
|
||||||
tcp->th_dport = htons(tx_portnum(last));
|
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),
|
bcopy((char *)ic, ((char *)ip) + (IP_HL(ip) << 2),
|
||||||
sizeof(*ic));
|
sizeof(*ic));
|
||||||
ip->ip_len = htons(ip->ip_len);
|
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;
|
*out = (**cpp == 'o') ? 1 : 0;
|
||||||
cpp++;
|
cpp++;
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
|
|
||||||
if (!strcasecmp(*cpp, "on")) {
|
if (!strcasecmp(*cpp, "on")) {
|
||||||
cpp++;
|
cpp++;
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
*ifn = strdup(*cpp++);
|
*ifn = strdup(*cpp++);
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(*cpp, "tcp")) {
|
if (!strcasecmp(*cpp, "tcp")) {
|
||||||
@ -376,7 +376,7 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
|
|||||||
ip6->ip6_nxt = IPPROTO_IPV6;
|
ip6->ip6_nxt = IPPROTO_IPV6;
|
||||||
|
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
|
|
||||||
switch (ip6->ip6_nxt)
|
switch (ip6->ip6_nxt)
|
||||||
{
|
{
|
||||||
@ -399,7 +399,7 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
|
|||||||
last = strchr(*cpp, ',');
|
last = strchr(*cpp, ',');
|
||||||
if (!last) {
|
if (!last) {
|
||||||
fprintf(stderr, "tcp/udp with no source port\n");
|
fprintf(stderr, "tcp/udp with no source port\n");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
*last++ = '\0';
|
*last++ = '\0';
|
||||||
tcp->th_sport = htons(tx_portnum(last));
|
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) {
|
if (inet_pton(AF_INET6, *cpp, &ip6->ip6_src) != 1) {
|
||||||
fprintf(stderr, "cannot parse source address '%s'\n", *cpp);
|
fprintf(stderr, "cannot parse source address '%s'\n", *cpp);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cpp++;
|
cpp++;
|
||||||
if (!*cpp)
|
if (!*cpp)
|
||||||
return 1;
|
return(1);
|
||||||
|
|
||||||
if (ip6->ip6_nxt == IPPROTO_TCP || ip6->ip6_nxt == IPPROTO_UDP) {
|
if (ip6->ip6_nxt == IPPROTO_TCP || ip6->ip6_nxt == IPPROTO_UDP) {
|
||||||
char *last;
|
char *last;
|
||||||
@ -424,7 +424,7 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
|
|||||||
last = strchr(*cpp, ',');
|
last = strchr(*cpp, ',');
|
||||||
if (!last) {
|
if (!last) {
|
||||||
fprintf(stderr, "tcp/udp with no destination port\n");
|
fprintf(stderr, "tcp/udp with no destination port\n");
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
*last++ = '\0';
|
*last++ = '\0';
|
||||||
tcp->th_dport = htons(tx_portnum(last));
|
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) {
|
if (inet_pton(AF_INET6, *cpp, &ip6->ip6_dst) != 1) {
|
||||||
fprintf(stderr, "cannot parse destination address '%s'\n",
|
fprintf(stderr, "cannot parse destination address '%s'\n",
|
||||||
*cpp);
|
*cpp);
|
||||||
return 1;
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cpp++;
|
cpp++;
|
||||||
@ -495,6 +495,6 @@ parseipv6(char **cpp, ip6_t *ip6, char **ifn, int *out)
|
|||||||
ip6->ip6_plen++;
|
ip6->ip6_plen++;
|
||||||
}
|
}
|
||||||
ip6->ip6_plen = htons(ip6->ip6_plen);
|
ip6->ip6_plen = htons(ip6->ip6_plen);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,7 +30,7 @@ seclevel(char *slevel)
|
|||||||
struct ipopt_names *so;
|
struct ipopt_names *so;
|
||||||
|
|
||||||
if (slevel == NULL || *slevel == '\0')
|
if (slevel == NULL || *slevel == '\0')
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
for (so = secclass; so->on_name; so++)
|
for (so = secclass; so->on_name; so++)
|
||||||
if (!strcasecmp(slevel, so->on_name))
|
if (!strcasecmp(slevel, so->on_name))
|
||||||
@ -38,9 +38,9 @@ seclevel(char *slevel)
|
|||||||
|
|
||||||
if (!so->on_name) {
|
if (!so->on_name) {
|
||||||
fprintf(stderr, "no such security level: '%s'\n", slevel);
|
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) {
|
if (!so->on_name) {
|
||||||
fprintf(stderr, "no such security class: %d.\n", class);
|
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;
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,9 @@ openkmem(char *kern, char *core)
|
|||||||
if (kvm_f == NULL)
|
if (kvm_f == NULL)
|
||||||
{
|
{
|
||||||
perror("openkmem:open");
|
perror("openkmem:open");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return kvm_f != NULL;
|
return(kvm_f != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -58,18 +58,18 @@ kmemcpy(register char *buf, long pos, register int n)
|
|||||||
register int r;
|
register int r;
|
||||||
|
|
||||||
if (!n)
|
if (!n)
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
if (kvm_f == NULL)
|
if (kvm_f == NULL)
|
||||||
if (openkmem(NULL, NULL) == -1)
|
if (openkmem(NULL, NULL) == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
while ((r = kvm_read(kvm_f, pos, buf, n)) < n)
|
while ((r = kvm_read(kvm_f, pos, buf, n)) < n)
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "pos=0x%lx ", (u_long)pos);
|
fprintf(stderr, "pos=0x%lx ", (u_long)pos);
|
||||||
perror("kmemcpy:read");
|
perror("kmemcpy:read");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ kmemcpy(register char *buf, long pos, register int n)
|
|||||||
pos += r;
|
pos += r;
|
||||||
n -= r;
|
n -= r;
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -86,11 +86,11 @@ kstrncpy(register char *buf, long pos, register int n)
|
|||||||
register int r;
|
register int r;
|
||||||
|
|
||||||
if (!n)
|
if (!n)
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
if (kvm_f == NULL)
|
if (kvm_f == NULL)
|
||||||
if (openkmem(NULL, NULL) == -1)
|
if (openkmem(NULL, NULL) == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
while (n > 0)
|
while (n > 0)
|
||||||
{
|
{
|
||||||
@ -99,7 +99,7 @@ kstrncpy(register char *buf, long pos, register int n)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "pos=0x%lx ", (u_long)pos);
|
fprintf(stderr, "pos=0x%lx ", (u_long)pos);
|
||||||
perror("kmemcpy:read");
|
perror("kmemcpy:read");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -110,5 +110,5 @@ kstrncpy(register char *buf, long pos, register int n)
|
|||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ kmemcpywrap(void *from, void *to, size_t size)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = kmemcpy((caddr_t)to, (u_long)from, size);
|
ret = kmemcpy((caddr_t)to, (u_long)from, size);
|
||||||
return ret;
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,12 +27,12 @@ kvatoname(ipfunc_t func, ioctlfunc_t iocfunc)
|
|||||||
if ((opts & OPT_DONTOPEN) == 0) {
|
if ((opts & OPT_DONTOPEN) == 0) {
|
||||||
fd = open(IPL_NAME, O_RDONLY);
|
fd = open(IPL_NAME, O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
(void) (*iocfunc)(fd, SIOCFUNCL, &res);
|
(void) (*iocfunc)(fd, SIOCFUNCL, &res);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
strncpy(funcname, res.ipfu_name, sizeof(funcname));
|
strncpy(funcname, res.ipfu_name, sizeof(funcname));
|
||||||
funcname[sizeof(funcname) - 1] = '\0';
|
funcname[sizeof(funcname) - 1] = '\0';
|
||||||
return funcname;
|
return(funcname);
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ load_dstlist(ippool_dst_t *dst, ioctlfunc_t iocfunc, ipf_dstnode_t *nodes)
|
|||||||
ippool_dst_t dest;
|
ippool_dst_t dest;
|
||||||
|
|
||||||
if (dst->ipld_name[0] == '\0')
|
if (dst->ipld_name[0] == '\0')
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
if (pool_open() == -1)
|
if (pool_open() == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
op.iplo_unit = dst->ipld_unit;
|
op.iplo_unit = dst->ipld_unit;
|
||||||
op.iplo_type = IPLT_DSTLIST;
|
op.iplo_type = IPLT_DSTLIST;
|
||||||
@ -41,8 +41,8 @@ load_dstlist(ippool_dst_t *dst, ioctlfunc_t iocfunc, ipf_dstnode_t *nodes)
|
|||||||
if ((opts & OPT_REMOVE) == 0) {
|
if ((opts & OPT_REMOVE) == 0) {
|
||||||
if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op))
|
if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op))
|
||||||
if ((opts & OPT_DONOTHING) == 0) {
|
if ((opts & OPT_DONOTHING) == 0) {
|
||||||
return ipf_perror_fd(pool_fd(), iocfunc,
|
return(ipf_perror_fd(pool_fd(), iocfunc,
|
||||||
"add destination list table");
|
"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 ((opts & OPT_REMOVE) != 0) {
|
||||||
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
|
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
|
||||||
if ((opts & OPT_DONOTHING) == 0) {
|
if ((opts & OPT_DONOTHING) == 0) {
|
||||||
return ipf_perror_fd(pool_fd(), iocfunc,
|
return(ipf_perror_fd(pool_fd(), iocfunc,
|
||||||
"delete destination list table");
|
"delete destination list table"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,11 @@ load_dstlistnode(int role, char *name, ipf_dstnode_t *node,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (pool_open() == -1)
|
if (pool_open() == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
dst = calloc(1, sizeof(*dst) + node->ipfd_dest.fd_name);
|
dst = calloc(1, sizeof(*dst) + node->ipfd_dest.fd_name);
|
||||||
if (dst == NULL)
|
if (dst == NULL)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
op.iplo_unit = role;
|
op.iplo_unit = role;
|
||||||
op.iplo_type = IPLT_DSTLIST;
|
op.iplo_type = IPLT_DSTLIST;
|
||||||
@ -59,9 +59,9 @@ load_dstlistnode(int role, char *name, ipf_dstnode_t *node,
|
|||||||
char msg[80];
|
char msg[80];
|
||||||
|
|
||||||
(void) snprintf(msg, sizeof(msg), "%s lookup node", what);
|
(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);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ load_file(char *filename)
|
|||||||
fp = fopen(filename + 7, "r");
|
fp = fopen(filename + 7, "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
fprintf(stderr, "load_file cannot open '%s'\n", filename);
|
fprintf(stderr, "load_file cannot open '%s'\n", filename);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
a = NULL;
|
a = NULL;
|
||||||
@ -40,7 +40,7 @@ load_file(char *filename)
|
|||||||
linenum, filename);
|
linenum, filename);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
alist_free(rtop);
|
alist_free(rtop);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -92,5 +92,5 @@ load_file(char *filename)
|
|||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return rtop;
|
return(rtop);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ load_hash(iphtable_t *iphp, iphtent_t *list, ioctlfunc_t iocfunc)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (pool_open() == -1)
|
if (pool_open() == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
for (n = 0, a = list; a != NULL; a = a->ipe_next)
|
for (n = 0, a = list; a != NULL; a = a->ipe_next)
|
||||||
n++;
|
n++;
|
||||||
@ -59,8 +59,8 @@ load_hash(iphtable_t *iphp, iphtent_t *list, ioctlfunc_t iocfunc)
|
|||||||
if ((opts & OPT_REMOVE) == 0) {
|
if ((opts & OPT_REMOVE) == 0) {
|
||||||
if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op))
|
if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op))
|
||||||
if ((opts & OPT_DONOTHING) == 0) {
|
if ((opts & OPT_DONOTHING) == 0) {
|
||||||
return ipf_perror_fd(pool_fd(), iocfunc,
|
return(ipf_perror_fd(pool_fd(), iocfunc,
|
||||||
"add lookup hash table");
|
"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));
|
iph.iph_table = calloc(size, sizeof(*iph.iph_table));
|
||||||
if (iph.iph_table == NULL) {
|
if (iph.iph_table == NULL) {
|
||||||
perror("calloc(size, sizeof(*iph.iph_table))");
|
perror("calloc(size, sizeof(*iph.iph_table))");
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
iph.iph_list = list;
|
iph.iph_list = list;
|
||||||
printhash(&iph, bcopywrap, iph.iph_name, opts, NULL);
|
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 ((opts & OPT_REMOVE) != 0) {
|
||||||
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
|
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
|
||||||
if ((opts & OPT_DONOTHING) == 0) {
|
if ((opts & OPT_DONOTHING) == 0) {
|
||||||
return ipf_perror_fd(pool_fd(), iocfunc,
|
return(ipf_perror_fd(pool_fd(), iocfunc,
|
||||||
"delete lookup hash table");
|
"delete lookup hash table"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ load_hashnode(int unit, char *name, iphtent_t *node, int ttl,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (pool_open() == -1)
|
if (pool_open() == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
op.iplo_type = IPLT_HASH;
|
op.iplo_type = IPLT_HASH;
|
||||||
op.iplo_unit = unit;
|
op.iplo_unit = unit;
|
||||||
@ -57,7 +57,7 @@ load_hashnode(int unit, char *name, iphtent_t *node, int ttl,
|
|||||||
char msg[80];
|
char msg[80];
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "%s node from lookup hash table", what);
|
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);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ load_http(char *url)
|
|||||||
if (strlen(url) > MAX_URL_LEN) {
|
if (strlen(url) > MAX_URL_LEN) {
|
||||||
fprintf(stderr, "load_http has a URL > %d bytes?!\n",
|
fprintf(stderr, "load_http has a URL > %d bytes?!\n",
|
||||||
MAX_URL_LEN);
|
MAX_URL_LEN);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = -1;
|
fd = -1;
|
||||||
@ -67,7 +67,7 @@ load_http(char *url)
|
|||||||
if (t == NULL) {
|
if (t == NULL) {
|
||||||
fprintf(stderr, "load_http has a malformed URL '%s'\n", url);
|
fprintf(stderr, "load_http has a malformed URL '%s'\n", url);
|
||||||
free(myurl);
|
free(myurl);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
*t++ = '\0';
|
*t++ = '\0';
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ load_http(char *url)
|
|||||||
if (strlen(s) + strlen(buffer) + 10 > sizeof(buffer)) {
|
if (strlen(s) + strlen(buffer) + 10 > sizeof(buffer)) {
|
||||||
fprintf(stderr, "load_http has a malformed URL '%s'\n", url);
|
fprintf(stderr, "load_http has a malformed URL '%s'\n", url);
|
||||||
free(myurl);
|
free(myurl);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
u = strchr(s, '@');
|
u = strchr(s, '@');
|
||||||
@ -204,5 +204,5 @@ load_http(char *url)
|
|||||||
free(myurl);
|
free(myurl);
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
close(fd);
|
close(fd);
|
||||||
return rtop;
|
return(rtop);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ load_pool(ip_pool_t *plp, ioctlfunc_t iocfunc)
|
|||||||
ip_pool_t pool;
|
ip_pool_t pool;
|
||||||
|
|
||||||
if (pool_open() == -1)
|
if (pool_open() == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
op.iplo_unit = plp->ipo_unit;
|
op.iplo_unit = plp->ipo_unit;
|
||||||
op.iplo_type = IPLT_POOL;
|
op.iplo_type = IPLT_POOL;
|
||||||
@ -40,8 +40,8 @@ load_pool(ip_pool_t *plp, ioctlfunc_t iocfunc)
|
|||||||
if ((opts & OPT_REMOVE) == 0) {
|
if ((opts & OPT_REMOVE) == 0) {
|
||||||
if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op)) {
|
if (pool_ioctl(iocfunc, SIOCLOOKUPADDTABLE, &op)) {
|
||||||
if ((opts & OPT_DONOTHING) == 0) {
|
if ((opts & OPT_DONOTHING) == 0) {
|
||||||
return ipf_perror_fd(pool_fd(), iocfunc,
|
return(ipf_perror_fd(pool_fd(), iocfunc,
|
||||||
"add lookup table");
|
"add lookup table"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,9 +62,9 @@ load_pool(ip_pool_t *plp, ioctlfunc_t iocfunc)
|
|||||||
if ((opts & OPT_REMOVE) != 0) {
|
if ((opts & OPT_REMOVE) != 0) {
|
||||||
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
|
if (pool_ioctl(iocfunc, SIOCLOOKUPDELTABLE, &op))
|
||||||
if ((opts & OPT_DONOTHING) == 0) {
|
if ((opts & OPT_DONOTHING) == 0) {
|
||||||
return ipf_perror_fd(pool_fd(), iocfunc,
|
return(ipf_perror_fd(pool_fd(), iocfunc,
|
||||||
"delete lookup table");
|
"delete lookup table"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ load_poolnode(int role, char *name, ip_pool_node_t *node, int ttl,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (pool_open() == -1)
|
if (pool_open() == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
op.iplo_unit = role;
|
op.iplo_unit = role;
|
||||||
op.iplo_type = IPLT_POOL;
|
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,
|
snprintf(msg, sizeof(msg), "%s pool node(%s/", what,
|
||||||
inet_ntoa(pn.ipn_addr.adf_addr.in4));
|
inet_ntoa(pn.ipn_addr.adf_addr.in4));
|
||||||
strcat(msg, inet_ntoa(pn.ipn_mask.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);
|
||||||
}
|
}
|
||||||
|
@ -27,5 +27,5 @@ load_url(char *url)
|
|||||||
hosts = load_http(url);
|
hosts = load_http(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hosts;
|
return(hosts);
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,5 @@ size_t msgdsize(mb_t *orig)
|
|||||||
|
|
||||||
for (m = orig; m != NULL; m = m->mb_next)
|
for (m = orig; m != NULL; m = m->mb_next)
|
||||||
sz += m->mb_len;
|
sz += m->mb_len;
|
||||||
return sz;
|
return(sz);
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,12 @@ nametokva(char *name, ioctlfunc_t iocfunc)
|
|||||||
if ((opts & OPT_DONTOPEN) == 0) {
|
if ((opts & OPT_DONTOPEN) == 0) {
|
||||||
fd = open(IPL_NAME, O_RDONLY);
|
fd = open(IPL_NAME, O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
(void) (*iocfunc)(fd, SIOCFUNCL, &res);
|
(void) (*iocfunc)(fd, SIOCFUNCL, &res);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
if (res.ipfu_addr == NULL)
|
if (res.ipfu_addr == NULL)
|
||||||
res.ipfu_addr = (ipfunc_t)-1;
|
res.ipfu_addr = (ipfunc_t)-1;
|
||||||
return res.ipfu_addr;
|
return(res.ipfu_addr);
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,13 @@ ntomask(int family, int nbits, u_32_t *ap)
|
|||||||
u_32_t mask;
|
u_32_t mask;
|
||||||
|
|
||||||
if (nbits < 0)
|
if (nbits < 0)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
switch (family)
|
switch (family)
|
||||||
{
|
{
|
||||||
case AF_INET :
|
case AF_INET :
|
||||||
if (nbits > 32 || use_inet6 == 1)
|
if (nbits > 32 || use_inet6 == 1)
|
||||||
return -1;
|
return(-1);
|
||||||
if (nbits == 0) {
|
if (nbits == 0) {
|
||||||
mask = 0;
|
mask = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -35,12 +35,12 @@ ntomask(int family, int nbits, u_32_t *ap)
|
|||||||
case 0 :
|
case 0 :
|
||||||
case AF_INET6 :
|
case AF_INET6 :
|
||||||
if ((nbits > 128) || (use_inet6 == -1))
|
if ((nbits > 128) || (use_inet6 == -1))
|
||||||
return -1;
|
return(-1);
|
||||||
fill6bits(nbits, ap);
|
fill6bits(nbits, ap);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ optname(char ***cp, u_short *sp, int linenum)
|
|||||||
if (!io->on_name) {
|
if (!io->on_name) {
|
||||||
fprintf(stderr, "%d: unknown IP option name %s\n",
|
fprintf(stderr, "%d: unknown IP option name %s\n",
|
||||||
linenum, s);
|
linenum, s);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
if (!strcasecmp(s, "sec-class"))
|
if (!strcasecmp(s, "sec-class"))
|
||||||
sec = 1;
|
sec = 1;
|
||||||
@ -38,7 +38,7 @@ optname(char ***cp, u_short *sp, int linenum)
|
|||||||
if (sec && !*(*cp + 1)) {
|
if (sec && !*(*cp + 1)) {
|
||||||
fprintf(stderr, "%d: missing security level after sec-class\n",
|
fprintf(stderr, "%d: missing security level after sec-class\n",
|
||||||
linenum);
|
linenum);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sec) {
|
if (sec) {
|
||||||
@ -53,11 +53,11 @@ optname(char ***cp, u_short *sp, int linenum)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%d: no such security level: %s\n",
|
"%d: no such security level: %s\n",
|
||||||
linenum, s);
|
linenum, s);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (smsk)
|
if (smsk)
|
||||||
*sp = smsk;
|
*sp = smsk;
|
||||||
}
|
}
|
||||||
return msk;
|
return(msk);
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ getoptbyname(char *optname)
|
|||||||
|
|
||||||
for (io = ionames; io->on_name; io++)
|
for (io = ionames; io->on_name; io++)
|
||||||
if (!strcasecmp(optname, io->on_name))
|
if (!strcasecmp(optname, io->on_name))
|
||||||
return io->on_bit;
|
return(io->on_bit);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +29,6 @@ getoptbyvalue(int optval)
|
|||||||
|
|
||||||
for (io = ionames; io->on_name; io++)
|
for (io = ionames; io->on_name; io++)
|
||||||
if (io->on_value == optval)
|
if (io->on_value == optval)
|
||||||
return io->on_bit;
|
return(io->on_bit);
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
@ -47,5 +47,5 @@ wordtab_t *parsefields(wordtab_t *table, char *arg)
|
|||||||
fields[num].w_value = 0;
|
fields[num].w_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fields;
|
return(fields);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ parseipfexpr(char *line, char **errorptr)
|
|||||||
oplist[0] = asize + 2;
|
oplist[0] = asize + 2;
|
||||||
oplist[asize + 1] = IPF_EXP_END;
|
oplist[asize + 1] = IPF_EXP_END;
|
||||||
|
|
||||||
return oplist;
|
return(oplist);
|
||||||
|
|
||||||
parseerror:
|
parseerror:
|
||||||
if (errorptr != NULL)
|
if (errorptr != NULL)
|
||||||
@ -277,5 +277,5 @@ parseipfexpr(char *line, char **errorptr)
|
|||||||
free(oplist);
|
free(oplist);
|
||||||
if (temp != NULL)
|
if (temp != NULL)
|
||||||
free(temp);
|
free(temp);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ parsewhoisline(char *line, addrfamily_t *addrp, addrfamily_t *maskp)
|
|||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
|
|
||||||
if (line == NULL)
|
if (line == NULL)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
while (*src != '\0') {
|
while (*src != '\0') {
|
||||||
s = strchr(src, '(');
|
s = strchr(src, '(');
|
||||||
@ -33,7 +33,7 @@ parsewhoisline(char *line, addrfamily_t *addrp, addrfamily_t *maskp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
memset(addrp, 0x00, sizeof(*maskp));
|
memset(addrp, 0x00, sizeof(*maskp));
|
||||||
memset(maskp, 0x00, sizeof(*maskp));
|
memset(maskp, 0x00, sizeof(*maskp));
|
||||||
@ -44,20 +44,20 @@ parsewhoisline(char *line, addrfamily_t *addrp, addrfamily_t *maskp)
|
|||||||
|
|
||||||
s = strchr(s, ')');
|
s = strchr(s, ')');
|
||||||
if (s == NULL || *++s != ' ')
|
if (s == NULL || *++s != ' ')
|
||||||
return -1;
|
return(-1);
|
||||||
/*
|
/*
|
||||||
* Parse the IPv6
|
* Parse the IPv6
|
||||||
*/
|
*/
|
||||||
if (inet_pton(AF_INET6, s, &a61.in6) != 1)
|
if (inet_pton(AF_INET6, s, &a61.in6) != 1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
s = strchr(s, ' ');
|
s = strchr(s, ' ');
|
||||||
if (s == NULL || strncmp(s, " - ", 3))
|
if (s == NULL || strncmp(s, " - ", 3))
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
s += 3;
|
s += 3;
|
||||||
if (inet_pton(AF_INET6, s, &a62) != 1)
|
if (inet_pton(AF_INET6, s, &a62) != 1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
addrp->adf_addr = a61;
|
addrp->adf_addr = a61;
|
||||||
addrp->adf_family = AF_INET6;
|
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.
|
* then we can't add it into a pool.
|
||||||
*/
|
*/
|
||||||
if (count6bits(maskp->adf_addr.i6) == -1)
|
if (count6bits(maskp->adf_addr.i6) == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
maskp->adf_family = AF_INET6;
|
maskp->adf_family = AF_INET6;
|
||||||
maskp->adf_len = addrp->adf_len;
|
maskp->adf_len = addrp->adf_len;
|
||||||
|
|
||||||
if (IP6_MASKNEQ(&addrp->adf_addr.in6, &maskp->adf_addr.in6,
|
if (IP6_MASKNEQ(&addrp->adf_addr.in6, &maskp->adf_addr.in6,
|
||||||
&addrp->adf_addr.in6)) {
|
&addrp->adf_addr.in6)) {
|
||||||
return -1;
|
return(-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return(0);
|
||||||
#else
|
#else
|
||||||
return -1;
|
return(-1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
s = strchr(s, ')');
|
s = strchr(s, ')');
|
||||||
if (s == NULL || *++s != ' ')
|
if (s == NULL || *++s != ' ')
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
s++;
|
s++;
|
||||||
|
|
||||||
if (inet_aton(s, &a1) != 1)
|
if (inet_aton(s, &a1) != 1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
s = strchr(s, ' ');
|
s = strchr(s, ' ');
|
||||||
if (s == NULL || strncmp(s, " - ", 3))
|
if (s == NULL || strncmp(s, " - ", 3))
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
s += 3;
|
s += 3;
|
||||||
if (inet_aton(s, &a2) != 1)
|
if (inet_aton(s, &a2) != 1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
addrp->adf_addr.in4 = a1;
|
addrp->adf_addr.in4 = a1;
|
||||||
addrp->adf_family = AF_INET;
|
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.
|
* we can't add it into a pool.
|
||||||
*/
|
*/
|
||||||
if (count4bits(maskp->adf_addr.in4.s_addr) == -1)
|
if (count4bits(maskp->adf_addr.in4.s_addr) == -1)
|
||||||
return -1;
|
return(-1);
|
||||||
|
|
||||||
maskp->adf_family = AF_INET;
|
maskp->adf_family = AF_INET;
|
||||||
maskp->adf_len = addrp->adf_len;
|
maskp->adf_len = addrp->adf_len;
|
||||||
bzero((char *)maskp + maskp->adf_len, sizeof(*maskp) - maskp->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) !=
|
if ((addrp->adf_addr.in4.s_addr & maskp->adf_addr.in4.s_addr) !=
|
||||||
addrp->adf_addr.in4.s_addr)
|
addrp->adf_addr.in4.s_addr)
|
||||||
return -1;
|
return(-1);
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@ pool_open(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if ((opts & OPT_DONTOPEN) != 0)
|
if ((opts & OPT_DONTOPEN) != 0)
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
if (poolfd == -1)
|
if (poolfd == -1)
|
||||||
poolfd = open(IPLOOKUP_NAME, O_RDWR);
|
poolfd = open(IPLOOKUP_NAME, O_RDWR);
|
||||||
return poolfd;
|
return(poolfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -33,7 +33,7 @@ pool_ioctl(iocfunc, cmd, ptr)
|
|||||||
ioctlcmd_t cmd;
|
ioctlcmd_t cmd;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
{
|
{
|
||||||
return (*iocfunc)(poolfd, cmd, ptr);
|
return(*iocfunc)(poolfd, cmd, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -49,5 +49,5 @@ pool_close(void)
|
|||||||
int
|
int
|
||||||
pool_fd(void)
|
pool_fd(void)
|
||||||
{
|
{
|
||||||
return poolfd;
|
return(poolfd);
|
||||||
}
|
}
|
||||||
|
@ -28,16 +28,16 @@ portname(int pr, int port)
|
|||||||
NULL : sv1;
|
NULL : sv1;
|
||||||
}
|
}
|
||||||
if (sv)
|
if (sv)
|
||||||
return (buf);
|
return(buf);
|
||||||
} else if ((pr != -2) && (p = getprotobynumber(pr))) {
|
} else if ((pr != -2) && (p = getprotobynumber(pr))) {
|
||||||
if ((sv = getservbyport(htons(port), p->p_name))) {
|
if ((sv = getservbyport(htons(port), p->p_name))) {
|
||||||
strncpy(buf, sv->s_name, sizeof(buf)-1);
|
strncpy(buf, sv->s_name, sizeof(buf)-1);
|
||||||
buf[sizeof(buf)-1] = '\0';
|
buf[sizeof(buf)-1] = '\0';
|
||||||
return (buf);
|
return(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) snprintf(buf, sizeof(buf), "%d", port);
|
(void) snprintf(buf, sizeof(buf), "%d", port);
|
||||||
return (buf);
|
return(buf);
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,5 @@ int prependmbt( fr_info_t *fin, mb_t *m)
|
|||||||
{
|
{
|
||||||
m->mb_next = *fin->fin_mp;
|
m->mb_next = *fin->fin_mp;
|
||||||
*fin->fin_mp = m;
|
*fin->fin_mp = m;
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -23,15 +23,15 @@ printdstl_live( ippool_dst_t *d, int fd, char *name, int opts,
|
|||||||
ipfobj_t obj;
|
ipfobj_t obj;
|
||||||
|
|
||||||
if ((name != NULL) && strncmp(name, d->ipld_name, FR_GROUPLEN))
|
if ((name != NULL) && strncmp(name, d->ipld_name, FR_GROUPLEN))
|
||||||
return d->ipld_next;
|
return(d->ipld_next);
|
||||||
|
|
||||||
entry = calloc(1, sizeof(*entry) + 64);
|
entry = calloc(1, sizeof(*entry) + 64);
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
return d->ipld_next;
|
return(d->ipld_next);
|
||||||
zero = calloc(1, sizeof(*zero) + 64);
|
zero = calloc(1, sizeof(*zero) + 64);
|
||||||
if (zero == NULL) {
|
if (zero == NULL) {
|
||||||
free(entry);
|
free(entry);
|
||||||
return d->ipld_next;
|
return(d->ipld_next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields == NULL)
|
if (fields == NULL)
|
||||||
@ -76,5 +76,5 @@ printdstl_live( ippool_dst_t *d, int fd, char *name, int opts,
|
|||||||
|
|
||||||
if ((opts & OPT_DEBUG) == 0)
|
if ((opts & OPT_DEBUG) == 0)
|
||||||
PRINTF(" };\n");
|
PRINTF(" };\n");
|
||||||
return d->ipld_next;
|
return(d->ipld_next);
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ printdstlist( ippool_dst_t *pp, copyfunc_t copyfunc, char *name, int opts,
|
|||||||
ippool_dst_t dst;
|
ippool_dst_t dst;
|
||||||
|
|
||||||
if ((*copyfunc)(pp, &dst, sizeof(dst)))
|
if ((*copyfunc)(pp, &dst, sizeof(dst)))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
if ((name != NULL) && strncmp(name, dst.ipld_name, FR_GROUPLEN))
|
if ((name != NULL) && strncmp(name, dst.ipld_name, FR_GROUPLEN))
|
||||||
return dst.ipld_next;
|
return(dst.ipld_next);
|
||||||
|
|
||||||
if (fields == NULL)
|
if (fields == NULL)
|
||||||
printdstlistdata(&dst, opts);
|
printdstlistdata(&dst, opts);
|
||||||
@ -39,7 +39,7 @@ printdstlist( ippool_dst_t *pp, copyfunc_t copyfunc, char *name, int opts,
|
|||||||
break;
|
break;
|
||||||
if ((*copyfunc)(node, n, node->ipfd_size)) {
|
if ((*copyfunc)(node, n, node->ipfd_size)) {
|
||||||
free(n);
|
free(n);
|
||||||
return NULL;
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
node = printdstlistnode(n, bcopywrap, opts, fields);
|
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)
|
if ((opts & OPT_DEBUG) == 0)
|
||||||
PRINTF(" };\n");
|
PRINTF(" };\n");
|
||||||
|
|
||||||
return dst.ipld_next;
|
return(dst.ipld_next);
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,13 @@ printdstlistnode(ipf_dstnode_t *inp, copyfunc_t copyfunc, int opts,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((*copyfunc)(inp, &node, sizeof(node)))
|
if ((*copyfunc)(inp, &node, sizeof(node)))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
np = calloc(1, node.ipfd_size);
|
np = calloc(1, node.ipfd_size);
|
||||||
if (np == NULL)
|
if (np == NULL)
|
||||||
return node.ipfd_next;
|
return(node.ipfd_next);
|
||||||
if ((*copyfunc)(inp, np, node.ipfd_size))
|
if ((*copyfunc)(inp, np, node.ipfd_size))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
if (fields != NULL) {
|
if (fields != NULL) {
|
||||||
for (i = 0; fields[i].w_value != 0; i++) {
|
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);
|
np->ipfd_names, np->ipfd_uid);
|
||||||
}
|
}
|
||||||
free(np);
|
free(np);
|
||||||
return node.ipfd_next;
|
return(node.ipfd_next);
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@ printhash( iphtable_t *hp, copyfunc_t copyfunc, char *name, int opts,
|
|||||||
size_t sz;
|
size_t sz;
|
||||||
|
|
||||||
if ((*copyfunc)((char *)hp, (char *)&iph, sizeof(iph)))
|
if ((*copyfunc)((char *)hp, (char *)&iph, sizeof(iph)))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
if ((name != NULL) && strncmp(name, iph.iph_name, FR_GROUPLEN))
|
if ((name != NULL) && strncmp(name, iph.iph_name, FR_GROUPLEN))
|
||||||
return iph.iph_next;
|
return(iph.iph_next);
|
||||||
|
|
||||||
if (fields == NULL)
|
if (fields == NULL)
|
||||||
printhashdata(hp, opts);
|
printhashdata(hp, opts);
|
||||||
@ -36,7 +36,7 @@ printhash( iphtable_t *hp, copyfunc_t copyfunc, char *name, int opts,
|
|||||||
sz = iph.iph_size * sizeof(*table);
|
sz = iph.iph_size * sizeof(*table);
|
||||||
table = malloc(sz);
|
table = malloc(sz);
|
||||||
if ((*copyfunc)((char *)iph.iph_table, (char *)table, sz))
|
if ((*copyfunc)((char *)iph.iph_table, (char *)table, sz))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
for (printed = 0, ipep = iph.iph_list; ipep != NULL; ) {
|
for (printed = 0, ipep = iph.iph_list; ipep != NULL; ) {
|
||||||
ipep = printhashnode(&iph, ipep, copyfunc, opts, fields);
|
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)
|
if ((opts & OPT_DEBUG) == 0)
|
||||||
PRINTF(" };\n");
|
PRINTF(" };\n");
|
||||||
|
|
||||||
return iph.iph_next;
|
return(iph.iph_next);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ printhash_live(iphtable_t *hp, int fd, char *name, int opts, wordtab_t *fields)
|
|||||||
ipfobj_t obj;
|
ipfobj_t obj;
|
||||||
|
|
||||||
if ((name != NULL) && strncmp(name, hp->iph_name, FR_GROUPLEN))
|
if ((name != NULL) && strncmp(name, hp->iph_name, FR_GROUPLEN))
|
||||||
return hp->iph_next;
|
return(hp->iph_next);
|
||||||
|
|
||||||
if (fields == NULL)
|
if (fields == NULL)
|
||||||
printhashdata(hp, opts);
|
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)
|
if ((opts & OPT_DEBUG) == 0)
|
||||||
PRINTF(" };\n");
|
PRINTF(" };\n");
|
||||||
return hp->iph_next;
|
return(hp->iph_next);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ printhashnode(iphtable_t *iph, iphtent_t *ipep, copyfunc_t copyfunc, int opts,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((*copyfunc)(ipep, &ipe, sizeof(ipe)))
|
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],
|
hv = IPE_V4_HASH_FN(ipe.ipe_addr.i6[0], ipe.ipe_mask.i6[0],
|
||||||
iph->iph_size);
|
iph->iph_size);
|
||||||
@ -90,5 +90,5 @@ printhashnode(iphtable_t *iph, iphtent_t *ipep, copyfunc_t copyfunc, int opts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ipep = ipe.ipe_next;
|
ipep = ipe.ipe_next;
|
||||||
return ipep;
|
return(ipep);
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,10 @@ printpool(ip_pool_t *pp, copyfunc_t copyfunc, char *name, int opts,
|
|||||||
ip_pool_t ipp;
|
ip_pool_t ipp;
|
||||||
|
|
||||||
if ((*copyfunc)(pp, &ipp, sizeof(ipp)))
|
if ((*copyfunc)(pp, &ipp, sizeof(ipp)))
|
||||||
return NULL;
|
return(NULL);
|
||||||
|
|
||||||
if ((name != NULL) && strncmp(name, ipp.ipo_name, FR_GROUPLEN))
|
if ((name != NULL) && strncmp(name, ipp.ipo_name, FR_GROUPLEN))
|
||||||
return ipp.ipo_next;
|
return(ipp.ipo_next);
|
||||||
|
|
||||||
printpooldata(&ipp, opts);
|
printpooldata(&ipp, opts);
|
||||||
|
|
||||||
@ -57,5 +57,5 @@ printpool(ip_pool_t *pp, copyfunc_t copyfunc, char *name, int opts,
|
|||||||
if ((opts & OPT_DEBUG) == 0)
|
if ((opts & OPT_DEBUG) == 0)
|
||||||
PRINTF(" };\n");
|
PRINTF(" };\n");
|
||||||
|
|
||||||
return ipp.ipo_next;
|
return(ipp.ipo_next);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ printpool_live(ip_pool_t *pool, int fd, char *name, int opts,
|
|||||||
ipfobj_t obj;
|
ipfobj_t obj;
|
||||||
|
|
||||||
if ((name != NULL) && strncmp(name, pool->ipo_name, FR_GROUPLEN))
|
if ((name != NULL) && strncmp(name, pool->ipo_name, FR_GROUPLEN))
|
||||||
return pool->ipo_next;
|
return(pool->ipo_next);
|
||||||
|
|
||||||
if (fields == NULL)
|
if (fields == NULL)
|
||||||
printpooldata(pool, opts);
|
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);
|
(void) ioctl(fd,SIOCIPFDELTOK, &iter.ili_key);
|
||||||
|
|
||||||
return pool->ipo_next;
|
return(pool->ipo_next);
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user