e20572064358a0b8e073d2911adcbaef37be157a
[strongswan.git] / src / libcharon / plugins / dhcp / dhcp_transaction.h
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
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 dhcp_transaction dhcp_transaction
18 * @{ @ingroup dhcp
19 */
20
21 #ifndef DHCP_TRANSACTION_H_
22 #define DHCP_TRANSACTION_H_
23
24 #include <utils/host.h>
25 #include <utils/identification.h>
26
27 typedef struct dhcp_transaction_t dhcp_transaction_t;
28
29 /**
30 * DHCP transaction class.
31 */
32 struct dhcp_transaction_t {
33
34 /**
35 * Get the DCHP transaction ID.
36 *
37 * @return DHCP transaction identifier
38 */
39 u_int32_t (*get_id)(dhcp_transaction_t *this);
40
41 /**
42 * Get the peer identity this transaction is used for.
43 *
44 * @return peer Identity
45 */
46 identification_t* (*get_identity)(dhcp_transaction_t *this);
47
48 /**
49 * Set the DHCP address received using this transaction.
50 *
51 * @param host received DHCP address
52 */
53 void (*set_address)(dhcp_transaction_t *this, host_t *address);
54
55 /**
56 * Get the DHCP address received using this transaction.
57 *
58 * @return received DHCP address
59 */
60 host_t* (*get_address)(dhcp_transaction_t *this);
61
62 /**
63 * Set the DCHP server address discovered.
64 *
65 * @param server DHCP server address
66 */
67 void (*set_server)(dhcp_transaction_t *this, host_t *server);
68
69 /**
70 * Get the DHCP server address.
71 *
72 * @return DHCP server address
73 */
74 host_t* (*get_server)(dhcp_transaction_t *this);
75
76 /**
77 * Destroy a dhcp_transaction_t.
78 */
79 void (*destroy)(dhcp_transaction_t *this);
80 };
81
82 /**
83 * Create a dhcp_transaction instance.
84 *
85 * @param id DHCP transaction identifier
86 * @param identity peer identity this transaction is used for
87 * @return transaction instance
88 */
89 dhcp_transaction_t *dhcp_transaction_create(u_int32_t id,
90 identification_t *identity);
91
92 #endif /** DHCP_TRANSACTION_H_ @}*/