From 1203fcceec113d502995f7242d7e1be09d373e80 Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Wed, 8 Apr 2015 01:41:05 -0500 Subject: net: cosmetic: Cleanup internal packet buffer names This patch cleans up the names of internal packet buffer names that are used within the network stack and the functions that use them. Signed-off-by: Joe Hershberger diff --git a/arch/powerpc/cpu/mpc8260/ether_fcc.c b/arch/powerpc/cpu/mpc8260/ether_fcc.c index 240e7ae..50d1654 100644 --- a/arch/powerpc/cpu/mpc8260/ether_fcc.c +++ b/arch/powerpc/cpu/mpc8260/ether_fcc.c @@ -720,8 +720,8 @@ eth_loopback_test (void) 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; diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 0d81b44..9aba0c5 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -125,10 +125,11 @@ void NcStart(void) /* 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); } } @@ -202,11 +203,11 @@ static void nc_send_packet(const char *buf, int 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()) @@ -229,7 +230,7 @@ static int nc_start(struct stdio_dev *dev) /* * 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(); diff --git a/include/net.h b/include/net.h index 8a3e5ff..294dc40 100644 --- a/include/net.h +++ b/include/net.h @@ -481,14 +481,14 @@ extern u8 net_ethaddr[6]; /* Our ethernet address */ 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]; @@ -556,10 +556,10 @@ void NetStop(void); 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 */ @@ -621,14 +621,14 @@ static inline void net_set_state(enum net_loop_state state) } /* 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 @@ -637,7 +637,7 @@ static inline void NetSendPacket(uchar *pkt, int len) * @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 diff --git a/net/arp.c b/net/arp.c index c613609..6841b61 100644 --- a/net/arp.c +++ b/net/arp.c @@ -35,7 +35,7 @@ int NetArpWaitTxPacketSize; 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) @@ -45,8 +45,8 @@ 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, @@ -58,9 +58,9 @@ 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; @@ -76,7 +76,7 @@ void arp_raw_request(struct in_addr source_ip, const uchar *targetEther, 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) @@ -184,7 +184,7 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len) (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 */ @@ -218,9 +218,9 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len) /* 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; diff --git a/net/bootp.c b/net/bootp.c index 9b27d4c..9788b52 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -147,8 +147,8 @@ static void BootpCopyNetParams(struct Bootp_t *bp) 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)); @@ -691,10 +691,10 @@ BootpRequest(void) #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; /* @@ -760,7 +760,7 @@ BootpRequest(void) #else net_set_udp_handler(bootp_handler); #endif - NetSendPacket(NetTxPacket, pktlen); + net_send_packet(net_tx_packet, pktlen); } #if defined(CONFIG_CMD_DHCP) @@ -894,10 +894,10 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) 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 */ @@ -945,7 +945,7 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) 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); } /* diff --git a/net/cdp.c b/net/cdp.c index e8e7a67..392437d 100644 --- a/net/cdp.c +++ b/net/cdp.c @@ -118,7 +118,7 @@ CDPSendTrigger(void) char buf[32]; #endif - pkt = NetTxPacket; + pkt = net_tx_packet; et = (struct ethernet_hdr *)pkt; /* NOTE: trigger sent not on any VLAN */ @@ -207,17 +207,17 @@ CDPSendTrigger(void) #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; } diff --git a/net/dns.c b/net/dns.c index 0ff2b75..50d78ae 100644 --- a/net/dns.c +++ b/net/dns.c @@ -45,7 +45,8 @@ DnsSend(void) 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; @@ -89,8 +90,8 @@ DnsSend(void) 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"); } diff --git a/net/net.c b/net/net.c index 6db2b9c..0e8e9c9 100644 --- a/net/net.c +++ b/net/net.c @@ -137,9 +137,9 @@ struct in_addr net_ip; /* 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 */ @@ -177,7 +177,7 @@ struct in_addr net_ntp_server; 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]; @@ -200,7 +200,7 @@ static ulong timeStart; /* Current timeout value */ static ulong timeDelta; /* THE transmit packet */ -uchar *NetTxPacket; +uchar *net_tx_packet; static int net_check_prereq(enum proto_t protocol); @@ -301,16 +301,17 @@ void net_init(void) */ 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(); @@ -710,16 +711,16 @@ NetSetTimeout(ulong iv, thand_f *f) } } -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 */ @@ -730,9 +731,9 @@ int NetSendUDPPacket(uchar *ether, struct in_addr dest, int dport, int sport, 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; @@ -756,7 +757,7 @@ int NetSendUDPPacket(uchar *ether, struct in_addr dest, int dport, int sport, } 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 */ } } @@ -979,8 +980,8 @@ void net_process_received_packet(uchar *in_packet, int len) 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? */ @@ -1307,7 +1308,7 @@ common: /**********************************************************************/ int -NetEthHdrSize(void) +net_eth_hdr_size(void) { ushort myvlanid; @@ -1319,8 +1320,7 @@ NetEthHdrSize(void) 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; diff --git a/net/nfs.c b/net/nfs.c index 23a9cc3..6899265 100644 --- a/net/nfs.c +++ b/net/nfs.c @@ -201,8 +201,8 @@ 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_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; @@ -211,8 +211,8 @@ rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) 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); } /************************************************************************** diff --git a/net/ping.c b/net/ping.c index e4e3086..7c6084c 100644 --- a/net/ping.c +++ b/net/ping.c @@ -50,8 +50,8 @@ static int ping_send(void) 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); @@ -106,7 +106,7 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len) 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;*/ diff --git a/net/rarp.c b/net/rarp.c index 2f5c104..f50d2fb 100644 --- a/net/rarp.c +++ b/net/rarp.c @@ -75,9 +75,9 @@ void RarpRequest(void) 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; @@ -94,7 +94,7 @@ void RarpRequest(void) /* 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); } diff --git a/net/sntp.c b/net/sntp.c index b99aa3e..1e2b678 100644 --- a/net/sntp.c +++ b/net/sntp.c @@ -31,14 +31,14 @@ SntpSend(void) 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 diff --git a/net/tftp.c b/net/tftp.c index 8ddc7be..f25abaa 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -337,7 +337,7 @@ TftpSend(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: @@ -435,8 +435,8 @@ TftpSend(void) 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 -- cgit v0.10.2