From e2eaf9194b16fdd15ebf274aafd05edc9fefb4bb Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Sat, 9 Oct 2010 13:53:44 +0200 Subject: [PATCH] Add "extern C {...} to header files for C++ builds. Also renamed "operator" to "op_token" for C++ builds. This doesn't affect the server core, but it should allow C++ modules to build. It should also allow C++ applications to use libfreeradius-radius --- src/include/conffile.h | 8 ++++++++ src/include/detail.h | 8 ++++++++ src/include/dhcp.h | 8 ++++++++ src/include/event.h | 8 ++++++++ src/include/hash.h | 9 +++++++++ src/include/heap.h | 8 ++++++++ src/include/ident.h | 8 ++++++++ src/include/libradius.h | 17 +++++++++++++++++ src/include/md4.h | 16 ++++++++++++---- src/include/md5.h | 14 ++++++++++++-- src/include/missing.h | 19 ++++++++++++++++--- src/include/modcall.h | 13 +++++++++++++ src/include/modpriv.h | 13 ++++++++++++- src/include/modules.h | 7 +++++++ src/include/packet.h | 9 +++++++++ src/include/rad_assert.h | 8 ++++++++ src/include/radiusd.h | 8 ++++++++ src/include/radutmp.h | 8 ++++++++ src/include/realms.h | 8 ++++++++ src/include/sha1.h | 14 ++++++++++++-- src/include/soh.h | 8 ++++++++ src/include/stats.h | 8 ++++++++ src/include/sysutmp.h | 8 ++++++++ src/include/token.h | 8 ++++++++ src/include/udpfromto.h | 8 ++++++++ src/include/vmps.h | 8 ++++++++ src/include/vqp.h | 8 ++++++++ 27 files changed, 255 insertions(+), 12 deletions(-) diff --git a/src/include/conffile.h b/src/include/conffile.h index 40a400e..55d4177 100644 --- a/src/include/conffile.h +++ b/src/include/conffile.h @@ -14,6 +14,10 @@ RCSIDH(conffile_h, "$Id$") #include #include +#ifdef __cplusplus +extern "C" { +#endif + /* * Export the minimum amount of information about these structs */ @@ -123,4 +127,8 @@ extern int cf_section2file(FILE *fp, const CONF_SECTION *cs); */ int cf_section_migrate(CONF_SECTION *dst, CONF_SECTION *src); +#ifdef __cplusplus +} +#endif + #endif /* _CONFFILE_H */ diff --git a/src/include/detail.h b/src/include/detail.h index c781619..e3c13ee 100644 --- a/src/include/detail.h +++ b/src/include/detail.h @@ -10,6 +10,10 @@ #include RCSIDH(detail_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + typedef enum detail_state_t { STATE_UNOPENED = 0, STATE_UNLOCKED, @@ -56,4 +60,8 @@ int detail_encode(UNUSED rad_listen_t *this, UNUSED REQUEST *request); int detail_decode(UNUSED rad_listen_t *this, UNUSED REQUEST *request); int detail_parse(CONF_SECTION *cs, rad_listen_t *this); +#ifdef __cplusplus +} +#endif + #endif /* DETAIL_H */ diff --git a/src/include/dhcp.h b/src/include/dhcp.h index 0f7e6f14..2d66ca0 100644 --- a/src/include/dhcp.h +++ b/src/include/dhcp.h @@ -28,6 +28,10 @@ #include RCSIDH(dhcp_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + /* * Not for production use. */ @@ -60,4 +64,8 @@ int fr_dhcp_decode(RADIUS_PACKET *packet); #define DHCP_BASE_ATTR(x) (x & 0xff) #define DHCP_UNPACK_OPTION1(x) (((x) & 0xff00) >> 8) +#ifdef __cplusplus +} +#endif + #endif /* FR_DHCP_H */ diff --git a/src/include/event.h b/src/include/event.h index bc21ba0..a62dc01 100644 --- a/src/include/event.h +++ b/src/include/event.h @@ -27,6 +27,10 @@ #include RCSIDH(event_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + typedef struct fr_event_list_t fr_event_list_t; typedef struct fr_event_t fr_event_t; @@ -54,4 +58,8 @@ int fr_event_fd_delete(fr_event_list_t *el, int type, int fd); int fr_event_loop(fr_event_list_t *el); void fr_event_loop_exit(fr_event_list_t *el, int code); +#ifdef __cplusplus +} +#endif + #endif /* FR_HASH_H */ diff --git a/src/include/hash.h b/src/include/hash.h index 847ff03..3324138 100644 --- a/src/include/hash.h +++ b/src/include/hash.h @@ -27,6 +27,10 @@ #include RCSIDH(hash_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + /* * Fast hash, which isn't too bad. Don't use for cryptography, * just for hashing internal data. @@ -61,4 +65,9 @@ int fr_hash_table_num_elements(fr_hash_table_t *ht); int fr_hash_table_walk(fr_hash_table_t *ht, fr_hash_table_walk_t callback, void *ctx); + +#ifdef __cplusplus +} +#endif + #endif /* FR_HASH_H */ diff --git a/src/include/heap.h b/src/include/heap.h index fdefd05..1f47449 100644 --- a/src/include/heap.h +++ b/src/include/heap.h @@ -25,6 +25,10 @@ #include RCSIDH(heap_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + typedef int (*fr_heap_cmp_t)(const void *, const void *); typedef struct fr_heap_t fr_heap_t; @@ -36,4 +40,8 @@ int fr_heap_extract(fr_heap_t *hp, void *data); void *fr_heap_peek(fr_heap_t *hp); int fr_heap_num_elements(fr_heap_t *hp); +#ifdef __cplusplus +} +#endif + #endif /* LRAD_HEAP_H */ diff --git a/src/include/ident.h b/src/include/ident.h index 4c26578..5a2a273 100644 --- a/src/include/ident.h +++ b/src/include/ident.h @@ -21,6 +21,10 @@ #ifndef IDENT_H #define IDENT_H +#ifdef __cplusplus +extern "C" { +#endif + #if defined(__GNUC__) /* force inclusion of ident keywords in the face of optimization */ #define RCSID(id) static const char rcsid[] __attribute__ ((used)) = id; @@ -35,4 +39,8 @@ #define RCSIDH(h, id) #endif +#ifdef __cplusplus +} +#endif + #endif /* IDENT_H */ diff --git a/src/include/libradius.h b/src/include/libradius.h index bbf5e79..5423583 100644 --- a/src/include/libradius.h +++ b/src/include/libradius.h @@ -57,6 +57,10 @@ RCSIDH(libradius_h, "$Id$") #define WITH_TCP (1) #endif +#ifdef __cplusplus +extern "C" { +#endif + #define EAP_START 2 #define AUTH_VECTOR_LEN 16 @@ -164,7 +168,16 @@ typedef struct value_pair { unsigned int vendor; int type; size_t length; /* of data */ +#ifdef __cplusplus + /* + * C++ hackery. The server and modules are all C, so + * the defs here don't affect them. But any C++ code + * gets excited over "operator", so we change the name. + */ + FR_TOKEN op_token; +#else FR_TOKEN operator; +#endif ATTR_FLAGS flags; struct value_pair *next; uint32_t lvalue; @@ -483,6 +496,10 @@ void *fr_fifo_pop(fr_fifo_t *fi); void *fr_fifo_peek(fr_fifo_t *fi); int fr_fifo_num_elements(fr_fifo_t *fi); +#ifdef __cplusplus +} +#endif + #include #ifdef WITH_TCP diff --git a/src/include/md4.h b/src/include/md4.h index bd71e48..348d7bb 100644 --- a/src/include/md4.h +++ b/src/include/md4.h @@ -26,6 +26,14 @@ RCSIDH(md4_h, "$Id$") #include +#ifdef WITH_OPENSSL_MD4 +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + void fr_md4_calc (unsigned char *, const unsigned char *, unsigned int); #ifndef WITH_OPENSSL_MD4 @@ -66,8 +74,6 @@ typedef struct FR_MD4Context { uint8_t buffer[MD4_BLOCK_LENGTH]; /* input buffer */ } FR_MD4_CTX; -/*#include */ - /*__BEGIN_DECLS*/ void fr_MD4Init(FR_MD4_CTX *); void fr_MD4Update(FR_MD4_CTX *, const uint8_t *, size_t) @@ -80,8 +86,6 @@ void fr_MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH]) /*__END_DECLS*/ #else /* WITH_OPENSSL_MD4 */ -#include - #define FR_MD4_CTX MD4_CTX #define fr_MD4Init MD4_Init #define fr_MD4Update MD4_Update @@ -89,4 +93,8 @@ void fr_MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH]) #define fr_MD4Transform MD4_Transform #endif +#ifdef __cplusplus +} +#endif + #endif /* _FR_MD4_H */ diff --git a/src/include/md5.h b/src/include/md5.h index 27767e6..fec196e 100644 --- a/src/include/md5.h +++ b/src/include/md5.h @@ -26,6 +26,14 @@ RCSIDH(md5_h, "$Id$") #include +#ifdef WITH_OPENSSL_MD5 +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + #ifndef WITH_OPENSSL_MD5 /* The below was retrieved from * http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/crypto/md5.h?rev=1.1 @@ -70,8 +78,6 @@ void fr_MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]) #else /* WITH_OPENSSL_HASH */ -#include - #define FR_MD5_CTX MD5_CTX #define fr_MD5Init MD5_Init #define fr_MD5Update MD5_Update @@ -79,4 +85,8 @@ void fr_MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]) #define fr_MD5Transform MD5_Transform #endif +#ifdef __cplusplus +} +#endif + #endif /* _FR_MD5_H */ diff --git a/src/include/missing.h b/src/include/missing.h index de82dd9..7c7b37f 100644 --- a/src/include/missing.h +++ b/src/include/missing.h @@ -58,6 +58,14 @@ RCSIDH(missing_h, "$Id$") #include #endif +#ifndef HAVE_VSNPRINTF +#include +#endif + +#ifdef HAVE_SYS_LOCKING_H +#include +#endif + /* * Check for inclusion of , versus * Taken verbatim from the autoconf manual. @@ -87,6 +95,10 @@ RCSIDH(missing_h, "$Id$") #define DARWIN (1) #endif +#ifdef __cplusplus +extern "C" { +#endif + /* * Functions from missing.c */ @@ -338,7 +350,6 @@ extern int getnameinfo (const struct sockaddr *__sa, */ #ifndef HAVE_VSNPRINTF -#include extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg); #endif @@ -382,8 +393,6 @@ int gettimeofday (struct timeval *tv, void *tz); #endif #ifdef HAVE_SYS_LOCKING_H -#include - #define lockf _locking #define F_ULOCK _LK_UNLCK /* Unlock locked sections. */ @@ -399,4 +408,8 @@ int gettimeofday (struct timeval *tv, void *tz); void timeval2ntp(const struct timeval *tv, uint8_t *ntp); void ntp2timeval(struct timeval *tv, const char *ntp); +#ifdef __cplusplus +} +#endif + #endif /* _FR_MISSING_H */ diff --git a/src/include/modcall.h b/src/include/modcall.h index 89ec4dc..9a95565 100644 --- a/src/include/modcall.h +++ b/src/include/modcall.h @@ -1,3 +1,6 @@ +#ifndef FR_MODCALL_H +#define FR_MODCALL_H + /* modcall.h: the outside interface to the module-calling tree. Includes * functions to build the tree from the config file, and to call it by * feeding it REQUESTs. @@ -6,6 +9,10 @@ #include /* Need CONF_* definitions */ +#ifdef __cplusplus +extern "C" { +#endif + /* * For each authorize/authtype/etc, we have an ordered * tree of instances to call. This data structure keeps track @@ -32,3 +39,9 @@ void add_to_modcallable(modcallable **parent, modcallable *this, /* Free a tree returned by compile_modgroup or compile_modsingle */ void modcallable_free(modcallable **pc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/modpriv.h b/src/include/modpriv.h index a79e4cb..43a414d 100644 --- a/src/include/modpriv.h +++ b/src/include/modpriv.h @@ -17,7 +17,13 @@ #ifndef WITHOUT_LIBLTDL #include "ltdl.h" -#else +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef WITHOUT_LIBLTDL typedef void *lt_dlhandle; lt_dlhandle lt_dlopenext(const char *name); @@ -62,4 +68,9 @@ typedef struct module_instance_t { module_instance_t *find_module_instance(CONF_SECTION *, const char *instname, int do_link); int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when); + +#ifdef __cplusplus +} +#endif + #endif /* FR_MODPRIV_H */ diff --git a/src/include/modules.h b/src/include/modules.h index 074cc44..dbb17f3 100644 --- a/src/include/modules.h +++ b/src/include/modules.h @@ -13,6 +13,10 @@ RCSIDH(modules_h, "$Id$") #include +#ifdef __cplusplus +extern "C" { +#endif + typedef int (*packetmethod)(void *instance, REQUEST *request); enum { @@ -87,5 +91,8 @@ int indexed_modcall(int comp, int idx, REQUEST *request); int virtual_servers_load(CONF_SECTION *config); void virtual_servers_free(time_t when); +#ifdef __cplusplus +} +#endif #endif /* RADIUS_MODULES_H */ diff --git a/src/include/packet.h b/src/include/packet.h index a700541..4b455db 100644 --- a/src/include/packet.h +++ b/src/include/packet.h @@ -27,6 +27,10 @@ #include RCSIDH(packet_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + uint32_t fr_request_packet_hash(const RADIUS_PACKET *packet); uint32_t fr_reply_packet_hash(const RADIUS_PACKET *packet); int fr_packet_cmp(const RADIUS_PACKET *a, const RADIUS_PACKET *b); @@ -76,4 +80,9 @@ int fr_packet_list_num_outgoing(fr_packet_list_t *pl); * required type. */ # define fr_packet2myptr(TYPE, MEMBER, PTR) (TYPE *) (((char *)PTR) - offsetof(TYPE, MEMBER)) + +#ifdef __cplusplus +} +#endif + #endif /* FR_PACKET_H */ diff --git a/src/include/rad_assert.h b/src/include/rad_assert.h index 3802783..a0b513b 100644 --- a/src/include/rad_assert.h +++ b/src/include/rad_assert.h @@ -25,6 +25,10 @@ #include RCSIDH(rad_assert_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + extern void rad_assert_fail (const char *file, unsigned int line, const char *expr); #ifdef NDEBUG @@ -40,4 +44,8 @@ extern void rad_assert_fail (const char *file, unsigned int line, const char *ex #define rad_assert assert #endif +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/include/radiusd.h b/src/include/radiusd.h index e26af57..92a363b 100644 --- a/src/include/radiusd.h +++ b/src/include/radiusd.h @@ -104,6 +104,9 @@ typedef struct auth_req REQUEST; #include #include +#ifdef __cplusplus +extern "C" { +#endif /* * See util.c @@ -706,4 +709,9 @@ int radius_update_attrlist(REQUEST *request, CONF_SECTION *cs, VALUE_PAIR *input_vps, const char *name); void radius_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from); int radius_get_vp(REQUEST *request, const char *name, VALUE_PAIR **vp_p); + +#ifdef __cplusplus +} +#endif + #endif /*RADIUSD_H*/ diff --git a/src/include/radutmp.h b/src/include/radutmp.h index 997c9ea..165a620 100644 --- a/src/include/radutmp.h +++ b/src/include/radutmp.h @@ -10,6 +10,10 @@ #include RCSIDH(radutmp_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + /* * Types of connection. */ @@ -55,4 +59,8 @@ struct radutmp { #define RUT_NAMESIZE sizeof(((struct radutmp *) NULL)->login) #define RUT_SESSSIZE sizeof(((struct radutmp *) NULL)->session_id) +#ifdef __cplusplus +} +#endif + #endif /* _RADUTMP_H */ diff --git a/src/include/realms.h b/src/include/realms.h index 9a590e9..0b00a1b 100644 --- a/src/include/realms.h +++ b/src/include/realms.h @@ -12,6 +12,10 @@ #include RCSIDH(realms_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + #define HOME_TYPE_INVALID (0) #define HOME_TYPE_AUTH (1) #define HOME_TYPE_ACCT (2) @@ -146,4 +150,8 @@ home_server *home_server_bynumber(int number); #endif home_pool_t *home_pool_byname(const char *name, int type); +#ifdef __cplusplus +} +#endif + #endif /* REALMS_H */ diff --git a/src/include/sha1.h b/src/include/sha1.h index 2880ac3..0a431a8 100644 --- a/src/include/sha1.h +++ b/src/include/sha1.h @@ -1,6 +1,14 @@ #ifndef _FR_SHA1_H #define _FR_SHA1_H +#ifdef WITH_OPENSSL_SHA1 +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + #ifndef WITH_OPENSSL_SHA1 typedef struct { uint32_t state[5]; @@ -23,8 +31,6 @@ void fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context); #else /* WITH_OPENSSL_SHA1 */ -#include - #define fr_SHA1_CTX SHA_CTX #define fr_SHA1Init SHA1_Init #define fr_SHA1Update SHA1_Update @@ -40,4 +46,8 @@ void fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context); */ extern void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160]); +#ifdef __cplusplus +} +#endif + #endif /* _FR_SHA1_H */ diff --git a/src/include/soh.h b/src/include/soh.h index 8585e64..7dc17f9 100644 --- a/src/include/soh.h +++ b/src/include/soh.h @@ -28,9 +28,17 @@ RCSIDH(soh_h, "$Id$") #include +#ifdef __cplusplus +extern "C" { +#endif + int soh_verify(VALUE_PAIR *sohvp, const uint8_t *data, unsigned int data_len); uint16_t soh_pull_be_16(const uint8_t *p); uint32_t soh_pull_be_24(const uint8_t *p); uint32_t soh_pull_be_32(const uint8_t *p); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/include/stats.h b/src/include/stats.h index 44d17cc..a781eb7 100644 --- a/src/include/stats.h +++ b/src/include/stats.h @@ -26,6 +26,10 @@ #include RCSIDH(stats_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + #ifdef WITH_STATS_64BIT typedef uint64_t fr_uint_t; #else @@ -101,4 +105,8 @@ void radius_stats_ema(fr_stats_ema_t *ema, #endif +#ifdef __cplusplus +} +#endif + #endif /* FR_STATS_H */ diff --git a/src/include/sysutmp.h b/src/include/sysutmp.h index f56e5d6..27d5cdd 100644 --- a/src/include/sysutmp.h +++ b/src/include/sysutmp.h @@ -37,6 +37,10 @@ RCSIDH(sysutmp_h, "$Id$") # include #endif +#ifdef __cplusplus +extern "C" { +#endif + #ifdef __osf__ # define UT_NAMESIZE 32 # define UT_LINESIZE 32 @@ -98,4 +102,8 @@ struct utmp { #endif /* HAVE_UTMP_H */ +#ifdef __cplusplus +} +#endif + #endif /* SYSUTMP_H_INCLUDED */ diff --git a/src/include/token.h b/src/include/token.h index 3a71d18..8b5c24d 100644 --- a/src/include/token.h +++ b/src/include/token.h @@ -26,6 +26,10 @@ #include RCSIDH(token_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + typedef enum fr_token_t { T_OP_INVALID = 0, /* invalid token */ T_EOL, /* end of line */ @@ -76,4 +80,8 @@ int getbareword (const char **ptr, char *buf, int buflen); FR_TOKEN gettoken(const char **ptr, char *buf, int buflen); FR_TOKEN getstring(const char **ptr, char *buf, int buflen); +#ifdef __cplusplus +} +#endif + #endif /* FR_TOKEN_H */ diff --git a/src/include/udpfromto.h b/src/include/udpfromto.h index 1c37048..525df38 100644 --- a/src/include/udpfromto.h +++ b/src/include/udpfromto.h @@ -11,6 +11,10 @@ RCSIDH(udpfromtoh, "$Id$") #include #include +#ifdef __cplusplus +extern "C" { +#endif + #ifdef WITH_UDPFROMTO int udpfromto_init(int s); int recvfromto(int s, void *buf, size_t len, int flags, @@ -21,4 +25,8 @@ int sendfromto(int s, void *buf, size_t len, int flags, struct sockaddr *to, socklen_t tolen); #endif +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/include/vmps.h b/src/include/vmps.h index fbfee65..ff44766 100644 --- a/src/include/vmps.h +++ b/src/include/vmps.h @@ -10,6 +10,10 @@ #include RCSIDH(vmps_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + int vqp_socket_recv(rad_listen_t *listener, RAD_REQUEST_FUNP *pfun, REQUEST **prequest); int vqp_socket_send(rad_listen_t *listener, REQUEST *request); @@ -17,4 +21,8 @@ int vqp_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request); int vqp_socket_decode(UNUSED rad_listen_t *listener, REQUEST *request); int vmps_process(REQUEST *request); +#ifdef __cplusplus +} +#endif + #endif /* VMPS_H */ diff --git a/src/include/vqp.h b/src/include/vqp.h index 7ff5552..9cb96ab 100644 --- a/src/include/vqp.h +++ b/src/include/vqp.h @@ -27,9 +27,17 @@ #include RCSIDH(vqp_h, "$Id$") +#ifdef __cplusplus +extern "C" { +#endif + RADIUS_PACKET *vqp_recv(int sockfd); int vqp_send(RADIUS_PACKET *packet); int vqp_decode(RADIUS_PACKET *packet); int vqp_encode(RADIUS_PACKET *packet, RADIUS_PACKET *original); +#ifdef __cplusplus +} +#endif + #endif /* FR_VQP_H */ -- 2.1.4