patch-1.3.60 linux/net/ax25/ax25_out.c

Next file: linux/net/ax25/ax25_route.c
Previous file: linux/net/ax25/ax25_in.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.59/linux/net/ax25/ax25_out.c linux/net/ax25/ax25_out.c
@@ -1,5 +1,5 @@
 /*
- *	AX.25 release 030
+ *	AX.25 release 031
  *
  *	This is ALPHA test software. This code may break your machine, randomly fail to work with new 
  *	releases, misbehave and/or generally screw up. It might even work. 
@@ -24,6 +24,7 @@
  *			Jonathan(G4KLX)	Only poll when window is full.
  *	AX.25 030	Jonathan(G4KLX)	Added fragmentation to ax25_output.
  *					Added support for extended AX.25.
+ *			Joerg(DL1BKE)	Added DAMA support
  */
 
 #include <linux/config.h>
@@ -109,7 +110,10 @@
 	}
 
 	if (ax25->state == AX25_STATE_3 || ax25->state == AX25_STATE_4)
-		ax25_kick(ax25);
+	{
+		if (!ax25->dama_slave)		/* bke 960114: we aren't allowed to transmit */
+			ax25_kick(ax25);	/* in DAMA mode unless we received a Poll */
+	}
 }
 
 /* 
@@ -184,8 +188,10 @@
 #endif
 			/*
 			 * Transmit the frame copy.
+			 * bke 960114: do not set the Poll bit on the last frame
+			 * in DAMA mode.
 			 */
-			ax25_send_iframe(ax25, skbn, (last) ? POLLON : POLLOFF);
+			ax25_send_iframe(ax25, skbn, (last && !ax25->dama_slave) ? POLLON : POLLOFF);
 
 			ax25->vs = next;
 
@@ -312,10 +318,99 @@
 	}
 }
 
+/* dl1bke 960114: shouldn't ax25/dama_check_need_response reside as  */
+/*                static inline void ...() in ax25.h, should it? ;-) */
+
 void ax25_check_need_response(ax25_cb *ax25, int type, int pf)
 {
-	if (type == C_COMMAND && pf)
+	if (!ax25->dama_slave && type == C_COMMAND && pf)
 		ax25_enquiry_response(ax25);
+}
+
+/* dl1bke 960114: transmit I frames on DAMA poll */
+
+void dama_enquiry_response(ax25_cb * ax25)
+{
+	ax25_cb * ax25o = NULL;
+	
+	if (!(ax25->condition & PEER_RX_BUSY_CONDITION) )
+	{
+		ax25_requeue_frames(ax25);
+		ax25_kick(ax25);
+	}
+	if (ax25->state == AX25_STATE_1 ||
+	    ax25->state == AX25_STATE_2 ||
+	    skb_peek(&ax25->ack_queue) != NULL) 
+	{
+		ax25_t1_timeout(ax25);
+
+	} else
+		ax25->n2count = 0;
+	
+	ax25->t3timer = ax25->t3;
+	
+
+	/* The FLEXNET DAMA master implementation refuses to send us ANY */
+	/* I frame for this connection if we send a REJ here, probably   */
+	/* due to it's frame collector scheme? A simple RR or  RNR will  */
+	/* invoke the retransmission, and in fact REJs are superflous    */
+	/* in DAMA mode anyway...					 */
+	
+#if 0
+	if (ax25->condition & REJECT_CONDITION)
+		ax25_send_control(ax25, REJ, POLLOFF, C_RESPONSE);
+	else
+#endif	
+		ax25_enquiry_response(ax25);
+		
+	/* Note that above response to the poll could be sent behind the  */
+	/* transmissions of the other channels as well... This version    */	
+	/* gives better performance on FLEXNET nodes. (Why, Gunter?)	  */
+
+	for (ax25o=ax25_list; ax25o; ax25o=ax25o->next)
+	{
+		if (ax25o->device != ax25->device)
+			continue;
+			
+		if (ax25o->state == AX25_STATE_1 || ax25o->state == AX25_STATE_2)
+		{
+			ax25_t1_timeout(ax25o);
+			continue;
+		}
+			
+		if ( !ax25o->dama_slave)
+			continue;
+			
+		if ( !(ax25o->condition & PEER_RX_BUSY_CONDITION) && 
+		     (ax25o->state == AX25_STATE_3 || 
+		     (ax25o->state == AX25_STATE_4 && ax25o->t1timer == 0)) )
+		{
+			ax25_requeue_frames(ax25o);
+			ax25_kick(ax25o);
+		}
+		
+		if (ax25o->state == AX25_STATE_1 ||
+		    ax25o->state == AX25_STATE_2 ||
+		    skb_peek(&ax25o->ack_queue) != NULL) ax25_t1_timeout(ax25o);
+
+		ax25o->t3timer = ax25o->t3;
+	}
+}
+
+void dama_check_need_response(ax25_cb *ax25, int type, int pf)
+{
+	if (ax25->dama_slave && type == C_COMMAND && pf)
+		dama_enquiry_response(ax25);
+}
+
+void dama_establish_data_link(ax25_cb *ax25)
+{
+	ax25->condition = 0x00;
+	ax25->n2count   = 0;
+
+	ax25->t3timer = 0;
+	ax25->t2timer = 0;
+	ax25->t1timer = ax25->t1 = ax25_calculate_t1(ax25);
 }
 
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this