- implemented create and destroy function
This commit is contained in:
@@ -20,4 +20,58 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <freeswan.h>
|
||||||
|
#include <pluto/constants.h>
|
||||||
|
#include <pluto/defs.h>
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data of an message_t object
|
||||||
|
*/
|
||||||
|
typedef struct private_message_s private_message_t;
|
||||||
|
|
||||||
|
struct private_message_s {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public part of a message_t object
|
||||||
|
*/
|
||||||
|
message_t public;
|
||||||
|
|
||||||
|
|
||||||
|
/* Private values */
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief implements function destroy of message_t
|
||||||
|
*/
|
||||||
|
static status_t destroy (private_message_t *this)
|
||||||
|
{
|
||||||
|
if (this == NULL)
|
||||||
|
{
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
|
pfree(this);
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Described in Header-File
|
||||||
|
*/
|
||||||
|
message_t * message_create()
|
||||||
|
{
|
||||||
|
private_message_t *this = alloc_thing(private_message_t, "private_message_t");
|
||||||
|
if (this == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Public functions */
|
||||||
|
this->public.destroy = (status_t(*)(message_t*))destroy;
|
||||||
|
|
||||||
|
|
||||||
|
return (&this->public);
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,4 +23,32 @@
|
|||||||
#ifndef MESSAGE_H_
|
#ifndef MESSAGE_H_
|
||||||
#define MESSAGE_H_
|
#define MESSAGE_H_
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This class is used to represent an IKEv2-Message.
|
||||||
|
*
|
||||||
|
* An IKEv2-Message is either a request or response.
|
||||||
|
*/
|
||||||
|
typedef struct message_s message_t;
|
||||||
|
|
||||||
|
struct message_s {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destroys a message object
|
||||||
|
*
|
||||||
|
* @param this message_t object
|
||||||
|
* @return SUCCESSFUL if succeeded, FAILED otherwise
|
||||||
|
*/
|
||||||
|
status_t (*destroy) (message_t *this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an message_t-object
|
||||||
|
*
|
||||||
|
* @return created message_t object
|
||||||
|
*/
|
||||||
|
message_t * message_create();
|
||||||
|
|
||||||
|
|
||||||
#endif /*MESSAGE_H_*/
|
#endif /*MESSAGE_H_*/
|
||||||
|
|||||||
Reference in New Issue
Block a user