summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net.h3
-rw-r--r--net/eth.c17
2 files changed, 19 insertions, 1 deletions
diff --git a/include/net.h b/include/net.h
index d59ae5caa7..63e25a012a 100644
--- a/include/net.h
+++ b/include/net.h
@@ -78,7 +78,8 @@ struct eth_device {
struct device_d *dev;
};
-int eth_register(struct eth_device* dev);/* Register network device */
+int eth_register(struct eth_device* dev); /* Register network device */
+void eth_unregister(struct eth_device* dev); /* Unregister network device */
int eth_open(void); /* open the device */
int eth_send(void *packet, int length); /* Send a packet */
diff --git a/net/eth.c b/net/eth.c
index e74ab3b5cf..139893c580 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -148,3 +148,20 @@ int eth_register(struct eth_device *edev)
return 0;
}
+void eth_unregister(struct eth_device *edev)
+{
+ if (edev->param_ip.value)
+ free(edev->param_ip.value);
+ if (edev->param_ethaddr.value)
+ free(edev->param_ethaddr.value);
+ if (edev->param_gateway.value)
+ free(edev->param_gateway.value);
+ if (edev->param_netmask.value)
+ free(edev->param_netmask.value);
+ if (edev->param_serverip.value)
+ free(edev->param_serverip.value);
+
+ if (eth_current == edev)
+ eth_current = NULL;
+}
+