[svn-commits] mattf: branch mattf/bug13495 r247 - /team/mattf/bug13495/isup_masq.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 23 16:10:31 CST 2008


Author: mattf
Date: Tue Dec 23 16:10:31 2008
New Revision: 247

URL: http://svn.digium.com/view/libss7?view=rev&rev=247
Log:
Add support for the new TCP message format

Modified:
    team/mattf/bug13495/isup_masq.c

Modified: team/mattf/bug13495/isup_masq.c
URL: http://svn.digium.com/view/libss7/team/mattf/bug13495/isup_masq.c?view=diff&rev=247&r1=246&r2=247
==============================================================================
--- team/mattf/bug13495/isup_masq.c (original)
+++ team/mattf/bug13495/isup_masq.c Tue Dec 23 16:10:31 2008
@@ -91,27 +91,12 @@
 
 static int get_msg_length(struct mtp2 *mtp2)
 {
-	char lenbuf[1];
+	unsigned char lenbuf[2];
 	int res;
 
-#if 0
-	do {
-		if (read(mtp2->fd, &lenbuf[i++], 1) < 0) {
-			ss7_message(mtp2->master, "Read returned -1in get_msg_length\n");
-			return -1;
-		}
-	} while ((i < 10) && lenbuf[i - 1] != 0);
-
-	if (i == 10) {
-		ss7_message(mtp2->master, "Reached read limit length, huh?");
-		return -1;
-	}
-
-	sscanf(lenbuf, "%d", &i);
-#endif
 	res = read(mtp2->fd, lenbuf, sizeof(lenbuf));
 
-	if (res != 1) {
+	if (res != 2) {
 		ss7_message(mtp2->master, "Read len of %d:%s\n", res, strerror(errno));
 		return -1;
 	}
@@ -120,9 +105,8 @@
 		ss7_message(mtp2->master, "Link dropped\n");
 		return -1;
 	}
-	
-
-	return lenbuf[0];
+
+	return (lenbuf[0] << 8) | lenbuf[1];
 }
 
 #if 0
@@ -188,6 +172,7 @@
 	return res;
 }
 
+#if 0
 static unsigned char * itoa(int val, int base)
 {
 	static unsigned char buf[32] = {0};
@@ -198,6 +183,7 @@
 	
 	return &buf[i+1];
 }  
+#endif
 
 static int isup_carefulwrite(int fd, unsigned char *s, int len, int timeoutms) 
 {
@@ -231,11 +217,15 @@
 static int isup_ip_send(struct mtp2 *mtp2, unsigned char *data, int len)
 {
 	int i;
+	unsigned char lenbuf[2];
 
 	isup_ip_dump(mtp2, '>', data, len);
+
+	lenbuf[0] = (len >> 8) & 0xff;
+	lenbuf[1] = len & 0xff;
 	
 	/* Send the length of entire ISUP message first */
-	i = isup_carefulwrite(mtp2->fd, itoa(len,10), 4, 50);
+	i = isup_carefulwrite(mtp2->fd, lenbuf, 2, 50);
 	
 	return isup_carefulwrite(mtp2->fd, data, len, 50);
 }
@@ -244,7 +234,9 @@
 {
 	int res;
 
-	res = isup_ip_send(mtp2, msg->buf + MTP2_SIZE, msg->size - MTP2_SIZE);
+	msg->buf[MTP2_SIZE - 1] = 5;
+	
+	res = isup_ip_send(mtp2, msg->buf + MTP2_SIZE - 1, msg->size - MTP2_SIZE + 1);
 
 	ss7_msg_free(msg);
 	




More information about the svn-commits mailing list