2005-11-09 13:37:55 +00:00
|
|
|
/**
|
|
|
|
* @file parser.h
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-09 13:37:55 +00:00
|
|
|
* @brief Generic parser class used to parse IKEv2-Header and Payload
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-09 13:37:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 PARSER_H_
|
|
|
|
#define PARSER_H_
|
|
|
|
|
|
|
|
#include "types.h"
|
2005-11-14 06:55:51 +00:00
|
|
|
#include "payloads/encodings.h"
|
|
|
|
#include "payloads/payload.h"
|
2005-11-09 13:37:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-11-10 09:35:28 +00:00
|
|
|
* @brief A parser_t object which parses payloads of specific type
|
2005-11-09 13:37:55 +00:00
|
|
|
*/
|
|
|
|
typedef struct parser_s parser_t;
|
|
|
|
|
2005-11-10 09:35:28 +00:00
|
|
|
struct parser_s {
|
2005-11-11 08:04:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief parses the next payload in the current context
|
|
|
|
*
|
|
|
|
* @warning caller is responsible for freeing allocated data_struct
|
|
|
|
*
|
|
|
|
* @param parser parser Object
|
|
|
|
* @param payload_type payload to parse
|
2005-11-14 09:43:18 +00:00
|
|
|
* @param[out] payload pointer where parsed payload was allocated
|
2005-11-11 08:04:51 +00:00
|
|
|
* @return
|
|
|
|
* - SUCCESSFUL if succeeded,
|
|
|
|
* - NOT_SUPPORTED if payload_type is not supported
|
|
|
|
* - OUT_OF_RES if out of ressources
|
|
|
|
* - PARSE_ERROR if corrupted data found
|
|
|
|
*/
|
2005-11-14 09:43:18 +00:00
|
|
|
status_t (*parse_payload) (parser_t *this, payload_type_t payload_type, payload_t **payload);
|
2005-11-10 19:19:56 +00:00
|
|
|
|
2005-11-09 13:37:55 +00:00
|
|
|
/**
|
2005-11-10 19:19:56 +00:00
|
|
|
* @brief Destroys a parser object
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-10 19:19:56 +00:00
|
|
|
* @param parser parser object
|
|
|
|
* @return
|
|
|
|
* - SUCCESSFUL in any case
|
2005-11-09 13:37:55 +00:00
|
|
|
*/
|
|
|
|
status_t (*destroy) (parser_t *this);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2005-11-11 08:04:51 +00:00
|
|
|
* @brief Constructor to create a parser
|
|
|
|
*
|
|
|
|
* The parser uses a set of payload_infos to know how to
|
|
|
|
* parse different payloads.
|
|
|
|
*
|
2005-11-14 09:43:18 +00:00
|
|
|
* @param chunk chunk of data to parse in this session
|
|
|
|
* @return the parser, or NULL if failed
|
2005-11-10 09:35:28 +00:00
|
|
|
*
|
2005-11-09 13:37:55 +00:00
|
|
|
*/
|
2005-11-14 09:43:18 +00:00
|
|
|
parser_t *parser_create(chunk_t data);
|
2005-11-09 13:37:55 +00:00
|
|
|
|
|
|
|
#endif /*PARSER_H_*/
|