]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - net/net.c
net: cosmetic: Cleanup internal packet buffer names
[karo-tx-uboot.git] / net / net.c
index b1461d515388847a1a259fbcca315bdb41ccaa3f..671813e33517e68e1d9efef5eb796f919e6d1ca9 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -129,22 +129,22 @@ struct in_addr net_mcast_addr;
 /** END OF BOOTP EXTENTIONS **/
 
 /* Our ethernet address */
-uchar          NetOurEther[6];
+u8 net_ethaddr[6];
 /* Boot server enet address */
-uchar          NetServerEther[6];
+u8 net_server_ethaddr[6];
 /* Our IP addr (0 = unknown) */
 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 */
-uchar          NetBcastAddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-uchar          NetEtherNullAddr[6];
+const u8 net_bcast_ethaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+const u8 net_null_ethaddr[6];
 #ifdef CONFIG_API
 void           (*push_packet)(void *, int len) = 0;
 #endif
@@ -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);
 
@@ -274,7 +274,7 @@ static void NetInitLoop(void)
                env_changed_id = env_id;
        }
        if (eth_get_dev())
-               memcpy(NetOurEther, eth_get_ethaddr(), 6);
+               memcpy(net_ethaddr, eth_get_ethaddr(), 6);
 
        return;
 }
@@ -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();
@@ -716,16 +717,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 */
@@ -734,17 +735,17 @@ int NetSendUDPPacket(uchar *ether, struct in_addr dest, int dport, int sport,
 
        /* if broadcast, make the ether address a broadcast and don't do ARP */
        if (dest.s_addr == 0xFFFFFFFF)
-               ether = NetBcastAddr;
+               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;
 
        /* if MAC address was not discovered yet, do an ARP request */
-       if (memcmp(ether, NetEtherNullAddr, 6) == 0) {
+       if (memcmp(ether, net_null_ethaddr, 6) == 0) {
                debug_cond(DEBUG_DEV_PKT, "sending ARP for %pI4\n", &dest);
 
                /* save the ip and eth addr for the packet to send after arp */
@@ -762,7 +763,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 */
        }
 }
@@ -985,8 +986,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? */
@@ -1285,7 +1286,7 @@ common:
        case CDP:
        case DHCP:
        case LINKLOCAL:
-               if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
+               if (memcmp(net_ethaddr, "\0\0\0\0\0\0", 6) == 0) {
                        int num = eth_get_dev_index();
 
                        switch (num) {
@@ -1313,7 +1314,7 @@ common:
 /**********************************************************************/
 
 int
-NetEthHdrSize(void)
+net_eth_hdr_size(void)
 {
        ushort myvlanid;
 
@@ -1325,8 +1326,7 @@ NetEthHdrSize(void)
                VLAN_ETHER_HDR_SIZE;
 }
 
-int
-NetSetEther(uchar *xet, uchar * addr, uint prot)
+int net_set_ether(uchar *xet, const uchar *dest_ethaddr, uint prot)
 {
        struct ethernet_hdr *et = (struct ethernet_hdr *)xet;
        ushort myvlanid;
@@ -1335,8 +1335,8 @@ NetSetEther(uchar *xet, uchar * addr, uint prot)
        if (myvlanid == (ushort)-1)
                myvlanid = VLAN_NONE;
 
-       memcpy(et->et_dest, addr, 6);
-       memcpy(et->et_src, NetOurEther, 6);
+       memcpy(et->et_dest, dest_ethaddr, 6);
+       memcpy(et->et_src, net_ethaddr, 6);
        if ((myvlanid & VLAN_IDMASK) == VLAN_NONE) {
                et->et_protlen = htons(prot);
                return ETHER_HDR_SIZE;
@@ -1356,7 +1356,7 @@ int net_update_ether(struct ethernet_hdr *et, uchar *addr, uint prot)
        ushort protlen;
 
        memcpy(et->et_dest, addr, 6);
-       memcpy(et->et_src, NetOurEther, 6);
+       memcpy(et->et_src, net_ethaddr, 6);
        protlen = ntohs(et->et_protlen);
        if (protlen == PROT_VLAN) {
                struct vlan_ethernet_hdr *vet =