bdp->cbd_sc = BD_ENET_TX_READY | BD_ENET_TX_PAD | \
BD_ENET_TX_LAST | BD_ENET_TX_TC;
- memset ((void *)bp, patbytes[i], ELBT_BUFSZ);
- NetSetEther(bp, net_bcast_ethaddr, 0x8000);
+ memset((void *)bp, patbytes[i], ELBT_BUFSZ);
+ net_set_ether(bp, net_bcast_ethaddr, 0x8000);
}
ecp->txbd[ELBT_NTXBD - 1].cbd_sc |= BD_ENET_TX_WRAP;
/* send arp request */
uchar *pkt;
net_set_arp_handler(nc_wait_arp_handler);
- pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
+ pkt = (uchar *)net_tx_packet + net_eth_hdr_size() +
+ IP_UDP_HDR_SIZE;
memcpy(pkt, output_packet, output_packet_len);
- NetSendUDPPacket(nc_ether, nc_ip, nc_out_port, nc_in_port,
- output_packet_len);
+ net_send_udp_packet(nc_ether, nc_ip, nc_out_port, nc_in_port,
+ output_packet_len);
}
}
inited = 1;
}
- pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
+ pkt = (uchar *)net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE;
memcpy(pkt, buf, len);
ether = nc_ether;
ip = nc_ip;
- NetSendUDPPacket(ether, ip, nc_out_port, nc_in_port, len);
+ net_send_udp_packet(ether, ip, nc_out_port, nc_in_port, len);
if (inited) {
if (eth_is_on_demand_init())
/*
* Initialize the static IP settings and buffer pointers
- * incase we call NetSendUDPPacket before NetLoop
+ * incase we call net_send_udp_packet before NetLoop
*/
net_init();
extern u8 net_server_ethaddr[6]; /* Boot server enet address */
extern struct in_addr net_ip; /* Our IP addr (0 = unknown) */
extern struct in_addr net_server_ip; /* Server IP addr (0 = unknown) */
-extern uchar *NetTxPacket; /* THE transmit packet */
+extern uchar *net_tx_packet; /* THE transmit packet */
#ifdef CONFIG_DM_ETH
extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */
#else
extern uchar *NetRxPackets[PKTBUFSRX]; /* Receive packets */
#endif
-extern uchar *NetRxPacket; /* Current receive packet */
-extern int NetRxPacketLen; /* Current rx packet length */
+extern uchar *net_rx_packet; /* Current receive packet */
+extern int net_rx_packet_len; /* Current rx packet length */
extern unsigned NetIPID; /* IP ID (counting) */
extern const u8 net_bcast_ethaddr[6]; /* Ethernet broadcast address */
extern const u8 net_null_ethaddr[6];
int NetStartAgain(void);
/* Get size of the ethernet header when we send */
-int NetEthHdrSize(void);
+int net_eth_hdr_size(void);
/* Set ethernet header; returns the size of the header */
-int NetSetEther(uchar *xet, const uchar *dest_ethaddr, uint prot);
+int net_set_ether(uchar *xet, const uchar *dest_ethaddr, uint prot);
int net_update_ether(struct ethernet_hdr *et, uchar *addr, uint prot);
/* Set IP header */
}
/* Transmit a packet */
-static inline void NetSendPacket(uchar *pkt, int len)
+static inline void net_send_packet(uchar *pkt, int len)
{
/* Currently no way to return errors from eth_send() */
(void) eth_send(pkt, len);
}
/*
- * Transmit "NetTxPacket" as UDP packet, performing ARP request if needed
+ * Transmit "net_tx_packet" as UDP packet, performing ARP request if needed
* (ether will be populated)
*
* @param ether Raw packet buffer
* @param sport Source UDP port
* @param payload_len Length of data after the UDP header
*/
-int NetSendUDPPacket(uchar *ether, struct in_addr dest, int dport,
+int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport,
int sport, int payload_len);
#ifndef CONFIG_DM_ETH
ulong NetArpWaitTimerStart;
int NetArpWaitTry;
-static uchar *NetArpTxPacket; /* THE ARP transmit packet */
+static uchar *net_arp_tx_packet; /* THE ARP transmit packet */
static uchar NetArpPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
void ArpInit(void)
net_arp_wait_packet_ip.s_addr = 0;
net_arp_wait_reply_ip.s_addr = 0;
NetArpWaitTxPacketSize = 0;
- NetArpTxPacket = &NetArpPacketBuf[0] + (PKTALIGN - 1);
- NetArpTxPacket -= (ulong)NetArpTxPacket % PKTALIGN;
+ net_arp_tx_packet = &NetArpPacketBuf[0] + (PKTALIGN - 1);
+ net_arp_tx_packet -= (ulong)net_arp_tx_packet % PKTALIGN;
}
void arp_raw_request(struct in_addr source_ip, const uchar *targetEther,
debug_cond(DEBUG_DEV_PKT, "ARP broadcast %d\n", NetArpWaitTry);
- pkt = NetArpTxPacket;
+ pkt = net_arp_tx_packet;
- eth_hdr_size = NetSetEther(pkt, net_bcast_ethaddr, PROT_ARP);
+ eth_hdr_size = net_set_ether(pkt, net_bcast_ethaddr, PROT_ARP);
pkt += eth_hdr_size;
arp = (struct arp_hdr *) pkt;
memcpy(&arp->ar_tha, targetEther, ARP_HLEN); /* target ET addr */
net_write_ip(&arp->ar_tpa, target_ip); /* target IP addr */
- NetSendPacket(NetArpTxPacket, eth_hdr_size + ARP_HDR_SIZE);
+ net_send_packet(net_arp_tx_packet, eth_hdr_size + ARP_HDR_SIZE);
}
void ArpRequest(void)
(net_read_ip(&arp->ar_spa).s_addr & net_netmask.s_addr))
udelay(5000);
#endif
- NetSendPacket((uchar *)et, eth_hdr_size + ARP_HDR_SIZE);
+ net_send_packet((uchar *)et, eth_hdr_size + ARP_HDR_SIZE);
return;
case ARPOP_REPLY: /* arp reply */
/* set the mac address in the waiting packet's header
and transmit it */
- memcpy(((struct ethernet_hdr *)NetTxPacket)->et_dest,
- &arp->ar_sha, ARP_HLEN);
- NetSendPacket(NetTxPacket, NetArpWaitTxPacketSize);
+ memcpy(((struct ethernet_hdr *)net_tx_packet)->et_dest,
+ &arp->ar_sha, ARP_HLEN);
+ net_send_packet(net_tx_packet, NetArpWaitTxPacketSize);
/* no arp request pending now */
net_arp_wait_packet_ip.s_addr = 0;
net_copy_ip(&tmp_ip, &bp->bp_siaddr);
if (tmp_ip.s_addr != 0)
net_copy_ip(&net_server_ip, &bp->bp_siaddr);
- memcpy(net_server_ethaddr, ((struct ethernet_hdr *)NetRxPacket)->et_src,
- 6);
+ memcpy(net_server_ethaddr,
+ ((struct ethernet_hdr *)net_rx_packet)->et_src, 6);
if (strlen(bp->bp_file) > 0)
copy_filename(net_boot_file_name, bp->bp_file,
sizeof(net_boot_file_name));
#endif /* CONFIG_BOOTP_RANDOM_DELAY */
printf("BOOTP broadcast %d\n", ++BootpTry);
- pkt = NetTxPacket;
+ pkt = net_tx_packet;
memset((void *)pkt, 0, PKTSIZE);
- eth_hdr_size = NetSetEther(pkt, net_bcast_ethaddr, PROT_IP);
+ eth_hdr_size = net_set_ether(pkt, net_bcast_ethaddr, PROT_IP);
pkt += eth_hdr_size;
/*
#else
net_set_udp_handler(bootp_handler);
#endif
- NetSendPacket(NetTxPacket, pktlen);
+ net_send_packet(net_tx_packet, pktlen);
}
#if defined(CONFIG_CMD_DHCP)
struct in_addr bcast_ip;
debug("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
- pkt = NetTxPacket;
+ pkt = net_tx_packet;
memset((void *)pkt, 0, PKTSIZE);
- eth_hdr_size = NetSetEther(pkt, net_bcast_ethaddr, PROT_IP);
+ eth_hdr_size = net_set_ether(pkt, net_bcast_ethaddr, PROT_IP);
pkt += eth_hdr_size;
iphdr = pkt; /* We'll need this later to set proper pkt size */
udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY);
#endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */
debug("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
- NetSendPacket(NetTxPacket, pktlen);
+ net_send_packet(net_tx_packet, pktlen);
}
/*
char buf[32];
#endif
- pkt = NetTxPacket;
+ pkt = net_tx_packet;
et = (struct ethernet_hdr *)pkt;
/* NOTE: trigger sent not on any VLAN */
#endif
/* length of ethernet packet */
- len = (uchar *)s - ((uchar *)NetTxPacket + ETHER_HDR_SIZE);
+ len = (uchar *)s - ((uchar *)net_tx_packet + ETHER_HDR_SIZE);
et->et_protlen = htons(len);
len = ETHER_HDR_SIZE + sizeof(CDP_SNAP_hdr);
- chksum = CDP_compute_csum((uchar *)NetTxPacket + len,
- (uchar *)s - (NetTxPacket + len));
+ chksum = CDP_compute_csum((uchar *)net_tx_packet + len,
+ (uchar *)s - (net_tx_packet + len));
if (chksum == 0)
chksum = 0xFFFF;
*cp = htons(chksum);
- NetSendPacket(NetTxPacket, (uchar *)s - NetTxPacket);
+ net_send_packet(net_tx_packet, (uchar *)s - net_tx_packet);
return 0;
}
enum dns_query_type qtype = DNS_A_RECORD;
name = NetDNSResolve;
- pkt = p = (uchar *)(NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE);
+ pkt = (uchar *)(net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE);
+ p = pkt;
/* Prepare DNS packet header */
header = (struct header *) pkt;
DnsOurPort = random_port();
- NetSendUDPPacket(net_server_ethaddr, net_dns_server, DNS_SERVICE_PORT,
- DnsOurPort, n);
+ net_send_udp_packet(net_server_ethaddr, net_dns_server,
+ DNS_SERVICE_PORT, DnsOurPort, n);
debug("DNS packet sent\n");
}
/* Server IP addr (0 = unknown) */
struct in_addr net_server_ip;
/* Current receive packet */
-uchar *NetRxPacket;
+uchar *net_rx_packet;
/* Current rx packet length */
-int NetRxPacketLen;
+int net_rx_packet_len;
/* IP packet ID */
unsigned NetIPID;
/* Ethernet bcast address */
int NetTimeOffset;
#endif
-static uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
+static uchar net_pkt_buf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
#ifdef CONFIG_DM_ETH
/* Receive packets */
uchar *net_rx_packets[PKTBUFSRX];
/* Current timeout value */
static ulong timeDelta;
/* THE transmit packet */
-uchar *NetTxPacket;
+uchar *net_tx_packet;
static int net_check_prereq(enum proto_t protocol);
*/
int i;
- NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
- NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
+ net_tx_packet = &net_pkt_buf[0] + (PKTALIGN - 1);
+ net_tx_packet -= (ulong)net_tx_packet % PKTALIGN;
#ifdef CONFIG_DM_ETH
for (i = 0; i < PKTBUFSRX; i++) {
- net_rx_packets[i] = NetTxPacket + (i + 1) *
- PKTSIZE_ALIGN;
+ net_rx_packets[i] = net_tx_packet +
+ (i + 1) * PKTSIZE_ALIGN;
}
#else
for (i = 0; i < PKTBUFSRX; i++)
- NetRxPackets[i] = NetTxPacket + (i + 1) * PKTSIZE_ALIGN;
+ NetRxPackets[i] = net_tx_packet +
+ (i + 1) * PKTSIZE_ALIGN;
#endif
ArpInit();
net_clear_handlers();
}
}
-int NetSendUDPPacket(uchar *ether, struct in_addr dest, int dport, int sport,
+int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport, int sport,
int payload_len)
{
uchar *pkt;
int eth_hdr_size;
int pkt_hdr_size;
- /* make sure the NetTxPacket is initialized (NetInit() was called) */
- assert(NetTxPacket != NULL);
- if (NetTxPacket == NULL)
+ /* make sure the net_tx_packet is initialized (NetInit() was called) */
+ assert(net_tx_packet != NULL);
+ if (net_tx_packet == NULL)
return -1;
/* convert to new style broadcast */
if (dest.s_addr == 0xFFFFFFFF)
ether = (uchar *)net_bcast_ethaddr;
- pkt = (uchar *)NetTxPacket;
+ pkt = (uchar *)net_tx_packet;
- eth_hdr_size = NetSetEther(pkt, ether, PROT_IP);
+ eth_hdr_size = net_set_ether(pkt, ether, PROT_IP);
pkt += eth_hdr_size;
net_set_udp_header(pkt, dest, dport, sport, payload_len);
pkt_hdr_size = eth_hdr_size + IP_UDP_HDR_SIZE;
} else {
debug_cond(DEBUG_DEV_PKT, "sending UDP to %pI4/%pM\n",
&dest, ether);
- NetSendPacket(NetTxPacket, pkt_hdr_size + payload_len);
+ net_send_packet(net_tx_packet, pkt_hdr_size + payload_len);
return 0; /* transmitted */
}
}
debug_cond(DEBUG_NET_PKT, "packet received\n");
- NetRxPacket = in_packet;
- NetRxPacketLen = len;
+ net_rx_packet = in_packet;
+ net_rx_packet_len = len;
et = (struct ethernet_hdr *)in_packet;
/* too small packet? */
/**********************************************************************/
int
-NetEthHdrSize(void)
+net_eth_hdr_size(void)
{
ushort myvlanid;
VLAN_ETHER_HDR_SIZE;
}
-int
-NetSetEther(uchar *xet, const uchar *dest_ethaddr, uint prot)
+int net_set_ether(uchar *xet, const uchar *dest_ethaddr, uint prot)
{
struct ethernet_hdr *et = (struct ethernet_hdr *)xet;
ushort myvlanid;
pktlen = (char *)p + datalen*sizeof(uint32_t) - (char *)&pkt;
- memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE,
- (char *)&pkt, pktlen);
+ memcpy((char *)net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE,
+ (char *)&pkt, pktlen);
if (rpc_prog == PROG_PORTMAP)
sport = SUNRPC_PORT;
else
sport = NfsSrvNfsPort;
- NetSendUDPPacket(net_server_ethaddr, nfs_server_ip, sport, NfsOurPort,
- pktlen);
+ net_send_udp_packet(net_server_ethaddr, nfs_server_ip, sport,
+ NfsOurPort, pktlen);
}
/**************************************************************************
net_arp_wait_packet_ip = net_ping_ip;
- eth_hdr_size = NetSetEther(NetTxPacket, net_null_ethaddr, PROT_IP);
- pkt = (uchar *)NetTxPacket + eth_hdr_size;
+ eth_hdr_size = net_set_ether(net_tx_packet, net_null_ethaddr, PROT_IP);
+ pkt = (uchar *)net_tx_packet + eth_hdr_size;
set_icmp_header(pkt, net_ping_ip);
icmph->type = ICMP_ECHO_REPLY;
icmph->checksum = 0;
icmph->checksum = compute_ip_checksum(icmph, len - IP_HDR_SIZE);
- NetSendPacket((uchar *)et, eth_hdr_size + len);
+ net_send_packet((uchar *)et, eth_hdr_size + len);
return;
/* default:
return;*/
int eth_hdr_size;
printf("RARP broadcast %d\n", ++RarpTry);
- pkt = NetTxPacket;
+ pkt = net_tx_packet;
- eth_hdr_size = NetSetEther(pkt, net_bcast_ethaddr, PROT_RARP);
+ eth_hdr_size = net_set_ether(pkt, net_bcast_ethaddr, PROT_RARP);
pkt += eth_hdr_size;
rarp = (struct arp_hdr *)pkt;
/* dest IP addr set to broadcast */
memset(&rarp->ar_data[16], 0xff, 4);
- NetSendPacket(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE);
+ net_send_packet(net_tx_packet, eth_hdr_size + ARP_HDR_SIZE);
NetSetTimeout(TIMEOUT, RarpTimeout);
}
pkt.vn = NTP_VERSION;
pkt.mode = NTP_MODE_CLIENT;
- memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE,
- (char *)&pkt, pktlen);
+ memcpy((char *)net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE,
+ (char *)&pkt, pktlen);
SntpOurPort = 10000 + (get_timer(0) % 4096);
sport = NTP_SERVICE_PORT;
- NetSendUDPPacket(net_server_ethaddr, net_ntp_server, sport, SntpOurPort,
- pktlen);
+ net_send_udp_packet(net_server_ethaddr, net_ntp_server, sport,
+ SntpOurPort, pktlen);
}
static void
* We will always be sending some sort of packet, so
* cobble together the packet headers now.
*/
- pkt = NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
+ pkt = net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE;
switch (TftpState) {
case STATE_SEND_RRQ:
break;
}
- NetSendUDPPacket(net_server_ethaddr, tftp_remote_ip, TftpRemotePort,
- TftpOurPort, len);
+ net_send_udp_packet(net_server_ethaddr, tftp_remote_ip, TftpRemotePort,
+ TftpOurPort, len);
}
#ifdef CONFIG_CMD_TFTPPUT