summaryrefslogtreecommitdiff
path: root/dialects/freebsd/dsock.c
diff options
context:
space:
mode:
Diffstat (limited to 'dialects/freebsd/dsock.c')
-rw-r--r--dialects/freebsd/dsock.c60
1 files changed, 46 insertions, 14 deletions
diff --git a/dialects/freebsd/dsock.c b/dialects/freebsd/dsock.c
index d942602..ee8ced7 100644
--- a/dialects/freebsd/dsock.c
+++ b/dialects/freebsd/dsock.c
@@ -32,7 +32,7 @@
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
-static char *rcsid = "$Id: dsock.c,v 1.30 2015/07/07 20:23:43 abe Exp $";
+static char *rcsid = "$Id: dsock.c,v 1.31 2018/02/14 14:26:03 abe Exp $";
#endif
@@ -79,7 +79,7 @@ static char *rcsid = "$Id: dsock.c,v 1.30 2015/07/07 20:23:43 abe Exp $";
* Local function prototypes
*/
-_PROTOTYPE(static int ckstate,(KA_T ta, struct tcpcb *t, int fam));
+_PROTOTYPE(static int ckstate,(KA_T pcb, KA_T ta, struct tcpcb *t, int fam));
/*
@@ -91,7 +91,8 @@ _PROTOTYPE(static int ckstate,(KA_T ta, struct tcpcb *t, int fam));
*/
static int
-ckstate(ta, t, fam)
+ckstate(pcb, ta, t, fam)
+ KA_T pcb; /* PCB address */
KA_T ta; /* TCP control block address */
struct tcpcb *t; /* TCP control block receptor */
int fam; /* protocol family */
@@ -100,14 +101,18 @@ ckstate(ta, t, fam)
/*
* Read TCP control block.
*/
- if (kread(ta, (char *)t, sizeof(struct tcpcb)))
+ if (kread(ta, (char *)t, sizeof(struct tcpcb))
+ || (KA_T)t->t_inpcb != pcb)
+ {
return(-1);
+ }
if (TcpStXn || TcpStIn) {
/*
* If there are TCP state inclusions or exclusions, check them.
*/
- tsnx = (int)t->t_state + TcpStOff;
+ if ((tsnx = (int)t->t_state + TcpStOff) >= TcpNstates)
+ return(0);
if (TcpStXn) {
if (TcpStX[tsnx]) {
Lf->sf &= ~SELNET;
@@ -236,22 +241,43 @@ process_socket(sa)
#if defined(HASSOOPT)
Lf->lts.ltm = (unsigned int)s.so_linger;
Lf->lts.opt = (unsigned int)s.so_options;
+
+# if __FreeBSD_version>=1200027
+ if (s.so_options & SO_ACCEPTCONN) {
+ Lf->lts.pqlen = (unsigned int)s.sol_incqlen;
+ Lf->lts.qlen = (unsigned int)s.sol_qlen;
+ Lf->lts.qlim = (unsigned int)s.sol_qlimit;
+ } else {
+ Lf->lts.rbsz = (unsigned long)s.so_rcv.sb_mbmax;
+ Lf->lts.sbsz = (unsigned long)s.so_snd.sb_mbmax;
+
+# if defined(HASSBSTATE)
+ Lf->lts.sbs_rcv = s.so_rcv.sb_state;
+ Lf->lts.sbs_snd = s.so_snd.sb_state;
+# endif /* defined(HASSBSTATE) */
+
+ }
+
+# else /* __FreeBSD_version<1200027 */
Lf->lts.pqlen = (unsigned int)s.so_incqlen;
Lf->lts.qlen = (unsigned int)s.so_qlen;
Lf->lts.qlim = (unsigned int)s.so_qlimit;
Lf->lts.rbsz = (unsigned long)s.so_rcv.sb_mbmax;
Lf->lts.sbsz = (unsigned long)s.so_snd.sb_mbmax;
+
+# if defined(HASSBSTATE)
+ Lf->lts.sbs_rcv = s.so_rcv.sb_state;
+ Lf->lts.sbs_snd = s.so_snd.sb_state;
+# endif /* defined(HASSBSTATE) */
+# endif /*__FreeBSD_version>=1200027 */
+
Lf->lts.pqlens = Lf->lts.qlens = Lf->lts.qlims = Lf->lts.rbszs
= Lf->lts.sbszs = (unsigned char)1;
-#endif /* defined(HASSOOPT) */
-#if defined(HASSOSTATE)
+# if defined(HASSOSTATE)
Lf->lts.ss = (unsigned int)s.so_state;
-# if defined(HASSBSTATE)
- Lf->lts.sbs_rcv = s.so_rcv.sb_state;
- Lf->lts.sbs_snd = s.so_snd.sb_state;
-# endif /* defined(HASSBSTATE) */
-#endif /* defined(HASSOSTATE) */
+# endif /* defined(HASSOSTATE) */
+#endif /* defined(HASSOPT) */
/*
* Process socket by the associated domain family.
@@ -306,8 +332,11 @@ process_socket(sa)
*/
if (p.pr_protocol == IPPROTO_TCP) {
if (in6p.in6p_ppcb) {
- if ((ts = ckstate((KA_T)in6p.in6p_ppcb, &t, fam)) == 1)
+ if ((ts = ckstate((KA_T)s.so_pcb, (KA_T)in6p.in6p_ppcb,
+ &t, fam)) == 1)
+ {
return;
+ }
}
}
enter_dev_ch(print_kptr((KA_T)(in6p.in6p_ppcb ? in6p.in6p_ppcb
@@ -357,8 +386,11 @@ process_socket(sa)
}
if (p.pr_protocol == IPPROTO_TCP) {
if (inp.inp_ppcb) {
- if ((ts = ckstate((KA_T)inp.inp_ppcb, &t, fam)) == 1)
+ if ((ts = ckstate((KA_T)s.so_pcb, (KA_T)inp.inp_ppcb,
+ &t, fam)) == 1)
+ {
return;
+ }
}
}
enter_dev_ch(print_kptr((KA_T)(inp.inp_ppcb ? inp.inp_ppcb