net: Add TCP protocol

Currently file transfers are done using tftp or NFS both
over udp. This requires a request to be sent from client
(u-boot) to the boot server.

The current standard is TCP with selective acknowledgment.

Signed-off-by: Duncan Hare <DH@Synoia.com>
Signed-off-by: Duncan Hare <DuncanCHare@yahoo.com>
Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
This commit is contained in:
Ying-Chun Liu (PaulLiu)
2022-11-08 14:17:28 +08:00
committed by Tom Rini
parent 3cdbbe52f7
commit a3bf193bf4
6 changed files with 1092 additions and 8 deletions

View File

@@ -365,6 +365,7 @@ struct vlan_ethernet_hdr {
#define PROT_NCSI 0x88f8 /* NC-SI control packets */
#define IPPROTO_ICMP 1 /* Internet Control Message Protocol */
#define IPPROTO_TCP 6 /* Transmission Control Protocol */
#define IPPROTO_UDP 17 /* User Datagram Protocol */
/*
@@ -690,19 +691,36 @@ static inline void net_send_packet(uchar *pkt, int len)
(void) eth_send(pkt, len);
}
/*
* Transmit "net_tx_packet" as UDP packet, performing ARP request if needed
* (ether will be populated)
/**
* net_send_ip_packet() - Transmit "net_tx_packet" as UDP or TCP packet,
* send ARP request if needed (ether will be populated)
* @ether: Raw packet buffer
* @dest: IP address to send the datagram to
* @dport: Destination UDP port
* @sport: Source UDP port
* @payload_len: Length of data after the UDP header
* @action: TCP action to be performed
* @tcp_seq_num: TCP sequence number of this transmission
* @tcp_ack_num: TCP stream acknolegement number
*
* @param ether Raw packet buffer
* @param dest IP address to send the datagram to
* @param dport Destination UDP port
* @param sport Source UDP port
* @param payload_len Length of data after the UDP header
* Return: 0 on success, other value on failure
*/
int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int sport,
int payload_len, int proto, u8 action, u32 tcp_seq_num,
u32 tcp_ack_num);
/**
* net_send_tcp_packet() - Transmit TCP packet.
* @payload_len: length of payload
* @dport: Destination TCP port
* @sport: Source TCP port
* @action: TCP action to be performed
* @tcp_seq_num: TCP sequence number of this transmission
* @tcp_ack_num: TCP stream acknolegement number
*
* Return: 0 on success, other value on failure
*/
int net_send_tcp_packet(int payload_len, int dport, int sport, u8 action,
u32 tcp_seq_num, u32 tcp_ack_num);
int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport,
int sport, int payload_len);