]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - net/net.c
net: cosmetic: Clean up RARP variables and functions
[karo-tx-uboot.git] / net / net.c
index fcab1ef9a3c2e1088e00ae59c1de27ce50d94439..bd92806ba4427ec0b907de16c4a701951cd32751 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -121,12 +121,6 @@ struct in_addr net_dns_server;
 /* Our 2nd DNS IP address */
 struct in_addr net_dns_server2;
 #endif
-/* Our NIS domain */
-char           NetOurNISDomain[32] = {0,};
-/* Our hostname */
-char           NetOurHostName[32] = {0,};
-/* Our bootpath */
-char           NetOurRootPath[64] = {0,};
 
 #ifdef CONFIG_MCAST_TFTP       /* Multicast TFTP */
 struct in_addr net_mcast_addr;
@@ -135,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
@@ -183,14 +177,9 @@ struct in_addr     net_ntp_server;
 int            NetTimeOffset;
 #endif
 
-static uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
-#ifdef CONFIG_DM_ETH
+static uchar net_pkt_buf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
 /* Receive packets */
 uchar *net_rx_packets[PKTBUFSRX];
-#else
-/* Receive packet */
-uchar *NetRxPackets[PKTBUFSRX];
-#endif
 /* Current UDP RX packet handler */
 static rxhand_f *udp_packet_handler;
 /* Current ARP RX packet handler */
@@ -206,7 +195,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);
 
@@ -246,7 +235,7 @@ void net_auto_load(void)
                /*
                 * Use NFS to load the bootfile.
                 */
-               NfsStart();
+               nfs_start();
                return;
        }
 #endif
@@ -258,7 +247,7 @@ void net_auto_load(void)
                net_set_state(NETLOOP_SUCCESS);
                return;
        }
-       TftpStart(TFTPGET);
+       tftp_start(TFTPGET);
 }
 
 static void NetInitLoop(void)
@@ -280,7 +269,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;
 }
@@ -307,18 +296,13 @@ void net_init(void)
                 */
                int i;
 
-               NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
-               NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
-#ifdef CONFIG_DM_ETH
+               net_tx_packet = &net_pkt_buf[0] + (PKTALIGN - 1);
+               net_tx_packet -= (ulong)net_tx_packet % PKTALIGN;
                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;
-#endif
-               ArpInit();
+               arp_init();
                net_clear_handlers();
 
                /* Only need to setup buffer pointers once. */
@@ -388,32 +372,32 @@ restart:
                case TFTPPUT:
 #endif
                        /* always use ARP to get server ethernet address */
-                       TftpStart(protocol);
+                       tftp_start(protocol);
                        break;
 #ifdef CONFIG_CMD_TFTPSRV
                case TFTPSRV:
-                       TftpStartServer();
+                       tftp_start_server();
                        break;
 #endif
 #if defined(CONFIG_CMD_DHCP)
                case DHCP:
-                       BootpReset();
+                       bootp_reset();
                        net_ip.s_addr = 0;
-                       DhcpRequest();          /* Basically same as BOOTP */
+                       dhcp_request();         /* Basically same as BOOTP */
                        break;
 #endif
 
                case BOOTP:
-                       BootpReset();
+                       bootp_reset();
                        net_ip.s_addr = 0;
-                       BootpRequest();
+                       bootp_request();
                        break;
 
 #if defined(CONFIG_CMD_RARP)
                case RARP:
-                       RarpTry = 0;
+                       rarp_try = 0;
                        net_ip.s_addr = 0;
-                       RarpRequest();
+                       rarp_request();
                        break;
 #endif
 #if defined(CONFIG_CMD_PING)
@@ -423,7 +407,7 @@ restart:
 #endif
 #if defined(CONFIG_CMD_NFS)
                case NFS:
-                       NfsStart();
+                       nfs_start();
                        break;
 #endif
 #if defined(CONFIG_CMD_CDP)
@@ -516,7 +500,7 @@ restart:
                        goto done;
                }
 
-               ArpTimeoutCheck();
+               arp_timeout_check();
 
                /*
                 *      Check for a timeout, and run the timeout handler
@@ -722,16 +706,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 */
@@ -740,35 +724,35 @@ 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 */
                net_arp_wait_packet_ip = dest;
-               NetArpWaitPacketMAC = ether;
+               arp_wait_packet_ethaddr = ether;
 
                /* size of the waiting packet */
-               NetArpWaitTxPacketSize = pkt_hdr_size + payload_len;
+               arp_wait_tx_packet_size = pkt_hdr_size + payload_len;
 
                /* and do the ARP request */
-               NetArpWaitTry = 1;
-               NetArpWaitTimerStart = get_timer(0);
-               ArpRequest();
+               arp_wait_try = 1;
+               arp_wait_timer_start = get_timer(0);
+               arp_request();
                return 1;       /* waiting */
        } 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 */
        }
 }
@@ -991,8 +975,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? */
@@ -1081,7 +1065,7 @@ void net_process_received_packet(uchar *in_packet, int len)
        switch (eth_proto) {
 
        case PROT_ARP:
-               ArpReceive(et, ip, len);
+               arp_receive(et, ip, len);
                break;
 
 #ifdef CONFIG_CMD_RARP
@@ -1291,7 +1275,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) {
@@ -1319,7 +1303,7 @@ common:
 /**********************************************************************/
 
 int
-NetEthHdrSize(void)
+net_eth_hdr_size(void)
 {
        ushort myvlanid;
 
@@ -1331,8 +1315,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;
@@ -1341,8 +1324,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;
@@ -1362,7 +1345,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 =