/* nsp_subr.c 1.2 82/05/15 */
#include "../h/protosw.h"
#include "../h/socketvar.h"
#include "../net/dn_systm.h"
#include "../net/nsp_var.h"
#define printd if(nspidebug)printf
* Nsp_chkaddr performs many functions common to the processing
* of input packets. The arguments are:
* m - the mbuf with the packet in it
* srcnode - the srcnode from the transport header
* type - the packet type, one of:
* NSP_DATA, NSP_LS, NSP_INTR, NSP_DATACK, NSP_OTHACK
* sp - pointer to a short to receive the segment number
* It performs the following functions:
* 1. verify that the packet is of the correct minimum length
* 2. find the associated NSP control block (by calling dn_addrtonspcb())
* 3. process any ack or nak and force retransmission or remove
* acked data from the retransmit queue, as required
* 4. update the mbuf to point past the segnum field
* 5. return the segnum and nspcb pointer
nsp_chkaddr(m
, srcnode
, type
, sp
)
register struct nspcb
*np
;
/* make sure we are accessing valid data */
if (m
->m_len
< sizeof (struct nspd
) - sizeof (d_short
)) {
n
= mtod(m
, struct nspd
*);
dstaddr
= D_SHORT(n
->nsp_dstaddr
);
np
= dn_addrtonspcb(dstaddr
);
no such address
, return "no link" message
if (np
->n_node
!= srcnode
) {
printf("nsp_chkaddr: n_node %d, srcnode %d\n", np
->n_node
,
/* make sure remote addresses match (consistency check) */
if (np
->n_rem
!= D_SHORT(n
->nsp_srcaddr
)) {
printf("nsp_chkaddr: n_rem %d, srcaddr %d\n", np
->n_rem
,
D_SHORT(n
->nsp_srcaddr
));
ack
= D_SHORT(n
->nsp_acknum
);
printd(", qual 0x%x, num %d", qual
, num
);
/* make sure there's room for a segnum */
if (m
->m_len
< sizeof (struct nspd
)) {
if (SEQ_GTR(num
, np
->na_rcvdat
) &&
SEQ_LEQ(num
, np
->nn_high
)) {
np
->nf_remdat
-= SEQ_SUB(num
, np
->na_rcvdat
);
if (qual
== NSPA_NAK
|| SEQ_LEQ(np
->nn_dat
, num
))
np
->nn_dat
= SEQ_ADD(num
, 1);
} else if (n
== np
->nn_oth
&& (np
->n_flags
&NF_OTHSENT
)) {
/* force retransmission of other data seg */
printf("nsp_chkaddr: NAK other\n");
np
->n_flags
&= ~NF_OTHSENT
;
np
->nn_oth
= SEQ_ADD(np
->nn_oth
, 1);
if (np
->n_flags
& NF_OTHINTR
) {
~(NF_OTHINTR
|NF_INTAVAIL
);
*sp
= D_SHORT(n
->nsp_segnum
);
num
= sizeof (struct nspd
);
num
= sizeof (struct nspd
) - sizeof (u_short
);