X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fdhcp-client.c;h=720cd2faddbbac80d1a7d1bcf04751a44b6df9f2;hb=837e80977cdd9fda61fb0789bfd6b64c7639c25a;hp=561562b05d86bff0eefee3fdba06ae50cdc57e79;hpb=80992a35775490f05da0740f285a5a9c7acb632a;p=openvswitch diff --git a/lib/dhcp-client.c b/lib/dhcp-client.c index 561562b0..720cd2fa 100644 --- a/lib/dhcp-client.c +++ b/lib/dhcp-client.c @@ -172,7 +172,7 @@ dhclient_create(const char *netdev_name, return error; } - cli = xcalloc(1, sizeof *cli); + cli = xzalloc(sizeof *cli); cli->modify_request = modify_request; cli->validate_offer = validate_offer; cli->aux = aux; @@ -411,7 +411,7 @@ dhclient_configure_netdev(struct dhclient *cli) } if (!error && router.s_addr) { - error = netdev_add_router(router); + error = netdev_add_router(cli->netdev, router); if (error) { VLOG_ERR("failed to add default route to "IP_FMT" on %s: %s", IP_ARGS(&router), netdev_get_name(cli->netdev), @@ -909,7 +909,7 @@ do_receive_msg(struct dhclient *cli, struct dhcp_msg *msg) struct ofpbuf b; int mtu; - mtu = netdev_get_mtu(cli->netdev); + netdev_get_mtu(cli->netdev, &mtu); ofpbuf_init(&b, mtu + VLAN_ETH_HEADER_LEN); netdev_get_etheraddr(cli->netdev, cli_mac); for (; cli->received < 50; cli->received++) { @@ -927,7 +927,7 @@ do_receive_msg(struct dhclient *cli, struct dhcp_msg *msg) flow_extract(&b, 0, &flow); if (flow.dl_type != htons(ETH_TYPE_IP) || flow.nw_proto != IP_TYPE_UDP - || flow.tp_dst != htons(68) + || flow.tp_dst != htons(DHCP_CLIENT_PORT) || !(eth_addr_is_broadcast(flow.dl_dst) || eth_addr_equals(flow.dl_dst, cli_mac))) { continue; @@ -1009,8 +1009,8 @@ do_send_msg(struct dhclient *cli, const struct dhcp_msg *msg) nh.ip_dst = INADDR_BROADCAST; nh.ip_csum = csum(&nh, sizeof nh); - th.udp_src = htons(66); - th.udp_dst = htons(67); + th.udp_src = htons(DHCP_CLIENT_PORT); + th.udp_dst = htons(DHCP_SERVER_PORT); th.udp_len = htons(UDP_HEADER_LEN + b.size); th.udp_csum = 0; udp_csum = csum_add32(0, nh.ip_src);