2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
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 dhcp_transaction dhcp_transaction
21 #ifndef DHCP_TRANSACTION_H_
22 #define DHCP_TRANSACTION_H_
24 #include <networking/host.h>
25 #include <utils/identification.h>
26 #include <attributes/attributes.h>
28 typedef struct dhcp_transaction_t dhcp_transaction_t
;
31 * DHCP transaction class.
33 struct dhcp_transaction_t
{
36 * Get the DHCP transaction ID.
38 * @return DHCP transaction identifier
40 uint32_t (*get_id
)(dhcp_transaction_t
*this);
43 * Get the peer identity this transaction is used for.
45 * @return peer Identity
47 identification_t
* (*get_identity
)(dhcp_transaction_t
*this);
50 * Set the DHCP address received using this transaction.
52 * @param host received DHCP address
54 void (*set_address
)(dhcp_transaction_t
*this, host_t
*address
);
57 * Get the DHCP address received using this transaction.
59 * @return received DHCP address
61 host_t
* (*get_address
)(dhcp_transaction_t
*this);
64 * Set the DHCP server address discovered.
66 * @param server DHCP server address
68 void (*set_server
)(dhcp_transaction_t
*this, host_t
*server
);
71 * Get the DHCP server address.
73 * @return DHCP server address
75 host_t
* (*get_server
)(dhcp_transaction_t
*this);
78 * Add an additional attribute to serve to peer.
80 * @param type type of attribute
81 * @param data attribute data
83 void (*add_attribute
)(dhcp_transaction_t
*this,
84 configuration_attribute_type_t type
, chunk_t data
);
87 * Create an enumerator over added attributes.
89 * @return enumerator over (configuration_attribute_t, chunk_t)
91 enumerator_t
* (*create_attribute_enumerator
)(dhcp_transaction_t
*this);
94 * Destroy a dhcp_transaction_t.
96 void (*destroy
)(dhcp_transaction_t
*this);
100 * Create a dhcp_transaction instance.
102 * @param id DHCP transaction identifier
103 * @param identity peer identity this transaction is used for
104 * @return transaction instance
106 dhcp_transaction_t
*dhcp_transaction_create(uint32_t id
,
107 identification_t
*identity
);
109 #endif /** DHCP_TRANSACTION_H_ @}*/