[svn-commits] mattf: trunk r85 - /trunk/
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Fri Jun 8 08:40:51 MST 2007
Author: mattf
Date: Fri Jun 8 10:40:50 2007
New Revision: 85
URL: http://svn.digium.com/view/libss7?view=rev&rev=85
Log:
Updates to add better debugging support
Modified:
trunk/isup.c
trunk/mtp2.c
trunk/mtp3.c
trunk/ss7.c
trunk/ss7_internal.h
trunk/ss7linktest.c
Modified: trunk/isup.c
URL: http://svn.digium.com/view/libss7/trunk/isup.c?view=diff&rev=85&r1=84&r2=85
==============================================================================
--- trunk/isup.c (original)
+++ trunk/isup.c Fri Jun 8 10:40:50 2007
@@ -802,7 +802,7 @@
return res + 1;
}
return res;
- } else
+ } else
return 1 + parms[x].receive(ss7, c, message, parmbuf + 1, parmbuf[0]);
case PARM_TYPE_OPTIONAL:
optparm = (struct isup_parm_opt *)parmbuf;
@@ -964,7 +964,7 @@
for (; (x - fixedparams) < varparams; x++) {
varoffsets[i] = &mh->data[offset] - &varoffsets[i];
i++;
- res = do_parm(ss7, c, mh->type, parms[x], (void *)(mh->data + offset), len, PARM_TYPE_VARIABLE, 1); /* Find out what else we need to add */
+ res = do_parm(ss7, c, mh->type, parms[x], (void *)(mh->data + offset), len, PARM_TYPE_VARIABLE, 1);
if (res < 0) {
ss7_error(ss7, "!! Unable to add mandatory variable parameter '%s'\n", param2str(parms[x]));
@@ -979,7 +979,7 @@
int addedparms = 0;
int offsetbegins = offset;
while (parms[x] > -1) {
- res = do_parm(ss7, c, mh->type, parms[x], (void *)(mh->data + offset), len, PARM_TYPE_OPTIONAL, 1); /* Find out what else we need to add */
+ res = do_parm(ss7, c, mh->type, parms[x], (void *)(mh->data + offset), len, PARM_TYPE_OPTIONAL, 1);
x++;
if (res < 0) {
@@ -1032,8 +1032,83 @@
return -1;
}
- ss7_message(ss7, "\t\tMessage Type: %s (%x)\n", message2str(mh->type), mh->type & 0xff);
+ ss7_dump_buf(ss7, 2, buf, 2);
ss7_message(ss7, "\t\tCIC: %d\n", cic);
+ ss7_dump_buf(ss7, 2, &buf[2], 1);
+ ss7_message(ss7, "\t\tMessage Type: %s\n", message2str(mh->type), mh->type & 0xff);
+
+#if 0
+ if (messages[ourmessage].messagetype == ISUP_IAM) {
+ if (ss7->switchtype == SS7_ITU) {
+ fixedparams = messages[ourmessage].mand_fixed_params;
+ varparams = messages[ourmessage].mand_var_params;
+ parms = messages[ourmessage].param_list;
+ } else {
+ /* Stupid ANSI SS7, they just had to be different, didn't they? */
+ fixedparams = 3;
+ varparams = 2;
+ parms = ansi_iam_params;
+ }
+ } else {
+ fixedparams = messages[ourmessage].mand_fixed_params;
+ varparams = messages[ourmessage].mand_var_params;
+ parms = messages[ourmessage].param_list;
+ }
+
+ /* Parse fixed parms */
+ for (x = 0; x < fixedparams; x++) {
+ res = do_parm(ss7, c, mh->type, parms[x], (void *)(mh->data + offset), len, PARM_TYPE_FIXED, 0, 0, 1);
+ res = dump_parm(ss7, c, mh->type, parms[x], (void *)(mh->data + offset), len, PARM_TYPE_FIXED)
+
+ if (res < 0) {
+ ss7_error(ss7, "!! Unable to parse mandatory fixed parameter '%s'\n", param2str(parms[x]));
+ return -1;
+ }
+
+ len -= res;
+ offset += res;
+ }
+
+ if (varparams) {
+ offset += varparams; /* add one for the optionals */
+ res -= varparams;
+ }
+ if (messages[ourmessage].opt_params) {
+ opt_ptr = &mh->data[offset++];
+ }
+
+ i = 0;
+
+ for (; (x - fixedparams) < varparams; x++) {
+ res = do_parm(ss7, c, mh->type, parms[x], (void *)(mh->data + offset), len, PARM_TYPE_VARIABLE, 0, 0, 1);
+
+ if (res < 0) {
+ ss7_error(ss7, "!! Unable to parse mandatory variable parameter '%s'\n", param2str(parms[x]));
+ return -1;
+ }
+
+ len -= res;
+ offset += res;
+ }
+
+ /* Optional paramter parsing code */
+ if (messages[ourmessage].opt_params && *opt_ptr) {
+ while ((len > 0) && (mh->data[offset] != 0)) {
+ struct isup_parm_opt *optparm = (struct isup_parm_opt *)(mh->data + offset);
+
+ res = do_parm(ss7, c, mh->type, optparm->type, mh->data + offset, len, PARM_TYPE_OPTIONAL, 0, 0, 1); /* Find out what else we need to add */
+
+ if (res < 0) {
+ ss7_message(ss7, "Unhandled optional parameter 0x%x '%s'\n", optparm->type, param2str(optparm->type));
+ isup_dump_buffer(ss7, optparm->data, optparm->len);
+ res = optparm->len + 2;
+ }
+
+ len -= res;
+ offset += res;
+ }
+ }
+#endif
return 0;
}
@@ -1114,7 +1189,7 @@
i = 0;
for (; (x - fixedparams) < varparams; x++) {
- res = do_parm(ss7, c, mh->type, parms[x], (void *)(mh->data + offset), len, PARM_TYPE_VARIABLE, 0); /* Find out what else we need to add */
+ res = do_parm(ss7, c, mh->type, parms[x], (void *)(mh->data + offset), len, PARM_TYPE_VARIABLE, 0);
if (res < 0) {
ss7_error(ss7, "!! Unable to parse mandatory variable parameter '%s'\n", param2str(parms[x]));
@@ -1130,7 +1205,7 @@
while ((len > 0) && (mh->data[offset] != 0)) {
struct isup_parm_opt *optparm = (struct isup_parm_opt *)(mh->data + offset);
- res = do_parm(ss7, c, mh->type, optparm->type, mh->data + offset, len, PARM_TYPE_OPTIONAL, 0); /* Find out what else we need to add */
+ res = do_parm(ss7, c, mh->type, optparm->type, mh->data + offset, len, PARM_TYPE_OPTIONAL, 0);
if (res < 0) {
ss7_message(ss7, "Unhandled optional parameter 0x%x '%s'\n", optparm->type, param2str(optparm->type));
Modified: trunk/mtp2.c
URL: http://svn.digium.com/view/libss7/trunk/mtp2.c?view=diff&rev=85&r1=84&r2=85
==============================================================================
--- trunk/mtp2.c (original)
+++ trunk/mtp2.c Fri Jun 8 10:40:50 2007
@@ -279,7 +279,7 @@
res = write(link->fd, h, size); /* Add 2 for FCS */
if (res > 0) {
- mtp2_dump(link, '>', h, size);
+ mtp2_dump(link, '>', h, size - 2);
if (retransmit) {
/* Update our retransmit positon since it transmitted */
update_retransmit_pos(link);
@@ -767,6 +767,7 @@
return;
else
link->lastsutxd = FISU;
+ ss7_dump_msg(link->master, buf, len);
ss7_message(link->master, "FSN: %d FIB %d\n", h->fsn, h->fib);
ss7_message(link->master, "BSN: %d BIB %d\n", h->bsn, h->bib);
@@ -799,12 +800,14 @@
mtypech = "SIB";
break;
}
+ ss7_dump_msg(link->master, buf, len);
ss7_message(link->master, "FSN: %d FIB %d\n", h->fsn, h->fib);
ss7_message(link->master, "BSN: %d BIB %d\n", h->bsn, h->bib);
ss7_message(link->master, "%c[%d] LSSU %s\n", prefix, link->slc, mtypech);
break;
case 2:
- ss7_dump_buf(link->master, buf, len);
+ ss7_dump_msg(link->master, buf, len);
+ ss7_dump_buf(link->master, 0, buf, 3);
ss7_message(link->master, "FSN: %d FIB %d\n", h->fsn, h->fib);
ss7_message(link->master, "BSN: %d BIB %d\n", h->bsn, h->bib);
ss7_message(link->master, "%c[%d] MSU\n", prefix, link->slc);
@@ -819,8 +822,9 @@
int mtp2_receive(struct mtp2 *link, unsigned char *buf, int len)
{
struct mtp_su_head *h = (struct mtp_su_head *)buf;
-
- mtp2_dump(link, '<', buf, len);
+ len -= 2; /* Strip the CRC off */
+
+ mtp2_dump(link, '<', buf, len - 2);
update_txbuf(link, h->bsn);
@@ -834,14 +838,14 @@
switch (h->li) {
case 0:
/* FISU */
- return fisu_rx(link, h, len);
+ return fisu_rx(link, h, len - 2);
case 1:
case 2:
/* LSSU */
- return lssu_rx(link, h, len);
+ return lssu_rx(link, h, len - 2);
default:
/* MSU */
- return msu_rx(link, h, len);
+ return msu_rx(link, h, len - 2);
}
return 0;
Modified: trunk/mtp3.c
URL: http://svn.digium.com/view/libss7/trunk/mtp3.c?view=diff&rev=85&r1=84&r2=85
==============================================================================
--- trunk/mtp3.c (original)
+++ trunk/mtp3.c Fri Jun 8 10:40:50 2007
@@ -229,6 +229,7 @@
h1 = get_h1(headerptr);
h0 = get_h0(headerptr);
+ ss7_dump_buf(ss7, 1, headerptr, 1);
ss7_message(ss7, "\tH0: %x H1: %x\n", h0, h1);
ss7_message(ss7, "\tMessage type: %s\n", net_mng_message2str(h0, h1));
return 0;
@@ -443,13 +444,11 @@
int rlsize;
- ss7_message(ss7, "\tNetwork Indicator 0x%x\n", ni);
-
+ ss7_dump_buf(ss7, 1, sio, 1);
+ ss7_message(ss7, "\tNetwork Indicator: %d Priority: %d User Part: %s\n", ni, priority, userpart2str(userpart));
rlsize = get_routinglabel(ss7->switchtype, sif, &rl);
-
- ss7_message(ss7, "\tOPC %d DPC %d\n", rl.opc, rl.dpc);
-
- ss7_message(ss7, "\tUser Part: %s (%x) Priority: %d\n", userpart2str(userpart), userpart, priority);
+ ss7_dump_buf(ss7, 1, sif, rlsize);
+ ss7_message(ss7, "\tOPC %d DPC %d SLS %d\n", rl.opc, rl.dpc, rl.sls);
/* Pass it to the correct user part */
switch (userpart) {
Modified: trunk/ss7.c
URL: http://svn.digium.com/view/libss7/trunk/ss7.c?view=diff&rev=85&r1=84&r2=85
==============================================================================
--- trunk/ss7.c (original)
+++ trunk/ss7.c Fri Jun 8 10:40:50 2007
@@ -70,7 +70,20 @@
ss7->debug = flags;
}
-void ss7_dump_buf(struct ss7 *ss7, unsigned char *buf, int len)
+void ss7_dump_buf(struct ss7 *ss7, int tabs, unsigned char *buf, int len)
+{
+ int i;
+
+ for (i = 0; i < tabs; i++)
+ ss7_message(ss7, "\t");
+ ss7_message(ss7, "[ ");
+ for (i = 0; i < len; i++) {
+ ss7_message(ss7, "%02x ", buf[i]);
+ }
+ ss7_message(ss7, "]\n");
+}
+
+void ss7_dump_msg(struct ss7 *ss7, unsigned char *buf, int len)
{
int i;
Modified: trunk/ss7_internal.h
URL: http://svn.digium.com/view/libss7/trunk/ss7_internal.h?view=diff&rev=85&r1=84&r2=85
==============================================================================
--- trunk/ss7_internal.h (original)
+++ trunk/ss7_internal.h Fri Jun 8 10:40:50 2007
@@ -98,6 +98,8 @@
void ss7_error(struct ss7 *ss7, char *fmt, ...);
-void ss7_dump_buf(struct ss7 *ss7, unsigned char *buf, int len);
+void ss7_dump_buf(struct ss7 *ss7, int tabs, unsigned char *buf, int len);
+
+void ss7_dump_msg(struct ss7 *ss7, unsigned char *buf, int len);
#endif /* _SS7_H */
Modified: trunk/ss7linktest.c
URL: http://svn.digium.com/view/libss7/trunk/ss7linktest.c?view=diff&rev=85&r1=84&r2=85
==============================================================================
--- trunk/ss7linktest.c (original)
+++ trunk/ss7linktest.c Fri Jun 8 10:40:50 2007
@@ -128,6 +128,7 @@
switch (e->e) {
case SS7_EVENT_UP:
printf("[%d] --- SS7 Up ---\n", linkset->linkno);
+ isup_grs(ss7, 1, 24, dpc);
break;
case MTP2_LINK_UP:
printf("[%d] MTP2 link up\n", linkset->linkno);
@@ -135,14 +136,13 @@
case ISUP_EVENT_GRS:
printf("Got GRS from cic %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
isup_gra(ss7, e->grs.startcic, e->grs.endcic, dpc);
- isup_grs(ss7, e->grs.startcic, e->grs.endcic, dpc);
break;
case ISUP_EVENT_RSC:
isup_rlc(ss7, e->rsc.call);
break;
case ISUP_EVENT_GRA:
printf("Got GRA from cic %d to %d.\n", e->gra.startcic, e->gra.endcic);
- //ss7_call(ss7);
+ ss7_call(ss7);
break;
case ISUP_EVENT_BLO:
isup_bla(ss7, e->blo.cic, dpc);
More information about the svn-commits
mailing list