summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-01-05 12:08:20 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-01-05 12:08:20 +0100
commit3dbe78ab5c0be677b142a6c111942557ba761f1c (patch)
tree034e6a794e756c9b48f1c5938b381d00e5c5fb37 /include
parent052d1c9e0756db2b02da98c97a6c50d26b8c28ce (diff)
parent8201a940e313cd9c2f989a7af5d6a4fb3f8ab31c (diff)
downloadbarebox-3dbe78ab5c0be677b142a6c111942557ba761f1c.tar.gz
barebox-3dbe78ab5c0be677b142a6c111942557ba761f1c.tar.xz
Merge branch 'for-next/net'
Diffstat (limited to 'include')
-rw-r--r--include/dhcp.h24
-rw-r--r--include/driver.h1
-rw-r--r--include/net.h31
3 files changed, 48 insertions, 8 deletions
diff --git a/include/dhcp.h b/include/dhcp.h
index 0796b30cf1..0977ff42da 100644
--- a/include/dhcp.h
+++ b/include/dhcp.h
@@ -18,8 +18,30 @@ struct dhcp_req_param {
char *client_id;
char *user_class;
char *client_uuid;
+ int retries;
};
-int dhcp(int retries, struct dhcp_req_param *param);
+struct dhcp_result {
+ IPaddr_t ip;
+ IPaddr_t netmask;
+ IPaddr_t gateway;
+ IPaddr_t nameserver;
+ IPaddr_t serverip;
+ char *hostname;
+ char *domainname;
+ char *rootpath;
+ char *devicetree;
+ char *bootfile;
+ char *tftp_server_name;
+ uint32_t leasetime;
+};
+
+struct eth_device;
+
+int dhcp_request(struct eth_device *edev, const struct dhcp_req_param *param,
+ struct dhcp_result **res);
+int dhcp_set_result(struct eth_device *edev, struct dhcp_result *res);
+void dhcp_result_free(struct dhcp_result *res);
+int dhcp(struct eth_device *edev, const struct dhcp_req_param *param);
#endif
diff --git a/include/driver.h b/include/driver.h
index 8617872053..e571fbbec5 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -134,6 +134,7 @@ int device_probe(struct device_d *dev);
/* detect devices attached to this device (cards, disks,...) */
int device_detect(struct device_d *dev);
int device_detect_by_name(const char *devname);
+void device_detect_all(void);
/* Unregister a device. This function can fail, e.g. when the device
* has children.
diff --git a/include/net.h b/include/net.h
index 632b6d5410..a09cb155a8 100644
--- a/include/net.h
+++ b/include/net.h
@@ -58,11 +58,16 @@ struct eth_device {
struct list_head list;
IPaddr_t ipaddr;
- IPaddr_t serverip;
IPaddr_t netmask;
- IPaddr_t gateway;
char ethaddr[6];
char *bootarg;
+ char *linuxdevname;
+
+ bool ifup;
+#define ETH_MODE_DHCP 0
+#define ETH_MODE_STATIC 1
+#define ETH_MODE_DISABLED 2
+ unsigned int global_mode;
};
#define dev_to_edev(d) container_of(d, struct eth_device, dev)
@@ -114,6 +119,8 @@ struct ethernet {
#define IPPROTO_ICMP 1 /* Internet Control Message Protocol */
#define IPPROTO_UDP 17 /* User Datagram Protocol */
+#define IP_BROADCAST 0xffffffff /* Broadcast IP aka 255.255.255.255 */
+
/*
* Internet Protocol (IP) header.
*/
@@ -214,12 +221,19 @@ struct icmphdr {
extern unsigned char *NetRxPackets[PKTBUFSRX];/* Receive packets */
-void net_set_ip(IPaddr_t ip);
+void net_set_ip(struct eth_device *edev, IPaddr_t ip);
void net_set_serverip(IPaddr_t ip);
-void net_set_netmask(IPaddr_t ip);
+void net_set_serverip_empty(IPaddr_t ip);
+void net_set_netmask(struct eth_device *edev, IPaddr_t ip);
void net_set_gateway(IPaddr_t ip);
-IPaddr_t net_get_ip(void);
+void net_set_nameserver(IPaddr_t ip);
+void net_set_domainname(const char *name);
+IPaddr_t net_get_ip(struct eth_device *edev);
IPaddr_t net_get_serverip(void);
+IPaddr_t net_get_gateway(void);
+IPaddr_t net_get_nameserver(void);
+const char *net_get_domainname(void);
+struct eth_device *net_route(IPaddr_t ip);
/* Do the work */
void net_poll(void);
@@ -406,8 +420,6 @@ static inline int is_valid_ether_addr(const u8 *addr)
typedef void rx_handler_f(void *ctx, char *packet, unsigned int len);
-void eth_set_current(struct eth_device *eth);
-struct eth_device *eth_get_current(void);
struct eth_device *eth_get_byname(const char *name);
/**
@@ -440,6 +452,10 @@ static inline char *net_alloc_packet(void)
struct net_connection *net_udp_new(IPaddr_t dest, uint16_t dport,
rx_handler_f *handler, void *ctx);
+struct net_connection *net_udp_eth_new(struct eth_device *edev, IPaddr_t dest,
+ uint16_t dport, rx_handler_f *handler,
+ void *ctx);
+
struct net_connection *net_icmp_new(IPaddr_t dest, rx_handler_f *handler,
void *ctx);
@@ -464,6 +480,7 @@ void led_trigger_network(enum led_trigger trigger);
#define IFUP_FLAG_FORCE (1 << 0)
+int ifup_edev(struct eth_device *edev, unsigned flags);
int ifup(const char *name, unsigned flags);
int ifup_all(unsigned flags);