Commit 5f1b982d authored by David Benjamin's avatar David Benjamin

Add missing __cplusplus header guards.

Avoid requiring consumers to wrap headers in extern "C". See, e.g.,
https://chromium.googlesource.com/external/webrtc/+/43e15bb9f01476114cf85be8a47922df2fd7dcf5/webrtc/pc/externalhmac.cc#17
parent f97b18d7
......@@ -49,6 +49,10 @@
#include "datatypes.h"
#include "err.h"
#ifdef __cplusplus
extern "C" {
#endif
/* aes internals */
typedef struct {
......@@ -70,4 +74,8 @@ void srtp_aes_encrypt(v128_t *plaintext, const srtp_aes_expanded_key_t *exp_key)
void srtp_aes_decrypt(v128_t *plaintext, const srtp_aes_expanded_key_t *exp_key);
#ifdef __cplusplus
}
#endif
#endif /* _AES_H */
......@@ -48,8 +48,16 @@
#include "datatypes.h"
#ifdef __cplusplus
extern "C" {
#endif
void * srtp_crypto_alloc(size_t size);
void srtp_crypto_free(void *ptr);
#ifdef __cplusplus
}
#endif
#endif /* CRYPTO_ALLOC_H */
......@@ -51,6 +51,10 @@
#include "err.h" /* error codes */
#include "crypto_types.h" /* for values of auth_type_id_t */
#ifdef __cplusplus
extern "C" {
#endif
typedef const struct srtp_auth_type_t *auth_type_pointer;
typedef struct srtp_auth_t *auth_pointer_t;
......@@ -149,4 +153,8 @@ srtp_err_status_t srtp_auth_type_self_test(const srtp_auth_type_t *at);
srtp_err_status_t srtp_auth_type_test(const srtp_auth_type_t *at,
const srtp_auth_test_case_t *test_data);
#ifdef __cplusplus
}
#endif
#endif /* AUTH_H */
......@@ -53,6 +53,10 @@
#include "crypto_types.h" /* for values of cipher_type_id_t */
#ifdef __cplusplus
extern "C" {
#endif
/*
* cipher_direction_t defines a particular cipher operation.
*
......@@ -210,4 +214,8 @@ srtp_err_status_t srtp_cipher_decrypt(srtp_cipher_t *c, uint8_t *buffer, uint32_
srtp_err_status_t srtp_cipher_get_tag(srtp_cipher_t *c, uint8_t *buffer, uint32_t *tag_len);
srtp_err_status_t srtp_cipher_set_aad(srtp_cipher_t *c, const uint8_t *aad, uint32_t aad_len);
#ifdef __cplusplus
}
#endif
#endif /* CIPHER_H */
......@@ -52,6 +52,10 @@
#include "crypto_types.h"
#include "key.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* crypto_kernel_state_t defines the possible states:
*
......@@ -219,4 +223,8 @@ srtp_err_status_t srtp_crypto_kernel_alloc_auth(srtp_auth_type_id_t id, auth_poi
*/
srtp_err_status_t srtp_crypto_kernel_set_debug_module(char *mod_name, int v);
#ifdef __cplusplus
}
#endif
#endif /* CRYPTO_KERNEL */
......@@ -47,6 +47,10 @@
#include "datatypes.h"
#ifdef __cplusplus
extern "C" {
#endif
unsigned char
v32_weight(v32_t a);
......@@ -233,6 +237,10 @@ void
octet_string_set_to_zero(uint8_t *s, int len);
#ifdef __cplusplus
}
#endif
#endif /* MATH_H */
......
......@@ -61,6 +61,10 @@
# include <winsock2.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* if DATATYPES_USE_MACROS is defined, then little functions are macros */
#define DATATYPES_USE_MACROS
......@@ -476,4 +480,8 @@ bitvector_left_shift(bitvector_t *x, int index);
char *
bitvector_bit_string(bitvector_t *x, char* buf, int len);
#ifdef __cplusplus
}
#endif
#endif /* _DATATYPES_H */
......@@ -50,6 +50,10 @@
#include <stdarg.h>
#include "srtp.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup Error Error Codes
*
......@@ -131,4 +135,8 @@ typedef struct {
#endif
#ifdef __cplusplus
}
#endif
#endif /* ERR_H */
......@@ -68,6 +68,10 @@
# include <machine/types.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Can we do 64 bit integers? */
#if !defined(HAVE_UINT64_T)
# if SIZEOF_UNSIGNED_LONG == 8
......@@ -136,4 +140,8 @@ extern uint32_t low32(uint64_t value);
#define GET_32(addr) (*(((uint32_t *) (addr)))
#endif
#ifdef __cplusplus
}
#endif
#endif /* INTEGERS_H */
......@@ -48,6 +48,10 @@
#include "rdbx.h" /* for srtp_xtd_seq_num_t */
#include "err.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct srtp_key_limit_ctx_t *srtp_key_limit_t;
typedef enum {
......@@ -75,4 +79,8 @@ typedef struct srtp_key_limit_ctx_t {
srtp_key_state_t state;
} srtp_key_limit_ctx_t;
#ifdef __cplusplus
}
#endif
#endif /* KEY_H */
......@@ -47,6 +47,10 @@
#include "auth.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
char foo;
} srtp_null_auth_ctx_t;
......@@ -62,4 +66,8 @@ srtp_err_status_t srtp_null_auth_compute(srtp_null_auth_ctx_t *state, uint8_t *m
#endif
#ifdef __cplusplus
}
#endif
#endif /* NULL_AUTH_H */
......@@ -51,6 +51,10 @@
#include "datatypes.h" /* for v128_t */
#include "err.h" /* for srtp_err_status_t */
#ifdef __cplusplus
extern "C" {
#endif
/*
* if the ith least significant bit is one, then the packet index
* window_end-i is in the database
......@@ -118,4 +122,8 @@ srtp_err_status_t srtp_rdb_increment(srtp_rdb_t *rdb);
uint32_t srtp_rdb_get_value(const srtp_rdb_t *rdb);
#ifdef __cplusplus
}
#endif
#endif /* REPLAY_DB_H */
......@@ -50,6 +50,10 @@
#include "datatypes.h"
#include "err.h"
#ifdef __cplusplus
extern "C" {
#endif
/* #define ROC_TEST */
#ifndef ROC_TEST
......@@ -182,13 +186,8 @@ void srtp_index_advance(srtp_xtd_seq_num_t *pi, srtp_sequence_number_t s);
int srtp_index_guess(const srtp_xtd_seq_num_t *local, srtp_xtd_seq_num_t *guess, srtp_sequence_number_t s);
#endif /* RDBX_H */
#ifdef __cplusplus
}
#endif
#endif /* RDBX_H */
......@@ -55,6 +55,15 @@
#ifdef OPENSSL
#include <openssl/evp.h>
#include <stdint.h>
#else
#include "datatypes.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef OPENSSL
typedef EVP_MD_CTX srtp_sha1_ctx_t;
......@@ -90,7 +99,6 @@ static inline void srtp_sha1_final (srtp_sha1_ctx_t *ctx, uint32_t *output)
EVP_DigestFinal(ctx, (unsigned char*)output, &len);
}
#else
#include "datatypes.h"
typedef struct {
uint32_t H[5]; /* state vector */
......@@ -134,4 +142,8 @@ void srtp_sha1_core(const uint32_t M[16], uint32_t hash_value[5]);
#endif /* else OPENSSL */
#ifdef __cplusplus
}
#endif
#endif /* SHA1_H */
......@@ -50,10 +50,18 @@
#include "datatypes.h" /* for uint8_t */
#include "err.h" /* for srtp_err_status_t */
#ifdef __cplusplus
extern "C" {
#endif
srtp_err_status_t stat_test_monobit(uint8_t *data);
srtp_err_status_t stat_test_poker(uint8_t *data);
srtp_err_status_t stat_test_runs(uint8_t *data);
#ifdef __cplusplus
}
#endif
#endif /* STAT_H */
......@@ -62,12 +62,12 @@
#ifndef EKT_H
#define EKT_H
#include "srtp_priv.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "srtp_priv.h"
#define SRTP_EKT_CIPHER_DEFAULT 1
#define SRTP_EKT_CIPHER_AES_128_ECB 1
#define SRTP_EKT_CIPHER_AES_192_KEY_WRAP 2
......
......@@ -45,6 +45,10 @@
#ifndef GETOPT_S_H
#define GETOPT_S_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* getopt_s(), optarg_s, and optind_s are small, locally defined
* versions of the POSIX standard getopt() interface.
......@@ -57,4 +61,8 @@ extern char *optarg_s; /* defined in getopt.c */
extern int optind_s; /* defined in getopt.c */
#ifdef __cplusplus
}
#endif
#endif /* GETOPT_S_H */
......@@ -62,6 +62,11 @@
//#include "srtp_priv.h"
#include "srtp.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* RTP_HEADER_LEN indicates the size of an RTP header
*/
......@@ -158,5 +163,8 @@ void
rtp_receiver_dealloc(rtp_receiver_t rtp_ctx);
#ifdef __cplusplus
}
#endif
#endif /* RTP_H */
......@@ -46,12 +46,12 @@
#ifndef SRTP_H
#define SRTP_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/**
* @defgroup SRTP Secure RTP
*
......
......@@ -56,6 +56,10 @@
#include "key.h"
#include "crypto_kernel.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SRTP_VER_STRING PACKAGE_STRING
#define SRTP_VERSION PACKAGE_VERSION
......@@ -153,5 +157,8 @@ typedef struct srtp_ctx_t_ {
srtp_event_handler(&data); \
}
#ifdef __cplusplus
}
#endif
#endif /* SRTP_PRIV_H */
......@@ -51,6 +51,10 @@
#include "integers.h" /* for uint32_t */
#ifdef __cplusplus
extern "C" {
#endif
#define UT_BUF 160 /* maximum amount of packet reorder */
typedef struct {
......@@ -76,5 +80,8 @@ ut_init(ut_connection *utc);
uint32_t
ut_next_index(ut_connection *utc);
#ifdef __cplusplus
}
#endif
#endif /* UT_SIM_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment