Skip to contentSkip to conversation

barebox picotcp integration (2015.07.19)

RFC In review Antony Pavlov 2 participants 24 messages Jul 19, 2015 – Jul 24, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover barebox picotcp integration (2015.07.19)

I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.picotcp).

This version is based on the latest barebox-next and picotcp v1.5.0 (there is also picotcp v1.5.1, but is has no interested for barebox changes since v1.5.0).

Changes since 2015.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):

* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.

Here are some notes:

1. just now tftp/nfs file transfer on top of picotcp is slower than

     the same transfer on top of legacy network stack;

2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.

N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c404205

3. The picoping command is used insted of traditional ping command.

Antony Pavlov (16):
net_udp_bind(): use uint16_t type for source port fs/tftp.c: drop unused server_port variable fs/nfs.c: use uint16_t for port numbers fs/nfs.c: use SUNRPC_PORT remote port by default
net: change UDP handler function API
net: change net_udp_send() API
net: introduce setudppeerport()
net: import picotcp from github
picotcp: add barebox target support
picotcp: switch to Kbuild
net: add initial picotcp support
net: picotcp: add test_picotcp command
net: picotcp: add ifconfig command
net: picotcp: add ping command
net: picotcp: add route command
sandbox_defconfig: switch to picotcp

 Makefile                                    |    1 +
 arch/sandbox/configs/sandbox_defconfig      |    8 +-
 commands/Kconfig                            |    4 +
 fs/nfs.c                                    |   14 +-
 fs/tftp.c                                   |   30 +-
 include/net.h                               |   61 +-
 include/pico_defines.h                      |    0
 include/stdint.h                            |    1 +
 net/Kconfig                                 |   16 +
 net/Makefile                                |    8 +
 net/dhcp.c                                  |   12 +-
 net/dns.c                                   |    9 +-
 net/eth.c                                   |   71 +
 net/net.c                                   |   95 +-
 net/netconsole.c                            |    7 +-
 net/nfs.c                                   |    6 +-
 net/picotcp.c                               |   20 +
 net/picotcp/.gitignore                      |   25 +
 net/picotcp/COPYING                         |    8 +
 net/picotcp/Kconfig                         |   56 +
 net/picotcp/LICENSE                         |  339 ++++
 net/picotcp/Makefile                        |   30 +
 net/picotcp/README.md                       |   33 +
 net/picotcp/include/arch/pico_barebox.h     |   76 +
 net/picotcp/include/heap.h                  |   83 +
 net/picotcp/include/pico_addressing.h       |   52 +
 net/picotcp/include/pico_config.h           |  231 +++
 net/picotcp/include/pico_constants.h        |   54 +
 net/picotcp/include/pico_device.h           |   54 +
 net/picotcp/include/pico_eth.h              |   21 +
 net/picotcp/include/pico_frame.h            |  122 ++
 net/picotcp/include/pico_module_eth.h       |   33 +
 net/picotcp/include/pico_protocol.h         |   95 ++
 net/picotcp/include/pico_queue.h            |  166 ++
 net/picotcp/include/pico_socket.h           |  268 ++++
 net/picotcp/include/pico_socket_multicast.h |   10 +
 net/picotcp/include/pico_stack.h            |   87 ++
 net/picotcp/include/pico_tree.h             |   93 ++
 net/picotcp/modules/Makefile                |    8 +
 net/picotcp/modules/pico_aodv.h             |  131 ++
 net/picotcp/modules/pico_arp.c              |  531 +++++++
 net/picotcp/modules/pico_arp.h              |   32 +
 net/picotcp/modules/pico_dev_loop.c         |   66 +
 net/picotcp/modules/pico_dev_loop.h         |   15 +
 net/picotcp/modules/pico_dev_mock.h         |   47 +
 net/picotcp/modules/pico_dev_null.c         |   60 +
 net/picotcp/modules/pico_dev_null.h         |   15 +
 net/picotcp/modules/pico_dhcp_client.c      |  960 ++++++++++++
 net/picotcp/modules/pico_dhcp_client.h      |   30 +
 net/picotcp/modules/pico_dhcp_common.c      |  189 +++
 net/picotcp/modules/pico_dhcp_common.h      |  186 +++
 net/picotcp/modules/pico_dns_client.h       |   46 +
 net/picotcp/modules/pico_dns_common.h       |  521 +++++++
 net/picotcp/modules/pico_dns_sd.h           |   90 ++
 net/picotcp/modules/pico_fragments.c        |  345 +++++
 net/picotcp/modules/pico_fragments.h        |   11 +
 net/picotcp/modules/pico_icmp4.c            |  395 +++++
 net/picotcp/modules/pico_icmp4.h            |  162 ++
 net/picotcp/modules/pico_icmp6.h            |  259 ++++
 net/picotcp/modules/pico_igmp.h             |   26 +
 net/picotcp/modules/pico_ipfilter.h         |   29 +
 net/picotcp/modules/pico_ipv4.c             | 1574 +++++++++++++++++++
 net/picotcp/modules/pico_ipv4.h             |  124 ++
 net/picotcp/modules/pico_ipv6.h             |  153 ++
 net/picotcp/modules/pico_ipv6_nd.h          |   26 +
 net/picotcp/modules/pico_mm.h               |   98 ++
 net/picotcp/modules/pico_nat.h              |   90 ++
 net/picotcp/modules/pico_olsr.h             |   32 +
 net/picotcp/modules/pico_socket_tcp.h       |   33 +
 net/picotcp/modules/pico_socket_udp.c       |  250 +++
 net/picotcp/modules/pico_socket_udp.h       |   19 +
 net/picotcp/modules/pico_tcp.h              |  102 ++
 net/picotcp/modules/pico_udp.c              |  216 +++
 net/picotcp/modules/pico_udp.h              |   45 +
 net/picotcp/stack/Makefile                  |    7 +
 net/picotcp/stack/pico_device.c             |  408 +++++
 net/picotcp/stack/pico_frame.c              |  286 ++++
 net/picotcp/stack/pico_protocol.c           |  214 +++
 net/picotcp/stack/pico_socket.c             | 2213 +++++++++++++++++++++++++++
 net/picotcp/stack/pico_socket_multicast.c   |  956 ++++++++++++
 net/picotcp/stack/pico_stack.c              | 1157 ++++++++++++++
 net/picotcp/stack/pico_tree.c               |  575 +++++++
 net/picotcp_ifconfig.c                      |  116 ++
 net/picotcp_ping.c                          |   85 +
 net/picotcp_route.c                         |   36 +
 net/picotcp_test_ipv4.c                     |   96 ++
 86 files changed, 15306 insertions(+), 58 deletions(-)
 create mode 100644 include/pico_defines.h
 create mode 100644 include/stdint.h
 create mode 100644 net/picotcp.c
 create mode 100644 net/picotcp/.gitignore
 create mode 100644 net/picotcp/COPYING
 create mode 100644 net/picotcp/Kconfig
 create mode 100644 net/picotcp/LICENSE
 create mode 100644 net/picotcp/Makefile
 create mode 100644 net/picotcp/README.md
 create mode 100644 net/picotcp/include/arch/pico_barebox.h
 create mode 100644 net/picotcp/include/heap.h
 create mode 100644 net/picotcp/include/pico_addressing.h
 create mode 100644 net/picotcp/include/pico_config.h
 create mode 100644 net/picotcp/include/pico_constants.h
 create mode 100644 net/picotcp/include/pico_device.h
 create mode 100644 net/picotcp/include/pico_eth.h
 create mode 100644 net/picotcp/include/pico_frame.h
 create mode 100644 net/picotcp/include/pico_module_eth.h
 create mode 100644 net/picotcp/include/pico_protocol.h
 create mode 100644 net/picotcp/include/pico_queue.h
 create mode 100644 net/picotcp/include/pico_socket.h
 create mode 100644 net/picotcp/include/pico_socket_multicast.h
 create mode 100644 net/picotcp/include/pico_stack.h
 create mode 100644 net/picotcp/include/pico_tree.h
 create mode 100644 net/picotcp/modules/Makefile
 create mode 100644 net/picotcp/modules/pico_aodv.h
 create mode 100644 net/picotcp/modules/pico_arp.c
 create mode 100644 net/picotcp/modules/pico_arp.h
 create mode 100644 net/picotcp/modules/pico_dev_loop.c
 create mode 100644 net/picotcp/modules/pico_dev_loop.h
 create mode 100644 net/picotcp/modules/pico_dev_mock.h
 create mode 100644 net/picotcp/modules/pico_dev_null.c
 create mode 100644 net/picotcp/modules/pico_dev_null.h
 create mode 100644 net/picotcp/modules/pico_dhcp_client.c
 create mode 100644 net/picotcp/modules/pico_dhcp_client.h
 create mode 100644 net/picotcp/modules/pico_dhcp_common.c
 create mode 100644 net/picotcp/modules/pico_dhcp_common.h
 create mode 100644 net/picotcp/modules/pico_dns_client.h
 create mode 100644 net/picotcp/modules/pico_dns_common.h
 create mode 100644 net/picotcp/modules/pico_dns_sd.h
 create mode 100644 net/picotcp/modules/pico_fragments.c
 create mode 100644 net/picotcp/modules/pico_fragments.h
 create mode 100644 net/picotcp/modules/pico_icmp4.c
 create mode 100644 net/picotcp/modules/pico_icmp4.h
 create mode 100644 net/picotcp/modules/pico_icmp6.h
 create mode 100644 net/picotcp/modules/pico_igmp.h
 create mode 100644 net/picotcp/modules/pico_ipfilter.h
 create mode 100644 net/picotcp/modules/pico_ipv4.c
 create mode 100644 net/picotcp/modules/pico_ipv4.h
 create mode 100644 net/picotcp/modules/pico_ipv6.h
 create mode 100644 net/picotcp/modules/pico_ipv6_nd.h
 create mode 100644 net/picotcp/modules/pico_mm.h
 create mode 100644 net/picotcp/modules/pico_nat.h
 create mode 100644 net/picotcp/modules/pico_olsr.h
 create mode 100644 net/picotcp/modules/pico_socket_tcp.h
 create mode 100644 net/picotcp/modules/pico_socket_udp.c
 create mode 100644 net/picotcp/modules/pico_socket_udp.h
 create mode 100644 net/picotcp/modules/pico_tcp.h
 create mode 100644 net/picotcp/modules/pico_udp.c
 create mode 100644 net/picotcp/modules/pico_udp.h
 create mode 100644 net/picotcp/stack/Makefile
 create mode 100644 net/picotcp/stack/pico_device.c
 create mode 100644 net/picotcp/stack/pico_frame.c
 create mode 100644 net/picotcp/stack/pico_protocol.c
 create mode 100644 net/picotcp/stack/pico_socket.c
 create mode 100644 net/picotcp/stack/pico_socket_multicast.c
 create mode 100644 net/picotcp/stack/pico_stack.c
 create mode 100644 net/picotcp/stack/pico_tree.c
 create mode 100644 net/picotcp_ifconfig.c
 create mode 100644 net/picotcp_ping.c
 create mode 100644 net/picotcp_route.c
 create mode 100644 net/picotcp_test_ipv4.c
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

RFC v2 1/16 net_udp_bind(): use uint16_t type for source port

---
 include/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/net.h +1 -1
index b93e264..d7a4751 100644
@@ -445,7 +445,7 @@ struct net_connection *net_icmp_new(IPaddr_t dest, rx_handler_f *handler,
 
 void net_unregister(struct net_connection *con);
 
-static inline int net_udp_bind(struct net_connection *con, int sport)
+static inline int net_udp_bind(struct net_connection *con, uint16_t sport)
 {
 	con->udp->uh_sport = ntohs(sport);
 	return 0;
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

RFC v2 2/16 fs/tftp.c: drop unused server_port variable

In reply to Antony Pavlov
---
 fs/tftp.c | 3 ---
 1 file changed, 3 deletions(-)
fs/tftp.c +0 -3
index 0de215e..56d4365 100644
@@ -75,7 +75,6 @@ struct file_priv {
 	uint16_t last_block;
 	int state;
 	int err;
-	int server_port;
 	const char *filename;
 	int filesize;
 	uint64_t resend_timeout;
@@ -299,7 +298,6 @@ static void tftp_recv(struct file_priv *priv,
 
 	case TFTP_OACK:
 		tftp_parse_oack(priv, pkt, len);
-		priv->server_port = ntohs(uh_sport);
 		priv->tftp_con->udp->uh_dport = uh_sport;
 
 		if (priv->push) {
@@ -322,7 +320,6 @@ static void tftp_recv(struct file_priv *priv,
 			/* first block received */
 			priv->state = STATE_RDATA;
 			priv->tftp_con->udp->uh_dport = uh_sport;
-			priv->server_port = ntohs(uh_sport);
 			priv->last_block = 0;
 
 			if (priv->block != 1) {	/* Assertion */
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

RFC v2 3/16 fs/nfs.c: use uint16_t for port numbers

In reply to Antony Pavlov
---
 fs/nfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs.c +2 -2
index 5bff54a..0269814 100644
@@ -132,8 +132,8 @@ struct nfs_priv {
 	struct net_connection *con;
 	IPaddr_t server;
 	char *path;
-	unsigned short mount_port;
-	unsigned short nfs_port;
+	uint16_t mount_port;
+	uint16_t nfs_port;
 	uint32_t rpc_id;
 	uint32_t rootfh_len;
 	char rootfh[NFS3_FHSIZE];
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

RFC v2 4/16 fs/nfs.c: use SUNRPC_PORT remote port by default

In reply to Antony Pavlov

pico_socket_connect() needs remote_port != 0.

---
 fs/nfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs.c +1 -1
index 0269814..3824752 100644
@@ -1350,7 +1350,7 @@ static int nfs_probe(struct device_d *dev)
 
 	debug("nfs: server: %s path: %s\n", tmp, npriv->path);
 
-	npriv->con = net_udp_new(npriv->server, 0, nfs_handler, npriv);
+	npriv->con = net_udp_new(npriv->server, SUNRPC_PORT, nfs_handler, npriv);
 	if (IS_ERR(npriv->con)) {
 		ret = PTR_ERR(npriv->con);
 		goto err1;
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

RFC v2 5/16 net: change UDP handler function API

In reply to Antony Pavlov
---
 fs/nfs.c         |  4 +---
 fs/tftp.c        |  9 +++------
 include/net.h    | 15 +++++++++++++--
 net/dhcp.c       |  8 ++------
 net/dns.c        |  7 +++----
 net/net.c        | 12 ++++++++----
 net/netconsole.c |  5 ++---
 net/nfs.c        |  3 +--
 8 files changed, 33 insertions(+), 30 deletions(-)
fs/nfs.c +1 -3
index 3824752..6c649c6 100644
@@ -943,10 +943,8 @@ static int nfs_read_req(struct file_priv *priv, uint64_t offset,
 	return 0;
 }
 
-static void nfs_handler(void *ctx, char *packet, unsigned len)
+static void nfs_handler(struct net_connection *con, char *pkt, unsigned len)
 {
-	char *pkt = net_eth_to_udp_payload(packet);
-
 	nfs_state = STATE_DONE;
 	nfs_packet = pkt;
 	nfs_len = len;
fs/tftp.c +3 -6
index 56d4365..c854da5 100644
@@ -368,14 +368,11 @@ static void tftp_recv(struct file_priv *priv,
 	}
 }
 
-static void tftp_handler(void *ctx, char *packet, unsigned len)
+static void tftp_handler(struct net_connection *con, char *packet, unsigned len)
 {
-	struct file_priv *priv = ctx;
-	char *pkt = net_eth_to_udp_payload(packet);
-	struct udphdr *udp = net_eth_to_udphdr(packet);
+	struct file_priv *priv = con->priv;
 
-	(void)len;
-	tftp_recv(priv, pkt, net_eth_to_udplen(packet), udp->uh_sport);
+	tftp_recv(priv, packet, len, getudppeerport(con));
 }
 
 static struct file_priv *tftp_do_open(struct device_d *dev,
include/net.h +13 -2
index d7a4751..fa2777e 100644
@@ -405,6 +405,8 @@ static inline int is_valid_ether_addr(const u8 *addr)
 }
 
 typedef void rx_handler_f(void *ctx, char *packet, unsigned int len);
+struct net_connection;
+typedef void udp_rx_handler_f(struct net_connection *con, char *packet, unsigned int len);
 
 void eth_set_current(struct eth_device *eth);
 struct eth_device *eth_get_current(void);
@@ -426,8 +428,9 @@ struct net_connection {
 	struct eth_device *edev;
 	struct icmphdr *icmp;
 	unsigned char *packet;
+	unsigned char *rpacket;
 	struct list_head list;
-	rx_handler_f *handler;
+	void *handler;
 	int proto;
 	void *priv;
 };
@@ -438,7 +441,7 @@ 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);
+		udp_rx_handler_f *handler, void *ctx);
 
 struct net_connection *net_icmp_new(IPaddr_t dest, rx_handler_f *handler,
 		void *ctx);
@@ -467,4 +470,12 @@ void led_trigger_network(enum led_trigger trigger);
 int ifup(const char *name, unsigned flags);
 int ifup_all(unsigned flags);
 
+/* NB! return port in network byte order */
+static inline uint16_t getudppeerport(struct net_connection *con)
+{
+	struct udphdr *udp = net_eth_to_udphdr(con->rpacket);
+
+	return udp->uh_sport;
+}
+
 #endif /* __NET_H__ */
net/dhcp.c +2 -6
index e1625ec..d8b6bf7 100644
@@ -588,18 +588,14 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
 /*
  *	Handle DHCP received packets.
  */
-static void dhcp_handler(void *ctx, char *packet, unsigned int len)
+static void dhcp_handler(struct net_connection *con, char *pkt, unsigned int len)
 {
-	char *pkt = net_eth_to_udp_payload(packet);
-	struct udphdr *udp = net_eth_to_udphdr(packet);
 	struct bootp *bp = (struct bootp *)pkt;
 
-	len = net_eth_to_udplen(packet);
-
 	debug("DHCPHandler: got packet: (len=%d) state: %d\n",
 		len, dhcp_state);
 
-	if (bootp_check_packet(pkt, ntohs(udp->uh_sport), len)) /* Filter out pkts we don't want */
+	if (bootp_check_packet(pkt, ntohs(getudppeerport(con)), len)) /* Filter out pkts we don't want */
 		return;
 
 	switch (dhcp_state) {
net/dns.c +3 -4
index 0e16ea2..05106c6 100644
@@ -192,11 +192,10 @@ static void dns_recv(struct header *header, unsigned len)
 	}
 }
 
-static void dns_handler(void *ctx, char *packet, unsigned len)
+static void dns_handler(struct net_connection *con, char *packet, unsigned len)
 {
-	(void)ctx;
-	dns_recv((struct header *)net_eth_to_udp_payload(packet),
-		net_eth_to_udplen(packet));
+	(void)con;
+	dns_recv((struct header *)packet, len);
 }
 
 IPaddr_t resolv(char *host)
net/net.c +8 -4
index e5bd9bb..8461caf 100644
@@ -255,7 +255,7 @@ void net_set_gateway(IPaddr_t gw)
 
 static LIST_HEAD(connection_list);
 
-static struct net_connection *net_new(IPaddr_t dest, rx_handler_f *handler,
+static struct net_connection *net_new(IPaddr_t dest, void *handler,
 		void *ctx)
 {
 	struct eth_device *edev = eth_get_current();
@@ -317,7 +317,7 @@ out:
 }
 
 struct net_connection *net_udp_new(IPaddr_t dest, uint16_t dport,
-		rx_handler_f *handler, void *ctx)
+		udp_rx_handler_f *handler, void *ctx)
 {
 	struct net_connection *con = net_new(dest, handler, ctx);
 
@@ -480,7 +480,10 @@ static int net_handle_udp(unsigned char *pkt, int len)
 	port = ntohs(udp->uh_dport);
 	list_for_each_entry(con, &connection_list, list) {
 		if (con->proto == IPPROTO_UDP && port == ntohs(con->udp->uh_sport)) {
-			con->handler(con->priv, pkt, len);
+			udp_rx_handler_f *handler = con->handler;
+			con->rpacket = pkt;
+			handler(con, net_eth_to_udp_payload(pkt),
+						net_eth_to_udplen(pkt));
 			return 0;
 		}
 	}
@@ -495,7 +498,8 @@ static int net_handle_icmp(unsigned char *pkt, int len)
 
 	list_for_each_entry(con, &connection_list, list) {
 		if (con->proto == IPPROTO_ICMP) {
-			con->handler(con->priv, pkt, len);
+			rx_handler_f *handler = con->handler;
+			handler(con->priv, pkt, len);
 			return 0;
 		}
 	}
net/netconsole.c +2 -3
index 0ee6a76..e7c722f 100644
@@ -44,12 +44,11 @@ struct nc_priv {
 
 static struct nc_priv *g_priv;
 
-static void nc_handler(void *ctx, char *pkt, unsigned len)
+static void nc_handler(struct net_connection *con, char *pkt, unsigned len)
 {
 	struct nc_priv *priv = g_priv;
-	unsigned char *packet = net_eth_to_udp_payload(pkt);
 
-	kfifo_put(priv->fifo, packet, net_eth_to_udplen(pkt));
+	kfifo_put(priv->fifo, pkt, len);
 }
 
 static int nc_getc(struct console_device *cdev)
net/nfs.c +1 -2
index 0a30219..5a907d5 100644
@@ -562,9 +562,8 @@ static int nfs_read_reply(unsigned char *pkt, unsigned len)
 Interfaces of barebox
 **************************************************************************/
 
-static void nfs_handler(void *ctx, char *packet, unsigned len)
+static void nfs_handler(struct net_connection *con, char *pkt, unsigned len)
 {
-	char *pkt = net_eth_to_udp_payload(packet);
 	int ret;
 
 	debug("%s\n", __func__);
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

RFC v2 6/16 net: change net_udp_send() API

In reply to Antony Pavlov
---
 fs/nfs.c         | 2 +-
 fs/tftp.c        | 9 +++++----
 include/net.h    | 2 +-
 net/dhcp.c       | 4 ++--
 net/dns.c        | 2 +-
 net/net.c        | 2 +-
 net/netconsole.c | 2 +-
 net/nfs.c        | 3 ++-
 8 files changed, 14 insertions(+), 12 deletions(-)
fs/nfs.c +1 -1
index 6c649c6..6c55b42 100644
@@ -414,7 +414,7 @@ static int rpc_req(struct nfs_priv *npriv, int rpc_prog, int rpc_proc,
 	npriv->con->udp->uh_dport = hton16(dport);
 
 again:
-	ret = net_udp_send(npriv->con,
+	ret = net_udp_send(npriv->con, payload,
 			sizeof(pkt) + datalen * sizeof(uint32_t));
 
 	nfs_timer_start = get_time_ns();
fs/tftp.c +5 -4
index c854da5..11a10de 100644
@@ -119,7 +119,8 @@ static int tftp_send(struct file_priv *priv)
 	unsigned char *xp;
 	int len = 0;
 	uint16_t *s;
-	unsigned char *pkt = net_udp_get_payload(priv->tftp_con);
+	uint8_t *payload = net_udp_get_payload(priv->tftp_con);
+	uint8_t *pkt = payload;
 	int ret;
 
 	debug("%s: state %d\n", __func__, priv->state);
@@ -168,7 +169,7 @@ static int tftp_send(struct file_priv *priv)
 		break;
 	}
 
-	ret = net_udp_send(priv->tftp_con, len);
+	ret = net_udp_send(priv->tftp_con, payload, len);
 
 	return ret;
 }
@@ -187,7 +188,7 @@ static int tftp_send_write(struct file_priv *priv, void *buf, int len)
 		priv->state = STATE_LAST;
 	len += 4;
 
-	ret = net_udp_send(priv->tftp_con, len);
+	ret = net_udp_send(priv->tftp_con, pkt, len);
 	priv->last_block = priv->block;
 	priv->state = STATE_WAITACK;
 
@@ -501,7 +502,7 @@ static int tftp_do_close(struct file_priv *priv)
 		*pkt++ = htons(TFTP_ERROR);
 		*pkt++ = 0;
 		*pkt++ = 0;
-		net_udp_send(priv->tftp_con, 6);
+		net_udp_send(priv->tftp_con, (char *)pkt, 6);
 	}
 
 	net_unregister(priv->tftp_con);
include/net.h +1 -1
index fa2777e..90cbb09 100644
@@ -460,7 +460,7 @@ static inline void *net_udp_get_payload(struct net_connection *con)
 		sizeof(struct udphdr);
 }
 
-int net_udp_send(struct net_connection *con, int len);
+int net_udp_send(struct net_connection *con, char *payload, int len);
 int net_icmp_send(struct net_connection *con, int len);
 
 void led_trigger_network(enum led_trigger trigger);
net/dhcp.c +2 -2
index d8b6bf7..e26acdc 100644
@@ -487,7 +487,7 @@ static int bootp_request(void)
 
 	dhcp_state = SELECTING;
 
-	ret = net_udp_send(dhcp_con, sizeof(*bp) + ext_len);
+	ret = net_udp_send(dhcp_con, payload, sizeof(*bp) + ext_len);
 
 	return ret;
 }
@@ -582,7 +582,7 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
 				OfferedIP);
 
 	debug("Transmitting DHCPREQUEST packet\n");
-	net_udp_send(dhcp_con, sizeof(*bp) + extlen);
+	net_udp_send(dhcp_con, payload, sizeof(*bp) + extlen);
 }
 
 /*
net/dns.c +1 -1
index 05106c6..7bb664c 100644
@@ -109,7 +109,7 @@ static int dns_send(char *name)
 	*p++ = 0;
 	*p++ = 1;				/* Class: inet, 0x0001 */
 
-	ret = net_udp_send(dns_con, p - packet);
+	ret = net_udp_send(dns_con, packet, p - packet);
 
 	free(fullname);
 
net/net.c +1 -1
index 8461caf..23a9173 100644
@@ -363,7 +363,7 @@ static int net_ip_send(struct net_connection *con, int len)
 	return eth_send(con->edev, con->packet, ETHER_HDR_SIZE + sizeof(struct iphdr) + len);
 }
 
-int net_udp_send(struct net_connection *con, int len)
+int net_udp_send(struct net_connection *con, char *payload, int len)
 {
 	con->udp->uh_ulen = htons(len + 8);
 	con->udp->uh_sum = 0;
net/netconsole.c +1 -1
index e7c722f..11a6d30 100644
@@ -100,7 +100,7 @@ static void nc_putc(struct console_device *cdev, char c)
 	*packet = c;
 
 	priv->busy = 1;
-	net_udp_send(priv->con, 1);
+	net_udp_send(priv->con, packet, 1);
 	priv->busy = 0;
 }
 
net/nfs.c +2 -1
index 5a907d5..41ad197 100644
@@ -225,7 +225,8 @@ static int rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
 		sport = nfs_server_nfs_port;
 
 	nfs_con->udp->uh_dport = htons(sport);
-	ret = net_udp_send(nfs_con, sizeof(pkt) + datalen * sizeof(uint32_t));
+	ret = net_udp_send(nfs_con, payload,
+				sizeof(pkt) + datalen * sizeof(uint32_t));
 
 	return ret;
 }
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

RFC v2 7/16 net: introduce setudppeerport()

In reply to Antony Pavlov
---
 fs/nfs.c      | 2 +-
 fs/tftp.c     | 9 +++++----
 include/net.h | 7 +++++++
 3 files changed, 13 insertions(+), 5 deletions(-)
fs/nfs.c +1 -1
index 6c55b42..8910fd1 100644
@@ -411,7 +411,7 @@ static int rpc_req(struct nfs_priv *npriv, int rpc_prog, int rpc_proc,
 	memcpy(payload, &pkt, sizeof(pkt));
 	memcpy(payload + sizeof(pkt), data, datalen * sizeof(uint32_t));
 
-	npriv->con->udp->uh_dport = hton16(dport);
+	setudppeerport(npriv->con, htons(dport));
 
 again:
 	ret = net_udp_send(npriv->con, payload,
fs/tftp.c +5 -4
index 11a10de..575f064 100644
@@ -177,7 +177,7 @@ static int tftp_send(struct file_priv *priv)
 static int tftp_send_write(struct file_priv *priv, void *buf, int len)
 {
 	uint16_t *s;
-	unsigned char *pkt = net_udp_get_payload(priv->tftp_con);
+	uint8_t *pkt = net_udp_get_payload(priv->tftp_con);
 	int ret;
 
 	s = (uint16_t *)pkt;
@@ -293,13 +293,14 @@ static void tftp_recv(struct file_priv *priv,
 			priv->state = STATE_DONE;
 			break;
 		}
-		priv->tftp_con->udp->uh_dport = uh_sport;
+		setudppeerport(priv->tftp_con, uh_sport);
+
 		priv->state = STATE_WDATA;
 		break;
 
 	case TFTP_OACK:
 		tftp_parse_oack(priv, pkt, len);
-		priv->tftp_con->udp->uh_dport = uh_sport;
+		setudppeerport(priv->tftp_con, uh_sport);
 
 		if (priv->push) {
 			/* send first block */
@@ -320,7 +321,7 @@ static void tftp_recv(struct file_priv *priv,
 		if (priv->state == STATE_RRQ || priv->state == STATE_OACK) {
 			/* first block received */
 			priv->state = STATE_RDATA;
-			priv->tftp_con->udp->uh_dport = uh_sport;
+			setudppeerport(priv->tftp_con, uh_sport);
 			priv->last_block = 0;
 
 			if (priv->block != 1) {	/* Assertion */
include/net.h +7 -0
index 90cbb09..ed63d3c 100644
@@ -478,4 +478,11 @@ static inline uint16_t getudppeerport(struct net_connection *con)
 	return udp->uh_sport;
 }
 
+#include <byteorder.h>
+
+static inline void setudppeerport(struct net_connection *con, uint16_t dport)
+{
+	con->udp->uh_dport = dport;
+}
+
 #endif /* __NET_H__ */
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

RFC v2 8/16 net: import picotcp from github

In reply to Antony Pavlov

Original repo: https://github.com/tass-belgium/picotcp

The last original repo commit is v1.5.0

commit f6d139147d86d74f9a53ba3c02b2a5b276858d95
Author: laurens <[email protected]>
Date: Thu Jun 25 12:54:38 2015 +0100

Remove old check from fragments module

from development branch

Import mini-howto:

    $ cd barebox.git
    $ rm -rf net/picotcp
    $ git clone --branch ${branch_name} ${PICOTCP_REPO} net/picotcp
    $ rm -rf net/picotcp/*
    $ ( cd net/picotcp; git checkout .gitignore COPYING LICENSE README.md )
    $ ( cd net/picotcp; mkdir include modules stack )
    $ ( cd net/picotcp/include; git checkout heap.h pico_addressing.h pico_config.h pico_constants.h pico_device.h pico_eth.h pico_frame.h pico_module_eth.h pico_protocol.h pico_queue.h pico_socket.h pico_socket_multicast.h pico_stack.h pico_tree.h )
    $ ( cd net/picotcp/modules; git checkout pico_aodv.h pico_arp.c pico_arp.h pico_dev_loop.c pico_dev_loop.h pico_dev_mock.h pico_dev_null.c pico_dev_null.h pico_dhcp_client.c pico_dhcp_client.h pico_dhcp_common.c pico_dhcp_common.h pico_dns_client.h pico_dns_common.h pico_dns_sd.h pico_fragments.c pico_fragments.h pico_icmp4.c pico_icmp4.h pico_icmp6.h pico_igmp.h pico_ipfilter.h pico_ipv4.c pico_ipv4.h pico_ipv6.h pico_ipv6_nd.h pico_mm.h pico_nat.h pico_olsr.h pico_socket_tcp.h pico_socket_udp.c pico_socket_udp.h pico_tcp.h pico_udp.c pico_udp.h )
    $ ( cd net/picotcp/stack; git checkout pico_device.c pico_frame.c pico_protocol.c pico_socket.c pico_socket_multicast.c pico_stack.c pico_tree.c )
    $ rm -rf net/picotcp/.git
    $ git add net/picotcp/
    $ git commit -s
---
 net/picotcp/.gitignore                      |   24 +
 net/picotcp/COPYING                         |    8 +
 net/picotcp/LICENSE                         |  339 ++++
 net/picotcp/README.md                       |   33 +
 net/picotcp/include/heap.h                  |   83 +
 net/picotcp/include/pico_addressing.h       |   52 +
 net/picotcp/include/pico_config.h           |  229 +++
 net/picotcp/include/pico_constants.h        |   54 +
 net/picotcp/include/pico_device.h           |   54 +
 net/picotcp/include/pico_eth.h              |   21 +
 net/picotcp/include/pico_frame.h            |  122 ++
 net/picotcp/include/pico_module_eth.h       |   33 +
 net/picotcp/include/pico_protocol.h         |   95 ++
 net/picotcp/include/pico_queue.h            |  166 ++
 net/picotcp/include/pico_socket.h           |  268 ++++
 net/picotcp/include/pico_socket_multicast.h |   10 +
 net/picotcp/include/pico_stack.h            |   87 ++
 net/picotcp/include/pico_tree.h             |   93 ++
 net/picotcp/modules/pico_aodv.h             |  131 ++
 net/picotcp/modules/pico_arp.c              |  531 +++++++
 net/picotcp/modules/pico_arp.h              |   32 +
 net/picotcp/modules/pico_dev_loop.c         |   66 +
 net/picotcp/modules/pico_dev_loop.h         |   15 +
 net/picotcp/modules/pico_dev_mock.h         |   47 +
 net/picotcp/modules/pico_dev_null.c         |   60 +
 net/picotcp/modules/pico_dev_null.h         |   15 +
 net/picotcp/modules/pico_dhcp_client.c      |  960 ++++++++++++
 net/picotcp/modules/pico_dhcp_client.h      |   30 +
 net/picotcp/modules/pico_dhcp_common.c      |  189 +++
 net/picotcp/modules/pico_dhcp_common.h      |  186 +++
 net/picotcp/modules/pico_dns_client.h       |   46 +
 net/picotcp/modules/pico_dns_common.h       |  521 +++++++
 net/picotcp/modules/pico_dns_sd.h           |   90 ++
 net/picotcp/modules/pico_fragments.c        |  345 +++++
 net/picotcp/modules/pico_fragments.h        |   11 +
 net/picotcp/modules/pico_icmp4.c            |  395 +++++
 net/picotcp/modules/pico_icmp4.h            |  162 ++
 net/picotcp/modules/pico_icmp6.h            |  259 ++++
 net/picotcp/modules/pico_igmp.h             |   26 +
 net/picotcp/modules/pico_ipfilter.h         |   29 +
 net/picotcp/modules/pico_ipv4.c             | 1574 +++++++++++++++++++
 net/picotcp/modules/pico_ipv4.h             |  124 ++
 net/picotcp/modules/pico_ipv6.h             |  153 ++
 net/picotcp/modules/pico_ipv6_nd.h          |   26 +
 net/picotcp/modules/pico_mm.h               |   98 ++
 net/picotcp/modules/pico_nat.h              |   90 ++
 net/picotcp/modules/pico_olsr.h             |   32 +
 net/picotcp/modules/pico_socket_tcp.h       |   33 +
 net/picotcp/modules/pico_socket_udp.c       |  250 +++
 net/picotcp/modules/pico_socket_udp.h       |   19 +
 net/picotcp/modules/pico_tcp.h              |  102 ++
 net/picotcp/modules/pico_udp.c              |  216 +++
 net/picotcp/modules/pico_udp.h              |   45 +
 net/picotcp/stack/pico_device.c             |  408 +++++
 net/picotcp/stack/pico_frame.c              |  286 ++++
 net/picotcp/stack/pico_protocol.c           |  214 +++
 net/picotcp/stack/pico_socket.c             | 2213 +++++++++++++++++++++++++++
 net/picotcp/stack/pico_socket_multicast.c   |  956 ++++++++++++
 net/picotcp/stack/pico_stack.c              | 1157 ++++++++++++++
 net/picotcp/stack/pico_tree.c               |  575 +++++++
 60 files changed, 14488 insertions(+)
net/picotcp/.gitignore new file +24 -0
new file mode 100644
index 0000000..88593da
@@ -0,0 +1,24 @@
+*.d
+*.o
+*.a
+*.out
+*.swp
+tags
+build
+UNIT_*
+core
+core.*
+.DS_Store
+cscope.files
+cscope.out
+*.so
+*.aux
+*.pdf
+*.toc
+*.gz
+*.log
+*.pyc
+*.elf
+*.gcov
+*.gcda
+*.gcno
net/picotcp/COPYING new file +8 -0
new file mode 100644
index 0000000..8a5fe4b
@@ -0,0 +1,8 @@
+PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems.
+
+Released under the GNU General Public License, version 2.
+See LICENSE for details.
+
+Different licensing models may exist, at the sole discretion of
+the Copyright holders.
+
net/picotcp/LICENSE new file +339 -0

339 lines not on this page · raw message

net/picotcp/README.md new file +33 -0
new file mode 100644
index 0000000..9e32eb7
@@ -0,0 +1,33 @@
+picoTCP
+
+---------------
+
+Welcome to the one and only <font color=ff00f0>picoTCP repository</font>. 
+
+picoTCP is a small-footprint, modular TCP/IP stack designed for embedded systems and the Internet of Things. It's actively being developed by *[Altran Intelligent Systems](http://intelligent-systems.altran.com/)*.
+
+This code is released under the terms of GNU GPL v2 only. Some rights reserved.
+Other licenses may apply at the sole discretion of the copyright holders.
+
+Learn how to use picoTCP in your project by going through the Getting Started guide on our [GitHub wiki](https://github.com/tass-belgium/picotcp/wiki).
+
+For more information visit the [picoTCP website](http://www.picotcp.com), send us an email or contact us on [Twitter](https://twitter.com/picotcp), [Facebook](https://www.facebook.com/picoTCP) or [Reddit](http://www.reddit.com/r/picotcp/).
+
+Wondering about picoTCP's code quality? Check [our TiCS score](http://tics.picotcp.com:42506/TIOBEPortal/TICS/treeviewer?)
+
+
+---------------
+
+Continuous integration
+
+Jenkins Functional tests: 
+[![Jenkins autotest](http://jenkins.picotcp.com:8080/buildStatus/icon?job=PicoTCP_rel_autotest)](http://jenkins.picotcp.com:8080/job/PicoTCP_rel_autotest)
+
+Jenkins Unit tests      : 
+[![Jenkins unit tests](http://jenkins.picotcp.com:8080/buildStatus/icon?job=PicoTCP_rel_unit_tests)](http://jenkins.picotcp.com:8080/job/PicoTCP_rel_unit_tests)
+
+Jenkins RFC compliance  :
+[![Jenkins RFC Compliance](http://jenkins.picotcp.com:8080/buildStatus/icon?job=PicoTCP_rel_RF_mbed)](http://jenkins.picotcp.com:8080/job/PicoTCP_rel_RF_mbed)
+
+Jenkins TICS quality    :
+[![Jenkins TICS](http://jenkins.picotcp.com:8080/buildStatus/icon?job=PicoTCP_rel_TICS)](http://jenkins.picotcp.com:8080/job/PicoTCP_rel_TICS/)
net/picotcp/include/heap.h new file +83 -0

83 lines not on this page · raw message

net/picotcp/include/pico_addressing.h new file +52 -0

52 lines not on this page · raw message

net/picotcp/include/pico_config.h new file +229 -0

229 lines not on this page · raw message

net/picotcp/include/pico_constants.h new file +54 -0

54 lines not on this page · raw message

net/picotcp/include/pico_device.h new file +54 -0

54 lines not on this page · raw message

net/picotcp/include/pico_eth.h new file +21 -0
new file mode 100644
index 0000000..89846c7
@@ -0,0 +1,21 @@
+/*********************************************************************
+   PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
+   See LICENSE and COPYING for usage.
+
+ *********************************************************************/
+#ifndef INCLUDE_PICO_ETH
+#define INCLUDE_PICO_ETH
+#include "pico_addressing.h"
+#include "pico_ipv4.h"
+#include "pico_ipv6.h"
+
+
+PACKED_STRUCT_DEF pico_eth_hdr {
+    uint8_t daddr[6];
+    uint8_t saddr[6];
+    uint16_t proto;
+};
+
+#define PICO_SIZE_ETHHDR 14
+
+#endif
net/picotcp/include/pico_frame.h new file +122 -0

122 lines not on this page · raw message

net/picotcp/include/pico_module_eth.h new file +33 -0
new file mode 100644
index 0000000..c86680d
@@ -0,0 +1,33 @@
+/*********************************************************************
+   PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
+   See LICENSE and COPYING for usage.
+
+ *********************************************************************/
+#ifndef PICO_MODULE_IPV4_H
+#define PICO_MODULE_IPV4_H
+
+struct pico_arp_entry {
+    struct eth dest;
+#ifdef PICO_CONFIG_IPV4
+    struct ipv4 addr_ipv4;
+#endif
+    RB_ENTRY(pico_arp_entry) node;
+};
+
+/* Configured device */
+struct pico_eth_link {
+    struct pico_device *dev;
+    struct eth address;
+    struct eth netmask;
+    RB_ENTRY(pico_eth_link) node;
+};
+
+#ifndef IS_MODULE_ETH
+# define _mod extern
+#else
+# define _mod
+#endif
+_mod struct pico_module pico_module_eth;
+#undef _mod
+
+#endif
net/picotcp/include/pico_protocol.h new file +95 -0

95 lines not on this page · raw message

net/picotcp/include/pico_queue.h new file +166 -0

166 lines not on this page · raw message

net/picotcp/include/pico_socket.h new file +268 -0

268 lines not on this page · raw message

net/picotcp/include/pico_socket_multicast.h new file +10 -0
new file mode 100644
index 0000000..44c30c5
@@ -0,0 +1,10 @@
+#ifndef PICO_SOCKET_MULTICAST_H
+#define PICO_SOCKET_MULTICAST_H
+int pico_socket_mcast_filter(struct pico_socket *s, union pico_address *mcast_group, union pico_address *src);
+void pico_multicast_delete(struct pico_socket *s);
+int pico_setsockopt_mcast(struct pico_socket *s, int option, void *value);
+int pico_getsockopt_mcast(struct pico_socket *s, int option, void *value);
+int pico_udp_get_mc_ttl(struct pico_socket *s, uint8_t *ttl);
+int pico_udp_set_mc_ttl(struct pico_socket *s, void *_ttl);
+
+#endif
net/picotcp/include/pico_stack.h new file +87 -0

87 lines not on this page · raw message

net/picotcp/include/pico_tree.h new file +93 -0

93 lines not on this page · raw message

net/picotcp/modules/pico_aodv.h new file +131 -0

131 lines not on this page · raw message

net/picotcp/modules/pico_arp.c new file +531 -0

531 lines not on this page · raw message

net/picotcp/modules/pico_arp.h new file +32 -0
new file mode 100644
index 0000000..18e1f69
@@ -0,0 +1,32 @@
+/*********************************************************************
+   PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
+   See LICENSE and COPYING for usage.
+
+ *********************************************************************/
+#ifndef INCLUDE_PICO_ARP
+#define INCLUDE_PICO_ARP
+#include "pico_eth.h"
+#include "pico_device.h"
+
+int pico_arp_receive(struct pico_frame *);
+
+
+struct pico_eth *pico_arp_get(struct pico_frame *f);
+int32_t pico_arp_request(struct pico_device *dev, struct pico_ip4 *dst, uint8_t type);
+
+#define PICO_ARP_STATUS_REACHABLE 0x00
+#define PICO_ARP_STATUS_PERMANENT 0x01
+#define PICO_ARP_STATUS_STALE     0x02
+
+#define PICO_ARP_QUERY    0x00
+#define PICO_ARP_PROBE    0x01
+#define PICO_ARP_ANNOUNCE 0x02
+
+struct pico_eth *pico_arp_lookup(struct pico_ip4 *dst);
+struct pico_ip4 *pico_arp_reverse_lookup(struct pico_eth *dst);
+int pico_arp_create_entry(uint8_t*hwaddr, struct pico_ip4 ipv4, struct pico_device*dev);
+int pico_arp_get_neighbors(struct pico_device *dev, struct pico_ip4 *neighbors, int maxlen);
+void pico_arp_register_ipconflict(struct pico_ip4 *ip, struct pico_eth *mac, void (*cb)(void));
+void pico_arp_postpone(struct pico_frame *f);
+void pico_arp_init(void);
+#endif
net/picotcp/modules/pico_dev_loop.c new file +66 -0

66 lines not on this page · raw message

net/picotcp/modules/pico_dev_loop.h new file +15 -0
new file mode 100644
index 0000000..6cb8de1
@@ -0,0 +1,15 @@
+/*********************************************************************
+   PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
+   See LICENSE and COPYING for usage.
+
+ *********************************************************************/
+#ifndef INCLUDE_PICO_LOOP
+#define INCLUDE_PICO_LOOP
+#include "pico_config.h"
+#include "pico_device.h"
+
+void pico_loop_destroy(struct pico_device *loop);
+struct pico_device *pico_loop_create(void);
+
+#endif
+
net/picotcp/modules/pico_dev_mock.h new file +47 -0

47 lines not on this page · raw message

net/picotcp/modules/pico_dev_null.c new file +60 -0

60 lines not on this page · raw message

net/picotcp/modules/pico_dev_null.h new file +15 -0
new file mode 100644
index 0000000..a0eb98e
@@ -0,0 +1,15 @@
+/*********************************************************************
+   PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved.
+   See LICENSE and COPYING for usage.
+
+ *********************************************************************/
+#ifndef INCLUDE_PICO_NULL
+#define INCLUDE_PICO_NULL
+#include "pico_config.h"
+#include "pico_device.h"
+
+void pico_null_destroy(struct pico_device *null);
+struct pico_device *pico_null_create(char *name);
+
+#endif
+
net/picotcp/modules/pico_dhcp_client.c new file +960 -0

332 lines not on this page · raw message

net/picotcp/modules/pico_dhcp_client.h new file +30 -0
new file mode 100644
index 0000000..2b5bbf9

Lines of this file are not shown. View the raw message.

net/picotcp/modules/pico_dhcp_common.c new file +189 -0

189 lines not on this page · raw message

net/picotcp/modules/pico_dhcp_common.h new file +186 -0

186 lines not on this page · raw message

net/picotcp/modules/pico_dns_client.h new file +46 -0

46 lines not on this page · raw message

net/picotcp/modules/pico_dns_common.h new file +521 -0

521 lines not on this page · raw message

net/picotcp/modules/pico_dns_sd.h new file +90 -0

90 lines not on this page · raw message

net/picotcp/modules/pico_fragments.c new file +345 -0

345 lines not on this page · raw message

net/picotcp/modules/pico_fragments.h new file +11 -0
new file mode 100644
index 0000000..e51ec44

Lines of this file are not shown. View the raw message.

net/picotcp/modules/pico_icmp4.c new file +395 -0

395 lines not on this page · raw message

net/picotcp/modules/pico_icmp4.h new file +162 -0

162 lines not on this page · raw message

net/picotcp/modules/pico_icmp6.h new file +259 -0

259 lines not on this page · raw message

net/picotcp/modules/pico_igmp.h new file +26 -0
new file mode 100644
index 0000000..03d6102

Lines of this file are not shown. View the raw message.

net/picotcp/modules/pico_ipfilter.h new file +29 -0
new file mode 100644
index 0000000..fb92e67

Lines of this file are not shown. View the raw message.

net/picotcp/modules/pico_ipv4.c new file +1574 -0

1,574 lines not on this page · raw message

net/picotcp/modules/pico_ipv4.h new file +124 -0

124 lines not on this page · raw message

net/picotcp/modules/pico_ipv6.h new file +153 -0

153 lines not on this page · raw message

net/picotcp/modules/pico_ipv6_nd.h new file +26 -0
new file mode 100644
index 0000000..f709b1e

Lines of this file are not shown. View the raw message.

net/picotcp/modules/pico_mm.h new file +98 -0

98 lines not on this page · raw message

net/picotcp/modules/pico_nat.h new file +90 -0

90 lines not on this page · raw message

net/picotcp/modules/pico_olsr.h new file +32 -0
new file mode 100644
index 0000000..11c3bf0

Lines of this file are not shown. View the raw message.

net/picotcp/modules/pico_socket_tcp.h new file +33 -0
new file mode 100644
index 0000000..6479103

Lines of this file are not shown. View the raw message.

net/picotcp/modules/pico_socket_udp.c new file +250 -0

250 lines not on this page · raw message

net/picotcp/modules/pico_socket_udp.h new file +19 -0
new file mode 100644
index 0000000..6b3a4c9

Lines of this file are not shown. View the raw message.

net/picotcp/modules/pico_tcp.h new file +102 -0

102 lines not on this page · raw message

net/picotcp/modules/pico_udp.c new file +216 -0

216 lines not on this page · raw message

net/picotcp/modules/pico_udp.h new file +45 -0

45 lines not on this page · raw message

net/picotcp/stack/pico_device.c new file +408 -0

408 lines not on this page · raw message

net/picotcp/stack/pico_frame.c new file +286 -0

286 lines not on this page · raw message

net/picotcp/stack/pico_protocol.c new file +214 -0

214 lines not on this page · raw message

net/picotcp/stack/pico_socket.c new file +2213 -0

2,213 lines not on this page · raw message

net/picotcp/stack/pico_socket_multicast.c new file +956 -0

956 lines not on this page · raw message

net/picotcp/stack/pico_stack.c new file +1157 -0

1,157 lines not on this page · raw message

net/picotcp/stack/pico_tree.c new file +575 -0

575 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Part of the diff is not shown here. View the raw message.

#9 lore raw

RFC v2 9/16 picotcp: add barebox target support

In reply to Antony Pavlov
---
 net/picotcp/include/arch/pico_barebox.h | 76 +++++++++++++++++++++++++++++++++
 net/picotcp/include/pico_config.h       |  2 +
 2 files changed, 78 insertions(+)
net/picotcp/include/arch/pico_barebox.h new file +76 -0
new file mode 100644
index 0000000..11e6ed3
@@ -0,0 +1,76 @@
+#ifndef PICO_SUPPORT_BAREBOX
+#define PICO_SUPPORT_BAREBOX
+
+#include <string.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <clock.h>
+#include <linux/math64.h>
+
+/*
+   #define MEMORY_MEASURE
+ */
+#define dbg printf
+
+#define stack_fill_pattern(...) do {} while(0)
+#define stack_count_free_words(...) do {} while(0)
+#define stack_get_free_words() (0)
+
+/* measure allocated memory */
+#ifdef MEMORY_MEASURE
+extern uint32_t max_mem;
+extern uint32_t cur_mem;
+
+static inline void *pico_zalloc(int x)
+{
+    uint32_t *ptr;
+    if ((cur_mem + x) > (10 * 1024))
+        return NULL;
+
+    ptr = (uint32_t *)calloc(x + 4, 1);
+    *ptr = (uint32_t)x;
+    cur_mem += x;
+    if (cur_mem > max_mem) {
+        max_mem = cur_mem;
+    }
+
+    return (void*)(ptr + 1);
+}
+
+static inline void pico_free(void *x)
+{
+    uint32_t *ptr = (uint32_t*)(((uint8_t *)x) - 4);
+    cur_mem -= *ptr;
+    free(ptr);
+}
+#else
+
+#define pico_zalloc(x) calloc(x, 1)
+#define pico_free(x) free(x)
+#endif
+
+static inline uint32_t PICO_TIME(void)
+{
+    uint64_t time;
+
+    time = get_time_ns();
+    do_div(time, 1000000000);
+
+    return (uint32_t) time;
+}
+
+static inline uint32_t PICO_TIME_MS(void)
+{
+    uint64_t time;
+
+    time = get_time_ns();
+    do_div(time, 1000000);
+
+    return (uint32_t) time;
+}
+
+static inline void PICO_IDLE(void)
+{
+}
+
+#endif /* PICO_SUPPORT_BAREBOX */
net/picotcp/include/pico_config.h +2 -0
index 6b9c040..79aaadc 100644
@@ -211,6 +211,8 @@ static inline uint64_t long_long_be(uint64_t le)
 # include "arch/pico_none.h"
 #elif defined GENERIC
 # include "arch/pico_generic_gcc.h"
+#elif defined __BAREBOX__
+# include "arch/pico_barebox.h"
 #elif defined __KERNEL__
 # include "arch/pico_linux.h"
 /* #elif defined ... */
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

RFC v2 10/16 picotcp: switch to Kbuild

In reply to Antony Pavlov
---
 net/picotcp/.gitignore       |  1 +
 net/picotcp/Kconfig          | 34 ++++++++++++++++++++++++++++++++++
 net/picotcp/Makefile         | 30 ++++++++++++++++++++++++++++++
 net/picotcp/modules/Makefile |  8 ++++++++
 net/picotcp/stack/Makefile   |  7 +++++++
 5 files changed, 80 insertions(+)
net/picotcp/.gitignore +1 -0
index 88593da..10f36c8 100644
@@ -22,3 +22,4 @@ cscope.out
 *.gcov
 *.gcda
 *.gcno
+*.o.cmd
net/picotcp/Kconfig new file +34 -0
new file mode 100644
index 0000000..3882984
@@ -0,0 +1,34 @@
+if NET_PICOTCP
+
+config NET_PICO_SUPPORT_IPV4
+	bool
+	default y if NET_PICOTCP
+
+config NET_PICO_SUPPORT_IPFRAG
+	bool
+	default y if NET_PICO_SUPPORT_IPV4
+
+config NET_PICO_SUPPORT_ICMP4
+	bool
+	default y if NET_PICO_SUPPORT_IPV4
+
+config NET_PICO_SUPPORT_UDP
+	bool
+	default y if NET_PICO_SUPPORT_IPV4
+
+
+config NET_PICO_SUPPORT_ETH
+	bool
+	default y if NET_PICOTCP
+
+config NET_PICO_SUPPORT_DEVLOOP
+	bool
+	default y if NET_PICOTCP
+
+comment "Misc options"
+
+config NET_PICO_BIGENDIAN
+	bool
+	prompt "bigendian picotcp"
+
+endif # NET_PICOTCP
net/picotcp/Makefile new file +30 -0
new file mode 100644
index 0000000..8127453
@@ -0,0 +1,30 @@
+ifeq ($(CONFIG_NET_PICO_SUPPORT_IPV4),y)
+CPPFLAGS += -DPICO_SUPPORT_IPV4
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_ICMP4),y)
+CPPFLAGS += -DPICO_SUPPORT_ICMP4 -DPICO_SUPPORT_PING
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_IPFRAG),y)
+CPPFLAGS += -DPICO_SUPPORT_IPFRAG
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_UDP),y)
+CPPFLAGS += -DPICO_SUPPORT_UDP
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_ETH),y)
+CPPFLAGS += -DPICO_SUPPORT_ETH
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_DEVLOOP),y)
+CPPFLAGS += -DPICO_SUPPORT_DEVLOOP
+endif
+
+ifeq ($(CONFIG_NET_PICO_BIGENDIAN),y)
+CPPFLAGS += -DPICO_BIGENDIAN
+endif
+
+obj-y += modules/
+obj-y += stack/
net/picotcp/modules/Makefile new file +8 -0
new file mode 100644
index 0000000..2fa2261
@@ -0,0 +1,8 @@
+obj-$(CONFIG_NET_PICO_SUPPORT_IPV4) += pico_ipv4.o
+obj-$(CONFIG_NET_PICO_SUPPORT_IPFRAG) += pico_fragments.o
+obj-$(CONFIG_NET_PICO_SUPPORT_ICMP4) += pico_icmp4.o
+obj-$(CONFIG_NET_PICO_SUPPORT_UDP) += pico_udp.o pico_socket_udp.o
+
+obj-$(CONFIG_NET_PICO_SUPPORT_ETH) += pico_arp.o
+obj-$(CONFIG_NET_PICO_SUPPORT_DEVLOOP) += pico_dev_loop.o
+obj-y += pico_dev_null.o
net/picotcp/stack/Makefile new file +7 -0
new file mode 100644
index 0000000..13be8d0
@@ -0,0 +1,7 @@
+obj-y += pico_device.o
+obj-y += pico_frame.o
+obj-y += pico_protocol.o
+obj-y += pico_socket.o
+obj-y += pico_socket_multicast.o
+obj-y += pico_stack.o
+obj-y += pico_tree.o
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#11 lore raw

RFC v2 11/16 net: add initial picotcp support

In reply to Antony Pavlov

This commit adds initial picotcp support:

* build stuff (Kbuild fixes and fake stdint.h);
* "pico_adapter" code for connecting barebox ethernet interfaces to picotcp;
* picotcp start initialization and necessary poller.

---
 Makefile               |  1 +
 commands/Kconfig       |  4 +++
 include/net.h          | 37 ++++++++++++++++++++++-
 include/pico_defines.h |  0
 include/stdint.h       |  1 +
 net/Kconfig            | 16 ++++++++++
 net/Makefile           |  3 ++
 net/eth.c              | 71 +++++++++++++++++++++++++++++++++++++++++++
 net/net.c              | 81 +++++++++++++++++++++++++++++++++++++++++++++++++-
 net/picotcp.c          | 20 +++++++++++++
 10 files changed, 232 insertions(+), 2 deletions(-)
Makefile +1 -0
index 5a7fd5f..972b5db 100644
@@ -292,6 +292,7 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve
 # Use LINUXINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
 LINUXINCLUDE    := -Iinclude -I$(srctree)/dts/include \
+                   -I$(srctree)/net/picotcp/include -I$(srctree)/net/picotcp/modules \
                    $(if $(KBUILD_SRC), -I$(srctree)/include) \
 		   -I$(srctree)/arch/$(ARCH)/include \
 		   -I$(objtree)/arch/$(ARCH)/include \
commands/Kconfig +4 -0
index 5571902..77193cb 100644
@@ -1184,6 +1184,7 @@ menu "Network"
 config CMD_DHCP
 	bool
 	select NET_DHCP
+	depends on NET_LEGACY
 	prompt "dhcp"
 	help
 	  DHCP client to obtain IP or boot params
@@ -1210,6 +1211,7 @@ config CMD_HOST
 config NET_CMD_IFUP
 	bool
 	prompt "ifup"
+	depends on NET_LEGACY
 	help
 	  Bring up network interfaces based on config files.
 
@@ -1237,6 +1239,7 @@ config CMD_MIITOOL
 
 config CMD_PING
 	tristate
+	depends on NET_LEGACY
 	prompt "ping"
 	help
 	  Send ICMP echo requests.
@@ -1245,6 +1248,7 @@ config CMD_PING
 
 config CMD_TFTP
 	depends on FS_TFTP
+	depends on NET_LEGACY
 	tristate
 	prompt "tftp"
 	help
include/net.h +36 -1
index ed63d3c..5f2d470 100644
@@ -24,6 +24,10 @@
 #include <linux/string.h>	/* memcpy */
 #include <asm/byteorder.h>	/* for nton* / ntoh* stuff */
 
+#include <pico_stack.h>
+#include <pico_socket.h>
+#include <pico_ipv4.h>
+
 /* How often do we retry to send packages */
 #define PKT_NUM_RETRIES 4
 
@@ -44,6 +48,7 @@ struct eth_device {
 	int  (*get_ethaddr) (struct eth_device*, u8 adr[6]);
 	int  (*set_ethaddr) (struct eth_device*, const unsigned char *adr);
 
+	struct pico_device *picodev;
 	struct eth_device *next;
 	void *priv;
 
@@ -433,6 +438,8 @@ struct net_connection {
 	void *handler;
 	int proto;
 	void *priv;
+	struct pico_socket *sock;
+	uint16_t remote_port;
 };
 
 static inline char *net_alloc_packet(void)
@@ -450,10 +457,28 @@ void net_unregister(struct net_connection *con);
 
 static inline int net_udp_bind(struct net_connection *con, uint16_t sport)
 {
+	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		union pico_address local_address;
+		uint16_t localport;
+
+		/* FIXME: use local_address == PICO_IPV4_INADDR_ANY */
+		memset(&local_address, 0, sizeof(union pico_address));
+
+		localport = ntohs(sport);
+
+		/* FIXME: check pico_socket_bind() return value */
+		pico_socket_bind(con->sock, &local_address, &localport);
+
+		return 0;
+	}
+
 	con->udp->uh_sport = ntohs(sport);
 	return 0;
 }
 
+#define UDP_PAYLOAD_SIZE (PKTSIZE - sizeof(struct ethernet) - sizeof(struct iphdr) - \
+		sizeof(struct udphdr))
+
 static inline void *net_udp_get_payload(struct net_connection *con)
 {
 	return con->packet + sizeof(struct ethernet) + sizeof(struct iphdr) +
@@ -475,6 +500,10 @@ static inline uint16_t getudppeerport(struct net_connection *con)
 {
 	struct udphdr *udp = net_eth_to_udphdr(con->rpacket);
 
+	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		return con->remote_port;
+	}
+
 	return udp->uh_sport;
 }
 
@@ -482,7 +511,13 @@ static inline uint16_t getudppeerport(struct net_connection *con)
 
 static inline void setudppeerport(struct net_connection *con, uint16_t dport)
 {
-	con->udp->uh_dport = dport;
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		con->udp->uh_dport = dport;
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		/* FIXME */
+//		pico_socket_connect(npriv->con->sock, &remote_address, dport);
+		con->sock->remote_port = dport;
+	}
 }
 
 #endif /* __NET_H__ */
include/pico_defines.h new file +0 -0
new file mode 100644
index 0000000..e69de29
include/stdint.h new file +1 -0
new file mode 100644
index 0000000..029276e
@@ -0,0 +1 @@
+/* fake stdint.h for picotcp */
net/Kconfig +16 -0
index a890492..f8f660c 100644
@@ -3,6 +3,18 @@ menuconfig NET
 
 if NET
 
+choice
+	prompt "network stack implementation"
+
+config NET_LEGACY
+	bool "legacy U-Boot network stack"
+
+config NET_PICOTCP
+	bool "picotcp network stack"
+	select POLLER
+
+endchoice
+
 config NET_NFS
 	bool
 	prompt "nfs support"
@@ -20,10 +32,14 @@ config NET_RESOLV
 
 config NET_IFUP
 	default y
+	depends on NET_LEGACY
 	bool
 
 config NET_DHCP
 	bool
+	depends on NET_LEGACY
 	prompt "dhcp support"
 
+source "net/picotcp/Kconfig"
+
 endif
net/Makefile +3 -0
index 8d564e7..7a4597d 100644
@@ -7,3 +7,6 @@ obj-$(CONFIG_CMD_PING)	+= ping.o
 obj-$(CONFIG_NET_RESOLV)+= dns.o
 obj-$(CONFIG_NET_NETCONSOLE) += netconsole.o
 obj-$(CONFIG_NET_IFUP)	+= ifup.o
+
+obj-$(CONFIG_NET_PICOTCP) += picotcp/
+obj-$(CONFIG_NET_PICOTCP) += picotcp.o
net/eth.c +71 -0

83 lines not on this page · raw message

net/net.c +80 -1

131 lines not on this page · raw message

net/picotcp.c new file +20 -0
new file mode 100644
index 0000000..ee16a68
@@ -0,0 +1,20 @@
+#include <init.h>
+#include <poller.h>
+#include <pico_stack.h>
+
+static struct poller_struct picotcp_poller;
+
+static void picotcp_poller_cb(struct poller_struct *poller)
+{
+	pico_stack_tick();
+}
+
+static int picotcp_net_init(void)
+{
+	pico_stack_init();
+
+	picotcp_poller.func = picotcp_poller_cb;
+
+	return poller_register(&picotcp_poller);
+}
+postcore_initcall(picotcp_net_init);
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#12 lore raw

RFC v2 12/16 net: picotcp: add test_picotcp command

In reply to Antony Pavlov

See original test_ipv4() from picotcp.git/test/unit/unit_ipv4.c.

---
 net/Makefile            |  2 ++
 net/picotcp/Kconfig     |  7 ++++
 net/picotcp_test_ipv4.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+)
net/Makefile +2 -0
index 7a4597d..bfe74fb 100644
@@ -10,3 +10,5 @@ obj-$(CONFIG_NET_IFUP)	+= ifup.o
 
 obj-$(CONFIG_NET_PICOTCP) += picotcp/
 obj-$(CONFIG_NET_PICOTCP) += picotcp.o
+
+obj-$(CONFIG_CMD_PICOTCP_TEST_IPV4) += picotcp_test_ipv4.o
net/picotcp/Kconfig +7 -0
index 3882984..17b8293 100644
@@ -31,4 +31,11 @@ config NET_PICO_BIGENDIAN
 	bool
 	prompt "bigendian picotcp"
 
+comment "Commands"
+
+config CMD_PICOTCP_TEST_IPV4
+	bool
+	depends on NET_PICO_SUPPORT_IPV4
+	prompt "test_picotcp command"
+
 endif # NET_PICOTCP
net/picotcp_test_ipv4.c new file +96 -0

96 lines not on this page · raw message

Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#13 lore raw

RFC v2 13/16 net: picotcp: add ifconfig command

In reply to Antony Pavlov
---
 net/Makefile           |   1 +
 net/picotcp/Kconfig    |   5 +++
 net/picotcp_ifconfig.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 122 insertions(+)
net/Makefile +1 -0
index bfe74fb..d5b133b 100644
@@ -12,3 +12,4 @@ obj-$(CONFIG_NET_PICOTCP) += picotcp/
 obj-$(CONFIG_NET_PICOTCP) += picotcp.o
 
 obj-$(CONFIG_CMD_PICOTCP_TEST_IPV4) += picotcp_test_ipv4.o
+obj-$(CONFIG_CMD_PICOTCP_IFCONFIG) += picotcp_ifconfig.o
net/picotcp/Kconfig +5 -0
index 17b8293..9a2d628 100644
@@ -38,4 +38,9 @@ config CMD_PICOTCP_TEST_IPV4
 	depends on NET_PICO_SUPPORT_IPV4
 	prompt "test_picotcp command"
 
+config CMD_PICOTCP_IFCONFIG
+	bool
+	depends on NET_PICO_SUPPORT_IPV4
+	prompt "ifconfig command"
+
 endif # NET_PICOTCP
net/picotcp_ifconfig.c new file +116 -0

116 lines not on this page · raw message

Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#14 lore raw

RFC v2 14/16 net: picotcp: add ping command

In reply to Antony Pavlov
---
 net/Makefile        |  1 +
 net/picotcp/Kconfig |  5 ++++
 net/picotcp_ping.c  | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
net/Makefile +1 -0
index d5b133b..04e347f 100644
@@ -13,3 +13,4 @@ obj-$(CONFIG_NET_PICOTCP) += picotcp.o
 
 obj-$(CONFIG_CMD_PICOTCP_TEST_IPV4) += picotcp_test_ipv4.o
 obj-$(CONFIG_CMD_PICOTCP_IFCONFIG) += picotcp_ifconfig.o
+obj-$(CONFIG_CMD_PICOTCP_PING) += picotcp_ping.o
net/picotcp/Kconfig +5 -0
index 9a2d628..cb60001 100644
@@ -43,4 +43,9 @@ config CMD_PICOTCP_IFCONFIG
 	depends on NET_PICO_SUPPORT_IPV4
 	prompt "ifconfig command"
 
+config CMD_PICOTCP_PING
+	bool
+	depends on NET_PICO_SUPPORT_ICMP4
+	prompt "ping command"
+
 endif # NET_PICOTCP
net/picotcp_ping.c new file +85 -0

85 lines not on this page · raw message

Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#15 lore raw

RFC v2 15/16 net: picotcp: add route command

In reply to Antony Pavlov
---
 net/Makefile        |  1 +
 net/picotcp/Kconfig |  5 +++++
 net/picotcp_route.c | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)
net/Makefile +1 -0
index 04e347f..6261454 100644
@@ -14,3 +14,4 @@ obj-$(CONFIG_NET_PICOTCP) += picotcp.o
 obj-$(CONFIG_CMD_PICOTCP_TEST_IPV4) += picotcp_test_ipv4.o
 obj-$(CONFIG_CMD_PICOTCP_IFCONFIG) += picotcp_ifconfig.o
 obj-$(CONFIG_CMD_PICOTCP_PING) += picotcp_ping.o
+obj-$(CONFIG_CMD_PICOTCP_ROUTE) += picotcp_route.o
net/picotcp/Kconfig +5 -0
index cb60001..2cd04d2 100644
@@ -48,4 +48,9 @@ config CMD_PICOTCP_PING
 	depends on NET_PICO_SUPPORT_ICMP4
 	prompt "ping command"
 
+config CMD_PICOTCP_ROUTE
+	bool
+	depends on NET_PICO_SUPPORT_IPV4
+	prompt "route command"
+
 endif # NET_PICOTCP
net/picotcp_route.c new file +36 -0
new file mode 100644
index 0000000..d24e9ba
@@ -0,0 +1,36 @@
+#include <common.h>
+#include <command.h>
+#include <complete.h>
+
+#include <pico_stack.h>
+#include <pico_ipv4.h>
+#include <pico_icmp4.h>
+
+static int do_route(int argc, char *argv[])
+{
+	struct pico_ipv4_route *r;
+	struct pico_tree_node *index;
+
+	printf("picotcp IPv4 routing table\n");
+	printf("Destination     Gateway         Genmask         Metric Iface\n");
+
+	pico_tree_foreach(index, &Routes) {
+		char ipstr[32];
+
+		r = index->keyValue;
+
+		pico_ipv4_to_string(ipstr, r->dest.addr);
+		printf("%-16s", ipstr);
+		pico_ipv4_to_string(ipstr, r->gateway.addr);
+		printf("%-16s", ipstr);
+		pico_ipv4_to_string(ipstr, r->netmask.addr);
+		printf("%-16s", ipstr);
+		printf("%-7d%s\n", r->metric, r->link->dev->name);
+	}
+
+	return 0;
+}
+
+BAREBOX_CMD_START(route)
+	.cmd		= do_route,
+BAREBOX_CMD_END
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#16 lore raw

RFC v2 16/16 sandbox_defconfig: switch to picotcp

In reply to Antony Pavlov

Picotcp sandbox barebox howto
=============================

Compile sandbox barebox:

  $ cd barebox.git
  $ unset ARCH
  $ unset CROSS_COMPILE
  $ make sandbox_defconfig
  ...
  $ make

Run barebox:

  $ su
  # ./barebox

Testing ping
------------

While sandbox barebox is running setup a IP-address for your host 'barebox' network interface, e.g.:

  # ifconfig barebox 192.168.1.1

Next, in sandbox barebox console setup network interface and try to ping host:

barebox:/ ifconfig eth 192.168.1.2 255.255.255.0 Assigned ipv4 192.168.1.2 to device eth barebox:/ picoping 192.168.1.1
48 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=1 ms
...
48 bytes from 192.168.1.1: icmp_req=10 ttl=64 time=0 ms

Testing domain name resolving
-----------------------------

Install simple maradns name server on the host.

Edit /etc/maradns/mararc config file, add these lines:

csv2 = {}
csv2["example.com."] = "db.example.com"

bind_address = "192.168.1.1"

Edit /etc/maradns/db.example.com, add these lines:

example.com. 192.168.1.1 ~
www.example.com. 192.168.1.1 ~
barebox.example.com. 192.168.1.2 ~

Run sandbox barebox and setup the www.example.com IP-address for your host 'barebox' network interface, e.g.:

  # ifconfig barebox 192.168.1.1

Restart maradns:

  $ /etc/init.d/maradns restart

Check name resolution:

barebox@barebox sandbox:/ ifconfig eth 192.168.1.2 255.255.255.0 Assigned ipv4 192.168.1.2 to device eth barebox@barebox sandbox:/ net.nameserver=192.168.1.1 barebox@barebox sandbox:/ host barebox.example.com barebox.example.com is at 192.168.1.2
barebox@barebox sandbox:/ host www.example.com www.example.com is at 192.168.1.1

The same checks for barebox legacy network stack:

barebox@barebox sandbox:/ eth0.ipaddr=192.168.1.2 barebox@barebox sandbox:/ eth0.serverip=192.168.1.1 barebox@barebox sandbox:/ net.domainname=example.com barebox@barebox sandbox:/ net.nameserver=192.168.1.1 barebox@barebox sandbox:/ host barebox.example.com
warning: No MAC address set. Using random address 9a:a1:86:31:05:1e barebox.example.com is at 192.168.1.2
barebox@barebox sandbox:/ host www.example.com www.example.com is at 192.168.1.1

Testing dhcp (ad memorandum)
----------------------------

Configure your host dhcp server, e.g. add this
to your /etc/dhcp/dhcpd.conf:

  subnet 192.168.1.0 netmask 255.255.255.0 {
    range dynamic-bootp 192.168.1.26 192.168.1.29;
    option routers 192.168.1.1;
    option broadcast-address 192.168.1.255;
    default-lease-time 600;
    max-lease-time 7200;
  }

While sandbox barebox is running setup a IP-address for your host 'barebox' network interface and restart your host dhcp server, e.g.:

  # ifconfig barebox 192.168.1.1
  # /etc/init.d/isc-dhcp-server restart

Next, in your sandbox barebox console run 'dhclient':

barebox:/ dhclient eth
Assigned ipv4 0.0.0.0 to device eth Assigned ipv4 192.168.1.26 to device eth DHCP client: renewal time (T1) 300
DHCP client: rebinding time (T2) 525
DHCP client: lease time 496
DHCP client: IP assigned by the server: 192.168.1.26

---
 arch/sandbox/configs/sandbox_defconfig | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/sandbox/configs/sandbox_defconfig +5 -3
index d82579b..320a22b 100644
@@ -36,10 +36,7 @@ CONFIG_CMD_LET=y
 CONFIG_CMD_MSLEEP=y
 CONFIG_CMD_READF=y
 CONFIG_CMD_SLEEP=y
-CONFIG_CMD_DHCP=y
 CONFIG_CMD_HOST=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_TFTP=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_EDIT=y
 CONFIG_CMD_MENU=y
@@ -61,8 +58,13 @@ CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_SPD_DECODE=y
 CONFIG_NET=y
+CONFIG_NET_PICOTCP=y
 CONFIG_NET_NFS=y
 CONFIG_NET_NETCONSOLE=y
+CONFIG_CMD_PICOTCP_TEST_IPV4=y
+CONFIG_CMD_PICOTCP_IFCONFIG=y
+CONFIG_CMD_PICOTCP_PING=y
+CONFIG_CMD_PICOTCP_ROUTE=y
 CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_DRIVER_NET_TAP=y
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#17 lore raw
In reply to Antony Pavlov

Hi Antony,

Quoted 21 lines · Antony Pavlov

I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.picotcp).

This version is based on the latest barebox-next and picotcp v1.5.0 (there is also picotcp v1.5.1, but is has no interested for barebox changes since v1.5.0).

Changes since 2015.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):

* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.

Here are some notes:

1. just now tftp/nfs file transfer on top of picotcp is slower than

     the same transfer on top of legacy network stack;
Quoted 8 lines

2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.

N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c404205

3. The picoping command is used insted of traditional ping command.

First of all I applied patches 1-4 to next.

I can't get this version to work. I have done:

# eth0.ethaddr=00:04:9f:01:b5:37
# eth0.ipaddr=192.168.23.170
# eth0.netmask=255.255.0.0

# mount -t tftp 192.168.23.4 /mnt/
# cp mnt/b b
T T T T could not open mnt/b: Interrupted system call
# picoping 192.168.23.4
 ---- Ping timeout!!!
PING 1 to 192.168.23.4: Error 1
picoping: I/O error

Anything I have missed?

I noticed that the MAC address is no longer set and the stack no longer checks for a link. I believe picotcp should call eth_send rather than invoking eth->send directly.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#18 lore raw
Quoted 27 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:

Hi Antony,

Quoted 24 lines · Antony Pavlov

I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.picotcp).

This version is based on the latest barebox-next and picotcp v1.5.0 (there is also picotcp v1.5.1, but is has no interested for barebox changes since v1.5.0).

Changes since 2015.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):

* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.

Here are some notes:

1. just now tftp/nfs file transfer on top of picotcp is slower than

     the same transfer on top of legacy network stack;

2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is the reason of your 'Ping timeout!!!'

Quoted 14 lines

I can't get this version to work. I have done:

# eth0.ethaddr=00:04:9f:01:b5:37
# eth0.ipaddr=192.168.23.170
# eth0.netmask=255.255.0.0

# mount -t tftp 192.168.23.4 /mnt/
# cp mnt/b b
T T T T could not open mnt/b: Interrupted system call
# picoping 192.168.23.4
 ---- Ping timeout!!!
PING 1 to 192.168.23.4: Error 1
picoping: I/O error
Quoted 1 line

Anything I have missed?

Please use ifconfig for interface setup. E.g.

ifconfig eth 192.168.23.170 255.255.0.0

I think it is possible to implement network interface setup via eth0.ipaddr and eth0.netmask manipulation (and even sacrifice ifconfig command).

Here is my picotcp test script

#!/bin/sh

SERVER=192.168.100.1
ifconfig eth 192.168.100.2 255.255.255.0

picoping $SERVER

net.nameserver=$SERVER
host barebox.example.com
host www.example.com

mount -t nfs $SERVER:/tftpboot /mnt
ls /mnt
md5sum /mnt/bash
umount /mnt
ls /mnt

mount -t tftp $SERVER /mnt
md5sum /mnt/test
umount /mnt

Quoted 3 lines

I noticed that the MAC address is no longer set and the stack no longer checks for a link. I believe picotcp should call eth_send rather than invoking eth->send directly.

Hmmm, It looks like I have completely missed any MAC-address manipulation stuff.

I see no means to use eth_send() from picotcp code at the moment.

Just now picotcp "parasitize" on legacy stack: for one phisical network interface there are the picotcp network interface and the legacy network interface at the same time, but only picotcp actualy operates (but some legacy network interface functions are not realized).

The main problem is that barebox has the 'only one network interface is active' conception, but picotcp can handle several active network interfaces at the same time. In this patchseries the 'only one network interface is active' conception is not used, so some commands (dhcp, ifup) do not work.

Picotcp selects necessary network interface for eth->send() invoking after routing. But if I just call eth_send() from picotcp a collision is possible.
E.g. if you have two network interfaces and picotcp want to use the 2nd for packet sending but barebox thinks that the 1st interface is active then eth_send() leads to sending via the 1st one.

I think it is possible to impart current_active_interface property to picotcp-barebox glue code for smooth integration.

I'll try to take into account your notes in the next picotcp integration patchseries;

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#19 lore raw
In reply to Sascha Hauer
Quoted 28 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:

Hi Antony,

Quoted 25 lines · Antony Pavlov

I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.picotcp).

This version is based on the latest barebox-next and picotcp v1.5.0 (there is also picotcp v1.5.1, but is has no interested for barebox changes since v1.5.0).

Changes since 2015.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):

* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.

Here are some notes:

1. just now tftp/nfs file transfer on top of picotcp is slower than

     the same transfer on top of legacy network stack;

2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.

Quoted 6 lines
Quoted 4 lines

N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c404205

3. The picoping command is used insted of traditional ping command.

First of all I applied patches 1-4 to next.

Sascha!

Please comment patches 5-7!

Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#20 lore raw
Quoted 36 lines · Antony Pavlov
Quoted 33 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:

Hi Antony,

Quoted 29 lines · Antony Pavlov

I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.picotcp).

This version is based on the latest barebox-next and picotcp v1.5.0 (there is also picotcp v1.5.1, but is has no interested for barebox changes since v1.5.0).

Changes since 2015.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):

* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.

Here are some notes:

1. just now tftp/nfs file transfer on top of picotcp is slower than

     the same transfer on top of legacy network stack;

2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.

N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c404205

3. The picoping command is used insted of traditional ping command.

Quoted 8 lines
Quoted 1 line

First of all I applied patches 1-4 to next.

Sascha!

Please comment patches 5-7!

Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.

From looking at them they are ok. I haven't found the place where you allocate packets now, but please make sure they are aligned for dma accesses, i.e. use net_alloc_packet(). Otherwise this happens:

eth0: Transmit data not aligned: c0416acc!

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#21 lore raw
Quoted 43 lines · On Mon, 20 Jul 2015 12:45:24 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 42 lines · Antony Pavlov
Quoted 28 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:

Hi Antony,

Quoted 25 lines · Antony Pavlov

I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.picotcp).

This version is based on the latest barebox-next and picotcp v1.5.0 (there is also picotcp v1.5.1, but is has no interested for barebox changes since v1.5.0).

Changes since 2015.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):

* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.

Here are some notes:

1. just now tftp/nfs file transfer on top of picotcp is slower than

     the same transfer on top of legacy network stack;

2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.

Quoted 6 lines
Quoted 4 lines

N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c404205

3. The picoping command is used insted of traditional ping command.

First of all I applied patches 1-4 to next.

Sascha!

Please comment patches 5-7!

Quoted 8 lines
Quoted 2 lines

Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.

From looking at them they are ok. I haven't found the place where you allocate packets now, but please make sure they are aligned for dma accesses, i.e. use net_alloc_packet(). Otherwise this happens:

eth0: Transmit data not aligned: c0416acc!

I see only one possibility: fix pico_zalloc() macro definition in net/picotcp/include/arch/pico_barebox.h.

Could you please check it on your hardware?

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#22 lore raw
In reply to Sascha Hauer
Quoted 43 lines · On Mon, 20 Jul 2015 12:45:24 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 42 lines · Antony Pavlov
Quoted 28 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:

Hi Antony,

Quoted 25 lines · Antony Pavlov

I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.picotcp).

This version is based on the latest barebox-next and picotcp v1.5.0 (there is also picotcp v1.5.1, but is has no interested for barebox changes since v1.5.0).

Changes since 2015.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):

* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.

Here are some notes:

1. just now tftp/nfs file transfer on top of picotcp is slower than

     the same transfer on top of legacy network stack;

2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.

Quoted 6 lines
Quoted 4 lines

N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c404205

3. The picoping command is used insted of traditional ping command.

First of all I applied patches 1-4 to next.

Sascha!

Please comment patches 5-7!

Quoted 9 lines
Quoted 2 lines

Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.

From looking at them they are ok. I haven't found the place where you allocate packets now, but please make sure they are aligned for dma accesses, i.e. use net_alloc_packet(). Otherwise this happens:

eth0: Transmit data not aligned: c0416acc!

Could you try this patch, please?

net/picotcp/include/arch/pico_barebox.h +10 -1
@@ -45,7 +45,16 @@ static inline void pico_free(void *x)
 }
 #else
 
-#define pico_zalloc(x) calloc(x, 1)
+#include <xfuncs.h>
+
+static inline void *xzmemalign(size_t alignment, size_t bytes)
+{
+	void *ptr = xmemalign(alignment, bytes);
+	memset(ptr, 0, bytes);
+	return ptr;
+}
+
+#define pico_zalloc(x) xzmemalign(32, x)
 #define pico_free(x) free(x)
 #endif
 

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#23 lore raw
Quoted 49 lines · Antony Pavlov
Quoted 46 lines · On Mon, 20 Jul 2015 12:45:24 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 44 lines · Antony Pavlov
Quoted 28 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:

Hi Antony,

Quoted 25 lines · Antony Pavlov

I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.picotcp).

This version is based on the latest barebox-next and picotcp v1.5.0 (there is also picotcp v1.5.1, but is has no interested for barebox changes since v1.5.0).

Changes since 2015.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):

* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.

Here are some notes:

1. just now tftp/nfs file transfer on top of picotcp is slower than

     the same transfer on top of legacy network stack;

2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.

Quoted 6 lines
Quoted 4 lines

N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c404205

3. The picoping command is used insted of traditional ping command.

First of all I applied patches 1-4 to next.

Sascha!

Please comment patches 5-7!

Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.

Quoted 8 lines
Quoted 6 lines

From looking at them they are ok. I haven't found the place where you allocate packets now, but please make sure they are aligned for dma accesses, i.e. use net_alloc_packet(). Otherwise this happens:

eth0: Transmit data not aligned: c0416acc!

Could you try this patch, please?

With this the packets are now sufficiently aligned. When I replace edev->send with eth_send in pico_adapter_send I get a step further. Packets are still sent with the wrong mac address. It uses 00:00:00:0a:0b:0c which is probably some dummy value you introduced somehwere, but the ethernet device is never configured with that value.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox