瀏覽代碼

Added support for TLV 36 and 67.

Subscriber management IPv4 or IPv6 list.
AdrianSimionov 10 年之前
父節點
當前提交
929676ec40

+ 1 - 1
src/docsis_common.h

@@ -31,7 +31,7 @@
 
 
 #ifndef NUM_IDENTIFIERS
-#define NUM_IDENTIFIERS 483
+#define NUM_IDENTIFIERS 485
 #endif /*  NUM_IDENTIFIERS, needed in docsis_symtable.h  */
 
 #define MAXINT 2000000000

+ 31 - 0
src/docsis_decode.c

@@ -100,6 +100,21 @@ void decode_ip (unsigned char *tlvbuf, symbol_type *sym, size_t length )
 	sym->sym_ident, inet_ntoa(helper) );
 }
 
+void decode_ip_list (unsigned char *tlvbuf, symbol_type *sym, size_t length )
+{
+  static struct in_addr helper;
+  unsigned int i;
+  printf("%s ", sym->sym_ident);
+  for ( i=0; i < length / 4; i++) {
+    memcpy (&helper, tlvbuf + i * 4, 4 );
+    printf( "%s", inet_ntoa(helper) );
+    if (i < (length/4) - 1 ) {
+      printf(",");
+    }
+  }
+  printf(";\n");  
+}
+
 void decode_ip6 (unsigned char *tlvbuf, symbol_type *sym, size_t length )
 {
   static struct in6_addr helper;
@@ -114,6 +129,22 @@ void decode_ip6 (unsigned char *tlvbuf, symbol_type *sym, size_t length )
 	sym->sym_ident, inet_ntop(AF_INET6,tlvbuf,ipstr,sizeof ipstr) );
 }
 
+void decode_ip6_list (unsigned char *tlvbuf, symbol_type *sym, size_t length )
+{
+  static struct in6_addr helper;
+  char ipstr[INET6_ADDRSTRLEN];
+  unsigned int i;
+  printf("%s ", sym->sym_ident);
+  for ( i=0; i < length / 16; i++) {
+    memcpy (&helper, tlvbuf + i * 16, 16 );
+    printf( "%s", inet_ntop(AF_INET6, tlvbuf + i * 16, ipstr, sizeof ipstr) );
+    if (i < (length/16) - 1 ) {
+      printf(",");
+    }
+  }
+  printf(";\n");  
+}
+
 void decode_ip_ip6 (unsigned char *tlvbuf, symbol_type *sym, size_t length )
 {
   static char ip6_addr[INET6_ADDRSTRLEN];

+ 2 - 0
src/docsis_decode.h

@@ -34,7 +34,9 @@ void decode_uint24 (unsigned char *tlvbuf, struct symbol_entry *sym, size_t leng
 void decode_ushort (unsigned char *tlvbuf, symbol_type *sym, size_t length );
 void decode_uchar (unsigned char *tlvbuf, symbol_type *sym, size_t length );
 void decode_ip (unsigned char *tlvbuf, symbol_type *sym, size_t length );
+void decode_ip_list (unsigned char *tlvbuf, symbol_type *sym, size_t length );
 void decode_ip6 (unsigned char *tlvbuf, symbol_type *sym, size_t length );
+void decode_ip6_list (unsigned char *tlvbuf, symbol_type *sym, size_t length );
 void decode_ip_ip6 (unsigned char *tlvbuf, symbol_type *sym, size_t length );
 void decode_char_ip_ip6 (unsigned char *tlvbuf, symbol_type *sym, size_t length );
 void decode_ip_ip6_port (unsigned char *tlvbuf, symbol_type *sym, size_t length );

+ 56 - 0
src/docsis_encode.c

@@ -178,6 +178,34 @@ int encode_ip( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
   return ( sizeof(struct in_addr));
 }
 
+int encode_ip_list( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
+{
+  int i;
+  char *token;
+  char *array[16];
+  const char s[2] = ",";
+  struct in_addr in;
+  union t_val *helper; /* We only use this to cast the void* we receive to what we think it should be */
+
+  helper = (union t_val *) tval;
+  i = 0;
+  token = strtok(helper->strval, s);
+  while (token != NULL) 
+  {
+    array[i] = token;
+    token = strtok (NULL, s);
+    if ( inet_aton ( array[i], &in) ) {
+      memcpy ( buf + 4 * i, &in, sizeof(struct in_addr));
+    } else {
+      fprintf(stderr, "Invalid IP address %s at line %d\n", helper->strval, line );
+      exit (-1);
+    }
+    i++;
+  }
+  free(helper->strval);
+  return ( i * sizeof(struct in_addr));
+}
+
 int encode_ip6( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
 {
   struct in6_addr in;
@@ -207,6 +235,34 @@ int encode_ip6( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
   return ( sizeof(struct in6_addr));
 }
 
+int encode_ip6_list( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
+{
+  int i;
+  char *token;
+  char *array[16];
+  const char s[2] = ",";
+  struct in6_addr in6;
+  union t_val *helper; /* We only use this to cast the void* we receive to what we think it should be */
+
+  helper = (union t_val *) tval;
+  i = 0;
+  token = strtok(helper->strval, s);
+  while (token != NULL) 
+  {
+    array[i] = token;
+    token = strtok (NULL, s);
+    if ( inet_pton ( AF_INET6, array[i], &in6) ) {
+      memcpy ( buf + 16 * i, &in6, sizeof(struct in6_addr));
+    } else {
+      fprintf(stderr, "Invalid IP address %s at line %d\n", helper->strval, line );
+      exit (-1);
+    }
+    i++;
+  }
+  free(helper->strval);
+  return ( i * sizeof(struct in6_addr));
+}
+
 int encode_ip_ip6( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
 {
   struct in6_addr in6;

+ 2 - 0
src/docsis_encode.h

@@ -30,7 +30,9 @@ int encode_uint24   	(unsigned char *buf, void *tval, struct symbol_entry *sym_p
 int encode_ushort 	(unsigned char *buf, void *tval, struct symbol_entry *sym_ptr );
 int encode_uchar  	(unsigned char *buf, void *tval, struct symbol_entry *sym_ptr );
 int encode_ip     	(unsigned char *buf, void *tval, struct symbol_entry *sym_ptr );
+int encode_ip_list     	(unsigned char *buf, void *tval, struct symbol_entry *sym_ptr );
 int encode_ip6     	(unsigned char *buf, void *tval, struct symbol_entry *sym_ptr );
+int encode_ip6_list     	(unsigned char *buf, void *tval, struct symbol_entry *sym_ptr );
 int encode_ip_ip6  	(unsigned char *buf, void *tval, struct symbol_entry *sym_ptr );
 int encode_char_ip_ip6  	(unsigned char *buf, void *tval, struct symbol_entry *sym_ptr );
 int encode_ip_ip6_port  	(unsigned char *buf, void *tval, struct symbol_entry *sym_ptr );

File diff suppressed because it is too large
+ 2 - 0
src/docsis_lex.l


+ 6 - 1
src/docsis_symtable.h

@@ -489,6 +489,9 @@ symbol_type symtable[NUM_IDENTIFIERS] =  {
 { 134,    "SnmpV3MgrPublicNumber",             2,      132,    (encode_hexstr),         (decode_hexstr),         1,           514           }, /* TLV 34.2 MULPIv3.0-I24 Annex C.1.2.9.2 */
 
 { 154,    "SubMgmtControl",                    35,     0,      (encode_hexstr),         (decode_hexstr),         3,           3             }, /* TLV 35 MULPIv3.0-I24 Annex C.1.1.19.1 */
+
+{ 477,    "SubscriberManagementCPEIPTable",    36,     0,      (encode_ip_list),        (decode_ip_list),        0,           0             }, /* TLV 36 MULPIv3.0-I24 Annex C.1.1.19.2 */
+
 { 155,    "SubMgmtFilters",                    37,     0,      (encode_ushort_list),    (decode_ushort_list),    4,           10            }, /* TLV 37 MULPIv3.0-I24 Annex C.1.1.19.4 */
 
 /* Snmpv3 Notification Receiver */
@@ -547,6 +550,8 @@ symbol_type symtable[NUM_IDENTIFIERS] =  {
 { 343,    "CMTSStaticMulticastSessionSource",  2,      341,    (encode_ip_ip6),         (decode_ip_ip6),         0,           0             }, /* TLV 64.2 MULPIv3.0-I24 Annex C.1.1.27.2 */
 { 344,    "CMTSStaticMulticastSessionCMIM",    3,      341,    (encode_hexstr),         (decode_hexstr),         0,           0             }, /* TLV 64.3 MULPIv3.0-I24 Annex C.1.1.27.3 */
 
+{ 478,    "SubscriberManagementCPEIPv6Table",  67,     0,      (encode_ip6_list),       (decode_ip6_list),       0,           0             }, /* TLV 67 MULPIv3.0-I24 Annex C.1.1.19.6 */
+
 /* eRouter TLVs */
 { 175,    "eRouter",                           202,    0,      (encode_nothing),        (decode_aggregate),      0,           0             }, /* TLV 202 eRouter-I12 */
 { 176,    "InitializationMode",                1,      175,    (encode_uchar),          (decode_uchar),          0,           3             }, /* TLV 202.1 eRouter-I12 Annex B.4.2 */
@@ -577,7 +582,7 @@ symbol_type symtable[NUM_IDENTIFIERS] =  {
 { 236,    "SNMPv3AccessViewMask",              3,      233,    (encode_hexstr),         (decode_hexstr),         2,           2             }, /* TLV 202.54.3 eRouter-I12 Annex B.4.6.3 */
 { 237,    "SNMPv3AccessViewType",              4,      233,    (encode_uchar),          (decode_uchar),          1,           2             }, /* TLV 202.54.4 eRouter-I12 Annex B.4.6.4 */
 
-/* A little more organized -> Start with 476 */
+/* A little more organized -> Start with 479 */
 
 /* Generic TLV ... we only use the limits, code and length don't matter ...*/
 { 998,    "GenericTLV",                        0,      0,      (encode_nothing),        (decode_special),        0,           0             },

+ 6 - 0
src/docsis_yy.y

@@ -71,6 +71,8 @@ struct tlv *_my_tlvtree_head;
 %token <strval>  T_STRING
 %token <strval>  T_HEX_STRING
 %token <strval>  T_TIMETICKS
+%token <strval>  T_IP_LIST
+%token <strval>  T_IP6_LIST
 
 %token <uintval>  T_ASNTYPE_INT
 %token <uintval>  T_ASNTYPE_UINT
@@ -170,8 +172,12 @@ assignment_stmt:  T_IDENTIFIER T_INTEGER ';' {
 			$$ = create_tlv ($1, (union t_val *)&$2);}
 		| T_IDENTIFIER T_IP ';' {
 			$$ = create_tlv ($1, (union t_val *)&$2);}
+		| T_IDENTIFIER T_IP_LIST ';' {
+			$$ = create_tlv ($1, (union t_val *)&$2);}			
 		| T_IDENTIFIER T_IP6 ';' {
 			$$ = create_tlv ($1, (union t_val *)&$2);}
+		| T_IDENTIFIER T_IP6_LIST ';' {
+			$$ = create_tlv ($1, (union t_val *)&$2);}			
 		| T_IDENTIFIER T_DUAL_TAG ';' {
 			$$ = create_tlv ($1, (union t_val *)&$2);}
 		| T_IDENTIFIER T_IP_IP6_PORT ';' {

二進制
tests/TLV_36_SubscriberManagementCPEIPTable.cm


+ 18 - 0
tests/TLV_36_SubscriberManagementCPEIPTable.conf

@@ -0,0 +1,18 @@
+Main 
+{
+	NetworkAccess 1;
+	UsServiceFlow
+	{
+		UsServiceFlowRef 1;
+		QosParamSetType 7;
+	}
+	DsServiceFlow
+	{
+		DsServiceFlowRef 2;
+		QosParamSetType 7;
+	}
+	SubscriberManagementCPEIPTable 10.11.0.1,1.2.3.5,1.5.4.6,1.1.1.1;
+	/* CmMic 40d02c6c63018403184b64e7298d2355; */
+	/* CmtsMic 6239e8f4973df44bfa9843f8f559312a; */
+	/*EndOfDataMkr*/
+}

+ 15 - 0
tests/TLV_36_SubscriberManagementCPEIPTable.txt

@@ -0,0 +1,15 @@
+Main 
+{
+NetworkAccess 1;
+UsServiceFlow
+{
+UsServiceFlowRef 1;
+QosParamSetType 7;
+}
+DsServiceFlow
+{
+DsServiceFlowRef 2;
+QosParamSetType 7;
+}
+SubscriberManagementCPEIPTable 10.11.0.1,1.2.3.5,1.5.4.6,1.1.1.1;
+}

二進制
tests/TLV_67_SubscriberManagementCPEIPv6Table.cm


+ 18 - 0
tests/TLV_67_SubscriberManagementCPEIPv6Table.conf

@@ -0,0 +1,18 @@
+Main 
+{
+	NetworkAccess 1;
+	UsServiceFlow
+	{
+		UsServiceFlowRef 1;
+		QosParamSetType 7;
+	}
+	DsServiceFlow
+	{
+		DsServiceFlowRef 2;
+		QosParamSetType 7;
+	}
+	SubscriberManagementCPEIPv6Table 1111::1:1,2222::2:2,3333::3:3,4444::4:4,5555::5:5;
+	/* CmMic 9126beb22d3700181b48a48c53ef62a7; */
+	/* CmtsMic 3db155a00eca5bae2ed4ae3c83fe7460; */
+	/*EndOfDataMkr*/
+}

+ 15 - 0
tests/TLV_67_SubscriberManagementCPEIPv6Table.txt

@@ -0,0 +1,15 @@
+Main 
+{
+NetworkAccess 1;
+UsServiceFlow
+{
+UsServiceFlowRef 1;
+QosParamSetType 7;
+}
+DsServiceFlow
+{
+DsServiceFlowRef 2;
+QosParamSetType 7;
+}
+SubscriberManagementCPEIPv6Table 1111::1:1,2222::2:2,3333::3:3,4444::4:4,5555::5:5;
+}