[Asterisk-cvs] zaptel ztd-eth.c,1.6,1.7

markster at lists.digium.com markster at lists.digium.com
Mon Aug 16 00:22:22 CDT 2004


Update of /usr/cvsroot/zaptel
In directory localhost.localdomain:/tmp/cvs-serv1716

Modified Files:
	ztd-eth.c 
Log Message:
Fix subaddressing (bug #2020)


Index: ztd-eth.c
===================================================================
RCS file: /usr/cvsroot/zaptel/ztd-eth.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ztd-eth.c	1 Feb 2004 05:53:58 -0000	1.6
+++ ztd-eth.c	16 Aug 2004 04:08:29 -0000	1.7
@@ -251,7 +251,7 @@
 {
 	struct ztdeth *z;
 	char src[256];
-	char tmp[256], *tmp2, *tmp3;
+	char tmp[256], *tmp2, *tmp3, *tmp4 = NULL;
 	int res,x;
 	unsigned long flags;
 
@@ -273,6 +273,11 @@
 			return NULL;
 		}
 		if (tmp2) {
+			tmp4 = strchr(tmp2+1, '/');
+			if (tmp4) {
+				*tmp4 = '\0';
+				tmp4++;
+			}
 			/* We don't have SSCANF :(  Gotta do this the hard way */
 			tmp3 = strchr(tmp2, ':');
 			for (x=0;x<6;x++) {
@@ -300,6 +305,25 @@
 			kfree(z);
 			return NULL;
 		}
+		if (tmp4) {
+			int sub = 0;
+			int mul = 1;
+
+			/* We have a subaddr */
+			tmp3 = tmp4 + strlen (tmp4) - 1;
+			while (tmp3 >= tmp4) {
+				if (*tmp3 >= '0' && *tmp3 <= '9') {
+					sub += (*tmp3 - '0') * mul;
+				} else {
+					printk("TDMoE: Invalid subaddress\n");
+					kfree(z);
+					return NULL;
+				}
+				mul *= 10;
+				tmp3--;
+			}
+			z->subaddr = htons(sub);
+		}
 		z->dev = dev_get_by_name(z->ethdev);
 		if (!z->dev) {
 			printk("TDMoE: Invalid device '%s'\n", z->ethdev);
@@ -311,7 +335,7 @@
 		for (x=0;x<5;x++)
 			sprintf(src + strlen(src), "%02x:", z->dev->dev_addr[x]);
 		sprintf(src + strlen(src), "%02x", z->dev->dev_addr[5]);
-		printk("TDMoE: Added new interface for %s at %s (addr=%s, src=%s)\n", span->name, z->dev->name, addr, src);
+		printk("TDMoE: Added new interface for %s at %s (addr=%s, src=%s, subaddr=%d)\n", span->name, z->dev->name, addr, src, ntohs(z->subaddr));
 			
 		spin_lock_irqsave(&zlock, flags);
 		z->next = zdevs;




More information about the svn-commits mailing list