[rtems commit] network/bootp: PR2031: Add and use header file

Sebastian Huber sebh at rtems.org
Wed Jun 6 11:43:19 UTC 2012


Module:    rtems
Branch:    master
Commit:    6c18c97be0967c3c5cd1eb3ee4e964f6ca0dfd9d
Changeset: http://git.rtems.org/rtems/commit/?id=6c18c97be0967c3c5cd1eb3ee4e964f6ca0dfd9d

Author:    Sebastien Bourdeauducq <sebastien at milkymist.org>
Date:      Tue May 22 12:06:20 2012 +0200

network/bootp: PR2031: Add and use header file

---

 cpukit/libnetworking/Makefile.am                   |    1 +
 cpukit/libnetworking/nfs/bootp_subr.c              |   18 +-------
 cpukit/libnetworking/rtems/bootp.h                 |   41 ++++++++++++++++++++
 cpukit/libnetworking/rtems/rtems_bootp.c           |    2 +
 cpukit/libnetworking/rtems/rtems_bsdnet_internal.h |    1 -
 cpukit/libnetworking/rtems/rtems_dhcp.c            |   26 ++----------
 6 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/cpukit/libnetworking/Makefile.am b/cpukit/libnetworking/Makefile.am
index 1a99098..927245b 100644
--- a/cpukit/libnetworking/Makefile.am
+++ b/cpukit/libnetworking/Makefile.am
@@ -4,6 +4,7 @@ include $(top_srcdir)/automake/compile.am
 AM_CPPFLAGS += -I$(srcdir)
 
 EXTRA_DIST = README
+EXTRA_DIST += rtems/bootp.h
 
 # poll is not supported
 UNUSED_FILES = poll.h
diff --git a/cpukit/libnetworking/nfs/bootp_subr.c b/cpukit/libnetworking/nfs/bootp_subr.c
index 75f6162..0645b89 100644
--- a/cpukit/libnetworking/nfs/bootp_subr.c
+++ b/cpukit/libnetworking/nfs/bootp_subr.c
@@ -72,6 +72,8 @@
 #include <rtems/bsdnet/servers.h>
 #include <inttypes.h>
 
+#include "rtems/bootp.h"
+
 #define BOOTP_MIN_LEN		300	/* Minimum size of bootp udp packet */
 
 /*
@@ -136,20 +138,6 @@ void bootpboot_p_rtlist(void);
 void bootpboot_p_iflist(void);
 #endif
 
-int  bootpc_call(struct bootp_packet *call,
-		 struct bootp_packet *reply,
-		 struct proc *procp);
-
-int bootpc_fakeup_interface(struct ifreq *ireq,struct socket *so,
-			struct proc *procp);
-
-int 
-bootpc_adjust_interface(struct ifreq *ireq,struct socket *so,
-			struct sockaddr_in *myaddr,
-			struct sockaddr_in *netmask,
-			struct sockaddr_in *gw,
-			struct proc *procp);
-
 #ifdef BOOTP_DEBUG
 void
 bootpboot_p_sa(struct sockaddr *sa, struct sockaddr *ma)
@@ -269,7 +257,7 @@ bootpboot_p_iflist(void)
  * - allocate or reallocate dst, so that string fits in
  * - copy string from src to dest
  */
-static void *bootp_strdup_realloc(char *dst,const char *src)
+void *bootp_strdup_realloc(char *dst,const char *src)
 {
   size_t len;
 
diff --git a/cpukit/libnetworking/rtems/bootp.h b/cpukit/libnetworking/rtems/bootp.h
new file mode 100644
index 0000000..d8eeb76
--- /dev/null
+++ b/cpukit/libnetworking/rtems/bootp.h
@@ -0,0 +1,41 @@
+/* Subroutines from cpukit/libnetworking/nfs/bootp_subr.c */
+
+#if !defined (__RTEMS_BOOTP_H__)
+#define __RTEMS_BOOTP_H__
+
+#include <stdbool.h>
+
+#if __cplusplus
+extern "C"
+{
+#endif
+
+struct bootp_packet;
+struct proc;
+struct ifreq;
+struct socket;
+struct sockaddr_in;
+
+bool bootpc_init(bool, bool);
+
+int bootpc_call(
+     struct bootp_packet *call,
+     struct bootp_packet *reply,
+     struct proc *procp);
+int bootpc_fakeup_interface(struct ifreq *ireq,
+                                    struct socket *so,
+                                    struct proc *procp);
+int bootpc_adjust_interface(struct ifreq *ireq,
+                                    struct socket *so,
+                                    struct sockaddr_in *myaddr,
+                                    struct sockaddr_in *netmask,
+                                    struct sockaddr_in *gw,
+                                    struct proc *procp);
+
+void *bootp_strdup_realloc(char *dst, const char *src);
+
+#if __cplusplus
+}
+#endif
+
+#endif
diff --git a/cpukit/libnetworking/rtems/rtems_bootp.c b/cpukit/libnetworking/rtems/rtems_bootp.c
index 852d900..2743dc0 100644
--- a/cpukit/libnetworking/rtems/rtems_bootp.c
+++ b/cpukit/libnetworking/rtems/rtems_bootp.c
@@ -8,6 +8,8 @@
 #include <rtems/rtems_bsdnet.h>
 #include <rtems/rtems_bsdnet_internal.h>
 
+#include "rtems/bootp.h"
+
 /*
  * Perform a BOOTP request
  */
diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
index d9be5af..b7f79cb 100644
--- a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
+++ b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
@@ -173,7 +173,6 @@ void domaininit (void *);
 void ifinit (void *);
 void ipintr (void);
 void arpintr (void);
-bool bootpc_init(bool, bool);
 int socket (int, int, int);
 int ioctl (int, ioctl_command_t, ...);
 
diff --git a/cpukit/libnetworking/rtems/rtems_dhcp.c b/cpukit/libnetworking/rtems/rtems_dhcp.c
index 951f74d..4039a48 100644
--- a/cpukit/libnetworking/rtems/rtems_dhcp.c
+++ b/cpukit/libnetworking/rtems/rtems_dhcp.c
@@ -99,6 +99,7 @@
 #include <rtems/mkrootfs.h>
 
 #include "rtems/dhcp.h"
+#include "rtems/bootp.h"
 
 #ifndef EALEN
 #define EALEN 6
@@ -167,25 +168,6 @@ struct dhcp_packet
 };
 
 /*
- * External Declarations for Functions found in
- * rtems/c/src/libnetworking/nfs/
- */
-extern int bootpc_call (struct dhcp_packet *call,
-                        struct dhcp_packet *reply,
-                        struct proc *procp);
-extern int bootpc_fakeup_interface (struct ifreq *ireq,
-                                    struct socket *so,
-                                    struct proc *procp);
-extern int bootpc_adjust_interface (struct ifreq *ireq,
-                                    struct socket *so,
-                                    struct sockaddr_in *myaddr,
-                                    struct sockaddr_in *netmask,
-                                    struct sockaddr_in *gw,
-                                    struct proc *procp);
-extern void *bootp_strdup_realloc (char *dst,
-                                   const char *src);
-
-/*
  * Variables
  */
 static int                dhcp_option_overload = 0;
@@ -755,7 +737,7 @@ dhcp_task (rtems_task_argument _sdl)
       /*
        * Send the Request.
        */
-      error = bootpc_call (&call, &dhcp_req, procp);
+      error = bootpc_call ((struct bootp_packet *)&call, (struct bootp_packet *)&dhcp_req, procp);
       if (error) {
         rtems_bsdnet_semaphore_release ();
         printf ("DHCP call failed -- error %d", error);
@@ -960,7 +942,7 @@ dhcp_init (int update_files)
   /*
    * Send the Discover.
    */
-  error = bootpc_call (&call, &reply, procp);
+  error = bootpc_call ((struct bootp_packet *)&call, (struct bootp_packet *)&reply, procp);
   if (error) {
     printf ("BOOTP call failed -- %s\n", strerror(error));
     soclose (so);
@@ -989,7 +971,7 @@ dhcp_init (int update_files)
    */
   dhcp_request_req (&call, &reply, sdl, true);
 
-  error = bootpc_call (&call, &reply, procp);
+  error = bootpc_call ((struct bootp_packet *)&call, (struct bootp_packet *)&reply, procp);
   if (error) {
     printf ("BOOTP call failed -- %s\n", strerror(error));
     soclose (so);




More information about the vc mailing list