From: Ted Lemon Date: Tue, 1 Feb 2000 03:19:56 +0000 (+0000) Subject: AIX and Digital Unix compatibility fixes. X-Git-Tag: V3-BETA-2-PATCH-1~369 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfdfb9f126bb8900fa60c4ac5c3326986e5708e7;p=thirdparty%2Fdhcp.git AIX and Digital Unix compatibility fixes. --- diff --git a/Makefile.conf b/Makefile.conf index 4cc480d65..4f0663891 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -73,7 +73,7 @@ MINORVERSION=MinorVersion # removes the comment characters from the appropriate set of # assignments, and writes the output to Makefile. -## AIX 4.1.5.0 +## AIX 4.3 ##--aix-- #CF = cf/aix.h #CC=cc -Daix diff --git a/common/dns.c b/common/dns.c index 22389baa6..ddc917b56 100644 --- a/common/dns.c +++ b/common/dns.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: dns.c,v 1.14 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dns.c,v 1.15 2000/02/01 03:19:38 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -444,7 +444,8 @@ void dns_packet (protocol) u_int16_t class; TIME ttl; u_int16_t rdlength; - int len, status; + socklen_t len; + int status; int i; struct dns_query *query; diff --git a/common/icmp.c b/common/icmp.c index 77dd12655..c13dcf28d 100644 --- a/common/icmp.c +++ b/common/icmp.c @@ -23,7 +23,7 @@ #ifndef lint static char copyright[] = -"$Id: icmp.c,v 1.17 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: icmp.c,v 1.18 2000/02/01 03:19:38 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -163,7 +163,8 @@ isc_result_t icmp_echoreply (h) struct sockaddr_in from; unsigned char icbuf [1500]; int status; - int len, hlen; + socklen_t len; + int hlen; struct iaddr ia; struct icmp_state *state; @@ -179,7 +180,7 @@ isc_result_t icmp_echoreply (h) /* Find the IP header length... */ ip = (struct ip *)icbuf; - hlen = ip -> ip_hl << 2; + hlen = IP_HL (ip) << 2; /* Short packet? */ if (status < hlen + (sizeof *icfrom)) { diff --git a/common/packet.c b/common/packet.c index b7be88bad..38e5962ac 100644 --- a/common/packet.c +++ b/common/packet.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: packet.c,v 1.30 2000/01/29 05:47:50 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: packet.c,v 1.31 2000/02/01 03:19:39 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -125,8 +125,8 @@ void assemble_udp_ip_header (interface, buf, bufix, struct udphdr udp; /* Fill out the IP header */ - ip.ip_v = 4; - ip.ip_hl = 5; + IP_V_SET (&ip, 4); + IP_HL_SET (&ip, 20); ip.ip_tos = IPTOS_LOWDELAY; ip.ip_len = htons(sizeof(ip) + sizeof(udp) + len); ip.ip_id = 0; diff --git a/common/parse.c b/common/parse.c index 6747ed263..38dea858f 100644 --- a/common/parse.c +++ b/common/parse.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: parse.c,v 1.60 2000/01/26 14:55:34 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: parse.c,v 1.61 2000/02/01 03:19:39 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -3352,11 +3352,7 @@ int parse_auth_key (key_id, cfile) return key_id -> len ? 1 : 0; } -int parse_warn (ANSI_DECL (struct parse *)cfile, - ANSI_DECL (const char *) fmt, VA_DOTDOTDOT) - KandR (struct parse *cfile;) - KandR (char *fmt;) - va_dcl +int parse_warn (struct parse *cfile, const char *fmt, ...) { va_list list; static char spaces [] = " "; @@ -3374,7 +3370,7 @@ int parse_warn (ANSI_DECL (struct parse *)cfile, cfile -> tlname, cfile -> lexline, mbuf); #endif - VA_start (list, fmt); + va_start (list, fmt); vsnprintf (mbuf, sizeof mbuf, fbuf, list); va_end (list); diff --git a/common/socket.c b/common/socket.c index 46803c339..9a64677b6 100644 --- a/common/socket.c +++ b/common/socket.c @@ -30,7 +30,7 @@ #ifndef lint static char copyright[] = -"$Id: socket.c,v 1.43 2000/01/02 22:21:23 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: socket.c,v 1.44 2000/02/01 03:19:39 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -213,7 +213,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom) struct sockaddr_in *from; struct hardware *hfrom; { - int flen = sizeof *from; + socklen_t flen = sizeof *from; int result; #ifdef IGNORE_HOSTUNREACH @@ -240,7 +240,7 @@ isc_result_t fallback_discard (object) { char buf [1540]; struct sockaddr_in from; - int flen = sizeof from; + socklen_t flen = sizeof from; int status; struct interface_info *interface; diff --git a/dhcpctl/Makefile.dist b/dhcpctl/Makefile.dist index 92e557b82..1d27f1c95 100644 --- a/dhcpctl/Makefile.dist +++ b/dhcpctl/Makefile.dist @@ -68,7 +68,7 @@ depend: makedepend $(INCLUDES) $(PREDEFINES) $(SRCS) clean: - -rm -f $(OBJ) test.o test + -rm -f $(OBJ) test.o test cltest.o cltest realclean: clean -rm -f libdhcpctl.a *~ $(CATMANPAGES) $(SEDMANPAGES) diff --git a/includes/cf/aix.h b/includes/cf/aix.h index 8a1b4d51f..7ce5c07c7 100644 --- a/includes/cf/aix.h +++ b/includes/cf/aix.h @@ -67,9 +67,10 @@ extern int h_errno; #define _PATH_DHCRELAY_PID "/etc/dhcrelay.pid" #endif -#include -#define VA_DOTDOTDOT va_alist +#include +#define VA_DOTDOTDOT ... #define VA_start(list, last) va_start (list) +#define va_dcl #define vsnprintf(buf, size, fmt, list) vsprintf (buf, fmt, list) #define NO_SNPRINTF diff --git a/includes/dhcpd.h b/includes/dhcpd.h index ce10734c5..09fb6a0de 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -21,6 +21,7 @@ */ #ifndef __CYGWIN32__ +#define _POSIX_PII_SOCKET #include #include #include @@ -997,7 +998,7 @@ int parse_option_token PROTO ((struct expression **, struct parse *, const char *, struct expression *, int, int)); int parse_allow_deny PROTO ((struct option_cache **, struct parse *, int)); int parse_auth_key PROTO ((struct data_string *, struct parse *)); -int parse_warn PROTO ((struct parse *, const char *, ...)) +int parse_warn (struct parse *, const char *, ...) __attribute__((__format__(__printf__,2,3))); /* tree.c */ @@ -1519,7 +1520,7 @@ int write_lease PROTO ((struct lease *)); int write_host PROTO ((struct host_decl *)); int write_group PROTO ((struct group_object *)); int db_printable PROTO ((const char *)); -int db_printable_len PROTO ((const char *, unsigned)); +int db_printable_len PROTO ((const unsigned char *, unsigned)); int write_billing_class PROTO ((struct class *)); int commit_leases PROTO ((void)); void db_startup PROTO ((int)); diff --git a/includes/netinet/ip.h b/includes/netinet/ip.h index 233abd6e6..4afb80d73 100644 --- a/includes/netinet/ip.h +++ b/includes/netinet/ip.h @@ -49,14 +49,7 @@ * against negative integers quite easily, and fail in subtle ways. */ struct ip { -#if BYTE_ORDER == LITTLE_ENDIAN - u_int8_t ip_hl:4, /* header length */ - ip_v:4; /* version */ -#endif -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t ip_v:4, /* version */ - ip_hl:4; /* header length */ -#endif + u_int8_t ip_fvhl; /* header length, version */ u_int8_t ip_tos; /* type of service */ int16_t ip_len; /* total length */ u_int16_t ip_id; /* identification */ @@ -70,6 +63,12 @@ struct ip { struct in_addr ip_src, ip_dst; /* source and dest address */ }; +#define IP_V(iph) ((iph)->ip_fvhl >> 4) +#define IP_HL(iph) ((iph)->ip_fvhl & 0x0F) +#define IP_V_SET(iph,x) ((iph)->ip_fvhl = ((iph)->ip_fvhl & 0x0F) | ((x) << 4)) +#define IP_HL_SET(iph,x) ((iph)->ip_fvhl = \ + ((iph)->ip_fvhl & 0xF0) | ((x) >> 2)) + #define IP_MAXPACKET 65535 /* maximum packet size */ /* @@ -129,14 +128,7 @@ struct ip_timestamp { u_int8_t ipt_code; /* IPOPT_TS */ u_int8_t ipt_len; /* size of structure (variable) */ u_int8_t ipt_ptr; /* index of current entry */ -#if BYTE_ORDER == LITTLE_ENDIAN - u_int8_t ipt_flg:4, /* flags, see below */ - ipt_oflw:4; /* overflow counter */ -#endif -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t ipt_oflw:4, /* overflow counter */ - ipt_flg:4; /* flags, see below */ -#endif + u_int8_t ipt_flg_oflw; /* flags, see below, overflow counter */ union ipt_timestamp { u_int32_t ipt_time[1]; struct ipt_ta { diff --git a/includes/omapip/omapip_p.h b/includes/omapip/omapip_p.h index 296ebfa2c..ae3b95e20 100644 --- a/includes/omapip/omapip_p.h +++ b/includes/omapip/omapip_p.h @@ -24,6 +24,7 @@ #define __OMAPIP_OMAPIP_P_H__ #ifndef __CYGWIN32__ +#define _POSIX_PII_SOCKET #include #include #include diff --git a/omapip/connection.c b/omapip/connection.c index c92ff91de..71e0b1e3f 100644 --- a/omapip/connection.c +++ b/omapip/connection.c @@ -32,6 +32,7 @@ isc_result_t omapi_connect (omapi_object_t *c, isc_result_t status; omapi_connection_object_t *obj; int flag; + socklen_t sl; obj = (omapi_connection_object_t *)dmalloc (sizeof *obj, MDL); if (!obj) @@ -131,10 +132,10 @@ isc_result_t omapi_connect (omapi_object_t *c, /* I don't know why this would fail, so I'm tempted not to test the return value. */ - hix = sizeof (obj -> local_addr); + sl = sizeof (obj -> local_addr); if (getsockname (obj -> socket, ((struct sockaddr *) - &obj -> local_addr), &hix) < 0) { + &obj -> local_addr), &sl) < 0) { } if (fcntl (obj -> socket, F_SETFL, O_NONBLOCK) < 0) { diff --git a/omapip/errwarn.c b/omapip/errwarn.c index 018a6399c..298bbdd0b 100644 --- a/omapip/errwarn.c +++ b/omapip/errwarn.c @@ -29,7 +29,7 @@ #ifndef lint static char copyright[] = -"$Id: errwarn.c,v 1.2 2000/01/26 14:56:05 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: errwarn.c,v 1.3 2000/02/01 03:19:52 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include @@ -48,15 +48,13 @@ static char fbuf [1024]; /* Log an error message, then exit... */ -void log_fatal (ANSI_DECL(const char *) fmt, VA_DOTDOTDOT) - KandR (char *fmt;) - va_dcl +void log_fatal (const char * fmt, ... ) { va_list list; do_percentm (fbuf, fmt); - VA_start (list, fmt); + va_start (list, fmt); vsnprintf (mbuf, sizeof mbuf, fbuf, list); va_end (list); @@ -82,15 +80,13 @@ void log_fatal (ANSI_DECL(const char *) fmt, VA_DOTDOTDOT) /* Log an error message... */ -int log_error (ANSI_DECL (const char *) fmt, VA_DOTDOTDOT) - KandR (char *fmt;) - va_dcl +int log_error (const char * fmt, ...) { va_list list; do_percentm (fbuf, fmt); - VA_start (list, fmt); + va_start (list, fmt); vsnprintf (mbuf, sizeof mbuf, fbuf, list); va_end (list); @@ -108,15 +104,13 @@ int log_error (ANSI_DECL (const char *) fmt, VA_DOTDOTDOT) /* Log a note... */ -int log_info (ANSI_DECL (const char *) fmt, VA_DOTDOTDOT) - KandR (char *fmt;) - va_dcl +int log_info (const char *fmt, ...) { va_list list; do_percentm (fbuf, fmt); - VA_start (list, fmt); + va_start (list, fmt); vsnprintf (mbuf, sizeof mbuf, fbuf, list); va_end (list); @@ -134,15 +128,13 @@ int log_info (ANSI_DECL (const char *) fmt, VA_DOTDOTDOT) /* Log a debug message... */ -int log_debug (ANSI_DECL (const char *) fmt, VA_DOTDOTDOT) - KandR (char *fmt;) - va_dcl +int log_debug (const char *fmt, ...) { va_list list; do_percentm (fbuf, fmt); - VA_start (list, fmt); + va_start (list, fmt); vsnprintf (mbuf, sizeof mbuf, fbuf, list); va_end (list); diff --git a/omapip/listener.c b/omapip/listener.c index 3f0d90163..9ba5d03f0 100644 --- a/omapip/listener.c +++ b/omapip/listener.c @@ -125,7 +125,7 @@ int omapi_listener_readfd (omapi_object_t *h) isc_result_t omapi_accept (omapi_object_t *h) { isc_result_t status; - int len; + socklen_t len; omapi_connection_object_t *obj; omapi_listener_object_t *listener; diff --git a/server/confpars.c b/server/confpars.c index 2d01edd4b..0bd2effbb 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: confpars.c,v 1.99 2000/01/31 23:41:56 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: confpars.c,v 1.100 2000/02/01 03:19:56 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -423,7 +423,6 @@ int parse_statement (cfile, group, type, host_decl, declaration) "option space definitions %s", "may not be scoped."); skip_to_semi (cfile); - free_option (option, MDL); break; } parse_option_space_decl (cfile); @@ -2208,14 +2207,16 @@ struct lease *parse_lease_declaration (cfile) (&binding -> value.buffer, binding -> value.len + 1, MDL))) log_fatal ("No memory for binding."); - strcpy (binding -> value.buffer -> data, val); + strcpy ((char *) + binding -> value.buffer -> data, val); binding -> value.data = binding -> value.buffer -> data; binding -> value.terminated = 1; } else { - s = (parse_numeric_aggregate - (cfile, (unsigned char *)0, - &binding -> value.len, ':', 16, 8)); + s = ((char *) + (parse_numeric_aggregate + (cfile, (unsigned char *)0, + &binding -> value.len, ':', 16, 8))); if (!s) return (struct lease *)0; if (binding -> value.len) { diff --git a/server/db.c b/server/db.c index 3481381d1..13d398a04 100644 --- a/server/db.c +++ b/server/db.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: db.c,v 1.42 2000/01/26 14:56:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: db.c,v 1.43 2000/02/01 03:19:56 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -134,7 +134,7 @@ int write_lease (lease) } if (lease -> uid_len) { int i; - if (db_printable_len ((const char *)lease -> uid, + if (db_printable_len (lease -> uid, lease -> uid_len)) { fprintf (db_file, "\n uid \"%*s\";", lease -> uid_len, lease -> uid); @@ -290,8 +290,7 @@ int write_host (host) if (host -> client_identifier.len) { int i; errno = 0; - if (db_printable_len ((const char *) - host -> client_identifier.data, + if (db_printable_len (host -> client_identifier.data, host -> client_identifier.len)) { fprintf (db_file, "\n uid \"%*s\";", host -> client_identifier.len, @@ -453,7 +452,7 @@ int db_printable (s) } int db_printable_len (s, len) - const char *s; + const unsigned char *s; unsigned len; { int i;