Added additional IKEv1 payload and encoding identifiers
authorMartin Willi <martin@revosec.ch>
Wed, 16 Nov 2011 12:40:09 +0000 (12:40 +0000)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:30:40 +0000 (17:30 +0100)
src/libcharon/encoding/parser.c
src/libcharon/encoding/payloads/encodings.c
src/libcharon/encoding/payloads/encodings.h
src/libcharon/encoding/payloads/payload.c
src/libcharon/encoding/payloads/payload.h

index 09b5216..c2c60f0 100644 (file)
@@ -521,6 +521,19 @@ METHOD(parser_t, parse_payload, status_t,
                                }
                                break;
                        }
+                       case TRANSFORMS_V1:
+                       {
+                               if (payload_length <
+                                                       spi_size + PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH ||
+                                       !parse_list(this, rule_number, output + rule->offset,
+                                                       TRANSFORM_SUBSTRUCTURE_V1, payload_length - spi_size -
+                                                                               PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH))
+                               {
+                                       pld->destroy(pld);
+                                       return PARSE_ERROR;
+                               }
+                               break;
+                       }
                        case TRANSFORM_ATTRIBUTES:
                        {
                                if (payload_length < TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH ||
@@ -533,6 +546,18 @@ METHOD(parser_t, parse_payload, status_t,
                                }
                                break;
                        }
+                       case TRANSFORM_ATTRIBUTES_V1:
+                       {
+                               if (payload_length < TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH ||
+                                       !parse_list(this, rule_number, output + rule->offset,
+                                               TRANSFORM_ATTRIBUTE_V1,
+                                               payload_length - TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH))
+                               {
+                                       pld->destroy(pld);
+                                       return PARSE_ERROR;
+                               }
+                               break;
+                       }
                        case CONFIGURATION_ATTRIBUTES:
                        {
                                if (payload_length < CP_PAYLOAD_HEADER_LENGTH ||
index 85caeda..d181d93 100644 (file)
@@ -32,8 +32,11 @@ ENUM(encoding_type_names, U_INT_4, ENCRYPTED_DATA,
        "KEY_EXCHANGE_DATA",
        "NOTIFICATION_DATA",
        "PROPOSALS",
+       "PROPOSALS_V1",
        "TRANSFORMS",
+       "TRANSFORMS_V1",
        "TRANSFORM_ATTRIBUTES",
+       "TRANSFORM_ATTRIBUTES_V1",
        "CONFIGURATION_ATTRIBUTES",
        "CONFIGURATION_ATTRIBUTE_VALUE",
        "ATTRIBUTE_FORMAT",
index 80df979..8c9fb86 100644 (file)
@@ -238,6 +238,11 @@ enum encoding_type_t {
        TRANSFORMS,
 
        /**
+        * Same as TRANSFORMS, but for IKEv1 in a PROPOSAL_SUBSTRUCTURE_V1.
+        */
+       TRANSFORMS_V1,
+
+       /**
         * Representating one or more Attributes of a transform substructure.
         *
         * The offset points to a linked_list_t pointer.
@@ -251,6 +256,11 @@ enum encoding_type_t {
        TRANSFORM_ATTRIBUTES,
 
        /**
+        * Same as TRANSFORM_ATTRIBUTES, but for IKEv1 in TRANSFORMS_V1.
+        */
+       TRANSFORM_ATTRIBUTES_V1,
+
+       /**
         * Representating one or more Attributes of a configuration payload.
         *
         * The offset points to a linked_list_t pointer.
index 14617b4..2021e84 100644 (file)
@@ -76,16 +76,22 @@ ENUM_NEXT(payload_type_names, ID_PEER, ID_PEER, EXTENSIBLE_AUTHENTICATION,
 ENUM_NEXT(payload_type_names, HEADER, CONFIGURATION_ATTRIBUTE, ID_PEER,
        "HEADER",
        "PROPOSAL_SUBSTRUCTURE",
+       "PROPOSAL_SUBSTRUCTURE_V1",
        "TRANSFORM_SUBSTRUCTURE",
+       "TRANSFORM_SUBSTRUCTURE_V1",
        "TRANSFORM_ATTRIBUTE",
+       "TRANSFORM_ATTRIBUTE_V1",
        "TRAFFIC_SELECTOR_SUBSTRUCTURE",
        "CONFIGURATION_ATTRIBUTE");
 #else
 ENUM_NEXT(payload_type_names, HEADER, CONFIGURATION_ATTRIBUTE, EXTENSIBLE_AUTHENTICATION,
        "HEADER",
        "PROPOSAL_SUBSTRUCTURE",
+       "PROPOSAL_SUBSTRUCTURE_V1",
        "TRANSFORM_SUBSTRUCTURE",
+       "TRANSFORM_SUBSTRUCTURE_V1",
        "TRANSFORM_ATTRIBUTE",
+       "TRANSFORM_ATTRIBUTE_V1",
        "TRAFFIC_SELECTOR_SUBSTRUCTURE",
        "CONFIGURATION_ATTRIBUTE");
 #endif /* ME */
@@ -131,18 +137,24 @@ ENUM_NEXT(payload_type_short_names, ID_PEER, ID_PEER, EXTENSIBLE_AUTHENTICATION,
 ENUM_NEXT(payload_type_short_names, HEADER, CONFIGURATION_ATTRIBUTE, ID_PEER,
        "HDR",
        "PROP",
+       "PROP",
+       "TRANS",
        "TRANS",
        "TRANSATTR",
+       "TRANSATTR",
        "TSSUB",
-       "CPATTR");
+       "CATTR");
 #else
 ENUM_NEXT(payload_type_short_names, HEADER, CONFIGURATION_ATTRIBUTE, EXTENSIBLE_AUTHENTICATION,
        "HDR",
        "PROP",
+       "PROP",
+       "TRANS",
        "TRANS",
        "TRANSATTR",
+       "TRANSATTR",
        "TSSUB",
-       "CPATTR");
+       "CATTR");
 #endif /* ME */
 ENUM_END(payload_type_short_names, CONFIGURATION_ATTRIBUTE);
 
@@ -159,21 +171,22 @@ payload_t *payload_create(payload_type_t type)
                case SECURITY_ASSOCIATION_V1:
                        return (payload_t*)sa_payload_create(type);
                case PROPOSAL_SUBSTRUCTURE:
-                       return (payload_t*)proposal_substructure_create();
+               case PROPOSAL_SUBSTRUCTURE_V1:
+                       return (payload_t*)proposal_substructure_create(type);
                case TRANSFORM_SUBSTRUCTURE:
-                       return (payload_t*)transform_substructure_create();
+               case TRANSFORM_SUBSTRUCTURE_V1:
+                       return (payload_t*)transform_substructure_create(type);
                case TRANSFORM_ATTRIBUTE:
-                       return (payload_t*)transform_attribute_create();
+               case TRANSFORM_ATTRIBUTE_V1:
+                       return (payload_t*)transform_attribute_create(type);
                case NONCE:
                        return (payload_t*)nonce_payload_create();
                case ID_INITIATOR:
-                       return (payload_t*)id_payload_create(ID_INITIATOR);
                case ID_RESPONDER:
-                       return (payload_t*)id_payload_create(ID_RESPONDER);
 #ifdef ME
                case ID_PEER:
-                       return (payload_t*)id_payload_create(ID_PEER);
 #endif /* ME */
+                       return (payload_t*)id_payload_create(type);
                case AUTHENTICATION:
                        return (payload_t*)auth_payload_create();
                case CERTIFICATE:
index ff1ae73..5e0b7dd 100644 (file)
@@ -203,58 +203,50 @@ enum payload_type_t {
        /**
         * Header has a value of PRIVATE USE space.
         *
-        * This payload type is not sent over wire and just
-        * used internally to handle IKEv2-Header like a payload.
+        * This type and all the following are never sent over wire and are
+        * used internally only.
         */
        HEADER = 256,
 
        /**
-        * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space.
-        *
-        * This payload type is not sent over wire and just
-        * used internally to handle a proposal substructure like a payload.
+        * PROPOSAL_SUBSTRUCTURE, IKEv2 proposals in a SA payload.
         */
-       PROPOSAL_SUBSTRUCTURE = 257,
+       PROPOSAL_SUBSTRUCTURE,
 
        /**
-        * TRANSFORM_SUBSTRUCTURE has a value of PRIVATE USE space.
-        *
-        * This payload type is not sent over wire and just
-        * used internally to handle a transform substructure like a payload.
+        * PROPOSAL_SUBSTRUCTURE_V1, IKEv1 proposals in a SA payload.
         */
-       TRANSFORM_SUBSTRUCTURE = 258,
+       PROPOSAL_SUBSTRUCTURE_V1,
 
        /**
-        * TRANSFORM_ATTRIBUTE has a value of PRIVATE USE space.
-        *
-        * This payload type is not sent over wire and just
-        * used internally to handle a transform attribute like a payload.
+        * TRANSFORM_SUBSTRUCTURE, IKEv2 transforms in a proposal substructure.
         */
-       TRANSFORM_ATTRIBUTE = 259,
+       TRANSFORM_SUBSTRUCTURE,
 
        /**
-        * TRAFFIC_SELECTOR_SUBSTRUCTURE has a value of PRIVATE USE space.
-        *
-        * This payload type is not sent over wire and just
-        * used internally to handle a transform selector like a payload.
+        * TRANSFORM_SUBSTRUCTURE_V1, IKEv1 transforms in a proposal substructure.
         */
-       TRAFFIC_SELECTOR_SUBSTRUCTURE = 260,
+       TRANSFORM_SUBSTRUCTURE_V1,
 
        /**
-        * CONFIGURATION_ATTRIBUTE has a value of PRIVATE USE space.
-        *
-        * This payload type is not sent over wire and just
-        * used internally to handle a transform attribute like a payload.
+        * TRANSFORM_ATTRIBUTE, IKEv2 attribute in a transform.
         */
-       CONFIGURATION_ATTRIBUTE = 261,
+       TRANSFORM_ATTRIBUTE,
 
        /**
-        * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space.
-        *
-        * This payload type is not sent over wire and just
-        * used internally to handle a proposal substructure like a payload.
+        * TRANSFORM_ATTRIBUTE_V1, IKEv1 attribute in a transform.
+        */
+       TRANSFORM_ATTRIBUTE_V1,
+
+       /**
+        * TRAFFIC_SELECTOR_SUBSTRUCTURE, traffic selector in a TS payload.
+        */
+       TRAFFIC_SELECTOR_SUBSTRUCTURE,
+
+       /**
+        * CONFIGURATION_ATTRIBUTE, attribute in a configuration payload.
         */
-       PROPOSAL_SUBSTRUCTURE_V1 = 262,
+       CONFIGURATION_ATTRIBUTE,
 };
 
 /**