diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2007-07-05 18:01:37 +0200 |
---|---|---|
committer | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-07-05 18:01:37 +0200 |
commit | 225b19227203911f9bda410746ef4e366a008852 (patch) | |
tree | 8d0ed80952742f7c288340b982194c62f55a6a83 /net/eth.c | |
parent | 3f8a5b17f27f752bf8a7741e5db84428eddcbd0d (diff) | |
download | barebox-225b19227203911f9bda410746ef4e366a008852.tar.gz barebox-225b19227203911f9bda410746ef4e366a008852.tar.xz |
svn_rev_260
add set function for enetaddr
Diffstat (limited to 'net/eth.c')
-rw-r--r-- | net/eth.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -30,9 +30,31 @@ #include <malloc.h> #include <asm-generic/errno.h> +static int enetaddr_set(struct device_d *dev, struct param_d *param, value_t val) +{ + struct eth_device *edev; + char buf[6]; + + if (dev->type != DEVICE_TYPE_ETHER) + return -EINVAL; + + edev = dev->priv; + + string_to_enet_addr(val.val_str, buf); + edev->set_mac_address(edev, buf); + memcpy(edev->enetaddr, buf, 6); + + if (param->value.val_str) + free(param->value.val_str); + param->value.val_str = strdup(val.val_str); + + + return 0; +} + static struct param_d eth_params[] = { { .name = "ip", .type = PARAM_TYPE_IPADDR,}, - { .name = "mac", .type = PARAM_TYPE_STRING,}, + { .name = "mac", .type = PARAM_TYPE_STRING, .set = enetaddr_set,}, { .name = "gateway", .type = PARAM_TYPE_IPADDR,}, { .name = "netmask", .type = PARAM_TYPE_IPADDR,}, { .name = "serverip", .type = PARAM_TYPE_IPADDR,}, |