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
16 #include "dhcp_transaction.h"
18 typedef struct private_dhcp_transaction_t private_dhcp_transaction_t
;
21 * Private data of an dhcp_transaction_t object.
23 struct private_dhcp_transaction_t
{
26 * Public dhcp_transaction_t interface.
28 dhcp_transaction_t
public;
38 identification_t
*identity
;
41 * received DHCP address
46 * discovered DHCP server address
51 METHOD(dhcp_transaction_t
, get_id
, u_int32_t
,
52 private_dhcp_transaction_t
*this)
57 METHOD(dhcp_transaction_t
, get_identity
, identification_t
*,
58 private_dhcp_transaction_t
*this)
60 return this->identity
;
63 METHOD(dhcp_transaction_t
, set_address
, void,
64 private_dhcp_transaction_t
*this, host_t
*address
)
66 DESTROY_IF(this->address
);
67 this->address
= address
;
70 METHOD(dhcp_transaction_t
, get_address
, host_t
*,
71 private_dhcp_transaction_t
*this)
76 METHOD(dhcp_transaction_t
, set_server
, void,
77 private_dhcp_transaction_t
*this, host_t
*server
)
79 DESTROY_IF(this->server
);
80 this->server
= server
;
83 METHOD(dhcp_transaction_t
, get_server
, host_t
*,
84 private_dhcp_transaction_t
*this)
89 METHOD(dhcp_transaction_t
, destroy
, void,
90 private_dhcp_transaction_t
*this)
92 this->identity
->destroy(this->identity
);
93 DESTROY_IF(this->address
);
94 DESTROY_IF(this->server
);
101 dhcp_transaction_t
*dhcp_transaction_create(u_int32_t id
,
102 identification_t
*identity
)
104 private_dhcp_transaction_t
*this;
109 .get_identity
= _get_identity
,
110 .set_address
= _set_address
,
111 .get_address
= _get_address
,
112 .set_server
= _set_server
,
113 .get_server
= _get_server
,
117 .identity
= identity
->clone(identity
),
120 return &this->public;