- mapping for payload_type_t added
This commit is contained in:
parent
fcab0071fe
commit
c795c4e5d7
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* @file definitions.c
|
||||
*
|
||||
* @brief general purpose functions used in definitions.h
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "definitions.h"
|
||||
|
||||
/*
|
||||
* see header
|
||||
*/
|
||||
char *mapping_find(mapping_t * maps, int value)
|
||||
{
|
||||
int i = 0;
|
||||
while (maps[i].value > MAPPING_END)
|
||||
{
|
||||
i++;
|
||||
if (maps[i].value == value)
|
||||
{
|
||||
return maps[i].string;
|
||||
}
|
||||
}
|
||||
return "INVALID MAPPING";
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* @file definitions.h
|
||||
*
|
||||
* @brief general purpose definitions and macros
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef DEFINITIONS_H_
|
||||
#define DEFINITIONS_H_
|
||||
|
||||
|
||||
#define MAPPING_END -1
|
||||
|
||||
/**
|
||||
* @brief mapping entry, where enum-to-string mappings are stored
|
||||
*/
|
||||
typedef struct mapping_s mapping_t;
|
||||
struct mapping_s
|
||||
{
|
||||
/**
|
||||
* enumeration value
|
||||
*/
|
||||
int value;
|
||||
/**
|
||||
* mapped string
|
||||
*/
|
||||
char *string;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief find a mapping_string in the mapping[]
|
||||
*
|
||||
* @param mappings mappings array
|
||||
* @param value enum-value to get the string from
|
||||
*
|
||||
*/
|
||||
char *mapping_find(mapping_t *mappings, int value);
|
||||
|
||||
|
||||
#endif /*DEFINITIONS_H_*/
|
|
@ -34,6 +34,32 @@
|
|||
|
||||
extern payload_info_t ike_header_info;
|
||||
|
||||
/*
|
||||
* build the mappings for payload_type_t
|
||||
*/
|
||||
mapping_t payload_type_t_mappings[] = {
|
||||
{NO_PAYLOAD, "NO_PAYLOAD"},
|
||||
{SECURITY_ASSOCIATION, "SECURITY_ASSOCIATION"},
|
||||
{KEY_EXCHANGE, "KEY_EXCHANGE"},
|
||||
{ID_INITIATOR, "ID_INITIATOR"},
|
||||
{ID_RESPONDER, "ID_RESPONDER"},
|
||||
{CERTIFICATE, "CERTIFICATE"},
|
||||
{CERTIFICATE_REQUEST, "CERTIFICATE_REQUEST"},
|
||||
{AUTHENTICATION, "AUTHENTICATION"},
|
||||
{NONCE, "NONCE"},
|
||||
{NOTIFY, "NOTIFY"},
|
||||
{DELETE, "DELETE"},
|
||||
{VENDOR_ID, "VENDOR_ID"},
|
||||
{TRAFFIC_SELECTOR_INITIATOR, "TRAFFIC_SELECTOR_INITIATOR"},
|
||||
{TRAFFIC_SELECTOR_RESPONDER, "TRAFFIC_SELECTOR_RESPONDER"},
|
||||
{ENCRYPTED, "ENCRYPTED"},
|
||||
{CONFIGURATION, "CONFIGURATION"},
|
||||
{EXTENSIBLE_AUTHENTICATION, "EXTENSIBLE_AUTHENTICATION"},
|
||||
{HEADER, "HEADER"},
|
||||
{MAPPING_END, NULL}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* List containing all payload informations
|
||||
* supported by parser and generator.
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#define ENCODINGS_H_
|
||||
|
||||
#include "types.h"
|
||||
#include "definitions.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -289,6 +290,12 @@ enum payload_type_e{
|
|||
HEADER = 140
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* build string mapping array for payload_type_t
|
||||
*/
|
||||
extern mapping_t payload_type_t_mappings[];
|
||||
|
||||
/**
|
||||
* Information of a specific payload are stored in this struct
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue