allowing build with only specific transports
authorvenaas <venaas>
Fri, 19 Dec 2008 14:36:09 +0000 (14:36 +0000)
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>
Fri, 19 Dec 2008 14:36:09 +0000 (14:36 +0000)
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@444 e88ac4ed-0b26-0410-9574-a7f39faa03bf

Makefile
dtls.c
radsecproxy.c
tcp.c
tls.c
udp.c

index 12dabd4..5be1a33 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CFLAGS = -g -Wall -pedantic -pthread
+CFLAGS = -g -Wall -pedantic -pthread -DRADPROT_UDP -DRADPROT_TCP -DRADPROT_TLS -DRADPROT_DTLS
 LDFLAGS = -lssl
 OBJ = util.o debug.o list.o hash.o gconfig.o tlv11.o radmsg.o udp.o tcp.o tls.o dtls.o radsecproxy.o
 
diff --git a/dtls.c b/dtls.c
index 6ada359..0fdbc3a 100644 (file)
--- a/dtls.c
+++ b/dtls.c
@@ -6,6 +6,7 @@
  * copyright notice and this permission notice appear in all copies.
  */
 
+#ifdef RADPROT_DTLS
 #include <signal.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -700,3 +701,8 @@ void initextradtls() {
        if (pthread_create(&cl6th, NULL, udpdtlsclientrd, (void *)&client6_sock))
            debugx(1, DBG_ERR, "pthread_create failed");
 }
+#else
+const struct protodefs *dtlsinit(uint8_t h) {
+    return NULL;
+}
+#endif
index 75802e9..2417baa 100644 (file)
@@ -2482,12 +2482,15 @@ SSL_CTX *tlscreatectx(uint8_t type, struct tls *conf) {
        sslinit();
 
     switch (type) {
+#ifdef RADPROT_TLS     
     case RAD_TLS:
        ctx = SSL_CTX_new(TLSv1_method());
 #ifdef DEBUG   
        SSL_CTX_set_info_callback(ctx, ssl_info_callback);
 #endif 
        break;
+#endif 
+#ifdef RADPROT_DTLS    
     case RAD_DTLS:
        ctx = SSL_CTX_new(DTLSv1_method());
 #ifdef DEBUG   
@@ -2495,6 +2498,7 @@ SSL_CTX *tlscreatectx(uint8_t type, struct tls *conf) {
 #endif 
        SSL_CTX_set_read_ahead(ctx, 1);
        break;
+#endif 
     }
     if (!ctx) {
        debug(DBG_ERR, "tlscreatectx: Error initialising SSL/TLS in TLS context %s", conf->name);
@@ -2556,6 +2560,7 @@ SSL_CTX *tlsgetctx(uint8_t type, struct tls *t) {
     gettimeofday(&now, NULL);
     
     switch (type) {
+#ifdef RADPROT_TLS
     case RAD_TLS:
        if (t->tlsexpiry && t->tlsctx) {
            if (t->tlsexpiry < now.tv_sec) {
@@ -2569,6 +2574,8 @@ SSL_CTX *tlsgetctx(uint8_t type, struct tls *t) {
                t->tlsexpiry = now.tv_sec + t->cacheexpiry;
        }
        return t->tlsctx;
+#endif
+#ifdef RADPROT_DTLS
     case RAD_DTLS:
        if (t->dtlsexpiry && t->dtlsctx) {
            if (t->dtlsexpiry < now.tv_sec) {
@@ -2582,6 +2589,7 @@ SSL_CTX *tlsgetctx(uint8_t type, struct tls *t) {
                t->dtlsexpiry = now.tv_sec + t->cacheexpiry;
        }
        return t->dtlsctx;
+#endif
     }
     return NULL;
 }
@@ -3636,14 +3644,30 @@ void getmainconfig(const char *configfile) {
        debugx(1, DBG_ERR, "malloc failed");    
  
     if (!getgenericconfig(&cfs, NULL,
+#ifdef RADPROT_UDP                       
                          "ListenUDP", CONF_MSTR, &listenargs[RAD_UDP],
+#endif                   
+#ifdef RADPROT_TCP                       
                          "ListenTCP", CONF_MSTR, &listenargs[RAD_TCP],
+#endif                   
+#ifdef RADPROT_TLS
                          "ListenTLS", CONF_MSTR, &listenargs[RAD_TLS],
+#endif                   
+#ifdef RADPROT_DTLS
                          "ListenDTLS", CONF_MSTR, &listenargs[RAD_DTLS],
+#endif                   
+#ifdef RADPROT_UDP                       
                          "SourceUDP", CONF_STR, &sourcearg[RAD_UDP],
+#endif                   
+#ifdef RADPROT_TCP                       
                          "SourceTCP", CONF_STR, &sourcearg[RAD_TCP],
+#endif                   
+#ifdef RADPROT_TLS
                          "SourceTLS", CONF_STR, &sourcearg[RAD_TLS],
+#endif                   
+#ifdef RADPROT_DTLS
                          "SourceDTLS", CONF_STR, &sourcearg[RAD_DTLS],
+#endif                   
                          "TTLAttribute", CONF_STR, &options.ttlattr,
                          "addTTL", CONF_LINT, &addttl,
                          "LogLevel", CONF_LINT, &loglevel,
@@ -3806,6 +3830,8 @@ int main(int argc, char **argv) {
     }
 
     for (i = 0; i < RAD_PROTOCOUNT; i++) {
+       if (!protodefs[i])
+           continue;
        if (protodefs[i]->initextra)
            protodefs[i]->initextra();
         if (find_clconf_type(i, NULL))
diff --git a/tcp.c b/tcp.c
index 29a226a..cddd554 100644 (file)
--- a/tcp.c
+++ b/tcp.c
@@ -6,6 +6,7 @@
  * copyright notice and this permission notice appear in all copies.
  */
 
+#ifdef RADPROT_TCP
 #include <signal.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -368,3 +369,8 @@ void *tcplistener(void *arg) {
     free(sp);
     return NULL;
 }
+#else
+const struct protodefs *tcpinit(uint8_t h) {
+    return NULL;
+}
+#endif
diff --git a/tls.c b/tls.c
index 93bec50..5a97960 100644 (file)
--- a/tls.c
+++ b/tls.c
@@ -6,6 +6,7 @@
  * copyright notice and this permission notice appear in all copies.
  */
 
+#ifdef RADPROT_TLS
 #include <signal.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -468,3 +469,8 @@ void *tlslistener(void *arg) {
     free(sp);
     return NULL;
 }
+#else
+const struct protodefs *tlsinit(uint8_t h) {
+    return NULL;
+}
+#endif
diff --git a/udp.c b/udp.c
index b0cb464..ad2789b 100644 (file)
--- a/udp.c
+++ b/udp.c
@@ -6,6 +6,7 @@
  * copyright notice and this permission notice appear in all copies.
  */
 
+#ifdef RADPROT_UDP
 #include <signal.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -336,3 +337,8 @@ void initextraudp() {
            debugx(1, DBG_ERR, "pthread_create failed");
     }
 }
+#else
+const struct protodefs *udpinit(uint8_t h) {
+    return NULL;
+}
+#endif