]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Build without TCP, too
authorAlan T. DeKok <aland@freeradius.org>
Tue, 21 Jun 2016 14:33:54 +0000 (10:33 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 21 Jun 2016 14:33:54 +0000 (10:33 -0400)
src/main/client.c
src/main/command.c
src/main/listen.c
src/main/process.c
src/main/realms.c
src/main/tls_listen.c

index 00229d092f39700d76f5b003d1f75fc5585cf57e..763d7bc6e1bf48c59c692213c38b7aac46b1aaa9 100644 (file)
@@ -478,9 +478,7 @@ RADCLIENT *client_find_old(fr_ipaddr_t const *ipaddr)
 static fr_ipaddr_t cl_ipaddr;
 static uint32_t cl_netmask;
 static char const *cl_srcipaddr = NULL;
-#ifdef WITH_TCP
 static char const *hs_proto = NULL;
-#endif
 
 #ifdef WITH_TCP
 static CONF_PARSER limit_config[] = {
index e667c72ea7b2987a3b748cc79c1abf5b58cb3164..3e04539dcbeaf6abc7d95a02097a4910e282e411 100644 (file)
@@ -3041,7 +3041,12 @@ static int command_domain_recv_co(rad_listen_t *listener, fr_cs_buffer_t *co)
 /*
  *     Write 32-bit magic number && version information.
  */
-static int command_write_magic(int newfd, listen_socket_t *sock)
+static int command_write_magic(int newfd,
+#ifndef WITH_TCP
+                              UNUSED
+#endif
+                              listen_socket_t *sock
+       )
 {
        ssize_t r;
        uint32_t magic;
@@ -3066,6 +3071,7 @@ static int command_write_magic(int newfd, listen_socket_t *sock)
        r = fr_channel_write(newfd, FR_CHANNEL_INIT_ACK, buffer, 8);
        if (r <= 0) goto do_close;
 
+#ifdef WITH_TCP
        /*
         *      Write an initial challenge
         */
@@ -3083,11 +3089,12 @@ static int command_write_magic(int newfd, listen_socket_t *sock)
                r = fr_channel_write(newfd, FR_CHANNEL_AUTH_CHALLENGE, co->buffer, 16);
                if (r <= 0) goto do_close;
        }
+#endif
 
        return 0;
 }
 
-
+#ifdef WITH_TCP
 static int command_tcp_recv(rad_listen_t *this)
 {
        ssize_t r;
@@ -3126,6 +3133,7 @@ static int command_tcp_recv(rad_listen_t *this)
        return command_domain_recv_co(this, co);
 }
 
+
 /*
  *     Should never be called.  The functions should just call write().
  */
@@ -3133,6 +3141,7 @@ static int command_tcp_send(UNUSED rad_listen_t *listener, UNUSED REQUEST *reque
 {
        return 0;
 }
+#endif
 
 static int command_domain_recv(rad_listen_t *listener)
 {
index b6fad6dbcc50a70441dbb33972e7bb1a01ff3388..65e5c8bf1370caaa159f1f0a845b7bbde3db07d1 100644 (file)
@@ -70,10 +70,12 @@ static void print_packet(RADIUS_PACKET *packet)
 static rad_listen_t *listen_alloc(TALLOC_CTX *ctx, RAD_LISTEN_TYPE type);
 
 #ifdef WITH_COMMAND_SOCKET
+#ifdef WITH_TCP
 static int command_tcp_recv(rad_listen_t *listener);
 static int command_tcp_send(rad_listen_t *listener, REQUEST *request);
 static int command_write_magic(int newfd, listen_socket_t *sock);
 #endif
+#endif
 
 static fr_protocol_t master_listen[];
 
@@ -766,9 +768,11 @@ int common_socket_print(rad_listen_t const *this, char *buffer, size_t bufsize)
 
        ADDSTRING(name);
 
+#ifdef WITH_TCP
        if (this->dual) {
                ADDSTRING("+acct");
        }
+#endif
 
        if (sock->interface) {
                ADDSTRING(" interface ");
index a490c3044e18501d534c2769b9b4b6f766d7657f..09192bee32adf2b04e0a4b5852d0152666fbcbb0 100644 (file)
@@ -1583,14 +1583,15 @@ int request_receive(TALLOC_CTX *ctx, rad_listen_t *listener, RADIUS_PACKET *pack
 #ifdef WITH_ACCOUNTING
        if (listener->type != RAD_LISTEN_DETAIL)
 #endif
+
+#ifdef WITH_TCP
        {
                sock = listener->data;
                sock->last_packet = now.tv_sec;
 
-#ifdef WITH_TCP
                packet->proto = sock->proto;
-#endif
        }
+#endif
 
        /*
         *      Skip everything if required.
@@ -2005,26 +2006,6 @@ static void tcp_socket_timer(void *ctx)
 
 
 #ifdef WITH_PROXY
-/*
- *     Add +/- 2s of jitter, as suggested in RFC 3539
- *     and in RFC 5080.
- */
-static void add_jitter(struct timeval *when)
-{
-       uint32_t jitter;
-
-       when->tv_sec -= 2;
-
-       jitter = fr_rand();
-       jitter ^= (jitter >> 10);
-       jitter &= ((1 << 22) - 1); /* 22 bits of 1 */
-
-       /*
-        *      Add in ~ (4 * USEC) of jitter.
-        */
-       tv_add(when, jitter);
-}
-
 /*
  *     Called by socket_del to remove requests with this socket
  */
@@ -2520,10 +2501,12 @@ int request_proxy_reply(RADIUS_PACKET *packet)
         *      Status-Server packets don't count as real packets.
         */
        if (request->proxy->code != PW_CODE_STATUS_SERVER) {
+#ifdef WITH_TCP
                listen_socket_t *sock = request->proxy_listener->data;
 
-               request->home_server->last_packet_recv = now.tv_sec;
                sock->last_packet = now.tv_sec;
+#endif
+               request->home_server->last_packet_recv = now.tv_sec;
        }
 
        request->num_proxied_responses++;
@@ -3421,6 +3404,26 @@ static void request_ping(REQUEST *request, int action)
        request_done(request, FR_ACTION_DONE);
 }
 
+/*
+ *     Add +/- 2s of jitter, as suggested in RFC 3539
+ *     and in RFC 5080.
+ */
+static void add_jitter(struct timeval *when)
+{
+       uint32_t jitter;
+
+       when->tv_sec -= 2;
+
+       jitter = fr_rand();
+       jitter ^= (jitter >> 10);
+       jitter &= ((1 << 22) - 1); /* 22 bits of 1 */
+
+       /*
+        *      Add in ~ (4 * USEC) of jitter.
+        */
+       tv_add(when, jitter);
+}
+
 /*
  *     Called from start of zombie period, OR after control socket
  *     marks the home server dead.
@@ -4681,7 +4684,6 @@ static void listener_free_cb(void *ctx)
        rad_assert(this->next == NULL);
        talloc_free(this);
 }
-#endif
 
 #ifdef WITH_PROXY
 static int proxy_eol_cb(void *ctx, void *data)
@@ -4721,7 +4723,8 @@ static int proxy_eol_cb(void *ctx, void *data)
         */
        return 0;
 }
-#endif
+#endif /* WITH_PROXY */
+#endif /* WITH_TCP */
 
 static int event_new_fd(rad_listen_t *this)
 {
@@ -4804,7 +4807,7 @@ static int event_new_fd(rad_listen_t *this)
                                        rad_panic("Failed to insert event");
                                }
                        }
-#endif
+#endif /* WITH_TCP */
                        break;
 #endif /* WITH_PROXY */
 
@@ -4831,7 +4834,7 @@ static int event_new_fd(rad_listen_t *this)
                                        fr_exit(1);
                                }
                        }
-#endif
+#endif /* WITH_TCP */
                        break;
                } /* switch over listener types */
 
@@ -4908,7 +4911,7 @@ static int event_new_fd(rad_listen_t *this)
                        }
                        PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
                }
-#endif
+#endif /* WITH_PROXY */
 
                /*
                 *      Requests are still using the socket.  Wait for
@@ -4940,7 +4943,7 @@ static int event_new_fd(rad_listen_t *this)
                 */
                this->status = RAD_LISTEN_STATUS_REMOVE_NOW;
        } /* socket is at EOL */
-#endif
+#endif   /* WITH_TCP */
 
        /*
         *      Nuke the socket.
@@ -4949,8 +4952,8 @@ static int event_new_fd(rad_listen_t *this)
                int devnull;
 #ifdef WITH_TCP
                listen_socket_t *sock = this->data;
-#endif
                struct timeval when;
+#endif
 
                /*
                 *      Re-open the socket, pointing it to /dev/null.
@@ -5011,7 +5014,7 @@ static int event_new_fd(rad_listen_t *this)
                        }
                        PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
                } else
-#endif
+#endif /* WITH_PROXY */
                {
                        INFO(" ... shutting down socket %s", buffer);
 
@@ -5042,8 +5045,8 @@ static int event_new_fd(rad_listen_t *this)
                                     &(sock->ev))) {
                        rad_panic("Failed to insert event");
                }
-       }
 #endif /* WITH_TCP */
+       }
 
        return 1;
 }
index e6e48ff60d4504000be7d7024b67be7f25224fb8..738e69abb94dbf6dbd83486819311127ed812e2e 100644 (file)
@@ -2692,7 +2692,11 @@ home_server_t *home_server_ldb(char const *realmname,
 }
 
 
-home_server_t *home_server_find(fr_ipaddr_t *ipaddr, uint16_t port, int proto)
+home_server_t *home_server_find(fr_ipaddr_t *ipaddr, uint16_t port,
+#ifndef WITH_TCP
+                               UNUSED
+#endif
+                               int proto)
 {
        home_server_t myhome;
 
index 59b1ea05e4659622abdfb8418d96e31a390e27d3..0045ede7ac8cb6b6c6bd8a62365e32ff637641ab 100644 (file)
@@ -33,6 +33,7 @@ USES_APPLE_DEPRECATED_API     /* OpenSSL API has been deprecated by Apple */
 #include <sys/stat.h>
 #endif
 
+#ifdef WITH_TCP
 #ifdef WITH_TLS
 #ifdef HAVE_OPENSSL_RAND_H
 #include <openssl/rand.h>
@@ -723,3 +724,4 @@ int proxy_tls_send(rad_listen_t *listener, REQUEST *request)
 #endif /* WITH_PROXY */
 
 #endif /* WITH_TLS */
+#endif /* WITH_TCP */