]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Use a generic encoding type for all variable length chunks
authorMartin Willi <martin@revosec.ch>
Thu, 17 Nov 2011 14:20:16 +0000 (14:20 +0000)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:30:42 +0000 (17:30 +0100)
18 files changed:
src/libcharon/encoding/generator.c
src/libcharon/encoding/parser.c
src/libcharon/encoding/payloads/auth_payload.c
src/libcharon/encoding/payloads/cert_payload.c
src/libcharon/encoding/payloads/certreq_payload.c
src/libcharon/encoding/payloads/configuration_attribute.c
src/libcharon/encoding/payloads/delete_payload.c
src/libcharon/encoding/payloads/eap_payload.c
src/libcharon/encoding/payloads/encodings.c
src/libcharon/encoding/payloads/encodings.h
src/libcharon/encoding/payloads/encryption_payload.c
src/libcharon/encoding/payloads/hash_payload.c
src/libcharon/encoding/payloads/id_payload.c
src/libcharon/encoding/payloads/ke_payload.c
src/libcharon/encoding/payloads/nonce_payload.c
src/libcharon/encoding/payloads/notify_payload.c
src/libcharon/encoding/payloads/unknown_payload.c
src/libcharon/encoding/payloads/vendor_id_payload.c

index 9cb1cdc5b9721897844eac81ef7602558a4b731c..d6828e7f9d322b6e2820fb0d2e8b52ba19ab0fe0 100644 (file)
@@ -448,21 +448,7 @@ METHOD(generator_t, generate_payload, void,
                                break;
                        case ADDRESS:
                        case SPI:
-                       case KEY_EXCHANGE_DATA:
-                       case KEY_EXCHANGE_DATA_V1:
-                       case NOTIFICATION_DATA:
-                       case NONCE_DATA:
-                       case HASH_DATA:
-                       case ID_DATA:
-                       case AUTH_DATA:
-                       case CERT_DATA:
-                       case CERTREQ_DATA:
-                       case SPIS:
-                       case CONFIGURATION_ATTRIBUTE_VALUE:
-                       case VID_DATA:
-                       case EAP_DATA:
-                       case ENCRYPTED_DATA:
-                       case UNKNOWN_DATA:
+                       case CHUNK_DATA:
                                generate_from_chunk(this, rules[i].offset);
                                break;
                        case PROPOSALS:
index 77923e74bd1a271c56fb285c7787a2950350af85..1876212aadf5c087da5c69c49af37fc9ee598193 100644 (file)
@@ -532,22 +532,7 @@ METHOD(parser_t, parse_payload, status_t,
                                }
                                break;
                        }
-                       /* chunks */
-                       case NONCE_DATA:
-                       case HASH_DATA:
-                       case ID_DATA:
-                       case AUTH_DATA:
-                       case CERT_DATA:
-                       case CERTREQ_DATA:
-                       case EAP_DATA:
-                       case SPIS:
-                       case VID_DATA:
-                       case CONFIGURATION_ATTRIBUTE_VALUE:
-                       case KEY_EXCHANGE_DATA:
-                       case KEY_EXCHANGE_DATA_V1:
-                       case NOTIFICATION_DATA:
-                       case ENCRYPTED_DATA:
-                       case UNKNOWN_DATA:
+                       case CHUNK_DATA:
                        {
                                if (payload_length < header_length ||
                                        !parse_chunk(this, rule_number, output + rule->offset,
index 57dc58f2a02b2e4184f440595279ebb042cf10d3..2410a1aaac8d25834fd1f83bca23ac38dc2c1158 100644 (file)
@@ -96,7 +96,7 @@ static encoding_rule_t encodings[] = {
        { RESERVED_BYTE,        offsetof(private_auth_payload_t, reserved_byte[1])      },
        { RESERVED_BYTE,        offsetof(private_auth_payload_t, reserved_byte[2])      },
        /* some auth data bytes, length is defined in PAYLOAD_LENGTH */
-       { AUTH_DATA,            offsetof(private_auth_payload_t, auth_data)     }
+       { CHUNK_DATA,           offsetof(private_auth_payload_t, auth_data)     }
 };
 
 /*
index 565be7f34836124e9ce8da162ab9f8e952846289..1ef93b724ea91706b8a0ca1905cf823bd6be2467 100644 (file)
@@ -113,7 +113,7 @@ static encoding_rule_t encodings[] = {
        /* 1 Byte CERT type*/
        { U_INT_8,                      offsetof(private_cert_payload_t, encoding)              },
        /* some cert data bytes, length is defined in PAYLOAD_LENGTH */
-       { CERT_DATA,            offsetof(private_cert_payload_t, data)                  }
+       { CHUNK_DATA,           offsetof(private_cert_payload_t, data)                  }
 };
 
 /*
index dc685e651513c1fde093dccdb42da44ec6ca4f5a..69e80ad7e917b9e18f971ad711a2d284f151e6dd 100644 (file)
@@ -90,7 +90,7 @@ static encoding_rule_t encodings[] = {
        /* 1 Byte CERTREQ type*/
        { U_INT_8,                      offsetof(private_certreq_payload_t, encoding)           },
        /* some certreq data bytes, length is defined in PAYLOAD_LENGTH */
-       { CERTREQ_DATA,         offsetof(private_certreq_payload_t, data)                       }
+       { CHUNK_DATA,           offsetof(private_certreq_payload_t, data)                       }
 };
 
 /*
index 8746b9b9e929727791a50d4ebe20857d5b59e764..88e43fa3dc1772aa3e5a869b3591d9da037ebf6b 100644 (file)
@@ -70,7 +70,7 @@ static encoding_rule_t encodings[] = {
        /* Length of attribute value */
        { CONFIGURATION_ATTRIBUTE_LENGTH,       offsetof(private_configuration_attribute_t, length)     },
        /* Value of attribute if attribute format flag is zero */
-       { CONFIGURATION_ATTRIBUTE_VALUE,        offsetof(private_configuration_attribute_t, value)      }
+       { CHUNK_DATA,                                           offsetof(private_configuration_attribute_t, value)      }
 };
 
 /*
index 5f0af8c861288b043f84c70ca1972b9990a1cde7..425bde0c3acd7964f851799367b3c8b988c2bac6 100644 (file)
@@ -98,7 +98,7 @@ static encoding_rule_t encodings[] = {
        { U_INT_8,                      offsetof(private_delete_payload_t, spi_size)            },
        { U_INT_16,                     offsetof(private_delete_payload_t, spi_count)           },
        /* some delete data bytes, length is defined in PAYLOAD_LENGTH */
-       { SPIS,                         offsetof(private_delete_payload_t, spis)                        }
+       { CHUNK_DATA,           offsetof(private_delete_payload_t, spis)                        }
 };
 
 /*
index 47a9b16738a4ef1d5bfdde61222fb33cb49db049..9982f05a160442cb99478e7f593191a0ba05f672 100644 (file)
@@ -81,7 +81,7 @@ static encoding_rule_t encodings[] = {
        /* Length of the whole payload*/
        { PAYLOAD_LENGTH,       offsetof(private_eap_payload_t, payload_length) },
        /* chunt to data, starting at "code" */
-       { EAP_DATA,                     offsetof(private_eap_payload_t, data)                   },
+       { CHUNK_DATA,           offsetof(private_eap_payload_t, data)                   },
 };
 
 /*
index 303ccca8a5d4cbdeaf3f529dd55b8d06894b4647..3fe2e6be65e8ee6c2ed9fbe4d756837437fe35e6 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "encodings.h"
 
-ENUM(encoding_type_names, U_INT_4, ENCRYPTED_DATA,
+ENUM(encoding_type_names, U_INT_4, IKE_SPI,
        "U_INT_4",
        "U_INT_8",
        "U_INT_16",
@@ -29,9 +29,6 @@ ENUM(encoding_type_names, U_INT_4, ENCRYPTED_DATA,
        "HEADER_LENGTH",
        "SPI_SIZE",
        "SPI",
-       "KEY_EXCHANGE_DATA",
-       "KEY_EXCHANGE_DATA_V1",
-       "NOTIFICATION_DATA",
        "PROPOSALS",
        "PROPOSALS_V1",
        "TRANSFORMS",
@@ -39,7 +36,6 @@ ENUM(encoding_type_names, U_INT_4, ENCRYPTED_DATA,
        "TRANSFORM_ATTRIBUTES",
        "TRANSFORM_ATTRIBUTES_V1",
        "CONFIGURATION_ATTRIBUTES",
-       "CONFIGURATION_ATTRIBUTE_VALUE",
        "ATTRIBUTE_FORMAT",
        "ATTRIBUTE_TYPE",
        "ATTRIBUTE_LENGTH_OR_VALUE",
@@ -48,16 +44,6 @@ ENUM(encoding_type_names, U_INT_4, ENCRYPTED_DATA,
        "TRAFFIC_SELECTORS",
        "TS_TYPE",
        "ADDRESS",
-       "NONCE_DATA",
-       "HASH_DATA",
-       "ID_DATA",
-       "AUTH_DATA",
-       "CERT_DATA",
-       "CERTREQ_DATA",
-       "EAP_DATA",
-       "SPIS",
-       "VID_DATA",
-       "UNKNOWN_DATA",
+       "CHUNK_DATA",
        "IKE_SPI",
-       "ENCRYPTED_DATA",
 );
index d0355228e1ec6ae47e6ae83b654b9771229241b8..f6208b8287ed901767b6a61f2d4e5c6d2b8b05de 100644 (file)
@@ -186,31 +186,6 @@ enum encoding_type_t {
         */
        SPI,
 
-       /**
-        * Representating a Key Exchange Data field.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
-        */
-       KEY_EXCHANGE_DATA,
-
-       /**
-        * Same as KEY_EXCHANGE_DATA, but for KEY_EXCHANGE_V1
-        */
-       KEY_EXCHANGE_DATA_V1,
-
-       /**
-        * Representating a Notification field.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - spi size - 8) bytes are read and written into the chunk pointing to.
-        */
-       NOTIFICATION_DATA,
-
        /**
         * Representating one or more proposal substructures.
         *
@@ -278,15 +253,6 @@ enum encoding_type_t {
         */
        CONFIGURATION_ATTRIBUTES,
 
-       /**
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
-        */
-       CONFIGURATION_ATTRIBUTE_VALUE,
-
        /**
         * Representing a 1 Bit flag specifying the format of a transform attribute.
         *
@@ -299,6 +265,7 @@ enum encoding_type_t {
         * is moved 1 bit forward afterwards.
         */
        ATTRIBUTE_FORMAT,
+
        /**
         * Representing a 15 Bit unsigned int value used as attribute type
         * in an attribute transform.
@@ -395,104 +362,9 @@ enum encoding_type_t {
        ADDRESS,
 
        /**
-        * Representating a Nonce Data field.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
-        */
-       NONCE_DATA,
-
-       /**
-        * Representating a Hash Data field.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
-        */
-       HASH_DATA,
-
-       /**
-        * Representating a ID Data field.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
+        * Representing a variable length byte field.
         */
-       ID_DATA,
-
-       /**
-        * Representating a AUTH Data field.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
-        */
-       AUTH_DATA,
-
-       /**
-        * Representating a CERT Data field.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 5) bytes are read and written into the chunk pointing to.
-        */
-       CERT_DATA,
-
-       /**
-        * Representating a CERTREQ Data field.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 5) bytes are read and written into the chunk pointing to.
-        */
-       CERTREQ_DATA,
-
-       /**
-        * Representating an EAP message field.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
-        */
-       EAP_DATA,
-
-       /**
-        * Representating the SPIS field in a DELETE payload.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
-        */
-       SPIS,
-
-       /**
-        * Representating the VID DATA field in a VENDOR ID payload.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
-        */
-       VID_DATA,
-
-       /**
-        * Representating the DATA of an unknown payload.
-        *
-        * When generating the content of the chunkt pointing to
-        * is written.
-        *
-        * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
-        */
-       UNKNOWN_DATA,
+       CHUNK_DATA,
 
        /**
         * Representating an IKE_SPI field in an IKEv2 Header.
@@ -503,11 +375,6 @@ enum encoding_type_t {
         * When parsing 8 bytes are read and written into the u_int64_t pointing to.
         */
        IKE_SPI,
-
-       /**
-        * Representing the encrypted data body of a encryption payload.
-        */
-       ENCRYPTED_DATA,
 };
 
 /**
index 08c64fb51e6c67d435590ac14eca90b1525392ef..bb9969d0bd6e144240f8bcf485e953ddbd448ee5 100644 (file)
@@ -87,7 +87,7 @@ static encoding_rule_t encodings[] = {
        /* Length of the whole encryption payload*/
        { PAYLOAD_LENGTH,       offsetof(private_encryption_payload_t, payload_length)  },
        /* encrypted data, stored in a chunk. contains iv, data, padding */
-       { ENCRYPTED_DATA,       offsetof(private_encryption_payload_t, encrypted)               },
+       { CHUNK_DATA,           offsetof(private_encryption_payload_t, encrypted)               },
 };
 
 /*
index ff968ee25f6ddf07de40442d92c785ca1e5ca065..9542b1c03712bcecaef423bacaf22c2be00249f1 100644 (file)
@@ -62,7 +62,7 @@ static encoding_rule_t encodings[] = {
        /* Length of the whole payload*/
        { PAYLOAD_LENGTH,       offsetof(private_hash_payload_t, payload_length)        },
        /* Hash Data is from variable size */
-       { HASH_DATA,            offsetof(private_hash_payload_t, hash)                          },
+       { CHUNK_DATA,           offsetof(private_hash_payload_t, hash)                          },
 };
 
 /*
index f936e9a2c09c2fc059267ad9ae75fe22597710c1..108d56bd8624d31f888537f7cb6dbd8b7a130032 100644 (file)
@@ -112,7 +112,7 @@ static encoding_rule_t encodings_v2[] = {
        { RESERVED_BYTE,        offsetof(private_id_payload_t, reserved_byte[1])},
        { RESERVED_BYTE,        offsetof(private_id_payload_t, reserved_byte[2])},
        /* some id data bytes, length is defined in PAYLOAD_LENGTH */
-       { ID_DATA,                      offsetof(private_id_payload_t, id_data)                 },
+       { CHUNK_DATA,           offsetof(private_id_payload_t, id_data)                 },
 };
 
 /*
@@ -144,7 +144,7 @@ static encoding_rule_t encodings_v1[] = {
        { U_INT_8,                      offsetof(private_id_payload_t, protocol_id)             },
        { U_INT_16,                     offsetof(private_id_payload_t, port)                    },
        /* some id data bytes, length is defined in PAYLOAD_LENGTH */
-       { ID_DATA,                      offsetof(private_id_payload_t, id_data)                 },
+       { CHUNK_DATA,           offsetof(private_id_payload_t, id_data)                 },
 };
 
 /*
index a6e5217aae8bfdddae4dff9af1b3e902cc5f1adf..438ea46b9fe1028e7870ab5385ba570a7ce0025f 100644 (file)
@@ -98,7 +98,7 @@ static encoding_rule_t encodings_v2[] = {
        { RESERVED_BYTE,                offsetof(private_ke_payload_t, reserved_byte[0])},
        { RESERVED_BYTE,                offsetof(private_ke_payload_t, reserved_byte[1])},
        /* Key Exchange Data is from variable size */
-       { KEY_EXCHANGE_DATA,    offsetof(private_ke_payload_t, key_exchange_data)},
+       { CHUNK_DATA,                   offsetof(private_ke_payload_t, key_exchange_data)},
 };
 
 /*
@@ -123,7 +123,7 @@ static encoding_rule_t encodings_v1[] = {
        /* Length of the whole payload*/
        { PAYLOAD_LENGTH,               offsetof(private_ke_payload_t, payload_length)  },
        /* Key Exchange Data is from variable size */
-       { KEY_EXCHANGE_DATA_V1, offsetof(private_ke_payload_t, key_exchange_data)},
+       { CHUNK_DATA,                   offsetof(private_ke_payload_t, key_exchange_data)},
 };
 
 /*
index 1e0cf557915b512c147c3659bd197d3112cbbdc3..58ef70a0e3f82a08fe6045f59336221079a70d74 100644 (file)
@@ -86,7 +86,7 @@ static encoding_rule_t encodings[] = {
        /* Length of the whole nonce payload*/
        { PAYLOAD_LENGTH,       offsetof(private_nonce_payload_t, payload_length)       },
        /* some nonce bytes, lenth is defined in PAYLOAD_LENGTH */
-       { NONCE_DATA,           offsetof(private_nonce_payload_t, nonce)                        },
+       { CHUNK_DATA,           offsetof(private_nonce_payload_t, nonce)                        },
 };
 
 /*                           1                   2                   3
index f2e1267c60a72e62daba19ec9b0e7f5cd8e1234a..7dab941b8c0604a7496b00565597d89c63602c41 100644 (file)
@@ -287,7 +287,7 @@ static encoding_rule_t encodings[] = {
        /* SPI as variable length field*/
        { SPI,                          offsetof(private_notify_payload_t, spi)                                 },
        /* Key Exchange Data is from variable size */
-       { NOTIFICATION_DATA,offsetof(private_notify_payload_t, notification_data)       }
+       { CHUNK_DATA,           offsetof(private_notify_payload_t, notification_data)   }
 };
 
 /*
index 29dfa9da4a2a073b6fdc458bd2050a05c515d711..fe7ced20be3026498cb3adb749b475073c64c50c 100644 (file)
@@ -84,7 +84,7 @@ static encoding_rule_t encodings[] = {
        /* Length of the whole payload*/
        { PAYLOAD_LENGTH,       offsetof(private_unknown_payload_t, payload_length)     },
        /* some unknown data bytes, length is defined in PAYLOAD_LENGTH */
-       { UNKNOWN_DATA,         offsetof(private_unknown_payload_t, data)                       },
+       { CHUNK_DATA,           offsetof(private_unknown_payload_t, data)                       },
 };
 
 /*
index 8a1d9970d345016ddda653f2906c22e4ec316aa9..0c1df56e244698fe9547bcebe547bc63a28789aa 100644 (file)
@@ -84,7 +84,7 @@ static encoding_rule_t encodings[] = {
        /* Length of the whole payload*/
        { PAYLOAD_LENGTH,       offsetof(private_vendor_id_payload_t, payload_length)},
        /* some vendor_id data bytes, length is defined in PAYLOAD_LENGTH */
-       { VID_DATA,                     offsetof(private_vendor_id_payload_t, data)                     }
+       { CHUNK_DATA,           offsetof(private_vendor_id_payload_t, data)                     }
 };
 
 /*