msg->xid = cli->xid;
msg->secs = cli->secs;
msg->type = type;
- memcpy(msg->chaddr, netdev_get_etheraddr(cli->netdev), ETH_ADDR_LEN);
+ netdev_get_etheraddr(cli->netdev, msg->chaddr);
}
/* If time goes backward this returns a large number, which makes it look like
static bool
do_receive_msg(struct dhclient *cli, struct dhcp_msg *msg)
{
+ uint8_t cli_mac[ETH_ADDR_LEN];
struct ofpbuf b;
+ int mtu;
- ofpbuf_init(&b, netdev_get_mtu(cli->netdev) + VLAN_ETH_HEADER_LEN);
+ mtu = netdev_get_mtu(cli->netdev);
+ ofpbuf_init(&b, mtu + 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.nw_proto != IP_TYPE_UDP
|| flow.tp_dst != htons(68)
|| !(eth_addr_is_broadcast(flow.dl_dst)
- || eth_addr_equals(flow.dl_dst,
- netdev_get_etheraddr(cli->netdev)))) {
+ || eth_addr_equals(flow.dl_dst, cli_mac))) {
continue;
}
dhcp_assemble(msg, &b);
- memcpy(eh.eth_src, netdev_get_etheraddr(cli->netdev), ETH_ADDR_LEN);
+ netdev_get_etheraddr(cli->netdev, eh.eth_src);
memcpy(eh.eth_dst, eth_addr_broadcast, ETH_ADDR_LEN);
eh.eth_type = htons(ETH_TYPE_IP);
return set_etheraddr(name, ARPHRD_ETHER, mac);
}
-/* Returns a pointer to 'netdev''s MAC address. The caller must not modify or
- * free the returned buffer. */
-const uint8_t *
-netdev_get_etheraddr(const struct netdev *netdev)
+/* Retrieves 'netdev''s MAC address. If successful, returns 0 and copies the
+ * the MAC address into 'mac'. On failure, returns a positive errno value and
+ * clears 'mac' to all-zeros. */
+int
+netdev_get_etheraddr(const struct netdev *netdev, uint8_t mac[ETH_ADDR_LEN])
{
- return netdev->etheraddr;
+ memcpy(mac, netdev->etheraddr, ETH_ADDR_LEN);
+ return 0;
}
/* Returns the name of the network device that 'netdev' represents,
int netdev_send(struct netdev *, const struct ofpbuf *);
void netdev_send_wait(struct netdev *);
int netdev_set_etheraddr(struct netdev *, const uint8_t mac[6]);
-const uint8_t *netdev_get_etheraddr(const struct netdev *);
+int netdev_get_etheraddr(const struct netdev *, uint8_t mac[6]);
const char *netdev_get_name(const struct netdev *);
int netdev_get_mtu(const struct netdev *);
int netdev_get_features(struct netdev *,
ofport = xmalloc(sizeof *ofport);
ofport->netdev = netdev;
ofport->opp.port_no = odp_port_to_ofp_port(odp_port->port);
- memcpy(ofport->opp.hw_addr, netdev_get_etheraddr(netdev), ETH_ALEN);
+ netdev_get_etheraddr(netdev, ofport->opp.hw_addr);
memcpy(ofport->opp.name, odp_port->devname,
MIN(sizeof ofport->opp.name, sizeof odp_port->devname));
ofport->opp.name[sizeof ofport->opp.name - 1] = '\0';