Richard Laager пре 13 година
родитељ
комит
0ad5976ede
8 измењених фајлова са 85 додато и 16 уклоњено
  1. 1 0
      examples/Makefile.am
  2. 29 0
      examples/docsis_ipv6.cfg
  3. 33 0
      examples/docsis_ipv6.txt
  4. 0 4
      src/docsis_decode.c
  5. 0 2
      src/docsis_decode.h
  6. 3 7
      src/docsis_encode.c
  7. 17 1
      src/docsis_lex.l
  8. 2 2
      src/docsis_symtable.h

+ 1 - 0
examples/Makefile.am

@@ -21,6 +21,7 @@ CONFIGS_IN = \
 	docsis20.cfg \
 	docsis20.cfg \
 	docsis20_no_snmp.cfg \
 	docsis20_no_snmp.cfg \
 	docsis20_stresstest.cfg \
 	docsis20_stresstest.cfg \
+	docsis_ipv6.cfg \
 	packetcable_mta.cfg
 	packetcable_mta.cfg
 CONFIGS_TEXT   = $(CONFIGS_IN:.cfg=.txt)
 CONFIGS_TEXT   = $(CONFIGS_IN:.cfg=.txt)
 CONFIGS_BINARY = $(CONFIGS_IN:.cfg=.bin)
 CONFIGS_BINARY = $(CONFIGS_IN:.cfg=.bin)

+ 29 - 0
examples/docsis_ipv6.cfg

@@ -0,0 +1,29 @@
+Main { /* this is a comment */
+DownstreamFrequency 	130000000;
+UpstreamChannelId   	123;
+/* this is a comment */
+NetworkAccess		1;
+ClassOfService {
+	ClassID		5;
+	MaxRateDown	512000;
+	MaxRateUp	64000;
+	PriorityUp	3 ;
+	GuaranteedUp	32000;
+	MaxBurstUp	54314;
+	PrivacyEnable	1;
+}
+
+SwUpgradeFilename "filename1.bin";
+
+BaselinePrivacy	{
+	AuthTimeout		25;
+	ReAuthTimeout		15;
+	AuthGraceTime		120;
+	OperTimeout		9;
+	ReKeyTimeout		10;
+	TEKGraceTime		600;
+}
+MaxCPE	13;
+SwUpgradeServer	10.1.1.1;
+SwUpgradeServer6 2001:DB8::1;
+}

+ 33 - 0
examples/docsis_ipv6.txt

@@ -0,0 +1,33 @@
+Main 
+{
+	DownstreamFrequency 130000000;
+	UpstreamChannelId 123;
+	NetworkAccess 1;
+	ClassOfService
+	{
+		ClassID 5;
+		MaxRateDown 512000;
+		MaxRateUp 64000;
+		PriorityUp 3;
+		GuaranteedUp 32000;
+		MaxBurstUp 54314;
+		PrivacyEnable 1;
+	}
+	SwUpgradeFilename "filename1.bin";
+	BaselinePrivacy
+	{
+		AuthTimeout 25;
+		ReAuthTimeout 15;
+		AuthGraceTime 120;
+		OperTimeout 9;
+		ReKeyTimeout 10;
+		TEKGraceTime 600;
+	}
+	MaxCPE 13;
+	SwUpgradeServer 10.1.1.1;
+	SwUpgradeServer6 2001:db8::1;
+	/* CmMic 775d20a2183878cd8351c58087183561; */
+	/* CmtsMic 81c6aa8340dab8e0d508fecf9c766fc4; */
+	/*EndOfDataMkr*/
+	/* Pad */
+}

+ 0 - 4
src/docsis_decode.c

@@ -27,7 +27,6 @@
 #include <netinet/in.h>
 #include <netinet/in.h>
 #include <netdb.h>
 #include <netdb.h>
 
 
-
 #include <math.h>
 #include <math.h>
 #include <ctype.h>
 #include <ctype.h>
 
 
@@ -38,9 +37,6 @@
 #include "ethermac.h"
 #include "ethermac.h"
 
 
 
 
-#include <sys/types.h>
-#include <sys/socket.h>
-
 struct symbol_entry *
 struct symbol_entry *
 find_symbol_by_code_and_pid (unsigned char code, unsigned int pid)
 find_symbol_by_code_and_pid (unsigned char code, unsigned int pid)
 {
 {

+ 0 - 2
src/docsis_decode.h

@@ -20,8 +20,6 @@
  *  DOCSIS is a registered trademark of Cablelabs, http://www.cablelabs.com
  *  DOCSIS is a registered trademark of Cablelabs, http://www.cablelabs.com
  */
  */
 
 
-/*IPv6-Function inspired by http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html */ 
-
 #ifndef _DOCSIS_DECODE_H
 #ifndef _DOCSIS_DECODE_H
 #define _DOCSIS_DECODE_H
 #define _DOCSIS_DECODE_H
 
 

+ 3 - 7
src/docsis_encode.c

@@ -22,8 +22,6 @@
 
 
 #include <netdb.h>
 #include <netdb.h>
 
 
-
-
 #include <errno.h>
 #include <errno.h>
 #include <string.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdlib.h>
@@ -135,7 +133,6 @@ 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( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
 {
 {
   struct in_addr in;
   struct in_addr in;
@@ -167,9 +164,8 @@ int encode_ip( 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( unsigned char *buf, void *tval, struct symbol_entry *sym_ptr )
 {
 {
-struct in6_addr in;
-int retval; 	     /* return value of inet_aton */
-union t_val *helper; /* We only use this to cast the void* we receive to what we think it should be */
+  struct in6_addr in;
+  union t_val *helper; /* We only use this to cast the void* we receive to what we think it should be */
 
 
   if ( buf == NULL ) {
   if ( buf == NULL ) {
         printf ("encode_ip called w/NULL buffer!\n");
         printf ("encode_ip called w/NULL buffer!\n");
@@ -183,7 +179,7 @@ union t_val *helper; /* We only use this to cast the void* we receive to what we
 
 
   helper = (union t_val *) tval;
   helper = (union t_val *) tval;
 
 
-  if (!(retval = inet_pton(AF_INET6, helper->strval, &in)) ) {
+  if ( !inet_pton(AF_INET6, helper->strval, &in) ) {
 	printf ( "Invalid IP address %s at line %d", helper->strval, line );
 	printf ( "Invalid IP address %s at line %d", helper->strval, line );
 	exit (-1);
 	exit (-1);
   }
   }

+ 17 - 1
src/docsis_lex.l

@@ -20,7 +20,23 @@
  *  DOCSIS is a registered trademark of Cablelabs, http://www.cablelabs.com
  *  DOCSIS is a registered trademark of Cablelabs, http://www.cablelabs.com
  */
  */
 
 
-/* IPv6 RegEx lent from http://www.regexlib.com/REDetails.aspx?regexp_id=2919 Author: mij */
+/*
+ * The IPv6 regular expression below is from SSHGuard:
+ *
+ * Copyright (c) 2010 Mij <mij@sshguard.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
 
 
 %{
 %{
 #include "docsis.h"
 #include "docsis.h"

+ 2 - 2
src/docsis_symtable.h

@@ -259,8 +259,8 @@ symbol_type symtable[NUM_IDENTIFIERS] =  {
 { 171, "CoSignerCVCData",      		33,   0,  (encode_hexstr),    (decode_hexstr),      0,        255    },
 { 171, "CoSignerCVCData",      		33,   0,  (encode_hexstr),    (decode_hexstr),      0,        255    },
 { 172, "CoSignerCVC",      		33,   0,  (encode_nothing),    (decode_hexstr),      0,        255    },
 { 172, "CoSignerCVC",      		33,   0,  (encode_nothing),    (decode_hexstr),      0,        255    },
 
 
-/*IPv6-Tests ... */
-{ 173,  "SwUpgradeServer6",    	58,  0,   (encode_ip6),        (decode_ip6),          0,        0          },
+/* IPv6 */
+{ 173, "SwUpgradeServer6",    	58,  0,   (encode_ip6),        (decode_ip6),          0,        0          },
 { 174, "SubMgmtControl6", 		63,  0,	  (encode_hexstr),    (decode_hexstr), 		2,	2 	},
 { 174, "SubMgmtControl6", 		63,  0,	  (encode_hexstr),    (decode_hexstr), 		2,	2 	},
 
 
 /* Generic TLV ... we only use the limits, code and length don't matter ...*/
 /* Generic TLV ... we only use the limits, code and length don't matter ...*/