From: Alan T. DeKok Date: Tue, 21 Jun 2016 14:33:54 +0000 (-0400) Subject: Build without TCP, too X-Git-Tag: release_3_0_12~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=509dc6ce51d07e7cea35430985d012c8267ae5ea;p=thirdparty%2Ffreeradius-server.git Build without TCP, too --- diff --git a/src/main/client.c b/src/main/client.c index 00229d092f3..763d7bc6e1b 100644 --- a/src/main/client.c +++ b/src/main/client.c @@ -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[] = { diff --git a/src/main/command.c b/src/main/command.c index e667c72ea7b..3e04539dcbe 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -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) { diff --git a/src/main/listen.c b/src/main/listen.c index b6fad6dbcc5..65e5c8bf137 100644 --- a/src/main/listen.c +++ b/src/main/listen.c @@ -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 "); diff --git a/src/main/process.c b/src/main/process.c index a490c3044e1..09192bee32a 100644 --- a/src/main/process.c +++ b/src/main/process.c @@ -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; } diff --git a/src/main/realms.c b/src/main/realms.c index e6e48ff60d4..738e69abb94 100644 --- a/src/main/realms.c +++ b/src/main/realms.c @@ -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; diff --git a/src/main/tls_listen.c b/src/main/tls_listen.c index 59b1ea05e46..0045ede7ac8 100644 --- a/src/main/tls_listen.c +++ b/src/main/tls_listen.c @@ -33,6 +33,7 @@ USES_APPLE_DEPRECATED_API /* OpenSSL API has been deprecated by Apple */ #include #endif +#ifdef WITH_TCP #ifdef WITH_TLS #ifdef HAVE_OPENSSL_RAND_H #include @@ -723,3 +724,4 @@ int proxy_tls_send(rad_listen_t *listener, REQUEST *request) #endif /* WITH_PROXY */ #endif /* WITH_TLS */ +#endif /* WITH_TCP */