Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/tcpdrop/tcpdrop.c
Show First 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | printf("%s %s %s %s: dropped\n", local.hs_host, local.hs_service, | ||||
foreign.hs_host, foreign.hs_service); | foreign.hs_host, foreign.hs_service); | ||||
return (true); | return (true); | ||||
} | } | ||||
static bool | static bool | ||||
tcpdropall(void) | tcpdropall(void) | ||||
{ | { | ||||
struct xinpgen *head, *xinp; | struct xinpgen *head, *xinp; | ||||
struct xtcpcb *xpcb; | struct xtcpcb *xtp; | ||||
struct tcpcb *tp; | struct xinpcb *xip; | ||||
struct inpcb *inp; | |||||
bool ok; | bool ok; | ||||
ok = true; | ok = true; | ||||
head = getxpcblist("net.inet.tcp.pcblist"); | head = getxpcblist("net.inet.tcp.pcblist"); | ||||
#define XINP_NEXT(xinp) \ | #define XINP_NEXT(xinp) \ | ||||
((struct xinpgen *)((uintptr_t)(xinp) + (xinp)->xig_len)) | ((struct xinpgen *)((uintptr_t)(xinp) + (xinp)->xig_len)) | ||||
for (xinp = XINP_NEXT(head); xinp->xig_len > sizeof *xinp; | for (xinp = XINP_NEXT(head); xinp->xig_len > sizeof *xinp; | ||||
xinp = XINP_NEXT(xinp)) { | xinp = XINP_NEXT(xinp)) { | ||||
xpcb = (struct xtcpcb *)xinp; | xtp = (struct xtcpcb *)xinp; | ||||
tp = &xpcb->xt_tp; | xip = &xtp->xt_inp; | ||||
inp = &xpcb->xt_inp; | |||||
/* | /* | ||||
* XXX | * XXX | ||||
* Check protocol, support just v4 or v6, etc. | * Check protocol, support just v4 or v6, etc. | ||||
*/ | */ | ||||
/* Ignore PCBs which were freed during copyout. */ | /* Ignore PCBs which were freed during copyout. */ | ||||
if (inp->inp_gencnt > head->xig_gen) | if (xip->inp_gencnt > head->xig_gen) | ||||
continue; | continue; | ||||
/* Skip listening sockets. */ | /* Skip listening sockets. */ | ||||
if (tp->t_state == TCPS_LISTEN) | if (xtp->t_state == TCPS_LISTEN) | ||||
continue; | continue; | ||||
if (!tcpdropconn(&inp->inp_inc)) | if (!tcpdropconn(&xip->inp_inc)) | ||||
ok = false; | ok = false; | ||||
} | } | ||||
free(head); | free(head); | ||||
return (ok); | return (ok); | ||||
} | } | ||||
static bool | static bool | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |