diff --git a/TODO b/TODO index fa97bac..fd87a76 100644 --- a/TODO +++ b/TODO @@ -2,3 +2,4 @@ * Have one more look at IPv6 extension headers * Add support for type-1, type-2 routing headers * Add support for short form of IPv6 prefix in RA prefix option + * MAC validation is yet to be added diff --git a/conf b/conf index 680ac15..682355a 100644 --- a/conf +++ b/conf @@ -20,35 +20,12 @@ IPV6_DST_ADDR=E23::9AD IPV6_EXT_HDRS=0 ICMP6 -ICMP6_TYPE=134 +ICMP6_TYPE=128 ICMP6_CODE=0 ICMP6_CHECKSUM=-1 -NDISC_RA -NDISC_RA_CUR_HOP_LIMIT=124 -NDISC_RA_M_FLAG=1 -NDISC_RA_O_FLAG=1 -NDISC_RA_ROUTER_LIFETIME=1223 -NDISC_RA_REACHABLE_TIME=2342 -NDISC_RA_RETRANS_TIMER=45543 -NDISC_RA_OPTION_NUM=3 - -NDISC_RA_OPTION=NDISC_RA_PREFIX_INFO -NDISC_RA_OP_TYPE=3 -NDISC_RA_OP_LEN=4 -NDISC_RA_PREFIX_LEN=64 -NDISC_RA_L_FLAG=1 -NDISC_RA_A_FLAG=0 -NDISC_RA_PREFIX_VALID_LIFETIME=12345 -NDISC_RA_PREFIX_PREFERRED_LIFETIME=54321 -NDISC_RA_PREFIX=2001:23 - -NDISC_RA_OPTION=NDISC_RA_SRC_LINK_ADDR -NDISC_RA_OP_TYPE=1 -NDISC_RA_OP_LEN=1 -NDISC_RA_OP_SRC_LINK_ADDR=00:01:02:03:04:05 - -NDISC_RA_OPTION=NDISC_RA_MTU -NDISC_RA_OP_TYPE=5 -NDISC_RA_OP_LEN=1 -NDISC_RA_MTU=245 +ECHO6 +ECHO6_IDENTIFIER=1234 +ECHO6_SEQ=3 +#ECHO6_DATA=NO_DATA +ECHO6_DATA=0xff00ff diff --git a/conf.help b/conf.help index 2b17bcc..ce0b9ad 100644 --- a/conf.help +++ b/conf.help @@ -1,3 +1,8 @@ + This is help file for the pgen configuration file. It gives a minimal +information about all possible options. pgen expects the user to give options +in the same order that appears in a packet. Also some sample conf files have +been given in sample_confs directory. + ***** Common ***** 1. BUFF_SIZE Size of the packet buffer. Any decimal number in the range of an 32-bit @@ -283,6 +288,7 @@ are, Type of RA option. pgen supports following types, NDISC_RA_PREFIX_INFO 3 NDISC_RA_SRC_LINK_ADDR 1 + NDISC_RA_TAR_LINK_ADDR 1 NDISC_RA_MTU 5 11. NDISC_RA_OP_LEN @@ -311,9 +317,96 @@ user has to give full prefix value. --- For Source Link Layer Address option --- 18. NDISC_RA_OP_SRC_LINK_ADDR The Source Link Layer Address. As of now the MAC address of the underlying -hardware. +hardware. For Target Link Layer Address option, use NDISC_RA_TYPE value 2. --- For MTU option --- 19. NDISC_RA_MTU The MTU value. ------------------------------------------------------------------------------- + +Router Solicitation------------------------------------------------------------ +1. NDISC_RS + Starting of Router Solicitation message + +2. NDISC_RS_OPTION + The Router Solicitaion option. pgen supports followint RS options + NDISC_RS_SRC_LINK_ADDR + +3. NDISC_RS_OP_TYPE + Option type for the RS option. For Target Source Link Layer address option +use NDISC_RS_OP_TYPE as 2 + +4. NDISC_RS_OP_LEN + Option length in 8-bit octet unit. + +5. NDISC_RS_SRC_LINK_ADDR + The Link Layer Address. As of now the Hardware mac address Source/Target +------------------------------------------------------------------------------- + +Neighbor Advertisement--------------------------------------------------------- +1. NDISC_NA + NA data starts here + +2. NDISC_NA_R + NA R flag. 1 for set and 0 for reset + +3. NDISC_NA_S + NA S flag. 1 for set and 0 for reset + +4. NDISC_NA_O + NA O flag. 1 for set and 0 for reset + +5. NDISC_NA_TARGET_ADDR + The target address from which this advertisement is being sent + +6. NDISC_NA_OPTION + The NA option. pgen supports + NDISC_NA_SRC_LINK_ADDR + +7. NDISC_NA_OP_TYPE + Type of NA option. For Target Link Layer Address, type will be 2 + +8. NDISC_NA_OP_LEN + Length of NA option in 8-octets unit + +9. NDISC_NA_OP_TAR_LINK_ADDR + The Target Link Layer Address. The Hardware MAC address. +------------------------------------------------------------------------------- + +Neighbor Solicitation---------------------------------------------------------- +1. NDISC_NS + Neighbor Solicitaion starts here + +2. NDISC_NS_TARGET_ADDR + Target Address of NS + +3. NDISC_NS_OPTION + Neighbor Soliciation option. The only supported option is + NDISC_NS_SRC_LINK_ADDR + +3. NDISC_NS_OP_TYPE + Type of NS option. 1 for Source Link Layer Address option and 2 for Target +Link Layer Address option. + +4. NDISC_NS_OP_LEN + Length of NS option in 8-octets unit + +5. NDISC_NS_OP_SRC_LINK_ADDR + Source Link Layer Address. The hardware MAC address of the sender. +------------------------------------------------------------------------------- + +ICMPv6 Echo-------------------------------------------------------------------- +1. ECHO6 + The ICMPv6 Echo packet starts here + +2. ECHO6_IDENTIFIER + Identifier of the Echo6 packet + +3. ECHO6_SEQ + Sequence of Echo6 packet + +4. ECHO6_DATA + Data for Echo6 packet. + NO_DATA For no data + Or the user has to give the data he wants in hex. +------------------------------------------------------------------------------- diff --git a/icmp6.c b/icmp6.c index 5b1baf4..b187834 100644 --- a/icmp6.c +++ b/icmp6.c @@ -562,6 +562,7 @@ char* pgen_ndisc_rs_writer(FILE *fp, char *cp_cur) { /* Source Link Layer address and the only known option */ else if (!strcmp(value, "NDISC_RS_SRC_LINK_ADDR")) { + op = (char *)&(pkt->option); if (pgen_parse_option(fp, option, value)) goto err; if (!strcmp(option, "NDISC_RS_OP_TYPE")) { @@ -757,6 +758,7 @@ char* pgen_ndisc_na_writer(FILE *fp, char *cp_cur) { /* This is only known option as of now. [RFC-4861] */ else if (!strcmp(value, "NDISC_NA_SRC_LINK_ADDR")) { + op_ptr = (char *)&(pkt->option); if (pgen_parse_option(fp, option, value)) goto err; @@ -866,9 +868,7 @@ char* pgen_icmp6_writer(FILE *fp, char *cp_cur) { if (!strcmp(option, "NO_ICMP6_BODY")); /* we are fine here. Do nothing */ - else if (!strcmp(option, "ECHO_REQ")) - cp_cur = pgen_echo6_writer(fp, cp_cur); - else if (!strcmp(option, "ECHO_REP")) + else if (!strcmp(option, "ECHO6")) cp_cur = pgen_echo6_writer(fp, cp_cur); else if (!strcmp(option, "NDISC_NS")) cp_cur = pgen_ndisc_ns_writer(fp, cp_cur); diff --git a/sample_confs/conf_icmp6_NA.txt b/sample_confs/conf_icmp6_NA.txt new file mode 100644 index 0000000..9c629d7 --- /dev/null +++ b/sample_confs/conf_icmp6_NA.txt @@ -0,0 +1,35 @@ +BUFF_SIZE=1024 + +IF_NAME=lo +PK_DST_MAC=00:01:9B:04:03:3C + +ETHER_HEADER +DST_MAC=ff:ff:ff:ff:ff:ff +SRC_MAC=5C:D9:98:C1:8E:FE +ETHR_TYPE=34525 + +IPV6 +IPV6_VERSION=6 +IPV6_TRAFFIC_CLASS=255 +IPV6_FLOW_LABEL=1234 +IPV6_PAYLOAD_LENGTH=64 +IPV6_NEXT_HEADER=58 +IPV6_HOP_LIMIT=128 +IPV6_SRC_ADDR=fe80::213 +IPV6_DST_ADDR=E23::9AD +IPV6_EXT_HDRS=0 + +ICMP6 +ICMP6_TYPE=136 +ICMP6_CODE=0 +ICMP6_CHECKSUM=-1 + +NDISC_NA +NDISC_NA_R=1 +NDISC_NA_S=0 +NDISC_NA_O=1 +NDISC_NA_TARGET_ADDR=fe89::34 +NDISC_NA_OPTION=NDISC_NA_SRC_LINK_ADDR +NDISC_NA_OP_TYPE=2 +NDISC_NA_OP_LEN=1 +NDISC_NA_OP_TAR_LINK_ADDR=12:AB:34:CD:56:EF diff --git a/sample_confs/conf_icmp6_NS.txt b/sample_confs/conf_icmp6_NS.txt new file mode 100644 index 0000000..b77e41a --- /dev/null +++ b/sample_confs/conf_icmp6_NS.txt @@ -0,0 +1,32 @@ +BUFF_SIZE=1024 + +IF_NAME=lo +PK_DST_MAC=00:01:9B:04:03:3C + +ETHER_HEADER +DST_MAC=ff:ff:ff:ff:ff:ff +SRC_MAC=5C:D9:98:C1:8E:FE +ETHR_TYPE=34525 + +IPV6 +IPV6_VERSION=6 +IPV6_TRAFFIC_CLASS=255 +IPV6_FLOW_LABEL=1234 +IPV6_PAYLOAD_LENGTH=64 +IPV6_NEXT_HEADER=58 +IPV6_HOP_LIMIT=128 +IPV6_SRC_ADDR=fe80::213 +IPV6_DST_ADDR=E23::9AD +IPV6_EXT_HDRS=0 + +ICMP6 +ICMP6_TYPE=135 +ICMP6_CODE=0 +ICMP6_CHECKSUM=-1 + +NDISC_NS +NDISC_NS_TARGET_ADDR=2001::24 +NDISC_NS_OPTION=NDISC_NS_SRC_LINK_ADDR +NDISC_NS_OP_TYPE=2 +NDISC_NS_OP_LEN=1 +NDISC_NS_OP_SRC_LINK_ADDR=90:87:87:12:34:44 diff --git a/sample_confs/conf_icmp6_RS.txt b/sample_confs/conf_icmp6_RS.txt new file mode 100644 index 0000000..7198b00 --- /dev/null +++ b/sample_confs/conf_icmp6_RS.txt @@ -0,0 +1,31 @@ +BUFF_SIZE=1024 + +IF_NAME=lo +PK_DST_MAC=00:01:9B:04:03:3C + +ETHER_HEADER +DST_MAC=ff:ff:ff:ff:ff:ff +SRC_MAC=5C:D9:98:C1:8E:FE +ETHR_TYPE=34525 + +IPV6 +IPV6_VERSION=6 +IPV6_TRAFFIC_CLASS=255 +IPV6_FLOW_LABEL=1234 +IPV6_PAYLOAD_LENGTH=64 +IPV6_NEXT_HEADER=58 +IPV6_HOP_LIMIT=128 +IPV6_SRC_ADDR=fe80::213 +IPV6_DST_ADDR=E23::9AD +IPV6_EXT_HDRS=0 + +ICMP6 +ICMP6_TYPE=133 +ICMP6_CODE=0 +ICMP6_CHECKSUM=-1 + +NDISC_RS +NDISC_RS_OPTION=NDISC_RS_SRC_LINK_ADDR +NDISC_RS_OP_TYPE=2 +NDISC_RS_OP_LEN=1 +NDISC_RS_OP_SRC_LINK_ADDR=12:23:34:45:56:ab diff --git a/sample_confs/conf_icmp6_echo6.txt b/sample_confs/conf_icmp6_echo6.txt new file mode 100644 index 0000000..682355a --- /dev/null +++ b/sample_confs/conf_icmp6_echo6.txt @@ -0,0 +1,31 @@ +BUFF_SIZE=1024 + +IF_NAME=lo +PK_DST_MAC=00:01:9B:04:03:3C + +ETHER_HEADER +DST_MAC=ff:ff:ff:ff:ff:ff +SRC_MAC=5C:D9:98:C1:8E:FE +ETHR_TYPE=34525 + +IPV6 +IPV6_VERSION=6 +IPV6_TRAFFIC_CLASS=255 +IPV6_FLOW_LABEL=1234 +IPV6_PAYLOAD_LENGTH=64 +IPV6_NEXT_HEADER=58 +IPV6_HOP_LIMIT=128 +IPV6_SRC_ADDR=fe80::213 +IPV6_DST_ADDR=E23::9AD +IPV6_EXT_HDRS=0 + +ICMP6 +ICMP6_TYPE=128 +ICMP6_CODE=0 +ICMP6_CHECKSUM=-1 + +ECHO6 +ECHO6_IDENTIFIER=1234 +ECHO6_SEQ=3 +#ECHO6_DATA=NO_DATA +ECHO6_DATA=0xff00ff