4 #include <sys/socket.h>
9 #include <netinet/in.h>
11 #include "ip_compat.h"
20 struct frauth
*frap
= &fra
;
21 fr_info_t
*fin
= &fra
.fra_info
;
22 fr_ip_t
*fi
= &fin
->fin_fi
;
26 fd
= open(IPL_NAME
, O_RDWR
);
29 while (ioctl(fd
, SIOCAUTHW
, &frap
) == 0) {
30 if (fra
.fra_info
.fin_out
)
31 fra
.fra_pass
= FR_OUTQUE
;
33 fra
.fra_pass
= FR_INQUE
;
35 printf("%s ", inet_ntoa(fi
->fi_src
));
36 if (fi
->fi_flx
& FI_TCPUDP
)
37 printf("port %d ", fin
->fin_data
[0]);
38 printf("-> %s ", inet_ntoa(fi
->fi_dst
));
39 if (fi
->fi_flx
& FI_TCPUDP
)
40 printf("port %d ", fin
->fin_data
[1]);
42 printf("Allow packet through ? [y/n]");
44 if (!fgets(yn
, sizeof(yn
), stdin
))
47 if (yn
[0] == 'n' || yn
[0] == 'N')
48 fra
.fra_pass
|= FR_BLOCK
;
49 else if (yn
[0] == 'y' || yn
[0] == 'Y') {
50 fra
.fra_pass
|= FR_PASS
;
51 if (fra
.fra_info
.fin_fi
.fi_flx
& FI_TCPUDP
)
52 fra
.fra_pass
|= FR_KEEPSTATE
;
54 fra
.fra_pass
|= FR_NOMATCH
;
55 printf("answer = %c (%x), id %d idx %d\n", yn
[0],
56 fra
.fra_pass
, fra
.fra_info
.fin_id
, fra
.fra_index
);
57 if (ioctl(fd
, SIOCAUTHR
, &frap
) != 0)
60 fprintf(stderr
, "errno=%d \n", errno
);
61 perror("frauth-SIOCAUTHW");