소스 검색

Added support for TLV 61 SubMgmtCPEIPv6PrefixList

AdrianSimionov 10 년 전
부모
커밋
df13004aaa

+ 1 - 1
src/docsis_common.h

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

+ 15 - 0
src/docsis_decode.c

@@ -145,6 +145,21 @@ void decode_ip6_list (unsigned char *tlvbuf, symbol_type *sym, size_t length )
   printf(";\n");  
 }
 
+void decode_ip6_prefix_list (unsigned char *tlvbuf, symbol_type *sym, size_t length )
+{
+  char ipstr[INET6_ADDRSTRLEN];
+  unsigned int i;
+  printf("%s ", sym->sym_ident);
+  for ( i=0; i < length / 17; i++) {
+    printf( "%s", inet_ntop(AF_INET6, tlvbuf + i * 17, ipstr, sizeof ipstr) );
+    printf( "/%d", tlvbuf[i * 17 + 16] );
+    if (i < (length/17) - 1 ) {
+      printf(",");
+    }
+  }
+  printf(";\n");  
+}
+
 void decode_ip_ip6 (unsigned char *tlvbuf, symbol_type *sym, size_t length )
 {
   static char ip6_addr[INET6_ADDRSTRLEN];

+ 1 - 0
src/docsis_decode.h

@@ -37,6 +37,7 @@ 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_ip6_prefix_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 );

+ 34 - 0
src/docsis_encode.c

@@ -263,6 +263,40 @@ int encode_ip6_list( unsigned char *buf, void *tval, struct symbol_entry *sym_pt
   return ( i * sizeof(struct in6_addr));
 }
 
+int encode_ip6_prefix_list( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
+{
+  int j, i;
+  char *token, final;
+  char *array[15];
+  const char s[2] = ",";
+  const char t[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);
+    i++;
+  }
+  for (j = 0; j <= i; j++) {
+    token = strtok(array[j], t);
+    while (token != NULL) {
+      if ( inet_pton ( AF_INET6, token, &in6) ) {
+        memcpy ( buf + 17 * j, &in6, sizeof(struct in6_addr));
+      } else {
+        final = (char)atoi(token);
+        memcpy ( buf + 17 * j + sizeof(struct in6_addr),&final,sizeof(unsigned char));
+      }
+      token = strtok (NULL, t);
+    }
+  }
+  free(helper->strval);
+  return ( i * ( sizeof(struct in6_addr) + sizeof(unsigned char) ) );
+}
+
 int encode_ip_ip6( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
 {
   struct in6_addr in6;

+ 1 - 0
src/docsis_encode.h

@@ -33,6 +33,7 @@ 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_ip6_prefix_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 );

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 0
src/docsis_lex.l


+ 1 - 0
src/docsis_symtable.h

@@ -544,6 +544,7 @@ symbol_type symtable[NUM_IDENTIFIERS] =  {
 /* IPv6 */
 { 173,    "SwUpgradeServer6",                  58,     0,      (encode_ip6),            (decode_ip6),            0,           0             }, /* TLV 58 MULPIv3.0-I24 Annex C.1.2.8 */
 
+{ 174,    "SubMgmtCPEIPv6PrefixList",          61,     0,      (encode_ip6_prefix_list), (decode_ip6_prefix_list), 0,         0             }, /* TLV 61 MULPIv3.0-I24 Annex C.1.1.19.3 */
 { 174,    "SubMgmtControl6",                   63,     0,      (encode_ushort),         (decode_ushort),         0,           0             }, /* TLV 63 MULPIv3.0-I24 Annex C.1.1.19.5 */
 { 341,    "CMTSStaticMulticastSessionEncodings",  64,  0,      (encode_nothing),        (decode_aggregate),      0,           0             }, /* TLV 64 MULPIv3.0-I24 Annex C.1.1.27 */
 { 342,    "CMTSStaticMulticastSessionGroup",   1,      341,    (encode_ip_ip6),         (decode_ip_ip6),         0,           0             }, /* TLV 64.1 MULPIv3.0-I24 Annex C.1.1.27.1 */

+ 6 - 3
src/docsis_yy.y

@@ -73,6 +73,7 @@ struct tlv *_my_tlvtree_head;
 %token <strval>  T_TIMETICKS
 %token <strval>  T_IP_LIST
 %token <strval>  T_IP6_LIST
+%token <strval>  T_IP6_PREFIX_LIST
 
 %token <uintval>  T_ASNTYPE_INT
 %token <uintval>  T_ASNTYPE_UINT
@@ -173,15 +174,17 @@ assignment_stmt:  T_IDENTIFIER T_INTEGER ';' {
 		| T_IDENTIFIER T_IP ';' {
 			$$ = create_tlv ($1, (union t_val *)&$2);}
 		| T_IDENTIFIER T_IP_LIST ';' {
-			$$ = create_tlv ($1, (union t_val *)&$2);}			
+			$$ = 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);}			
+			$$ = create_tlv ($1, (union t_val *)&$2);}
+		| T_IDENTIFIER T_IP6_PREFIX_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 ';' {
-			$$ = create_tlv ($1, (union t_val *)&$2);}			
+			$$ = create_tlv ($1, (union t_val *)&$2);}
 		| T_IDENTIFIER T_MAC ';' {
 			$$ = create_tlv ($1, (union t_val *)&$2);}
 		| T_IDENTIFIER T_ETHERMASK ';' {

BIN
tests/TLV_61_SubMgmtCPEIPv6PrefixList.cm


+ 18 - 0
tests/TLV_61_SubMgmtCPEIPv6PrefixList.conf

@@ -0,0 +1,18 @@
+Main 
+{
+	NetworkAccess 1;
+	UsServiceFlow
+	{
+		UsServiceFlowRef 1;
+		QosParamSetType 7;
+	}
+	DsServiceFlow
+	{
+		DsServiceFlowRef 2;
+		QosParamSetType 7;
+	}
+	SubMgmtCPEIPv6PrefixList 5005::5:5/16,2033:2:2:33::3/32,2002::2:2/127;
+	/* CmMic bddb849d542b36b15fef18b86d2d716c; */
+	/* CmtsMic 2c5535196e51c0b2fbe6d81319bd5801; */
+	/*EndOfDataMkr*/
+}

+ 15 - 0
tests/TLV_61_SubMgmtCPEIPv6PrefixList.txt

@@ -0,0 +1,15 @@
+Main 
+{
+NetworkAccess 1;
+UsServiceFlow
+{
+UsServiceFlowRef 1;
+QosParamSetType 7;
+}
+DsServiceFlow
+{
+DsServiceFlowRef 2;
+QosParamSetType 7;
+}
+SubMgmtCPEIPv6PrefixList 5005::5:5/16,2033:2:2:33::3/32,2002::2:2/127;
+}