patch-2.1.22 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
- Lines: 308
- Date:
Sun Jan 19 15:47:27 1997
- Orig file:
v2.1.21/linux/net/ax25/ax25_out.c
- Orig date:
Thu Jan 2 15:55:26 1997
diff -u --recursive --new-file v2.1.21/linux/net/ax25/ax25_out.c linux/net/ax25/ax25_out.c
@@ -64,17 +64,9 @@
unsigned char *p;
int frontlen, mtu, len, fragno, ka9qfrag, first = 1;
long flags;
-
- /*
- * dl1bke 960301: We use the new PACLEN parameter as MTU of the AX.25 layer.
- * This will (hopefully) allow user programs to write() data
- * w/o having to think of the maximal amount of data we can
- * send with one call. It's called PACLEN to (1) avoid confusion
- * with (IP) MTU and (2) TAPR calls this PACLEN, too ;-)
- */
mtu = ax25->paclen;
-
+
if ((skb->len - 1) > mtu) {
if (*skb->data == AX25_P_TEXT) {
skb_pull(skb, 1); /* skip PID */
@@ -83,7 +75,7 @@
mtu -= 2; /* Allow for fragment control info */
ka9qfrag = 1;
}
-
+
fragno = skb->len / mtu;
if (skb->len % mtu == 0) fragno--;
@@ -92,17 +84,14 @@
while (skb->len > 0) {
save_flags(flags);
cli();
- /*
- * do _not_ use sock_alloc_send_skb, our socket may have
- * sk->shutdown set...
- */
+
if ((skbn = alloc_skb(mtu + 2 + frontlen, GFP_ATOMIC)) == NULL) {
restore_flags(flags);
printk(KERN_DEBUG "ax25_output: alloc_skb returned NULL\n");
return;
}
- if (skbn->sk)
+ if (skb->sk != NULL)
skb_set_owner_w(skbn, skb->sk);
restore_flags(flags);
@@ -110,7 +99,7 @@
skbn->arp = 1;
len = (mtu > skb->len) ? skb->len : mtu;
-
+
if (ka9qfrag == 1) {
skb_reserve(skbn, frontlen + 2);
@@ -121,7 +110,7 @@
*p = fragno--;
if (first) {
- *p |= SEG_FIRST;
+ *p |= AX25_SEG_FIRST;
first = 0;
}
} else {
@@ -134,7 +123,7 @@
skb_pull(skb, len);
skb_queue_tail(&ax25->write_queue, skbn); /* Throw it on the queue */
}
-
+
kfree_skb(skb, FREE_WRITE);
} else {
skb_queue_tail(&ax25->write_queue, skb); /* Throw it on the queue */
@@ -157,23 +146,23 @@
if (skb == NULL)
return;
- if (ax25->modulus == MODULUS) {
+ if (ax25->modulus == AX25_MODULUS) {
frame = skb_push(skb, 1);
- *frame = I;
- *frame |= (poll_bit) ? PF : 0;
+ *frame = AX25_I;
+ *frame |= (poll_bit) ? AX25_PF : 0;
*frame |= (ax25->vr << 5);
*frame |= (ax25->vs << 1);
} else {
frame = skb_push(skb, 2);
- frame[0] = I;
+ frame[0] = AX25_I;
frame[0] |= (ax25->vs << 1);
- frame[1] = (poll_bit) ? EPF : 0;
+ frame[1] = (poll_bit) ? AX25_EPF : 0;
frame[1] |= (ax25->vr << 1);
}
- ax25_transmit_buffer(ax25, skb, C_COMMAND);
+ ax25_transmit_buffer(ax25, skb, AX25_COMMAND);
}
void ax25_kick(ax25_cb *ax25)
@@ -187,8 +176,8 @@
start = (skb_peek(&ax25->ack_queue) == NULL) ? ax25->va : ax25->vs;
end = (ax25->va + ax25->window) % ax25->modulus;
- if (!(ax25->condition & PEER_RX_BUSY_CONDITION) &&
- start != end &&
+ if (!(ax25->condition & AX25_COND_PEER_RX_BUSY) &&
+ start != end &&
skb_peek(&ax25->write_queue) != NULL) {
ax25->vs = start;
@@ -210,18 +199,18 @@
break;
}
+ if (skb->sk != NULL)
+ skb_set_owner_w(skbn, skb->sk);
+
next = (ax25->vs + 1) % ax25->modulus;
-#ifdef notdef
- last = (next == end) || skb_peek(&ax25->write_queue) == NULL;
-#else
last = (next == end);
-#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 && !ax25->dama_slave) ? POLLON : POLLOFF);
+ ax25_send_iframe(ax25, skbn, (last && !ax25->dama_slave) ? AX25_POLLON : AX25_POLLOFF);
ax25->vs = next;
@@ -229,12 +218,10 @@
* Requeue the original data frame.
*/
skb_queue_tail(&ax25->ack_queue, skb);
-#ifdef notdef
- } while (!last);
-#else
+
} while (!last && (skb = skb_dequeue(&ax25->write_queue)) != NULL);
-#endif
- ax25->condition &= ~ACK_PENDING_CONDITION;
+
+ ax25->condition &= ~AX25_COND_ACK_PENDING;
if (ax25->t1timer == 0) {
ax25->t3timer = 0;
@@ -292,12 +279,11 @@
ax25->condition = 0x00;
ax25->n2count = 0;
- if (ax25->modulus == MODULUS) {
- ax25_send_control(ax25, SABM, POLLON, C_COMMAND);
- } else {
- ax25_send_control(ax25, SABME, POLLON, C_COMMAND);
- }
-
+ if (ax25->modulus == AX25_MODULUS)
+ ax25_send_control(ax25, AX25_SABM, AX25_POLLON, AX25_COMMAND);
+ else
+ ax25_send_control(ax25, AX25_SABME, AX25_POLLON, AX25_COMMAND);
+
ax25->t3timer = 0;
ax25->t2timer = 0;
ax25->t1timer = ax25->t1 = ax25_calculate_t1(ax25);
@@ -305,34 +291,34 @@
void ax25_transmit_enquiry(ax25_cb *ax25)
{
- if (ax25->condition & OWN_RX_BUSY_CONDITION)
- ax25_send_control(ax25, RNR, POLLON, C_COMMAND);
+ if (ax25->condition & AX25_COND_OWN_RX_BUSY)
+ ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_COMMAND);
else
- ax25_send_control(ax25, RR, POLLON, C_COMMAND);
+ ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_COMMAND);
- ax25->condition &= ~ACK_PENDING_CONDITION;
+ ax25->condition &= ~AX25_COND_ACK_PENDING;
ax25->t1timer = ax25->t1 = ax25_calculate_t1(ax25);
}
void ax25_enquiry_response(ax25_cb *ax25)
{
- if (ax25->condition & OWN_RX_BUSY_CONDITION)
- ax25_send_control(ax25, RNR, POLLON, C_RESPONSE);
+ if (ax25->condition & AX25_COND_OWN_RX_BUSY)
+ ax25_send_control(ax25, AX25_RNR, AX25_POLLON, AX25_RESPONSE);
else
- ax25_send_control(ax25, RR, POLLON, C_RESPONSE);
+ ax25_send_control(ax25, AX25_RR, AX25_POLLON, AX25_RESPONSE);
- ax25->condition &= ~ACK_PENDING_CONDITION;
+ ax25->condition &= ~AX25_COND_ACK_PENDING;
}
void ax25_timeout_response(ax25_cb *ax25)
{
- if (ax25->condition & OWN_RX_BUSY_CONDITION)
- ax25_send_control(ax25, RNR, POLLOFF, C_RESPONSE);
+ if (ax25->condition & AX25_COND_OWN_RX_BUSY)
+ ax25_send_control(ax25, AX25_RNR, AX25_POLLOFF, AX25_RESPONSE);
else
- ax25_send_control(ax25, RR, POLLOFF, C_RESPONSE);
+ ax25_send_control(ax25, AX25_RR, AX25_POLLOFF, AX25_RESPONSE);
- ax25->condition &= ~ACK_PENDING_CONDITION;
+ ax25->condition &= ~AX25_COND_ACK_PENDING;
}
void ax25_check_iframes_acked(ax25_cb *ax25, unsigned short nr)
@@ -356,7 +342,7 @@
*/
void ax25_check_need_response(ax25_cb *ax25, int type, int pf)
{
- if (!ax25->dama_slave && type == C_COMMAND && pf)
+ if (!ax25->dama_slave && type == AX25_COMMAND && pf)
ax25_enquiry_response(ax25);
}
@@ -366,35 +352,32 @@
void dama_enquiry_response(ax25_cb *ax25)
{
ax25_cb *ax25o;
-
- if (!(ax25->condition & PEER_RX_BUSY_CONDITION)) {
+
+ if (!(ax25->condition & AX25_COND_PEER_RX_BUSY)) {
ax25_requeue_frames(ax25);
ax25_kick(ax25);
}
- if (ax25->state == AX25_STATE_1 || ax25->state == AX25_STATE_2 ||
- skb_peek(&ax25->ack_queue) != NULL) {
+ if (ax25->state == AX25_STATE_1 || ax25->state == AX25_STATE_2 || skb_peek(&ax25->ack_queue) != NULL)
ax25_t1_timeout(ax25);
- } else {
+ 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 its frame collector scheme? A simple RR or RNR will */
/* invoke the retransmission, and in fact REJs are superfluous */
/* in DAMA mode anyway... */
-
+
#if 0
- if (ax25->condition & REJECT_CONDITION)
- ax25_send_control(ax25, REJ, POLLOFF, C_RESPONSE);
+ if (ax25->condition & AX25_COND_REJECT)
+ ax25_send_control(ax25, AX25_REJ, AX25_POLLOFF, AX25_RESPONSE);
else
-#endif
+#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?) */
@@ -413,18 +396,16 @@
if (!ax25o->dama_slave)
continue;
-
- if ( !(ax25o->condition & PEER_RX_BUSY_CONDITION) &&
+
+ if ( !(ax25o->condition & AX25_COND_PEER_RX_BUSY) &&
(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) {
+
+ 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;
}
@@ -432,7 +413,7 @@
void dama_check_need_response(ax25_cb *ax25, int type, int pf)
{
- if (ax25->dama_slave && type == C_COMMAND && pf)
+ if (ax25->dama_slave && type == AX25_COMMAND && pf)
dama_enquiry_response(ax25);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov