diff options
author | Martin Willi <martin@revosec.ch> | 2010-03-24 15:28:14 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2010-03-25 14:29:10 +0100 |
commit | b262429e0b991ec8dbe7f7694c8f0418023f0fde (patch) | |
tree | 51012f3a4818c86cbf01b98a8d25c790274b8feb /src/libcharon/plugins/dhcp/dhcp_socket.c | |
parent | 913eb696929d9c611cc9a85a0609c122467f696e (diff) | |
download | strongswan-b262429e0b991ec8dbe7f7694c8f0418023f0fde.tar.bz2 strongswan-b262429e0b991ec8dbe7f7694c8f0418023f0fde.tar.xz |
Include configuration payloads for DNS/WINS server received via DHCP
Diffstat (limited to 'src/libcharon/plugins/dhcp/dhcp_socket.c')
-rw-r--r-- | src/libcharon/plugins/dhcp/dhcp_socket.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/libcharon/plugins/dhcp/dhcp_socket.c b/src/libcharon/plugins/dhcp/dhcp_socket.c index b789e11ec..190024ce6 100644 --- a/src/libcharon/plugins/dhcp/dhcp_socket.c +++ b/src/libcharon/plugins/dhcp/dhcp_socket.c @@ -446,7 +446,7 @@ METHOD(dhcp_socket_t, release, void, */ static void handle_offer(private_dhcp_socket_t *this, dhcp_t *dhcp, int optlen) { - dhcp_transaction_t *transaction; + dhcp_transaction_t *transaction = NULL; enumerator_t *enumerator; host_t *offer, *server; @@ -470,6 +470,34 @@ static void handle_offer(private_dhcp_socket_t *this, dhcp_t *dhcp, int optlen) } } enumerator->destroy(enumerator); + + if (transaction) + { + int optsize, optpos = 0, pos; + dhcp_option_t *option; + + while (optlen > sizeof(dhcp_option_t)) + { + option = (dhcp_option_t*)&dhcp->options[optpos]; + optsize = sizeof(dhcp_option_t) + option->len; + if (option->type == DHCP_OPTEND || optlen < optsize) + { + break; + } + if (option->type == DHCP_DNS_SERVER || + option->type == DHCP_NBNS_SERVER) + { + for (pos = 0; pos + 4 <= option->len; pos += 4) + { + transaction->add_attribute(transaction, option->type == + DHCP_DNS_SERVER ? INTERNAL_IP4_DNS : INTERNAL_IP4_NBNS, + chunk_create((char*)&option->data[pos], 4)); + } + } + optlen -= optsize; + optpos += optsize; + } + } this->mutex->unlock(this->mutex); this->condvar->broadcast(this->condvar); offer->destroy(offer); |