[PATCH 2/5] net: Move some variables to net-common files
Andrew Goodbody
andrew.goodbody at linaro.org
Mon Dec 8 13:52:08 CET 2025
Make some variables available to be used by either the legacy network
code or LWIP by moving them into the net-common files. This also allowed
removing a small number of duplicated variables from the LWIP code.
Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
include/net-common.h | 21 +++++++++++++++++++--
include/net-legacy.h | 9 ---------
net/lwip/net-lwip.c | 5 -----
net/net-common.c | 18 ++++++++++++++++++
net/net.c | 21 ---------------------
5 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/include/net-common.h b/include/net-common.h
index d7a0f7dff7e50527e77419ead9a9ff30deeea545..ea43c72ab06a782c621f61811b9774c1185d88fc 100644
--- a/include/net-common.h
+++ b/include/net-common.h
@@ -132,13 +132,30 @@ static inline void net_set_state(enum net_loop_state state)
}
extern int net_restart_wrap; /* Tried all network devices */
-extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */
+extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */
+extern uchar *net_rx_packet; /* Current receive packet */
extern const u8 net_bcast_ethaddr[ARP_HLEN]; /* Ethernet broadcast address */
-extern char net_boot_file_name[1024];/* Boot File name */
extern struct in_addr net_ip; /* Our IP addr (0 = unknown) */
/* Indicates whether the pxe path prefix / config file was specified in dhcp option */
extern char *pxelinux_configfile;
+/* Our IP addr (0 = unknown) */
+extern struct in_addr net_ip;
+/* Server IP addr (0 = unknown) */
+extern struct in_addr net_server_ip;
+/* Our subnet mask (0=unknown) */
+extern struct in_addr net_netmask;
+/* Our gateways IP address */
+extern struct in_addr net_gateway;
+/* Boot File name */
+extern char net_boot_file_name[1024];
+/* Indicates whether the file name was specified on the command line */
+extern bool net_boot_file_name_explicit;
+/* The actual transferred size of the bootfile (in bytes) */
+extern u32 net_boot_file_size;
+/* Boot file size in blocks as reported by the DHCP server */
+extern u32 net_boot_file_expected_size_in_blocks;
+
/**
* compute_ip_checksum() - Compute IP checksum
*
diff --git a/include/net-legacy.h b/include/net-legacy.h
index 0a10121b0cf50898a90bb1179966f01dbdda65ad..3a07cb53839d458a6eeaa1fcc935b29ac928aad8 100644
--- a/include/net-legacy.h
+++ b/include/net-legacy.h
@@ -289,8 +289,6 @@ extern u8 net_ethaddr[ARP_HLEN]; /* Our ethernet address */
extern u8 net_server_ethaddr[ARP_HLEN]; /* Boot server enet address */
extern struct in_addr net_server_ip; /* Server IP addr (0 = unknown) */
extern uchar *net_tx_packet; /* THE transmit packet */
-extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */
-extern uchar *net_rx_packet; /* Current receive packet */
extern int net_rx_packet_len; /* Current rx packet length */
extern const u8 net_null_ethaddr[ARP_HLEN];
@@ -307,13 +305,6 @@ enum proto_t {
WOL, UDP, NCSI, WGET, RS
};
-/* Indicates whether the file name was specified on the command line */
-extern bool net_boot_file_name_explicit;
-/* The actual transferred size of the bootfile (in bytes) */
-extern u32 net_boot_file_size;
-/* Boot file size in blocks as reported by the DHCP server */
-extern u32 net_boot_file_expected_size_in_blocks;
-
#if defined(CONFIG_DNS)
extern char *net_dns_resolve; /* The host to resolve */
extern char *net_dns_env_var; /* the env var to put the ip into */
diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c
index 8741f65fe12e23cc30068506453a762533f8a67f..b3b6c796976ea9d7aec4148992f7cd41cd8f8743 100644
--- a/net/lwip/net-lwip.c
+++ b/net/lwip/net-lwip.c
@@ -33,13 +33,8 @@ static int net_restarted;
int net_restart_wrap;
static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN]
__aligned(PKTALIGN);
-uchar *net_rx_packets[PKTBUFSRX];
-uchar *net_rx_packet;
const u8 net_bcast_ethaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
char *pxelinux_configfile;
-/* Our IP addr (0 = unknown) */
-struct in_addr net_ip;
-char net_boot_file_name[1024];
static err_t net_lwip_tx(struct netif *netif, struct pbuf *p)
{
diff --git a/net/net-common.c b/net/net-common.c
index ec1e179f7d9cdd459dc3b8c2d13f6e478ad4ce87..155149c80439306cb02b7c3e4080d210ae0991fb 100644
--- a/net/net-common.c
+++ b/net/net-common.c
@@ -8,6 +8,24 @@
/* Network loop state */
enum net_loop_state net_state;
+/* Our IP addr (0 = unknown) */
+struct in_addr net_ip;
+/* Server IP addr (0 = unknown) */
+struct in_addr net_server_ip;
+/* Our subnet mask (0=unknown) */
+struct in_addr net_netmask;
+/* Our gateways IP address */
+struct in_addr net_gateway;
+/* Boot File name */
+char net_boot_file_name[1024];
+/* Indicates whether the file name was specified on the command line */
+bool net_boot_file_name_explicit;
+/* The actual transferred size of the bootfile (in bytes) */
+u32 net_boot_file_size;
+/* Boot file size in blocks as reported by the DHCP server */
+u32 net_boot_file_expected_size_in_blocks;
+uchar *net_rx_packets[PKTBUFSRX];
+uchar *net_rx_packet;
void copy_filename(char *dst, const char *src, int size)
{
diff --git a/net/net.c b/net/net.c
index 03a39419d10817aff5f12badc0f604a403fe7fb2..bd7f12248fa3fcdf1ecdced31559dc805e151ba1 100644
--- a/net/net.c
+++ b/net/net.c
@@ -128,10 +128,6 @@
/** BOOTP EXTENTIONS **/
-/* Our subnet mask (0=unknown) */
-struct in_addr net_netmask;
-/* Our gateways IP address */
-struct in_addr net_gateway;
/* Our DNS IP address */
struct in_addr net_dns_server;
#if defined(CONFIG_BOOTP_DNS2)
@@ -147,12 +143,6 @@ char *pxelinux_configfile;
u8 net_ethaddr[6];
/* Boot server enet address */
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 *net_rx_packet;
/* Current rx packet length */
int net_rx_packet_len;
/* IP packet ID */
@@ -176,18 +166,7 @@ ushort net_our_vlan = 0xFFFF;
/* ditto */
ushort net_native_vlan = 0xFFFF;
-/* Boot File name */
-char net_boot_file_name[1024];
-/* Indicates whether the file name was specified on the command line */
-bool net_boot_file_name_explicit;
-/* The actual transferred size of the bootfile (in bytes) */
-u32 net_boot_file_size;
-/* Boot file size in blocks as reported by the DHCP server */
-u32 net_boot_file_expected_size_in_blocks;
-
static uchar net_pkt_buf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
-/* Receive packets */
-uchar *net_rx_packets[PKTBUFSRX];
/* Current UDP RX packet handler */
static rxhand_f *udp_packet_handler;
/* Current ARP RX packet handler */
--
2.47.3
More information about the U-Boot
mailing list