}
-static int client_socket_encode(rad_listen_t *listener, REQUEST *request)
+static int client_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request)
{
if (!request->reply->code) return 0;
}
-static int client_socket_decode(rad_listen_t *listener, REQUEST *request)
+static int client_socket_decode(UNUSED rad_listen_t *listener, REQUEST *request)
{
if (rad_verify(request->packet, NULL, request->secret) < 0) {
return -1;
return rad_decode(request->packet, NULL, request->secret);
}
-static int proxy_socket_encode(rad_listen_t *listener, REQUEST *request)
+static int proxy_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request)
{
rad_encode(request->proxy, NULL, request->home_server->secret);
rad_sign(request->proxy, NULL, request->home_server->secret);
}
-static int proxy_socket_decode(rad_listen_t *listener, REQUEST *request)
+static int proxy_socket_decode(UNUSED rad_listen_t *listener, REQUEST *request)
{
if (rad_verify(request->proxy_reply, request->proxy,
request->home_server->secret) < 0) {
((listen_detail_t *)(this->data))->detail);
}
-static int detail_encode(rad_listen_t *this, REQUEST *request)
+static int detail_encode(UNUSED rad_listen_t *this, UNUSED REQUEST *request)
{
/*
* We never encode responses "sent to" the detail file.
return 0;
}
-static int detail_decode(rad_listen_t *this, REQUEST *request)
+static int detail_decode(UNUSED rad_listen_t *this, UNUSED REQUEST *request)
{
/*
* We never decode responses read from the detail file.
return 0;
}
+
+#ifdef WITH_SNMP
+static int radius_snmp_recv(rad_listen_t *listener,
+ UNUSED RAD_REQUEST_FUNP *pfun,
+ UNUSED REQUEST **prequest)
+{
+ if (!mainconfig.do_snmp) return 0;
+
+ if ((rad_snmp.smux_fd >= 0) &&
+ (rad_snmp.smux_event == SMUX_READ)) {
+ smux_read();
+ }
+
+ /*
+ * If we've got to re-connect, then do so now,
+ * before calling select again.
+ */
+ if (rad_snmp.smux_event == SMUX_CONNECT) {
+ smux_connect();
+ }
+
+ /*
+ * Reset this every time, as the smux connect may have
+ * opened a new socket.
+ */
+ listener->fd = rad_snmp.smux_fd;
+
+ return 0;
+}
+
+
+static int radius_snmp_print(rad_listen_t *this, char *buffer, size_t bufsize)
+{
+ return snprintf(buffer, bufsize, "SMUX with OID .1.3.6.1.4.1.3317.1.3.1");
+}
+
+#endif
+
static const rad_listen_master_t master_listen[RAD_LISTEN_MAX] = {
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL}, /* RAD_LISTEN_NONE */
/* detail */
{ detail_parse, detail_free,
detail_recv, detail_send,
- detail_print, detail_encode, detail_decode }
+ detail_print, detail_encode, detail_decode },
+
+ { NULL, NULL, NULL, NULL, NULL, NULL, NULL}, /* RAD_LISTEN_SNMP */
};
}
}
+#ifdef WITH_SNMP
+ if (mainconfig.do_snmp) {
+ radius_snmp_init();
+
+ this = rad_malloc(sizeof(*this));
+ memset(this, 0, sizeof(*this));
+
+ this->type = RAD_LISTEN_SNMP;
+ this->fd = rad_snmp.smux_fd;
+
+ this->recv = radius_snmp_recv;
+ this->print = radius_snmp_print;
+
+ *last = this;
+ last = &(this->next);
+ }
+#endif
+
/*
* Sanity check the configuration.
*/
#endif
}
-#ifdef WITH_SNMP
- if (mainconfig.do_snmp) radius_snmp_init();
-#endif
-
/*
* Ensure that we're using the CORRECT pid after forking,
* NOT the one we started with.
DEBUG("Listening on detail file %s", buffer);
break;
+ case RAD_LISTEN_SNMP:
+ DEBUG("Listening on SNMP %s", buffer);
+ break;
+
default:
break;
}
if (listener->fd > max_fd) max_fd = listener->fd;
}
-#ifdef WITH_SNMP
- if (mainconfig.do_snmp &&
- (rad_snmp.smux_fd >= 0)) {
- FD_SET(rad_snmp.smux_fd, &readfds);
- if (rad_snmp.smux_fd > max_fd) max_fd = rad_snmp.smux_fd;
- }
-#endif
-
if (!ptv) {
DEBUG2("Nothing to do. Sleeping until we see a request.");
} else if (tv.tv_sec) {
continue;
}
- // EVENT FIX FIXME! Nuke this!
-
/*
* Drop the request into the thread pool,
* and let the thread pool take care of
}
} /* loop over listening sockets*/
-#ifdef WITH_SNMP
- if (mainconfig.do_snmp) {
- /*
- * After handling all authentication/accounting
- * requests, THEN process any pending SMUX/SNMP
- * queries.
- *
- * Note that the handling is done in the main server,
- * which probably isn't a Good Thing. It really
- * should be wrapped, and handled in a thread pool.
- */
- if ((rad_snmp.smux_fd >= 0) &&
- FD_ISSET(rad_snmp.smux_fd, &readfds) &&
- (rad_snmp.smux_event == SMUX_READ)) {
- smux_read();
- }
-
- /*
- * If we've got to re-connect, then do so now,
- * before calling select again.
- */
- if (rad_snmp.smux_event == SMUX_CONNECT) {
- smux_connect();
- }
- }
-#endif
-
ptv = &tv;
radius_event_process(&ptv);