Fix parsing of IPv6 headers in ip_packet_t
[strongswan.git] / src / libipsec / ipsec_processor.h
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 /**
17 * @defgroup ipsec_processor ipsec_processor
18 * @{ @ingroup libipsec
19 */
20
21 #ifndef IPSEC_PROCESSOR_H_
22 #define IPSEC_PROCESSOR_H_
23
24 #include "ip_packet.h"
25 #include "esp_packet.h"
26
27 typedef struct ipsec_processor_t ipsec_processor_t;
28
29 /**
30 * Callback called to deliver an inbound plaintext packet.
31 *
32 * @param data data supplied during registration of the callback
33 * @param packet plaintext IP packet to deliver
34 */
35 typedef void (*ipsec_inbound_cb_t)(void *data, ip_packet_t *packet);
36
37 /**
38 * Callback called to send an ESP packet.
39 *
40 * @note The ESP packet currently comes without IP header (and without UDP
41 * header in case of UDP encapsulation)
42 *
43 * @param data data supplied during registration of the callback
44 * @param packet ESP packet to send
45 */
46 typedef void (*ipsec_outbound_cb_t)(void *data, esp_packet_t *packet);
47
48 /**
49 * IPsec processor
50 */
51 struct ipsec_processor_t {
52
53 /**
54 * Queue an inbound ESP packet for processing.
55 *
56 * @param packet the ESP packet to process
57 */
58 void (*queue_inbound)(ipsec_processor_t *this, esp_packet_t *packet);
59
60 /**
61 * Queue an outbound plaintext IP packet for processing.
62 *
63 * @param packet the plaintext IP packet
64 */
65 void (*queue_outbound)(ipsec_processor_t *this, ip_packet_t *packet);
66
67 /**
68 * Register the callback used to deliver inbound plaintext packets.
69 *
70 * @param cb the inbound callback function
71 * @param data optional data provided to callback
72 */
73 void (*register_inbound)(ipsec_processor_t *this, ipsec_inbound_cb_t cb,
74 void *data);
75
76 /**
77 * Unregister a previously registered inbound callback.
78 *
79 * @param cb previously registered callback function
80 */
81 void (*unregister_inbound)(ipsec_processor_t *this,
82 ipsec_inbound_cb_t cb);
83
84 /**
85 * Register the callback used to send outbound ESP packets.
86 *
87 * @param cb the outbound callback function
88 * @param data optional data provided to callback
89 */
90 void (*register_outbound)(ipsec_processor_t *this, ipsec_outbound_cb_t cb,
91 void *data);
92
93 /**
94 * Unregister a previously registered outbound callback.
95 *
96 * @param cb previously registered callback function
97 */
98 void (*unregister_outbound)(ipsec_processor_t *this,
99 ipsec_outbound_cb_t cb);
100
101 /**
102 * Destroy an ipsec_processor_t.
103 */
104 void (*destroy)(ipsec_processor_t *this);
105
106 };
107
108 /**
109 * Create an ipsec_processor_t instance
110 *
111 * @return IPsec processor instance
112 */
113 ipsec_processor_t *ipsec_processor_create();
114
115 #endif /** IPSEC_PROCESSOR_H_ @}*/