/*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "poll-loop.h"
#include "sat-math.h"
#include "timeval.h"
-
-#define THIS_MODULE VLM_dhcp_client
#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(dhcp_client);
+
#define DHCLIENT_STATES \
DHCLIENT_STATE(INIT, 1 << 0) \
DHCLIENT_STATE(INIT_REBOOT, 1 << 1) \
bool am_bound;
if (cli->state != state) {
- VLOG_DBG("%s: entering %s", cli_name, state_name(state));
+ VLOG_DBG("%s: entering %s", cli_name, state_name(state));
cli->state = state;
}
cli->state_entered = time_now();
const char *cli_name = dhclient_get_name(cli);
uint8_t cli_mac[ETH_ADDR_LEN];
struct ofpbuf b;
- int mtu;
- netdev_get_mtu(cli->netdev, &mtu);
- ofpbuf_init(&b, mtu + VLAN_ETH_HEADER_LEN);
+ ofpbuf_init(&b, ETH_TOTAL_MAX + VLAN_ETH_HEADER_LEN);
netdev_get_etheraddr(cli->netdev, cli_mac);
for (; cli->received < 50; cli->received++) {
const struct ip_header *ip;
const struct dhcp_header *dhcp;
- flow_t flow;
+ struct flow flow;
int error;
ofpbuf_clear(&b);
flow_extract(&b, 0, 0, &flow);
if (flow.dl_type != htons(ETH_TYPE_IP)
- || flow.nw_proto != IP_TYPE_UDP
+ || flow.nw_proto != IPPROTO_UDP
|| flow.tp_dst != htons(DHCP_CLIENT_PORT)
|| !(eth_addr_is_broadcast(flow.dl_dst)
|| eth_addr_equals(flow.dl_dst, cli_mac))) {
if (!error) {
if (VLOG_IS_DBG_ENABLED()) {
VLOG_DBG_RL(&rl, "%s: received %s", cli_name,
- dhcp_msg_to_string(msg, false, &cli->s));
+ dhcp_msg_to_string(msg, false, &cli->s));
} else {
VLOG_INFO_RL(&rl, "%s: received %s",
cli_name, dhcp_type_name(msg->type));
nh.ip_id = 0;
nh.ip_frag_off = htons(IP_DONT_FRAGMENT);
nh.ip_ttl = 64;
- nh.ip_proto = IP_TYPE_UDP;
+ nh.ip_proto = IPPROTO_UDP;
nh.ip_csum = 0;
nh.ip_src = dhclient_get_ip(cli);
/* XXX need to use UDP socket for nonzero server IPs so that we can get
th.udp_csum = 0;
udp_csum = csum_add32(0, nh.ip_src);
udp_csum = csum_add32(udp_csum, nh.ip_dst);
- udp_csum = csum_add16(udp_csum, IP_TYPE_UDP << 8);
+ udp_csum = csum_add16(udp_csum, IPPROTO_UDP << 8);
udp_csum = csum_add16(udp_csum, th.udp_len);
udp_csum = csum_continue(udp_csum, &th, sizeof th);
th.udp_csum = csum_finish(csum_continue(udp_csum, b.data, b.size));
if (b.size <= ETH_TOTAL_MAX) {
if (VLOG_IS_DBG_ENABLED()) {
VLOG_DBG("%s: sending %s",
- cli_name, dhcp_msg_to_string(msg, false, &cli->s));
+ cli_name, dhcp_msg_to_string(msg, false, &cli->s));
} else {
VLOG_INFO("%s: sending %s", cli_name, dhcp_type_name(msg->type));
}