Extended nonce payload for IKEv1 support
[strongswan.git] / src / libcharon / encoding / payloads / payload.c
index d1e677d..56563ac 100644 (file)
 
 ENUM_BEGIN(payload_type_names, NO_PAYLOAD, NO_PAYLOAD,
        "NO_PAYLOAD");
-ENUM_NEXT(payload_type_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICATION, NO_PAYLOAD,
+ENUM_NEXT(payload_type_names, SECURITY_ASSOCIATION_V1, VENDOR_ID_V1, NO_PAYLOAD,
+       "SECURITY_ASSOCIATION_V1",
+       "PROPOSAL_V1",
+       "TRANSFORM_V1",
+       "KEY_EXCHANGE_V1",
+       "ID_V1",
+       "CERTIFICATE_V1",
+       "CERTIFICATE_REQUEST_V1",
+       "HASH_V1",
+       "SIGNATURE_V1",
+       "NONCE_V1",
+       "NOTIFICATION_V1",
+       "DELETE_V1",
+       "VENDOR_ID_V1");
+ENUM_NEXT(payload_type_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICATION, VENDOR_ID_V1,
        "SECURITY_ASSOCIATION",
        "KEY_EXCHANGE",
        "ID_INITIATOR",
@@ -62,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 */
@@ -80,7 +100,21 @@ ENUM_END(payload_type_names, CONFIGURATION_ATTRIBUTE);
 /* short forms of payload names */
 ENUM_BEGIN(payload_type_short_names, NO_PAYLOAD, NO_PAYLOAD,
        "--");
-ENUM_NEXT(payload_type_short_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICATION, NO_PAYLOAD,
+ENUM_NEXT(payload_type_short_names, SECURITY_ASSOCIATION_V1, VENDOR_ID_V1, NO_PAYLOAD,
+       "SA",
+       "PROP",
+       "TRANS",
+       "KE",
+       "ID",
+       "CERT",
+       "CERTREQ",
+       "HASH",
+       "SIG",
+       "No",
+       "NO",
+       "D",
+       "V");
+ENUM_NEXT(payload_type_short_names, SECURITY_ASSOCIATION, EXTENSIBLE_AUTHENTICATION, VENDOR_ID_V1,
        "SA",
        "KE",
        "IDi",
@@ -103,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);
 
@@ -128,23 +168,26 @@ payload_t *payload_create(payload_type_t type)
                case HEADER:
                        return (payload_t*)ike_header_create();
                case SECURITY_ASSOCIATION:
-                       return (payload_t*)sa_payload_create();
+               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 NONCE_V1:
+                       return (payload_t*)nonce_payload_create(type);
                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:
@@ -164,7 +207,8 @@ payload_t *payload_create(payload_type_t type)
                case DELETE:
                        return (payload_t*)delete_payload_create(0);
                case VENDOR_ID:
-                       return (payload_t*)vendor_id_payload_create();
+               case VENDOR_ID_V1:
+                       return (payload_t*)vendor_id_payload_create(type);
                case CONFIGURATION:
                        return (payload_t*)cp_payload_create();
                case CONFIGURATION_ATTRIBUTE:
@@ -183,8 +227,15 @@ payload_t *payload_create(payload_type_t type)
  */
 bool payload_is_known(payload_type_t type)
 {
-       if (type == HEADER ||
-               (type >= SECURITY_ASSOCIATION && type <= EXTENSIBLE_AUTHENTICATION))
+       if (type == HEADER)
+       {
+               return TRUE;
+       }
+       if (type >= SECURITY_ASSOCIATION && type <= EXTENSIBLE_AUTHENTICATION)
+       {
+               return TRUE;
+       }
+       if (type >= SECURITY_ASSOCIATION_V1 && type <= VENDOR_ID_V1)
        {
                return TRUE;
        }