소스 검색

Added decode_ip_ip6 function needed to decode TLV 64..1 and 64.2

AdrianSimionov 10 년 전
부모
커밋
335a6b6bd7
3개의 변경된 파일20개의 추가작업 그리고 4개의 파일을 삭제
  1. 15 0
      src/docsis_decode.c
  2. 1 0
      src/docsis_decode.h
  3. 4 4
      src/docsis_symtable.h

+ 15 - 0
src/docsis_decode.c

@@ -109,6 +109,21 @@ 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_ip_ip6 (unsigned char *tlvbuf, symbol_type *sym, size_t length )
+{
+  static char ip6_addr[INET6_ADDRSTRLEN];
+  char ipstr[INET6_ADDRSTRLEN];
+  static struct in_addr ip_addr;
+  if (length == 4 ) {
+    memcpy (&ip_addr, tlvbuf, 4);
+    printf("%s %s;\n", sym->sym_ident, inet_ntoa(ip_addr) );
+  }
+  if (length == 16 ) {
+      memcpy (&ip6_addr, tlvbuf, INET6_ADDRSTRLEN);
+      printf("%s %s;\n", sym->sym_ident, inet_ntop(AF_INET6,ip6_addr,ipstr,sizeof ipstr) );
+  }
+}
+
 void decode_ip_ip6_port (unsigned char *tlvbuf, symbol_type *sym, size_t length )
 {
   static char ip6_addr[INET6_ADDRSTRLEN];

+ 1 - 0
src/docsis_decode.h

@@ -34,6 +34,7 @@ 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_ip6 (unsigned char *tlvbuf, symbol_type *sym, size_t length );
+void decode_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 );
 void decode_ether (unsigned char *tlvbuf, symbol_type *sym, size_t length );
 void decode_dual_qtag (unsigned char *tlvbuf, symbol_type *sym, size_t length );

+ 4 - 4
src/docsis_symtable.h

@@ -419,10 +419,10 @@ symbol_type symtable[NUM_IDENTIFIERS] =  {
 /*{ 156, "SnmpMibObject",                    64, 0,    (encode_nothing),     (decode_snmp_object),    1,        2048       },*/
 
 { 341,    "CMTSStaticMulticastSessionEncodings",  64,  0,      (encode_nothing),        (decode_aggregate),      0,           0             }, /* TLV 64 MULPIv3.0-I24 Annex C.1.1.27 */
-/* TODO For TLV 64.1 and 64.2 encoding and decoding as IPv4 is a temporary solution, another encoder/decoder needs to be created to support both IPv4 and IPv6 */
-{ 342,    "CMTSStaticMulticastSessionGroup",   1,      341,    (encode_ip),             (decode_ip),             0,           0             }, /* TLV 64 MULPIv3.0-I24 Annex C.1.1.27.1 */
-{ 343,    "CMTSStaticMulticastSessionSource",  2,      341,    (encode_ip),             (decode_ip),             0,           0             }, /* TLV 64 MULPIv3.0-I24 Annex C.1.1.27.2 */
-{ 344,    "CMTSStaticMulticastSessionCMIM",    3,      341,    (encode_hexstr),         (decode_hexstr),         0,           0             }, /* TLV 64 MULPIv3.0-I24 Annex C.1.1.27.3 */
+/* TODO For TLV 64.1 and 64.2 encoding as IPv4 is a temporary solution, another encoder needs to be created to support both IPv4 and IPv6 */
+{ 342,    "CMTSStaticMulticastSessionGroup",   1,      341,    (encode_ip),             (decode_ip_ip6),         0,           0             }, /* TLV 64.1 MULPIv3.0-I24 Annex C.1.1.27.1 */
+{ 343,    "CMTSStaticMulticastSessionSource",  2,      341,    (encode_ip),             (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 */
 
 /* eRouter TLVs */
 { 175,    "eRouter",                           202,    0,      (encode_nothing),        (decode_aggregate),      0,           0             }, /* TLV 202 eRouter-I12 */