예제 #1
0
int radius_client_send(struct radius_client_data *radius,
		       struct radius_msg *msg, RadiusType msg_type,
		       const u8 *addr)
{
	struct hostapd_radius_servers *conf = radius->conf;
	u8 *shared_secret;
	size_t shared_secret_len;
	char *name;
	int s, res;

	if (msg_type == RADIUS_ACCT_INTERIM) {
		/* Remove any pending interim acct update for the same STA. */
		radius_client_list_del(radius, msg_type, addr);
	}

	if (msg_type == RADIUS_ACCT || msg_type == RADIUS_ACCT_INTERIM) {
		if (conf->acct_server == NULL) {
			hostapd_logger(radius->ctx, NULL,
				       HOSTAPD_MODULE_RADIUS,
				       HOSTAPD_LEVEL_INFO,
				       "No accounting server configured");
			return -1;
		}
		shared_secret = conf->acct_server->shared_secret;
		shared_secret_len = conf->acct_server->shared_secret_len;
		radius_msg_finish_acct(msg, shared_secret, shared_secret_len);
		name = "accounting";
		s = radius->acct_sock;
		conf->acct_server->requests++;
	} else {
		if (conf->auth_server == NULL) {
			hostapd_logger(radius->ctx, NULL,
				       HOSTAPD_MODULE_RADIUS,
				       HOSTAPD_LEVEL_INFO,
				       "No authentication server configured");
			return -1;
		}
		shared_secret = conf->auth_server->shared_secret;
		shared_secret_len = conf->auth_server->shared_secret_len;
		radius_msg_finish(msg, shared_secret, shared_secret_len);
		name = "authentication";
		s = radius->auth_sock;
		conf->auth_server->requests++;
	}

	hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS,
		       HOSTAPD_LEVEL_DEBUG, "Sending RADIUS message to %s "
		       "server", name);
	if (conf->msg_dumps)
		radius_msg_dump(msg);

	res = send(s, msg->buf, msg->buf_used, 0);
	if (res < 0)
		radius_client_handle_send_error(radius, s, msg_type);

	radius_client_list_add(radius, msg, msg_type, shared_secret,
			       shared_secret_len, addr);

	return res;
}
예제 #2
0
int radius_client_send(struct radius_client_data *radius,
                       struct radius_msg *msg, RadiusType msg_type, u8 *addr)
{
    struct hostapd_data *hapd = radius->hapd;
    u8 *shared_secret;
    size_t shared_secret_len;
    char *name;
    int s, res;

    if (msg_type == RADIUS_ACCT_INTERIM) {
        /* Remove any pending interim acct update for the same STA. */
        radius_client_list_del(radius, msg_type, addr);
    }

    if (msg_type == RADIUS_ACCT || msg_type == RADIUS_ACCT_INTERIM) {
        shared_secret = hapd->conf->acct_server->shared_secret;
        shared_secret_len = hapd->conf->acct_server->shared_secret_len;
        radius_msg_finish_acct(msg, shared_secret, shared_secret_len);
        name = "accounting";
        s = radius->acct_serv_sock;
        hapd->conf->acct_server->requests++;
    } else {
        shared_secret = hapd->conf->auth_server->shared_secret;
        shared_secret_len = hapd->conf->auth_server->shared_secret_len;
        radius_msg_finish(msg, shared_secret, shared_secret_len);
        name = "authentication";
        s = radius->auth_serv_sock;
        hapd->conf->auth_server->requests++;
    }

    HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL,
                  "Sending RADIUS message to %s server\n", name);
    if (HOSTAPD_DEBUG_COND(HOSTAPD_DEBUG_MSGDUMPS))
        radius_msg_dump(msg);

    res = send(s, msg->buf, msg->buf_used, 0);
    if (res < 0)
        radius_client_handle_send_error(radius, s, msg_type);

    radius_client_list_add(radius, msg, msg_type, shared_secret,
                           shared_secret_len, addr);

    return res;
}
예제 #3
0
int radius_client_send(struct wpa_supplicant *wpa_s, struct radius_msg *msg,
		       RadiusType msg_type, u8 *addr)
{
	u8 *shared_secret;
	size_t shared_secret_len;
	char *name;
	int s, res;

	if (msg_type == RADIUS_ACCT_INTERIM) {
		/* Remove any pending interim acct update for the same STA. */
		radius_client_list_del(wpa_s, msg_type, addr);
	}

	if (msg_type == RADIUS_ACCT || msg_type == RADIUS_ACCT_INTERIM) {
		shared_secret = wpa_s->acct_server->shared_secret;
		shared_secret_len = wpa_s->acct_server->shared_secret_len;
		radius_msg_finish_acct(msg, shared_secret, shared_secret_len);
		name = "accounting";
		s = wpa_s->radius->acct_serv_sock;
	} else {
		shared_secret = wpa_s->auth_server->shared_secret;
		shared_secret_len = wpa_s->auth_server->shared_secret_len;
		radius_msg_finish(msg, shared_secret, shared_secret_len);
		name = "authentication";
		s = wpa_s->radius->auth_serv_sock;
	}

	HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL,
		      "Sending RADIUS message to %s server\n", name);
	if (HOSTAPD_DEBUG_COND(HOSTAPD_DEBUG_MSGDUMPS))
		radius_msg_dump(msg);

	res = send(s, msg->buf, msg->buf_used, 0);
	if (res < 0)
		perror("send[RADIUS]");

	radius_client_list_add(wpa_s, msg, msg_type, shared_secret,
			       shared_secret_len, addr);

	return res;
}