[SLOF] [PATCH v2 04/10] libnet: Make netapps.h includable from .code files

Thomas Huth thuth at redhat.com
Tue Sep 20 05:08:26 AEST 2016


Unfortunately netapps.h currently can't be included from .code
Forth-to-C wrapper files - it includes tftp.h which in turn
includes ipv6.h, and that header contains some constructs which
can't be used in .code files. So let's make netapps.h independent
from tftp.h and add some "extern" keywords like it is done with
the other header files already that are included from .code files.

Signed-off-by: Thomas Huth <thuth at redhat.com>
---
 lib/libnet/netapps.h | 13 +++++++------
 lib/libnet/netload.c |  3 ++-
 lib/libnet/tftp.h    |  5 +++--
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib/libnet/netapps.h b/lib/libnet/netapps.h
index 8fceba8..693de69 100644
--- a/lib/libnet/netapps.h
+++ b/lib/libnet/netapps.h
@@ -13,14 +13,15 @@
 #ifndef _NETAPPS_H_
 #define _NETAPPS_H_
 
-#include <tftp.h>
-
 #define F_IPV4	4
 #define F_IPV6	6
 
-int netboot(int argc, char *argv[]);
-int netsave(int argc, char *argv[]);
-int ping(int argc, char *argv[]);
-int dhcp(char *ret_buffer, filename_ip_t * fn_ip, unsigned int retries, int flags);
+struct filename_ip;
+
+extern int netboot(int argc, char *argv[]);
+extern int netsave(int argc, char *argv[]);
+extern int ping(int argc, char *argv[]);
+extern int dhcp(char *ret_buffer, struct filename_ip *fn_ip,
+		unsigned int retries, int flags);
 
 #endif
diff --git a/lib/libnet/netload.c b/lib/libnet/netload.c
index 7ded3e4..1b7c1bc 100644
--- a/lib/libnet/netload.c
+++ b/lib/libnet/netload.c
@@ -328,7 +328,8 @@ parse_args(const char *arg_str, obp_tftp_args_t *obp_tftp_args)
  * @return               ZERO - IP and configuration info obtained;
  *                       NON ZERO - error condition occurs.
  */
-int dhcp(char *ret_buffer, filename_ip_t * fn_ip, unsigned int retries, int flags)
+int dhcp(char *ret_buffer, struct filename_ip *fn_ip, unsigned int retries,
+	 int flags)
 {
 	int i = (int) retries+1;
 	int rc = -1;
diff --git a/lib/libnet/tftp.h b/lib/libnet/tftp.h
index 6b5996c..303feaf 100644
--- a/lib/libnet/tftp.h
+++ b/lib/libnet/tftp.h
@@ -22,7 +22,7 @@ struct tftphdr {
 	uint16_t th_data;
 };
 
-typedef struct {
+struct filename_ip {
 	uint32_t own_ip;
 	ip6_addr_t own_ip6;
 	uint32_t server_ip;
@@ -30,7 +30,8 @@ typedef struct {
 	ip6_addr_t dns_ip6;
 	int8_t filename[256];
 	int    fd;
-} __attribute__ ((packed)) filename_ip_t ;
+} __attribute__ ((packed));
+typedef struct filename_ip filename_ip_t;
 
 typedef struct {
 	uint32_t bad_tftp_packets;
-- 
1.8.3.1



More information about the SLOF mailing list