mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
net: cosmetic: Un-typedef IP_t
Rename IP header related things to IP_UDP. The existing definition of IP_t includes UDP header, so name it to accurately describe the structure. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
parent
8b9c53221f
commit
594c26f8a7
15 changed files with 55 additions and 52 deletions
|
@ -69,7 +69,7 @@ void NcStart(void)
|
|||
/* send arp request */
|
||||
uchar *pkt;
|
||||
NetSetHandler(nc_wait_arp_handler);
|
||||
pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE;
|
||||
pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
|
||||
memcpy(pkt, output_packet, output_packet_len);
|
||||
NetSendUDPPacket(nc_ether, nc_ip, nc_port, nc_port,
|
||||
output_packet_len);
|
||||
|
@ -131,7 +131,7 @@ static void nc_send_packet(const char *buf, int len)
|
|||
return;
|
||||
inited = 1;
|
||||
}
|
||||
pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE;
|
||||
pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
|
||||
memcpy(pkt, buf, len);
|
||||
ether = nc_ether;
|
||||
ip = nc_ip;
|
||||
|
|
|
@ -194,9 +194,9 @@ typedef struct {
|
|||
#define IPPROTO_UDP 17 /* User Datagram Protocol */
|
||||
|
||||
/*
|
||||
* Internet Protocol (IP) header.
|
||||
* Internet Protocol (IP) + UDP header.
|
||||
*/
|
||||
typedef struct {
|
||||
struct ip_udp_hdr {
|
||||
uchar ip_hl_v; /* header length and version */
|
||||
uchar ip_tos; /* type of service */
|
||||
ushort ip_len; /* total length */
|
||||
|
@ -211,7 +211,7 @@ typedef struct {
|
|||
ushort udp_dst; /* UDP destination port */
|
||||
ushort udp_len; /* Length of UDP packet */
|
||||
ushort udp_xsum; /* Checksum */
|
||||
} IP_t;
|
||||
};
|
||||
|
||||
#define IP_OFFS 0x1fff /* ip offset *= 8 */
|
||||
#define IP_FLAGS 0xe000 /* first 3 bits */
|
||||
|
@ -219,9 +219,10 @@ typedef struct {
|
|||
#define IP_FLAGS_DFRAG 0x4000 /* don't fragments */
|
||||
#define IP_FLAGS_MFRAG 0x2000 /* more fragments */
|
||||
|
||||
#define IP_HDR_SIZE_NO_UDP (sizeof(IP_t) - 8)
|
||||
#define IP_HDR_SIZE (sizeof(IP_t))
|
||||
#define IP_HDR_SIZE_NO_UDP (sizeof(struct ip_udp_hdr) - 8)
|
||||
|
||||
#define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr))
|
||||
#define UDP_HDR_SIZE (IP_UDP_HDR_SIZE - IP_HDR_SIZE_NO_UDP)
|
||||
|
||||
/*
|
||||
* Address Resolution Protocol (ARP) header.
|
||||
|
|
|
@ -113,7 +113,7 @@ void ArpTimeoutCheck(void)
|
|||
}
|
||||
}
|
||||
|
||||
void ArpReceive(Ethernet_t *et, IP_t *ip, int len)
|
||||
void ArpReceive(Ethernet_t *et, struct ip_udp_hdr *ip, int len)
|
||||
{
|
||||
ARP_t *arp;
|
||||
IPaddr_t tmp;
|
||||
|
|
|
@ -25,6 +25,6 @@ extern int NetArpWaitTry;
|
|||
void ArpInit(void);
|
||||
void ArpRequest(void);
|
||||
void ArpTimeoutCheck(void);
|
||||
void ArpReceive(Ethernet_t *et, IP_t *ip, int len);
|
||||
void ArpReceive(Ethernet_t *et, struct ip_udp_hdr *ip, int len);
|
||||
|
||||
#endif /* __ARP_H__ */
|
||||
|
|
|
@ -622,7 +622,7 @@ BootpRequest(void)
|
|||
/* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC,
|
||||
sizeof (struct Bootp_t)); */
|
||||
iphdr = pkt; /* We need this later for NetSetIP() */
|
||||
pkt += IP_HDR_SIZE;
|
||||
pkt += IP_UDP_HDR_SIZE;
|
||||
|
||||
bp = (struct Bootp_t *)pkt;
|
||||
bp->bp_op = OP_BOOTREQUEST;
|
||||
|
@ -807,7 +807,7 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer)
|
|||
pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP);
|
||||
|
||||
iphdr = pkt; /* We'll need this later to set proper pkt size */
|
||||
pkt += IP_HDR_SIZE;
|
||||
pkt += IP_UDP_HDR_SIZE;
|
||||
|
||||
bp = (struct Bootp_t *)pkt;
|
||||
bp->bp_op = OP_BOOTREQUEST;
|
||||
|
|
|
@ -52,7 +52,7 @@ struct Bootp_t {
|
|||
};
|
||||
|
||||
#define BOOTP_HDR_SIZE sizeof(struct Bootp_t)
|
||||
#define BOOTP_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE + BOOTP_HDR_SIZE)
|
||||
#define BOOTP_SIZE (ETHER_HDR_SIZE + IP_UDP_HDR_SIZE + BOOTP_HDR_SIZE)
|
||||
|
||||
/**********************************************************************/
|
||||
/*
|
||||
|
|
|
@ -45,7 +45,7 @@ DnsSend(void)
|
|||
enum dns_query_type qtype = DNS_A_RECORD;
|
||||
|
||||
name = NetDNSResolve;
|
||||
pkt = p = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE);
|
||||
pkt = p = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE);
|
||||
|
||||
/* Prepare DNS packet header */
|
||||
header = (struct header *) pkt;
|
||||
|
|
62
net/net.c
62
net/net.c
|
@ -619,12 +619,13 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
|
|||
pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP);
|
||||
|
||||
NetSetIP(pkt, dest, dport, sport, len);
|
||||
memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket +
|
||||
(pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
|
||||
memcpy(pkt + IP_UDP_HDR_SIZE, (uchar *)NetTxPacket +
|
||||
(pkt - (uchar *)NetArpWaitTxPacket) +
|
||||
IP_UDP_HDR_SIZE, len);
|
||||
|
||||
/* size of the waiting packet */
|
||||
NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) +
|
||||
IP_HDR_SIZE + len;
|
||||
IP_UDP_HDR_SIZE + len;
|
||||
|
||||
/* and do the ARP request */
|
||||
NetArpWaitTry = 1;
|
||||
|
@ -638,7 +639,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
|
|||
pkt = (uchar *)NetTxPacket;
|
||||
pkt += NetSetEther(pkt, ether, PROT_IP);
|
||||
NetSetIP(pkt, dest, dport, sport, len);
|
||||
(void) eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_HDR_SIZE + len);
|
||||
eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE + len);
|
||||
|
||||
return 0; /* transmitted */
|
||||
}
|
||||
|
@ -676,12 +677,12 @@ struct hole {
|
|||
u16 unused;
|
||||
};
|
||||
|
||||
static IP_t *__NetDefragment(IP_t *ip, int *lenp)
|
||||
static struct ip_udp_hdr *__NetDefragment(struct ip_udp_hdr *ip, int *lenp)
|
||||
{
|
||||
static uchar pkt_buff[IP_PKTSIZE] __aligned(PKTALIGN);
|
||||
static u16 first_hole, total_len;
|
||||
struct hole *payload, *thisfrag, *h, *newh;
|
||||
IP_t *localip = (IP_t *)pkt_buff;
|
||||
struct ip_udp_hdr *localip = (struct ip_udp_hdr *)pkt_buff;
|
||||
uchar *indata = (uchar *)ip;
|
||||
int offset8, start, len, done = 0;
|
||||
u16 ip_off = ntohs(ip->ip_off);
|
||||
|
@ -796,7 +797,7 @@ static IP_t *__NetDefragment(IP_t *ip, int *lenp)
|
|||
return localip;
|
||||
}
|
||||
|
||||
static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
|
||||
static inline struct ip_udp_hdr *NetDefragment(struct ip_udp_hdr *ip, int *lenp)
|
||||
{
|
||||
u16 ip_off = ntohs(ip->ip_off);
|
||||
if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG)))
|
||||
|
@ -806,7 +807,7 @@ static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
|
|||
|
||||
#else /* !CONFIG_IP_DEFRAG */
|
||||
|
||||
static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
|
||||
static inline struct ip_udp_hdr *NetDefragment(struct ip_udp_hdr *ip, int *lenp)
|
||||
{
|
||||
u16 ip_off = ntohs(ip->ip_off);
|
||||
if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG)))
|
||||
|
@ -821,7 +822,8 @@ static inline IP_t *NetDefragment(IP_t *ip, int *lenp)
|
|||
*
|
||||
* @parma ip IP packet containing the ICMP
|
||||
*/
|
||||
static void receive_icmp(IP_t *ip, int len, IPaddr_t src_ip, Ethernet_t *et)
|
||||
static void receive_icmp(struct ip_udp_hdr *ip, int len,
|
||||
IPaddr_t src_ip, Ethernet_t *et)
|
||||
{
|
||||
ICMP_t *icmph = (ICMP_t *)&ip->udp_src;
|
||||
|
||||
|
@ -850,7 +852,7 @@ void
|
|||
NetReceive(uchar *inpkt, int len)
|
||||
{
|
||||
Ethernet_t *et;
|
||||
IP_t *ip;
|
||||
struct ip_udp_hdr *ip;
|
||||
IPaddr_t tmp;
|
||||
IPaddr_t src_ip;
|
||||
int x;
|
||||
|
@ -898,11 +900,11 @@ NetReceive(uchar *inpkt, int len)
|
|||
*/
|
||||
x = ntohs(et->et_prot);
|
||||
|
||||
ip = (IP_t *)(inpkt + E802_HDR_SIZE);
|
||||
ip = (struct ip_udp_hdr *)(inpkt + E802_HDR_SIZE);
|
||||
len -= E802_HDR_SIZE;
|
||||
|
||||
} else if (x != PROT_VLAN) { /* normal packet */
|
||||
ip = (IP_t *)(inpkt + ETHER_HDR_SIZE);
|
||||
ip = (struct ip_udp_hdr *)(inpkt + ETHER_HDR_SIZE);
|
||||
len -= ETHER_HDR_SIZE;
|
||||
|
||||
} else { /* VLAN packet */
|
||||
|
@ -926,7 +928,7 @@ NetReceive(uchar *inpkt, int len)
|
|||
vlanid = cti & VLAN_IDMASK;
|
||||
x = ntohs(vet->vet_type);
|
||||
|
||||
ip = (IP_t *)(inpkt + VLAN_ETHER_HDR_SIZE);
|
||||
ip = (struct ip_udp_hdr *)(inpkt + VLAN_ETHER_HDR_SIZE);
|
||||
len -= VLAN_ETHER_HDR_SIZE;
|
||||
}
|
||||
|
||||
|
@ -961,8 +963,9 @@ NetReceive(uchar *inpkt, int len)
|
|||
case PROT_IP:
|
||||
debug("Got IP\n");
|
||||
/* Before we start poking the header, make sure it is there */
|
||||
if (len < IP_HDR_SIZE) {
|
||||
debug("len bad %d < %lu\n", len, (ulong)IP_HDR_SIZE);
|
||||
if (len < IP_UDP_HDR_SIZE) {
|
||||
debug("len bad %d < %lu\n", len,
|
||||
(ulong)IP_UDP_HDR_SIZE);
|
||||
return;
|
||||
}
|
||||
/* Check the packet length */
|
||||
|
@ -1074,19 +1077,19 @@ NetReceive(uchar *inpkt, int len)
|
|||
|
||||
|
||||
#ifdef CONFIG_NETCONSOLE
|
||||
nc_input_packet((uchar *)ip + IP_HDR_SIZE,
|
||||
ntohs(ip->udp_dst),
|
||||
ntohs(ip->udp_src),
|
||||
ntohs(ip->udp_len) - 8);
|
||||
nc_input_packet((uchar *)ip + IP_UDP_HDR_SIZE,
|
||||
ntohs(ip->udp_dst),
|
||||
ntohs(ip->udp_src),
|
||||
ntohs(ip->udp_len) - UDP_HDR_SIZE);
|
||||
#endif
|
||||
/*
|
||||
* IP header OK. Pass the packet to the current handler.
|
||||
*/
|
||||
(*packetHandler)((uchar *)ip + IP_HDR_SIZE,
|
||||
ntohs(ip->udp_dst),
|
||||
src_ip,
|
||||
ntohs(ip->udp_src),
|
||||
ntohs(ip->udp_len) - 8);
|
||||
(*packetHandler)((uchar *)ip + IP_UDP_HDR_SIZE,
|
||||
ntohs(ip->udp_dst),
|
||||
src_ip,
|
||||
ntohs(ip->udp_src),
|
||||
ntohs(ip->udp_len) - UDP_HDR_SIZE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1237,10 +1240,9 @@ NetSetEther(uchar *xet, uchar * addr, uint prot)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
|
||||
void NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
|
||||
{
|
||||
IP_t *ip = (IP_t *)xip;
|
||||
struct ip_udp_hdr *ip = (struct ip_udp_hdr *)xip;
|
||||
|
||||
/*
|
||||
* If the data is an odd number of bytes, zero the
|
||||
|
@ -1248,7 +1250,7 @@ NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
|
|||
* will work.
|
||||
*/
|
||||
if (len & 1)
|
||||
xip[IP_HDR_SIZE + len] = 0;
|
||||
xip[IP_UDP_HDR_SIZE + len] = 0;
|
||||
|
||||
/*
|
||||
* Construct an IP and UDP header.
|
||||
|
@ -1257,7 +1259,7 @@ NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
|
|||
/* IP_HDR_SIZE / 4 (not including UDP) */
|
||||
ip->ip_hl_v = 0x45;
|
||||
ip->ip_tos = 0;
|
||||
ip->ip_len = htons(IP_HDR_SIZE + len);
|
||||
ip->ip_len = htons(IP_UDP_HDR_SIZE + len);
|
||||
ip->ip_id = htons(NetIPID++);
|
||||
ip->ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */
|
||||
ip->ip_ttl = 255;
|
||||
|
@ -1269,7 +1271,7 @@ NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len)
|
|||
NetCopyIP((void *)&ip->ip_dst, &dest);
|
||||
ip->udp_src = htons(sport);
|
||||
ip->udp_dst = htons(dport);
|
||||
ip->udp_len = htons(8 + len);
|
||||
ip->udp_len = htons(UDP_HDR_SIZE + len);
|
||||
ip->udp_xsum = 0;
|
||||
ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
|
|||
|
||||
pktlen = (char *)p + datalen*sizeof(uint32_t) - (char *)&pkt;
|
||||
|
||||
memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE,
|
||||
memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE,
|
||||
(char *)&pkt, pktlen);
|
||||
|
||||
if (rpc_prog == PROG_PORTMAP)
|
||||
|
|
|
@ -19,7 +19,7 @@ IPaddr_t NetPingIP;
|
|||
static int ping_send(void)
|
||||
{
|
||||
static uchar mac[6];
|
||||
IP_t *ip;
|
||||
struct ip_udp_hdr *ip;
|
||||
ushort *s;
|
||||
uchar *pkt;
|
||||
|
||||
|
@ -35,7 +35,7 @@ static int ping_send(void)
|
|||
pkt = NetArpWaitTxPacket;
|
||||
pkt += NetSetEther(pkt, mac, PROT_IP);
|
||||
|
||||
ip = (IP_t *)pkt;
|
||||
ip = (struct ip_udp_hdr *)pkt;
|
||||
|
||||
/*
|
||||
* Construct an IP and ICMP header.
|
||||
|
@ -98,7 +98,7 @@ void ping_start(void)
|
|||
ping_send();
|
||||
}
|
||||
|
||||
void ping_receive(Ethernet_t *et, IP_t *ip, int len)
|
||||
void ping_receive(Ethernet_t *et, struct ip_udp_hdr *ip, int len)
|
||||
{
|
||||
ICMP_t *icmph = (ICMP_t *)&(ip->udp_src);
|
||||
IPaddr_t src_ip;
|
||||
|
|
|
@ -28,7 +28,7 @@ void ping_start(void);
|
|||
* @param ip IP header in the same packet
|
||||
* @param len Packet length
|
||||
*/
|
||||
void ping_receive(Ethernet_t *et, IP_t *ip, int len);
|
||||
void ping_receive(Ethernet_t *et, struct ip_udp_hdr *ip, int len);
|
||||
|
||||
#endif /* __PING_H__ */
|
||||
#endif
|
||||
|
|
|
@ -41,7 +41,7 @@ int RarpTry;
|
|||
/*
|
||||
* Handle a RARP received packet.
|
||||
*/
|
||||
void rarp_receive(IP_t *ip, unsigned len)
|
||||
void rarp_receive(struct ip_udp_hdr *ip, unsigned len)
|
||||
{
|
||||
ARP_t *arp;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
extern int RarpTry;
|
||||
|
||||
/* Process the receipt of a RARP packet */
|
||||
extern void rarp_receive(IP_t *ip, unsigned len);
|
||||
extern void rarp_receive(struct ip_udp_hdr *ip, unsigned len);
|
||||
extern void RarpRequest(void); /* Send a RARP request */
|
||||
|
||||
/**********************************************************************/
|
||||
|
|
|
@ -31,7 +31,7 @@ SntpSend(void)
|
|||
pkt.vn = NTP_VERSION;
|
||||
pkt.mode = NTP_MODE_CLIENT;
|
||||
|
||||
memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE,
|
||||
memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE,
|
||||
(char *)&pkt, pktlen);
|
||||
|
||||
SntpOurPort = 10000 + (get_timer(0) % 4096);
|
||||
|
|
|
@ -322,7 +322,7 @@ TftpSend(void)
|
|||
* We will always be sending some sort of packet, so
|
||||
* cobble together the packet headers now.
|
||||
*/
|
||||
pkt = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE);
|
||||
pkt = NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
|
||||
|
||||
switch (TftpState) {
|
||||
case STATE_SEND_RRQ:
|
||||
|
|
Loading…
Reference in a new issue