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_plugin.h"
20 #include "dhcp_socket.h"
21 #include "dhcp_provider.h"
23 typedef struct private_dhcp_plugin_t private_dhcp_plugin_t
;
26 * private data of dhcp plugin
28 struct private_dhcp_plugin_t
{
31 * implements plugin interface
36 * DHCP communication socket
38 dhcp_socket_t
*socket
;
43 dhcp_provider_t
*provider
;
46 METHOD(plugin_t
, destroy
, void,
47 private_dhcp_plugin_t
*this)
49 lib
->attributes
->remove_provider(lib
->attributes
, &this->provider
->provider
);
50 this->provider
->destroy(this->provider
);
51 this->socket
->destroy(this->socket
);
58 plugin_t
*dhcp_plugin_create()
60 private_dhcp_plugin_t
*this;
63 .public.plugin
.destroy
= _destroy
,
64 .socket
= dhcp_socket_create(),
73 this->provider
= dhcp_provider_create(this->socket
);
74 lib
->attributes
->add_provider(lib
->attributes
, &this->provider
->provider
);
76 return &this->public.plugin
;