#include <sys/malloc.h>
#include <sys/socket.h>
+#include <net/if.h>
+
#include <netat/sysglue.h>
#include <netat/appletalk.h>
#include <netat/ddp.h>
#include <netat/at_pcb.h>
+#include <netat/at_var.h>
#include <netat/atp.h>
+#include <netat/asp.h>
#include <netat/debug.h>
-static void atp_trans_complete();
-void atp_x_done();
+__private_extern__ int atp_resp_seqno2big = 0;
+
+static void atp_trans_complete(struct atp_trans *);
void atp_x_done_locked(void *);
-extern void atp_req_timeout();
+void atp_treq_event(void *);
/*
* Decide what to do about received messages
{
register at_atp_t *athp;
register struct atp_state *atp;
- register int s, s_gen;
gbuf_t *m_asp = NULL;
struct timeval timenow;
+ u_short temp_net;
atp = (struct atp_state *)gref->info;
if (atp->dflag)
case ATP_CMD_TRESP:
{
register struct atp_trans *trp;
- register int seqno;
- register at_ddp_t *ddp;
+ register unsigned int seqno;
+ register at_ddp_t *ddp;
/*
* we just got a response, find the trans record
*/
- ATDISABLE(s, atp->atp_lock);
for (trp = atp->atp_trans_wait.head; trp; trp = trp->tr_list.next) {
- if (trp->tr_tid == UAS_VALUE(athp->tid))
+ if (trp->tr_tid == UAS_VALUE_NTOH(athp->tid))
break;
}
* If we can't find one then ignore the message
*/
seqno = athp->bitmap;
+ if (seqno > 7) {
+ atp_resp_seqno2big++;
+ ddp = AT_DDP_HDR(m);
+ dPrintf(D_M_ATP_LOW, (D_L_INPUT|D_L_ERROR),
+ ("atp_rput: dropping TRESP seqno too big, tid=%d,loc=%d,rem=%d.%d,seqno=%u\n",
+ UAS_VALUE_NTOH(athp->tid),
+ ddp->dst_socket, ddp->src_node, ddp->src_socket, seqno));
+ gbuf_freem(m);
+ return;
+ }
if (trp == NULL) {
- ATENABLE(s, atp->atp_lock);
ddp = AT_DDP_HDR(m);
dPrintf(D_M_ATP_LOW, (D_L_INPUT|D_L_ERROR),
- ("atp_rput: dropping TRESP, no trp,tid=%d,loc=%d,rem=%d.%d,seqno=%d\n",
- UAS_VALUE(athp->tid),
- ddp->dst_socket,ddp->src_node,ddp->src_socket,seqno));
+ ("atp_rput: dropping TRESP, no trp,tid=%d,loc=%d,rem=%d.%d,seqno=%u\n",
+ UAS_VALUE_NTOH(athp->tid),
+ ddp->dst_socket, ddp->src_node, ddp->src_socket, seqno));
gbuf_freem(m);
return;
}
* If no longer valid, drop it
*/
if (trp->tr_state == TRANS_FAILED) {
- ATENABLE(s, atp->atp_lock);
ddp = AT_DDP_HDR(m);
dPrintf(D_M_ATP_LOW, (D_L_INPUT|D_L_ERROR),
("atp_rput: dropping TRESP, failed trp,tid=%d,loc=%d,rem=%d.%d\n",
- UAS_VALUE(athp->tid),
+ UAS_VALUE_NTOH(athp->tid),
ddp->dst_socket, ddp->src_node, ddp->src_socket));
gbuf_freem(m);
return;
* If we have already received it, ignore it
*/
if (!(trp->tr_bitmap&atp_mask[seqno]) || trp->tr_rcv[seqno]) {
- ATENABLE(s, atp->atp_lock);
ddp = AT_DDP_HDR(m);
dPrintf(D_M_ATP_LOW, (D_L_INPUT|D_L_ERROR),
- ("atp_rput: dropping TRESP, duplicate,tid=%d,loc=%d,rem=%d.%d,seqno=%d\n",
- UAS_VALUE(athp->tid),
+ ("atp_rput: dropping TRESP, duplicate,tid=%d,loc=%d,rem=%d.%d,seqno=%u\n",
+ UAS_VALUE_NTOH(athp->tid),
ddp->dst_socket, ddp->src_node, ddp->src_socket, seqno));
gbuf_freem(m);
return;
* the message to the user
*/
if (trp->tr_bitmap == 0) {
- ATENABLE(s, atp->atp_lock);
/*
* Cancel the request timer and any
/*
* If they want treq again, send them
*/
- ATENABLE(s, atp->atp_lock);
atp_untimout(atp_req_timeout, trp);
atp_send(trp);
return;
}
- ATENABLE(s, atp->atp_lock);
return;
}
*/
ddp = AT_DDP_HDR(m);
- ATDISABLE(s, atp->atp_lock);
for (rcbp = atp->atp_rcb.head; rcbp; rcbp = rcbp->rc_list.next) {
- if (rcbp->rc_tid == UAS_VALUE(athp->tid) &&
+ if (rcbp->rc_tid == UAS_VALUE_NTOH(athp->tid) &&
rcbp->rc_socket.node == ddp->src_node &&
rcbp->rc_socket.net == NET_VALUE(ddp->src_net) &&
rcbp->rc_socket.socket == ddp->src_socket) {
{
ddp = 0;
atp_rcb_free(rcbp);
- ATENABLE(s, atp->atp_lock);
}
break;
}
}
- if (ddp)
- ATENABLE(s, atp->atp_lock);
gbuf_freem(m);
return;
}
*/
ddp = AT_DDP_HDR(m);
- ATDISABLE(s, atp->atp_lock);
for (rcbp = atp->atp_rcb.head; rcbp; rcbp = rcbp->rc_list.next) {
- if (rcbp->rc_tid == UAS_VALUE(athp->tid) &&
+ if (rcbp->rc_tid == UAS_VALUE_NTOH(athp->tid) &&
rcbp->rc_socket.node == ddp->src_node &&
rcbp->rc_socket.net == NET_VALUE(ddp->src_net) &&
rcbp->rc_socket.socket == ddp->src_socket)
*/
/* we just did this, why do again? -jjs 4-10-95 */
for (rcbp = atp->atp_attached.head; rcbp; rcbp = rcbp->rc_list.next) {
- if (rcbp->rc_tid == UAS_VALUE(athp->tid) &&
+ if (rcbp->rc_tid == UAS_VALUE_NTOH(athp->tid) &&
rcbp->rc_socket.node == ddp->src_node &&
rcbp->rc_socket.net == NET_VALUE(ddp->src_net) &&
rcbp->rc_socket.socket == ddp->src_socket) {
- ATENABLE(s, atp->atp_lock);
gbuf_freem(m);
dPrintf(D_M_ATP_LOW, D_L_INPUT,
("atp_rput: dropping TREQ, matches req queue\n"));
* assume someone is interested in
* in an asynchronous incoming request
*/
- ATENABLE(s, atp->atp_lock);
if ((rcbp = atp_rcb_alloc(atp)) == NULL) {
gbuf_freem(m);
return;
}
rcbp->rc_state = RCB_UNQUEUED;
- ATDISABLE(s, atp->atp_lock);
rcbp->rc_local_node = ddp->dst_node;
- NET_NET(rcbp->rc_local_net, ddp->dst_net);
+ temp_net = NET_VALUE(ddp->dst_net);
+ NET_ASSIGN_NOSWAP(rcbp->rc_local_net, temp_net);
rcbp->rc_socket.socket = ddp->src_socket;
rcbp->rc_socket.node = ddp->src_node;
rcbp->rc_socket.net = NET_VALUE(ddp->src_net);
- rcbp->rc_tid = UAS_VALUE(athp->tid);
+ rcbp->rc_tid = UAS_VALUE_NTOH(athp->tid);
rcbp->rc_bitmap = athp->bitmap;
rcbp->rc_not_sent_bitmap = athp->bitmap;
rcbp->rc_xo = athp->xo;
rcbp->rc_state = RCB_PENDING;
ATP_Q_APPEND(atp->atp_attached, rcbp, rc_list);
if (m_asp != NULL) {
- ATENABLE(s, atp->atp_lock);
atp_req_ind(atp, m_asp);
return;
}
* the replies
*/
getmicrouptime(&timenow);
- ATDISABLE(s_gen, atpgen_lock);
if (rcbp->rc_timestamp) {
rcbp->rc_timestamp = timenow.tv_sec;
if (rcbp->rc_timestamp == 0)
rcbp->rc_timestamp = 1;
}
- ATENABLE(s_gen, atpgen_lock);
rcbp->rc_bitmap = athp->bitmap;
rcbp->rc_not_sent_bitmap = athp->bitmap;
- ATENABLE(s, atp->atp_lock);
gbuf_freem(m);
atp_reply(rcbp);
return;
* we haven't sent any data yet
* ignore the request
*/
- ATENABLE(s, atp->atp_lock);
gbuf_freem(m);
return;
}
}
- ATENABLE(s, atp->atp_lock);
return;
}