patch - berkeley commons not portable
K. Richard Pixley
rpixley at sj.symbol.com
Fri Aug 27 16:40:32 UTC 2004
Not all toolchains use the berkeley style of commons definitions or
resolutions. On some toolchains, multiple definitions result in
linkage errors due to collisions. The more portable technique is to
declare commons exactly once and to declare references in the other
places where such commons are used.
The following patch uses externs, changes in declaration scope, and
some code motion to correct a number of these collisions.
--rich
--- dhcp-3.0.1/client/dhclient.c 2004-07-09 17:11:16.000000000 -0700
+++ dhcp-work2/client/dhclient.c 2004-08-27 09:29:22.000000000 -0700
@@ -66,8 +66,6 @@
static char message [] = "Internet Systems Consortium DHCP Client";
static char url [] = "For info, please visit http://www.isc.org/products/DHCP";
-u_int16_t local_port=0;
-u_int16_t remote_port=0;
int no_daemon=0;
struct string_list *client_env=NULL;
int client_env_count=0;
diff -u -r dhcp-3.0.1/common/comapi.c dhcp-work/common/comapi.c
--- dhcp-3.0.1/common/comapi.c 2004-06-10 10:59:14.000000000 -0700
+++ dhcp-work/common/comapi.c 2004-07-08 16:01:43.000000000 -0700
@@ -53,7 +53,6 @@
OMAPI_OBJECT_ALLOC (group_object, struct group_object, dhcp_type_group)
OMAPI_OBJECT_ALLOC (dhcp_control, dhcp_control_object_t, dhcp_type_control)
-omapi_object_type_t *dhcp_type_interface;
omapi_object_type_t *dhcp_type_group;
omapi_object_type_t *dhcp_type_shared_network;
omapi_object_type_t *dhcp_type_subnet;
diff -u -r dhcp-3.0.1/common/discover.c dhcp-work/common/discover.c
--- dhcp-3.0.1/common/discover.c 2004-06-10 10:59:16.000000000 -0700
+++ dhcp-work/common/discover.c 2004-07-08 16:50:27.000000000 -0700
@@ -58,7 +58,6 @@
unsigned int,
struct iaddr, struct hardware *));
-omapi_object_type_t *dhcp_type_interface;
#if defined (TRACING)
trace_type_t *interface_trace;
trace_type_t *inpacket_trace;
@@ -69,6 +68,7 @@
int interface_max;
OMAPI_OBJECT_ALLOC (interface, struct interface_info, dhcp_type_interface)
+omapi_object_type_t *dhcp_type_interface;
isc_result_t interface_setup ()
{
diff -u -r dhcp-3.0.1/common/parse.c dhcp-work/common/parse.c
--- dhcp-3.0.1/common/parse.c 2004-06-17 13:54:38.000000000 -0700
+++ dhcp-work/common/parse.c 2004-07-08 16:53:28.000000000 -0700
@@ -44,6 +44,14 @@
struct enumeration *enumerations;
+struct collection default_collection = {
+ (struct collection *)0,
+ "default",
+ (struct class *)0,
+};
+
+struct collection *collections = &default_collection;
+
void add_enumeration (struct enumeration *enumeration)
{
enumeration -> next = enumerations;
diff -u -r dhcp-3.0.1/includes/dhcpd.h dhcp-work/includes/dhcpd.h
--- dhcp-3.0.1/includes/dhcpd.h 2004-06-10 10:59:29.000000000 -0700
+++ dhcp-work/includes/dhcpd.h 2004-07-08 16:21:36.000000000 -0700
@@ -1118,7 +1118,7 @@
/* dhcpd.c */
extern TIME cur_time;
-int ddns_update_style;
+extern int ddns_update_style;
extern const char *path_dhcpd_conf;
extern const char *path_dhcpd_db;
@@ -1133,7 +1133,7 @@
void lease_pinged PROTO ((struct iaddr, u_int8_t *, int));
void lease_ping_timeout PROTO ((void *));
int dhcpd_interface_setup_hook (struct interface_info *ip, struct iaddr *ia);
-enum dhcp_shutdown_state shutdown_state;
+extern enum dhcp_shutdown_state shutdown_state;
isc_result_t dhcp_io_shutdown (omapi_object_t *, void *);
isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
control_object_state_t newstate);
@@ -1391,7 +1391,7 @@
void bootp PROTO ((struct packet *));
/* memory.c */
-int (*group_write_hook) (struct group_object *);
+extern int (*group_write_hook) (struct group_object *);
extern struct group *root_group;
extern group_hash_t *group_name_hash;
isc_result_t delete_group (struct group_object *, int);
@@ -1731,7 +1731,7 @@
extern int (*dhcp_interface_setup_hook) (struct interface_info *,
struct iaddr *);
extern int (*dhcp_interface_discovery_hook) (struct interface_info *);
-isc_result_t (*dhcp_interface_startup_hook) (struct interface_info *);
+extern isc_result_t (*dhcp_interface_startup_hook) (struct interface_info *);
extern void (*bootp_packet_handler) PROTO ((struct interface_info *,
struct dhcp_packet *, unsigned,
@@ -1740,9 +1740,9 @@
extern struct timeout *timeouts;
extern omapi_object_type_t *dhcp_type_interface;
#if defined (TRACING)
-trace_type_t *interface_trace;
-trace_type_t *inpacket_trace;
-trace_type_t *outpacket_trace;
+extern trace_type_t *interface_trace;
+extern trace_type_t *inpacket_trace;
+extern trace_type_t *outpacket_trace;
#endif
extern struct interface_info **interface_vector;
extern int interface_count;
@@ -1794,11 +1794,11 @@
extern int dhcp_option_default_priority_list [];
extern int dhcp_option_default_priority_list_count;
extern const char *hardware_types [256];
-int universe_count, universe_max;
-struct universe **universes;
+extern int universe_count, universe_max;
+extern struct universe **universes;
extern universe_hash_t *universe_hash;
void initialize_common_option_spaces PROTO ((void));
-struct universe *config_universe;
+extern struct universe *config_universe;
/* stables.c */
#if defined (FAILOVER_PROTOCOL)
@@ -2055,8 +2055,8 @@
/* resolv.c */
extern char path_resolv_conf [];
-struct name_server *name_servers;
-struct domain_search_list *domains;
+extern struct name_server *name_servers;
+extern struct domain_search_list *domains;
void read_resolv_conf PROTO ((TIME));
struct name_server *first_name_server PROTO ((void));
@@ -2068,11 +2068,11 @@
/* class.c */
extern int have_billing_classes;
-struct class unknown_class;
-struct class known_class;
-struct collection default_collection;
-struct collection *collections;
-struct executable_statement *default_classification_rules;
+extern struct class unknown_class;
+extern struct class known_class;
+extern struct collection default_collection;
+extern struct collection *collections;
+extern struct executable_statement *default_classification_rules;
void classification_setup PROTO ((void));
void classify_client PROTO ((struct packet *));
--- dhcp-3.0.1/relay/dhcrelay.c 2004-07-09 17:11:17.000000000 -0700
+++ dhcp-work2/relay/dhcrelay.c 2004-08-27 09:29:22.000000000 -0700
@@ -91,9 +91,6 @@
forward_untouched, /* Forward without changes. */
discard } agent_relay_mode = forward_and_replace;
-u_int16_t local_port;
-u_int16_t remote_port;
-
struct server_list {
struct server_list *next;
struct sockaddr_in to;
diff -u -r dhcp-3.0.1/server/class.c dhcp-work/server/class.c
--- dhcp-3.0.1/server/class.c 2004-06-10 10:59:51.000000000 -0700
+++ dhcp-work/server/class.c 2004-07-08 16:53:27.000000000 -0700
@@ -40,13 +40,6 @@
#include "dhcpd.h"
-struct collection default_collection = {
- (struct collection *)0,
- "default",
- (struct class *)0,
-};
-
-struct collection *collections = &default_collection;
struct executable_statement *default_classification_rules;
int have_billing_classes;
diff -u -r dhcp-3.0.1/server/mdb.c dhcp-work/server/mdb.c
--- dhcp-3.0.1/server/mdb.c 2004-06-10 10:59:56.000000000 -0700
+++ dhcp-work/server/mdb.c 2004-07-08 16:00:49.000000000 -0700
@@ -49,8 +49,6 @@
lease_hash_t *lease_ip_addr_hash;
lease_hash_t *lease_hw_addr_hash;
-omapi_object_type_t *dhcp_type_host;
-
static int find_uid_statement (struct executable_statement *esp,
void *vp, int condp)
{
More information about the dhcp-hackers
mailing list