[libss7-commits] mattf: trunk r63 - in /trunk: mtp2.c mtp2.h mtp3.c
ss7_internal.h
libss7-commits at lists.digium.com
libss7-commits at lists.digium.com
Fri Nov 3 09:49:38 MST 2006
Author: mattf
Date: Fri Nov 3 10:49:37 2006
New Revision: 63
URL: http://svn.digium.com/view/libss7?rev=63&view=rev
Log:
Updates so that we can better support retransmission reqeusts.
Modified:
trunk/mtp2.c
trunk/mtp2.h
trunk/mtp3.c
trunk/ss7_internal.h
Modified: trunk/mtp2.c
URL: http://svn.digium.com/view/libss7/trunk/mtp2.c?rev=63&r1=62&r2=63&view=diff
==============================================================================
--- trunk/mtp2.c (original)
+++ trunk/mtp2.c Fri Nov 3 10:49:37 2006
@@ -25,7 +25,6 @@
#define mtp_error ss7_error
#define mtp_message ss7_message
-#if 0
static inline int len_txbuf(struct mtp2 *link)
{
int res = 0;
@@ -37,7 +36,6 @@
}
return res;
}
-#endif
static inline char * linkstate2str(int linkstate)
{
@@ -76,9 +74,9 @@
h->fsn = link->curfsn;
if (nack)
- link->curfib = !link->curfib;
-
- h->bib = link->curfib;
+ link->curbib = !link->curbib;
+
+ h->bib = link->curbib;
h->bsn = link->lastfsnacked;
}
@@ -110,12 +108,15 @@
free(cur);
list = list->next;
}
+
+ link->retransmit_pos = NULL;
}
static void reset_mtp(struct mtp2 *link)
{
link->curfsn = 127;
link->curfib = 1;
+ link->curbib = 1;
link->lastfsnacked = 127;
flush_bufs(link);
@@ -159,7 +160,7 @@
case LSSU_SIE:
case LSSU_SIPO:
case LSSU_SIB:
- head->bib = link->curfib;
+ head->bib = link->curbib;
head->bsn = link->lastfsnacked;
head->fib = link->curfib;
head->fsn = link->curfsn;
@@ -193,6 +194,13 @@
#endif
}
+static void mtp2_retransmit(struct mtp2 *link)
+{
+ /* Have to reverse the current fib */
+ link->curfib = !link->curfib;
+ link->retransmit_pos = link->tx_buf;
+}
+
int mtp2_transmit(struct mtp2 *link)
{
int res = 0;
@@ -200,31 +208,59 @@
unsigned char buf[64];
unsigned int size;
struct ss7_msg *m = NULL;
-
- if (link->tx_q)
- m = link->tx_q;
-
- if (m) {
- struct mtp_su_head *header = (struct mtp_su_head *)m->buf;
+ int retransmit = 0;
+
+ if (link->retransmit_pos) {
+ struct mtp_su_head *h1;
+ m = link->retransmit_pos;
+ retransmit = 1;
+
+ if (!m) {
+ ss7_error(link->master, "Huh, requested to retransmit, but nothing in retransmit buffer?!!\n");
+ return -1;
+ }
+
h = m->buf;
size = m->size;
- init_mtp2_header(link, header, 1, 0);
+
+ h1 = (struct mtp_su_head *)h;
+ /* Update the FIB and BSN since they aren't the same */
+ h1->fib = link->curfib;
+ h1->bsn = link->lastfsnacked;
+
} else {
- size = sizeof(buf);
- if (link->autotxsutype == FISU)
- make_fisu(link, buf, &size, 0);
- else
- make_lssu(link, buf, &size, link->autotxsutype);
- h = buf;
+ if (link->tx_q)
+ m = link->tx_q;
+
+ if (m) {
+ struct mtp_su_head *header = (struct mtp_su_head *)m->buf;
+ h = m->buf;
+ size = m->size;
+ init_mtp2_header(link, header, 1, 0);
+ } else {
+ size = sizeof(buf);
+ if (link->autotxsutype == FISU)
+ make_fisu(link, buf, &size, 0);
+ else
+ make_lssu(link, buf, &size, link->autotxsutype);
+ h = buf;
+ }
}
res = write(link->fd, h, size); /* Add 2 for FCS */
if (res > 0) {
mtp2_dump(link, '>', h, size);
- if (m) {
- link->tx_q = m->next;
- add_txbuf(link, m);
+ if (retransmit) {
+ /* Update our retransmit positon since it transmitted */
+ link->retransmit_pos = m->next;
+ } else {
+ if (m) {
+ /* Advance to next MSU to be transmitted */
+ link->tx_q = m->next;
+ /* Add it to the tx'd message queue (MSUs that haven't been acknowledged) */
+ add_txbuf(link, m);
+ }
}
}
@@ -283,9 +319,6 @@
struct ss7_msg *frlist = NULL;
/* Make a list, frlist that will be the SUs to free */
-#if 0
- mtp_message(link->master, "Txbuf contains %d items\n", len_txbuf(link));
-#endif
/* Empty list */
if (!link->tx_buf) {
return;
@@ -295,7 +328,7 @@
while (cur) {
h = (struct mtp_su_head *)cur->buf;
- if (h->bsn == upto) {
+ if (h->fsn == upto) {
frlist = cur;
if (!prev) /* Head of list */
link->tx_buf = NULL;
@@ -591,6 +624,10 @@
{
int res = 0;
+#if 0
+ mtp_message(link->master, "Txbuf contains %d items\n", len_txbuf(link));
+#endif
+
switch (link->state) {
case MTP_ALIGNEDREADY:
mtp2_setstate(link, MTP_INSERVICE);
@@ -759,11 +796,10 @@
update_txbuf(link, h->bsn);
-#if 0
+ /* Check for retransmission request */
if (h->bib != link->curfib)
/* Negative ack */
mtp2_retransmit(link);
-#endif
switch (h->li) {
case 0:
Modified: trunk/mtp2.h
URL: http://svn.digium.com/view/libss7/trunk/mtp2.h?rev=63&r1=62&r2=63&view=diff
==============================================================================
--- trunk/mtp2.h (original)
+++ trunk/mtp2.h Fri Nov 3 10:49:37 2006
@@ -88,6 +88,7 @@
unsigned char curfsn:7;
unsigned char curfib:1;
unsigned char lastfsnacked:7;
+ unsigned char curbib:1;
int fd;
int t1;
@@ -109,6 +110,7 @@
struct ss7_msg *tx_buf;
struct ss7_msg *tx_q;
+ struct ss7_msg *retransmit_pos;
struct ss7 *master;
};
Modified: trunk/mtp3.c
URL: http://svn.digium.com/view/libss7/trunk/mtp3.c?rev=63&r1=62&r2=63&view=diff
==============================================================================
--- trunk/mtp3.c (original)
+++ trunk/mtp3.c Fri Nov 3 10:49:37 2006
@@ -383,7 +383,6 @@
return 0;
} else if (h1 == 2) {
- net_mng_send_tra(mtp2);
return 0;
} else
ss7_error(ss7, "Unhandled STD_TEST message: h0 = %x h1 = %x", h0, h1);
Modified: trunk/ss7_internal.h
URL: http://svn.digium.com/view/libss7/trunk/ss7_internal.h?rev=63&r1=62&r2=63&view=diff
==============================================================================
--- trunk/ss7_internal.h (original)
+++ trunk/ss7_internal.h Fri Nov 3 10:49:37 2006
@@ -54,7 +54,6 @@
struct ss7 {
unsigned int switchtype;
unsigned int numlinks;
- int sent_tra;
/* Simple "routing table" */
point_code def_dpc;
More information about the libss7-commits
mailing list