1 /*
2 * Copyright (C) 2000-2005 by Darren Reed.
3 *
4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * $Id: printfr.c,v 1.43.2.12 2005/06/12 07:18:42 darrenr Exp $
7 *
8 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
9 * Use is subject to license terms.
10 */
11
12 #pragma ident "%Z%%M% %I% %E% SMI"
13
14 #include "ipf.h"
15
16 /*
17 * print the filter structure in a useful way
18 */
19 void printfr(fp, iocfunc)
20 struct frentry *fp;
21 ioctlfunc_t iocfunc;
22 {
23 struct protoent *p;
24 u_short sec[2];
25 u_32_t type;
26 u_char *t;
27 char *s;
28 int pr;
29
30 pr = -2;
31 type = fp->fr_type & ~FR_T_BUILTIN;
32
369 if (fp->fr_flags & FR_KEEPFRAG) {
370 printf(" keep frags");
371 if (fp->fr_flags & (FR_FRSTRICT)) {
372 printf(" (");
373 if (fp->fr_flags & FR_FRSTRICT)
374 printf(" strict");
375 printf(" )");
376
377 }
378 }
379 if (fp->fr_isc != (struct ipscan *)-1) {
380 if (fp->fr_isctag[0])
381 printf(" scan %s", fp->fr_isctag);
382 else
383 printf(" scan *");
384 }
385 if (*fp->fr_grhead != '\0')
386 printf(" head %s", fp->fr_grhead);
387 if (*fp->fr_group != '\0')
388 printf(" group %s", fp->fr_group);
389 if (fp->fr_logtag != FR_NOLOGTAG || *fp->fr_nattag.ipt_tag) {
390 char *s = "";
391
392 printf(" set-tag(");
393 if (fp->fr_logtag != FR_NOLOGTAG) {
394 printf("log=%u", fp->fr_logtag);
395 s = ", ";
396 }
397 if (*fp->fr_nattag.ipt_tag) {
398 printf("%snat=%-.*s", s, IPFTAG_LEN,
399 fp->fr_nattag.ipt_tag);
400 }
401 printf(")");
402 }
403 if (fp->fr_pps)
404 printf(" pps %d", fp->fr_pps);
405 (void)putchar('\n');
406 }
|
1 /*
2 * Copyright (C) 2000-2005 by Darren Reed.
3 *
4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * $Id: printfr.c,v 1.43.2.12 2005/06/12 07:18:42 darrenr Exp $
7 *
8 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
9 * Use is subject to license terms.
10 * Copyright 2019 Joyent, Inc.
11 */
12
13 #include <uuid/uuid.h>
14
15 #include "ipf.h"
16
17 /*
18 * print the filter structure in a useful way
19 */
20 void printfr(fp, iocfunc)
21 struct frentry *fp;
22 ioctlfunc_t iocfunc;
23 {
24 struct protoent *p;
25 u_short sec[2];
26 u_32_t type;
27 u_char *t;
28 char *s;
29 int pr;
30
31 pr = -2;
32 type = fp->fr_type & ~FR_T_BUILTIN;
33
370 if (fp->fr_flags & FR_KEEPFRAG) {
371 printf(" keep frags");
372 if (fp->fr_flags & (FR_FRSTRICT)) {
373 printf(" (");
374 if (fp->fr_flags & FR_FRSTRICT)
375 printf(" strict");
376 printf(" )");
377
378 }
379 }
380 if (fp->fr_isc != (struct ipscan *)-1) {
381 if (fp->fr_isctag[0])
382 printf(" scan %s", fp->fr_isctag);
383 else
384 printf(" scan *");
385 }
386 if (*fp->fr_grhead != '\0')
387 printf(" head %s", fp->fr_grhead);
388 if (*fp->fr_group != '\0')
389 printf(" group %s", fp->fr_group);
390 if (fp->fr_logtag != FR_NOLOGTAG || *fp->fr_nattag.ipt_tag ||
391 (fp->fr_flags & FR_CFWLOG) || !uuid_is_null(fp->fr_uuid)) {
392 char *s = "";
393
394 printf(" set-tag(");
395 if (fp->fr_logtag != FR_NOLOGTAG) {
396 printf("log=%u", fp->fr_logtag);
397 s = ", ";
398 }
399 if (*fp->fr_nattag.ipt_tag) {
400 printf("%snat=%-.*s", s, IPFTAG_LEN,
401 fp->fr_nattag.ipt_tag);
402 s = ", ";
403 }
404 if (fp->fr_flags & FR_CFWLOG) {
405 printf("cfwlog");
406 s = ", ";
407 }
408
409 if (!uuid_is_null(fp->fr_uuid)) {
410 char uuid[UUID_PRINTABLE_STRING_LENGTH];
411
412 uuid_unparse(fp->fr_uuid, uuid);
413 printf("%suuid=%s", s, uuid);
414 }
415 printf(")");
416 }
417 if (fp->fr_pps)
418 printf(" pps %d", fp->fr_pps);
419 (void)putchar('\n');
420 }
|