2 * Copyright (C) 2012 Tobias Brunner
3 * HSR Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * @defgroup ipsec_processor ipsec_processor
18 * @{ @ingroup libipsec
21 #ifndef IPSEC_PROCESSOR_H_
22 #define IPSEC_PROCESSOR_H_
24 #include "ip_packet.h"
25 #include "esp_packet.h"
27 typedef struct ipsec_processor_t ipsec_processor_t
;
30 * Callback called to deliver an inbound plaintext packet.
32 * @param data data supplied during registration of the callback
33 * @param packet plaintext IP packet to deliver
35 typedef void (*ipsec_inbound_cb_t
)(void *data
, ip_packet_t
*packet
);
38 * Callback called to send an ESP packet.
40 * @note The ESP packet currently comes without IP header (and without UDP
41 * header in case of UDP encapsulation)
43 * @param data data supplied during registration of the callback
44 * @param packet ESP packet to send
46 typedef void (*ipsec_outbound_cb_t
)(void *data
, esp_packet_t
*packet
);
51 struct ipsec_processor_t
{
54 * Queue an inbound ESP packet for processing.
56 * @param packet the ESP packet to process
58 void (*queue_inbound
)(ipsec_processor_t
*this, esp_packet_t
*packet
);
61 * Queue an outbound plaintext IP packet for processing.
63 * @param packet the plaintext IP packet
65 void (*queue_outbound
)(ipsec_processor_t
*this, ip_packet_t
*packet
);
68 * Register the callback used to deliver inbound plaintext packets.
70 * @param cb the inbound callback function
71 * @param data optional data provided to callback
73 void (*register_inbound
)(ipsec_processor_t
*this, ipsec_inbound_cb_t cb
,
77 * Unregister a previously registered inbound callback.
79 * @param cb previously registered callback function
81 void (*unregister_inbound
)(ipsec_processor_t
*this,
82 ipsec_inbound_cb_t cb
);
85 * Register the callback used to send outbound ESP packets.
87 * @param cb the outbound callback function
88 * @param data optional data provided to callback
90 void (*register_outbound
)(ipsec_processor_t
*this, ipsec_outbound_cb_t cb
,
94 * Unregister a previously registered outbound callback.
96 * @param cb previously registered callback function
98 void (*unregister_outbound
)(ipsec_processor_t
*this,
99 ipsec_outbound_cb_t cb
);
102 * Destroy an ipsec_processor_t.
104 void (*destroy
)(ipsec_processor_t
*this);
109 * Create an ipsec_processor_t instance
111 * @return IPsec processor instance
113 ipsec_processor_t
*ipsec_processor_create();
115 #endif /** IPSEC_PROCESSOR_H_ @}*/