svn commit: r187819 - head/sbin/ipfw

Luigi Rizzo luigi at
Wed Jan 28 03:43:14 PST 2009

Author: luigi
Date: Wed Jan 28 11:43:12 2009
New Revision: 187819

  Avoid the use of duplicated typedefs -- see the comment for details.


Modified: head/sbin/ipfw/ipfw2.h
--- head/sbin/ipfw/ipfw2.h	Wed Jan 28 11:31:09 2009	(r187818)
+++ head/sbin/ipfw/ipfw2.h	Wed Jan 28 11:43:12 2009	(r187819)
@@ -210,12 +210,18 @@ struct in6_addr;
 void n2mask(struct in6_addr *mask, int n);
 int contigmask(uint8_t *p, int len);
-/* forward declarations to avoid header dependency */
-typedef struct _ipfw_insn ipfw_insn;
-typedef struct _ipfw_insn_u32 ipfw_insn_u32;
-typedef struct _ipfw_insn_ip6 ipfw_insn_ip6;
-typedef struct _ipfw_insn_icmp6 ipfw_insn_icmp6;
+ * Forward declarations to avoid include way too many headers.
+ * C does not allow duplicated typedefs, so we use the base struct
+ * that the typedef points to.
+ * Should the typedefs use a different type, the compiler will
+ * still detect the change when compiling the body of the
+ * functions involved, so we do not lose error checking.
+ */
+struct _ipfw_insn;
+struct _ipfw_insn_u32;
+struct _ipfw_insn_ip6;
+struct _ipfw_insn_icmp6;
  * The reserved set numer. This is a constant in ip_fw.h
@@ -243,15 +249,15 @@ int ipfw_delete_pipe(int pipe_or_queue, 
 /* ipv6.c */
 void print_unreach6_code(uint16_t code);
-void print_ip6(ipfw_insn_ip6 *cmd, char const *s);
-void print_flow6id( ipfw_insn_u32 *cmd);
-void print_icmp6types(ipfw_insn_u32 *cmd);
-void print_ext6hdr( ipfw_insn *cmd );
+void print_ip6(struct _ipfw_insn_ip6 *cmd, char const *s);
+void print_flow6id(struct _ipfw_insn_u32 *cmd);
+void print_icmp6types(struct _ipfw_insn_u32 *cmd);
+void print_ext6hdr(struct _ipfw_insn *cmd );
-ipfw_insn *add_srcip6(ipfw_insn *cmd, char *av);
-ipfw_insn *add_dstip6(ipfw_insn *cmd, char *av);
+struct _ipfw_insn *add_srcip6(struct _ipfw_insn *cmd, char *av);
+struct _ipfw_insn *add_dstip6(struct _ipfw_insn *cmd, char *av);
-void fill_flow6( ipfw_insn_u32 *cmd, char *av );
+void fill_flow6(struct _ipfw_insn_u32 *cmd, char *av );
 void fill_unreach6_code(u_short *codep, char *str);
-void fill_icmp6types(ipfw_insn_icmp6 *cmd, char *av);
-int fill_ext6hdr( ipfw_insn *cmd, char *av);
+void fill_icmp6types(struct _ipfw_insn_icmp6 *cmd, char *av);
+int fill_ext6hdr(struct _ipfw_insn *cmd, char *av);

More information about the svn-src-head mailing list