Convert perror/printf calls to wpa_printf

This makes debug and error logging more consistent and allows them to be
directed to a file more easily.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-11-02 12:51:30 +02:00
parent 8f47f31dd8
commit 61323e70e1
12 changed files with 156 additions and 143 deletions

View file

@ -44,7 +44,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
msg = radius_msg_new(RADIUS_CODE_ACCOUNTING_REQUEST, msg = radius_msg_new(RADIUS_CODE_ACCOUNTING_REQUEST,
radius_client_get_id(hapd->radius)); radius_client_get_id(hapd->radius));
if (msg == NULL) { if (msg == NULL) {
printf("Could not create net RADIUS packet\n"); wpa_printf(MSG_INFO, "Could not create new RADIUS packet");
return NULL; return NULL;
} }
@ -55,7 +55,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
sta->acct_session_id_hi, sta->acct_session_id_lo); sta->acct_session_id_hi, sta->acct_session_id_lo);
if (!radius_msg_add_attr(msg, RADIUS_ATTR_ACCT_SESSION_ID, if (!radius_msg_add_attr(msg, RADIUS_ATTR_ACCT_SESSION_ID,
(u8 *) buf, os_strlen(buf))) { (u8 *) buf, os_strlen(buf))) {
printf("Could not add Acct-Session-Id\n"); wpa_printf(MSG_INFO, "Could not add Acct-Session-Id");
goto fail; goto fail;
} }
} else { } else {
@ -64,7 +64,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_STATUS_TYPE, if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_STATUS_TYPE,
status_type)) { status_type)) {
printf("Could not add Acct-Status-Type\n"); wpa_printf(MSG_INFO, "Could not add Acct-Status-Type");
goto fail; goto fail;
} }
@ -74,7 +74,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
hapd->conf->ieee802_1x ? hapd->conf->ieee802_1x ?
RADIUS_ACCT_AUTHENTIC_RADIUS : RADIUS_ACCT_AUTHENTIC_RADIUS :
RADIUS_ACCT_AUTHENTIC_LOCAL)) { RADIUS_ACCT_AUTHENTIC_LOCAL)) {
printf("Could not add Acct-Authentic\n"); wpa_printf(MSG_INFO, "Could not add Acct-Authentic");
goto fail; goto fail;
} }
@ -99,7 +99,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
if (!radius_msg_add_attr(msg, RADIUS_ATTR_USER_NAME, val, if (!radius_msg_add_attr(msg, RADIUS_ATTR_USER_NAME, val,
len)) { len)) {
printf("Could not add User-Name\n"); wpa_printf(MSG_INFO, "Could not add User-Name");
goto fail; goto fail;
} }
} }
@ -117,7 +117,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CLASS, if (!radius_msg_add_attr(msg, RADIUS_ATTR_CLASS,
val, len)) { val, len)) {
printf("Could not add Class\n"); wpa_printf(MSG_INFO, "Could not add Class");
goto fail; goto fail;
} }
} }
@ -254,14 +254,14 @@ static void accounting_sta_report(struct hostapd_data *hapd,
stop ? RADIUS_ACCT_STATUS_TYPE_STOP : stop ? RADIUS_ACCT_STATUS_TYPE_STOP :
RADIUS_ACCT_STATUS_TYPE_INTERIM_UPDATE); RADIUS_ACCT_STATUS_TYPE_INTERIM_UPDATE);
if (!msg) { if (!msg) {
printf("Could not create RADIUS Accounting message\n"); wpa_printf(MSG_INFO, "Could not create RADIUS Accounting message");
return; return;
} }
os_get_time(&now); os_get_time(&now);
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_SESSION_TIME, if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_SESSION_TIME,
now.sec - sta->acct_session_start)) { now.sec - sta->acct_session_start)) {
printf("Could not add Acct-Session-Time\n"); wpa_printf(MSG_INFO, "Could not add Acct-Session-Time");
goto fail; goto fail;
} }
@ -269,19 +269,19 @@ static void accounting_sta_report(struct hostapd_data *hapd,
if (!radius_msg_add_attr_int32(msg, if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_INPUT_PACKETS, RADIUS_ATTR_ACCT_INPUT_PACKETS,
data.rx_packets)) { data.rx_packets)) {
printf("Could not add Acct-Input-Packets\n"); wpa_printf(MSG_INFO, "Could not add Acct-Input-Packets");
goto fail; goto fail;
} }
if (!radius_msg_add_attr_int32(msg, if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_OUTPUT_PACKETS, RADIUS_ATTR_ACCT_OUTPUT_PACKETS,
data.tx_packets)) { data.tx_packets)) {
printf("Could not add Acct-Output-Packets\n"); wpa_printf(MSG_INFO, "Could not add Acct-Output-Packets");
goto fail; goto fail;
} }
if (!radius_msg_add_attr_int32(msg, if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_INPUT_OCTETS, RADIUS_ATTR_ACCT_INPUT_OCTETS,
data.rx_bytes)) { data.rx_bytes)) {
printf("Could not add Acct-Input-Octets\n"); wpa_printf(MSG_INFO, "Could not add Acct-Input-Octets");
goto fail; goto fail;
} }
gigawords = sta->acct_input_gigawords; gigawords = sta->acct_input_gigawords;
@ -292,13 +292,13 @@ static void accounting_sta_report(struct hostapd_data *hapd,
!radius_msg_add_attr_int32( !radius_msg_add_attr_int32(
msg, RADIUS_ATTR_ACCT_INPUT_GIGAWORDS, msg, RADIUS_ATTR_ACCT_INPUT_GIGAWORDS,
gigawords)) { gigawords)) {
printf("Could not add Acct-Input-Gigawords\n"); wpa_printf(MSG_INFO, "Could not add Acct-Input-Gigawords");
goto fail; goto fail;
} }
if (!radius_msg_add_attr_int32(msg, if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_OUTPUT_OCTETS, RADIUS_ATTR_ACCT_OUTPUT_OCTETS,
data.tx_bytes)) { data.tx_bytes)) {
printf("Could not add Acct-Output-Octets\n"); wpa_printf(MSG_INFO, "Could not add Acct-Output-Octets");
goto fail; goto fail;
} }
gigawords = sta->acct_output_gigawords; gigawords = sta->acct_output_gigawords;
@ -309,14 +309,14 @@ static void accounting_sta_report(struct hostapd_data *hapd,
!radius_msg_add_attr_int32( !radius_msg_add_attr_int32(
msg, RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS, msg, RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS,
gigawords)) { gigawords)) {
printf("Could not add Acct-Output-Gigawords\n"); wpa_printf(MSG_INFO, "Could not add Acct-Output-Gigawords");
goto fail; goto fail;
} }
} }
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_EVENT_TIMESTAMP, if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_EVENT_TIMESTAMP,
now.sec)) { now.sec)) {
printf("Could not add Event-Timestamp\n"); wpa_printf(MSG_INFO, "Could not add Event-Timestamp");
goto fail; goto fail;
} }
@ -326,7 +326,7 @@ static void accounting_sta_report(struct hostapd_data *hapd,
if (stop && cause && if (stop && cause &&
!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_TERMINATE_CAUSE, !radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_TERMINATE_CAUSE,
cause)) { cause)) {
printf("Could not add Acct-Terminate-Cause\n"); wpa_printf(MSG_INFO, "Could not add Acct-Terminate-Cause");
goto fail; goto fail;
} }
@ -400,13 +400,12 @@ accounting_receive(struct radius_msg *msg, struct radius_msg *req,
void *data) void *data)
{ {
if (radius_msg_get_hdr(msg)->code != RADIUS_CODE_ACCOUNTING_RESPONSE) { if (radius_msg_get_hdr(msg)->code != RADIUS_CODE_ACCOUNTING_RESPONSE) {
printf("Unknown RADIUS message code\n"); wpa_printf(MSG_INFO, "Unknown RADIUS message code");
return RADIUS_RX_UNKNOWN; return RADIUS_RX_UNKNOWN;
} }
if (radius_msg_verify(msg, shared_secret, shared_secret_len, req, 0)) { if (radius_msg_verify(msg, shared_secret, shared_secret_len, req, 0)) {
printf("Incoming RADIUS packet did not have correct " wpa_printf(MSG_INFO, "Incoming RADIUS packet did not have correct Authenticator - dropped");
"Authenticator - dropped\n");
return RADIUS_RX_INVALID_AUTHENTICATOR; return RADIUS_RX_INVALID_AUTHENTICATOR;
} }
@ -432,7 +431,7 @@ static void accounting_report_state(struct hostapd_data *hapd, int on)
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_TERMINATE_CAUSE, if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_TERMINATE_CAUSE,
RADIUS_ACCT_TERMINATE_CAUSE_NAS_REBOOT)) RADIUS_ACCT_TERMINATE_CAUSE_NAS_REBOOT))
{ {
printf("Could not add Acct-Terminate-Cause\n"); wpa_printf(MSG_INFO, "Could not add Acct-Terminate-Cause");
radius_msg_free(msg); radius_msg_free(msg);
return; return;
} }

View file

@ -540,7 +540,7 @@ void handle_probe_req(struct hostapd_data *hapd,
is_broadcast_ether_addr(mgmt->da)); is_broadcast_ether_addr(mgmt->da));
if (hostapd_drv_send_mlme(hapd, resp, resp_len, noack) < 0) if (hostapd_drv_send_mlme(hapd, resp, resp_len, noack) < 0)
perror("handle_probe_req: send"); wpa_printf(MSG_INFO, "handle_probe_req: send failed");
os_free(resp); os_free(resp);

View file

@ -204,7 +204,7 @@ static void iapp_send_add(struct iapp_data *iapp, u8 *mac_addr, u16 seq_num)
addr.sin_port = htons(IAPP_UDP_PORT); addr.sin_port = htons(IAPP_UDP_PORT);
if (sendto(iapp->udp_sock, buf, (char *) (add + 1) - buf, 0, if (sendto(iapp->udp_sock, buf, (char *) (add + 1) - buf, 0,
(struct sockaddr *) &addr, sizeof(addr)) < 0) (struct sockaddr *) &addr, sizeof(addr)) < 0)
perror("sendto[IAPP-ADD]"); wpa_printf(MSG_INFO, "sendto[IAPP-ADD]: %s", strerror(errno));
} }
@ -231,7 +231,7 @@ static void iapp_send_layer2_update(struct iapp_data *iapp, u8 *addr)
* FIX: what is correct RW with 802.11? */ * FIX: what is correct RW with 802.11? */
if (send(iapp->packet_sock, &msg, sizeof(msg), 0) < 0) if (send(iapp->packet_sock, &msg, sizeof(msg), 0) < 0)
perror("send[L2 Update]"); wpa_printf(MSG_INFO, "send[L2 Update]: %s", strerror(errno));
} }
@ -276,8 +276,8 @@ static void iapp_process_add_notify(struct iapp_data *iapp,
struct sta_info *sta; struct sta_info *sta;
if (len != sizeof(*add)) { if (len != sizeof(*add)) {
printf("Invalid IAPP-ADD packet length %d (expected %lu)\n", wpa_printf(MSG_INFO, "Invalid IAPP-ADD packet length %d (expected %lu)",
len, (unsigned long) sizeof(*add)); len, (unsigned long) sizeof(*add));
return; return;
} }
@ -326,7 +326,8 @@ static void iapp_receive_udp(int sock, void *eloop_ctx, void *sock_ctx)
len = recvfrom(iapp->udp_sock, buf, sizeof(buf), 0, len = recvfrom(iapp->udp_sock, buf, sizeof(buf), 0,
(struct sockaddr *) &from, &fromlen); (struct sockaddr *) &from, &fromlen);
if (len < 0) { if (len < 0) {
perror("recvfrom"); wpa_printf(MSG_INFO, "iapp_receive_udp - recvfrom: %s",
strerror(errno));
return; return;
} }
@ -350,17 +351,18 @@ static void iapp_receive_udp(int sock, void *eloop_ctx, void *sock_ctx)
hdr->version, hdr->command, hdr->version, hdr->command,
be_to_host16(hdr->identifier), hlen); be_to_host16(hdr->identifier), hlen);
if (hdr->version != IAPP_VERSION) { if (hdr->version != IAPP_VERSION) {
printf("Dropping IAPP frame with unknown version %d\n", wpa_printf(MSG_INFO, "Dropping IAPP frame with unknown version %d",
hdr->version); hdr->version);
return; return;
} }
if (hlen > len) { if (hlen > len) {
printf("Underflow IAPP frame (hlen=%d len=%d)\n", hlen, len); wpa_printf(MSG_INFO, "Underflow IAPP frame (hlen=%d len=%d)",
hlen, len);
return; return;
} }
if (hlen < len) { if (hlen < len) {
printf("Ignoring %d extra bytes from IAPP frame\n", wpa_printf(MSG_INFO, "Ignoring %d extra bytes from IAPP frame",
len - hlen); len - hlen);
len = hlen; len = hlen;
} }
@ -376,7 +378,7 @@ static void iapp_receive_udp(int sock, void *eloop_ctx, void *sock_ctx)
/* TODO: process */ /* TODO: process */
break; break;
default: default:
printf("Unknown IAPP command %d\n", hdr->command); wpa_printf(MSG_INFO, "Unknown IAPP command %d", hdr->command);
break; break;
} }
} }
@ -403,7 +405,8 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
iapp->udp_sock = socket(PF_INET, SOCK_DGRAM, 0); iapp->udp_sock = socket(PF_INET, SOCK_DGRAM, 0);
if (iapp->udp_sock < 0) { if (iapp->udp_sock < 0) {
perror("socket[PF_INET,SOCK_DGRAM]"); wpa_printf(MSG_INFO, "iapp_init - socket[PF_INET,SOCK_DGRAM]: %s",
strerror(errno));
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
@ -411,35 +414,38 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
os_memset(&ifr, 0, sizeof(ifr)); os_memset(&ifr, 0, sizeof(ifr));
os_strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); os_strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
if (ioctl(iapp->udp_sock, SIOCGIFINDEX, &ifr) != 0) { if (ioctl(iapp->udp_sock, SIOCGIFINDEX, &ifr) != 0) {
perror("ioctl(SIOCGIFINDEX)"); wpa_printf(MSG_INFO, "iapp_init - ioctl(SIOCGIFINDEX): %s",
strerror(errno));
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
ifindex = ifr.ifr_ifindex; ifindex = ifr.ifr_ifindex;
if (ioctl(iapp->udp_sock, SIOCGIFADDR, &ifr) != 0) { if (ioctl(iapp->udp_sock, SIOCGIFADDR, &ifr) != 0) {
perror("ioctl(SIOCGIFADDR)"); wpa_printf(MSG_INFO, "iapp_init - ioctl(SIOCGIFADDR): %s",
strerror(errno));
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
paddr = (struct sockaddr_in *) &ifr.ifr_addr; paddr = (struct sockaddr_in *) &ifr.ifr_addr;
if (paddr->sin_family != AF_INET) { if (paddr->sin_family != AF_INET) {
printf("Invalid address family %i (SIOCGIFADDR)\n", wpa_printf(MSG_INFO, "IAPP: Invalid address family %i (SIOCGIFADDR)",
paddr->sin_family); paddr->sin_family);
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
iapp->own.s_addr = paddr->sin_addr.s_addr; iapp->own.s_addr = paddr->sin_addr.s_addr;
if (ioctl(iapp->udp_sock, SIOCGIFBRDADDR, &ifr) != 0) { if (ioctl(iapp->udp_sock, SIOCGIFBRDADDR, &ifr) != 0) {
perror("ioctl(SIOCGIFBRDADDR)"); wpa_printf(MSG_INFO, "iapp_init - ioctl(SIOCGIFBRDADDR): %s",
strerror(errno));
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
paddr = (struct sockaddr_in *) &ifr.ifr_addr; paddr = (struct sockaddr_in *) &ifr.ifr_addr;
if (paddr->sin_family != AF_INET) { if (paddr->sin_family != AF_INET) {
printf("Invalid address family %i (SIOCGIFBRDADDR)\n", wpa_printf(MSG_INFO, "Invalid address family %i (SIOCGIFBRDADDR)",
paddr->sin_family); paddr->sin_family);
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
@ -450,7 +456,8 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
uaddr.sin_port = htons(IAPP_UDP_PORT); uaddr.sin_port = htons(IAPP_UDP_PORT);
if (bind(iapp->udp_sock, (struct sockaddr *) &uaddr, if (bind(iapp->udp_sock, (struct sockaddr *) &uaddr,
sizeof(uaddr)) < 0) { sizeof(uaddr)) < 0) {
perror("bind[UDP]"); wpa_printf(MSG_INFO, "iapp_init - bind[UDP]: %s",
strerror(errno));
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
@ -461,14 +468,16 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
mreq.imr_ifindex = 0; mreq.imr_ifindex = 0;
if (setsockopt(iapp->udp_sock, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, if (setsockopt(iapp->udp_sock, SOL_IP, IP_ADD_MEMBERSHIP, &mreq,
sizeof(mreq)) < 0) { sizeof(mreq)) < 0) {
perror("setsockopt[UDP,IP_ADD_MEMBERSHIP]"); wpa_printf(MSG_INFO, "iapp_init - setsockopt[UDP,IP_ADD_MEMBERSHIP]: %s",
strerror(errno));
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
iapp->packet_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); iapp->packet_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (iapp->packet_sock < 0) { if (iapp->packet_sock < 0) {
perror("socket[PF_PACKET,SOCK_RAW]"); wpa_printf(MSG_INFO, "iapp_init - socket[PF_PACKET,SOCK_RAW]: %s",
strerror(errno));
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
@ -478,19 +487,20 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
addr.sll_ifindex = ifindex; addr.sll_ifindex = ifindex;
if (bind(iapp->packet_sock, (struct sockaddr *) &addr, if (bind(iapp->packet_sock, (struct sockaddr *) &addr,
sizeof(addr)) < 0) { sizeof(addr)) < 0) {
perror("bind[PACKET]"); wpa_printf(MSG_INFO, "iapp_init - bind[PACKET]: %s",
strerror(errno));
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
if (eloop_register_read_sock(iapp->udp_sock, iapp_receive_udp, if (eloop_register_read_sock(iapp->udp_sock, iapp_receive_udp,
iapp, NULL)) { iapp, NULL)) {
printf("Could not register read socket for IAPP.\n"); wpa_printf(MSG_INFO, "Could not register read socket for IAPP");
iapp_deinit(iapp); iapp_deinit(iapp);
return NULL; return NULL;
} }
printf("IEEE 802.11F (IAPP) using interface %s\n", iface); wpa_printf(MSG_INFO, "IEEE 802.11F (IAPP) using interface %s", iface);
/* TODO: For levels 2 and 3: send RADIUS Initiate-Request, receive /* TODO: For levels 2 and 3: send RADIUS Initiate-Request, receive
* RADIUS Initiate-Accept or Initiate-Reject. IAPP port should actually * RADIUS Initiate-Accept or Initiate-Reject. IAPP port should actually
@ -515,7 +525,8 @@ void iapp_deinit(struct iapp_data *iapp)
mreq.imr_ifindex = 0; mreq.imr_ifindex = 0;
if (setsockopt(iapp->udp_sock, SOL_IP, IP_DROP_MEMBERSHIP, if (setsockopt(iapp->udp_sock, SOL_IP, IP_DROP_MEMBERSHIP,
&mreq, sizeof(mreq)) < 0) { &mreq, sizeof(mreq)) < 0) {
perror("setsockopt[UDP,IP_DEL_MEMBERSHIP]"); wpa_printf(MSG_INFO, "iapp_deinit - setsockopt[UDP,IP_DEL_MEMBERSHIP]: %s",
strerror(errno));
} }
eloop_unregister_read_sock(iapp->udp_sock); eloop_unregister_read_sock(iapp->udp_sock);

View file

@ -286,7 +286,7 @@ static void send_auth_reply(struct hostapd_data *hapd,
MAC2STR(dst), auth_alg, auth_transaction, MAC2STR(dst), auth_alg, auth_transaction,
resp, (unsigned long) ies_len); resp, (unsigned long) ies_len);
if (hostapd_drv_send_mlme(hapd, reply, rlen, 0) < 0) if (hostapd_drv_send_mlme(hapd, reply, rlen, 0) < 0)
perror("send_auth_reply: send"); wpa_printf(MSG_INFO, "send_auth_reply: send");
os_free(buf); os_free(buf);
} }
@ -552,8 +552,8 @@ static void handle_auth(struct hostapd_data *hapd,
char *radius_cui = NULL; char *radius_cui = NULL;
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) { if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
printf("handle_auth - too short payload (len=%lu)\n", wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
(unsigned long) len); (unsigned long) len);
return; return;
} }
@ -601,23 +601,23 @@ static void handle_auth(struct hostapd_data *hapd,
#endif /* CONFIG_SAE */ #endif /* CONFIG_SAE */
((hapd->conf->auth_algs & WPA_AUTH_ALG_SHARED) && ((hapd->conf->auth_algs & WPA_AUTH_ALG_SHARED) &&
auth_alg == WLAN_AUTH_SHARED_KEY))) { auth_alg == WLAN_AUTH_SHARED_KEY))) {
printf("Unsupported authentication algorithm (%d)\n", wpa_printf(MSG_INFO, "Unsupported authentication algorithm (%d)",
auth_alg); auth_alg);
resp = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; resp = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
goto fail; goto fail;
} }
if (!(auth_transaction == 1 || auth_alg == WLAN_AUTH_SAE || if (!(auth_transaction == 1 || auth_alg == WLAN_AUTH_SAE ||
(auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 3))) { (auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 3))) {
printf("Unknown authentication transaction number (%d)\n", wpa_printf(MSG_INFO, "Unknown authentication transaction number (%d)",
auth_transaction); auth_transaction);
resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION; resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
goto fail; goto fail;
} }
if (os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) { if (os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
printf("Station " MACSTR " not allowed to authenticate.\n", wpa_printf(MSG_INFO, "Station " MACSTR " not allowed to authenticate",
MAC2STR(mgmt->sa)); MAC2STR(mgmt->sa));
resp = WLAN_STATUS_UNSPECIFIED_FAILURE; resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
goto fail; goto fail;
} }
@ -628,8 +628,8 @@ static void handle_auth(struct hostapd_data *hapd,
&psk, &identity, &radius_cui); &psk, &identity, &radius_cui);
if (res == HOSTAPD_ACL_REJECT) { if (res == HOSTAPD_ACL_REJECT) {
printf("Station " MACSTR " not allowed to authenticate.\n", wpa_printf(MSG_INFO, "Station " MACSTR " not allowed to authenticate",
MAC2STR(mgmt->sa)); MAC2STR(mgmt->sa));
resp = WLAN_STATUS_UNSPECIFIED_FAILURE; resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
goto fail; goto fail;
} }
@ -1255,8 +1255,8 @@ static void handle_assoc(struct hostapd_data *hapd,
if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) : if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
sizeof(mgmt->u.assoc_req))) { sizeof(mgmt->u.assoc_req))) {
printf("handle_assoc(reassoc=%d) - too short payload (len=%lu)" wpa_printf(MSG_INFO, "handle_assoc(reassoc=%d) - too short payload (len=%lu)",
"\n", reassoc, (unsigned long) len); reassoc, (unsigned long) len);
return; return;
} }
@ -1442,8 +1442,8 @@ static void handle_disassoc(struct hostapd_data *hapd,
struct sta_info *sta; struct sta_info *sta;
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.disassoc)) { if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.disassoc)) {
printf("handle_disassoc - too short payload (len=%lu)\n", wpa_printf(MSG_INFO, "handle_disassoc - too short payload (len=%lu)",
(unsigned long) len); (unsigned long) len);
return; return;
} }
@ -1453,8 +1453,8 @@ static void handle_disassoc(struct hostapd_data *hapd,
sta = ap_get_sta(hapd, mgmt->sa); sta = ap_get_sta(hapd, mgmt->sa);
if (sta == NULL) { if (sta == NULL) {
printf("Station " MACSTR " trying to disassociate, but it " wpa_printf(MSG_INFO, "Station " MACSTR " trying to disassociate, but it is not associated",
"is not associated.\n", MAC2STR(mgmt->sa)); MAC2STR(mgmt->sa));
return; return;
} }
@ -1528,8 +1528,8 @@ static void handle_beacon(struct hostapd_data *hapd,
struct ieee802_11_elems elems; struct ieee802_11_elems elems;
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.beacon)) { if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.beacon)) {
printf("handle_beacon - too short payload (len=%lu)\n", wpa_printf(MSG_INFO, "handle_beacon - too short payload (len=%lu)",
(unsigned long) len); (unsigned long) len);
return; return;
} }
@ -1749,8 +1749,8 @@ void ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
stype == WLAN_FC_STYPE_ACTION) && stype == WLAN_FC_STYPE_ACTION) &&
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) { os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) {
printf("MGMT: BSSID=" MACSTR " not our address\n", wpa_printf(MSG_INFO, "MGMT: BSSID=" MACSTR " not our address",
MAC2STR(mgmt->bssid)); MAC2STR(mgmt->bssid));
return; return;
} }
@ -1817,8 +1817,8 @@ static void handle_auth_cb(struct hostapd_data *hapd,
} }
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) { if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
printf("handle_auth_cb - too short payload (len=%lu)\n", wpa_printf(MSG_INFO, "handle_auth_cb - too short payload (len=%lu)",
(unsigned long) len); (unsigned long) len);
return; return;
} }
@ -1828,8 +1828,8 @@ static void handle_auth_cb(struct hostapd_data *hapd,
sta = ap_get_sta(hapd, mgmt->da); sta = ap_get_sta(hapd, mgmt->da);
if (!sta) { if (!sta) {
printf("handle_auth_cb: STA " MACSTR " not found\n", wpa_printf(MSG_INFO, "handle_auth_cb: STA " MACSTR " not found",
MAC2STR(mgmt->da)); MAC2STR(mgmt->da));
return; return;
} }
@ -1879,15 +1879,15 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) : if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) :
sizeof(mgmt->u.assoc_resp))) { sizeof(mgmt->u.assoc_resp))) {
printf("handle_assoc_cb(reassoc=%d) - too short payload " wpa_printf(MSG_INFO, "handle_assoc_cb(reassoc=%d) - too short payload (len=%lu)",
"(len=%lu)\n", reassoc, (unsigned long) len); reassoc, (unsigned long) len);
return; return;
} }
sta = ap_get_sta(hapd, mgmt->da); sta = ap_get_sta(hapd, mgmt->da);
if (!sta) { if (!sta) {
printf("handle_assoc_cb: STA " MACSTR " not found\n", wpa_printf(MSG_INFO, "handle_assoc_cb: STA " MACSTR " not found",
MAC2STR(mgmt->da)); MAC2STR(mgmt->da));
return; return;
} }
@ -2103,7 +2103,7 @@ void ieee802_11_mgmt_cb(struct hostapd_data *hapd, const u8 *buf, size_t len,
wpa_printf(MSG_DEBUG, "mgmt::action cb"); wpa_printf(MSG_DEBUG, "mgmt::action cb");
break; break;
default: default:
printf("unknown mgmt cb frame subtype %d\n", stype); wpa_printf(MSG_INFO, "unknown mgmt cb frame subtype %d", stype);
break; break;
} }
} }

View file

@ -69,7 +69,7 @@ void ieee802_11_send_sa_query_req(struct hostapd_data *hapd,
WLAN_SA_QUERY_TR_ID_LEN); WLAN_SA_QUERY_TR_ID_LEN);
end = mgmt.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN; end = mgmt.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
if (hostapd_drv_send_mlme(hapd, &mgmt, end - (u8 *) &mgmt, 0) < 0) if (hostapd_drv_send_mlme(hapd, &mgmt, end - (u8 *) &mgmt, 0) < 0)
perror("ieee802_11_send_sa_query_req: send"); wpa_printf(MSG_INFO, "ieee802_11_send_sa_query_req: send failed");
} }
@ -107,7 +107,7 @@ static void ieee802_11_send_sa_query_resp(struct hostapd_data *hapd,
WLAN_SA_QUERY_TR_ID_LEN); WLAN_SA_QUERY_TR_ID_LEN);
end = resp.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN; end = resp.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
if (hostapd_drv_send_mlme(hapd, &resp, end - (u8 *) &resp, 0) < 0) if (hostapd_drv_send_mlme(hapd, &resp, end - (u8 *) &resp, 0) < 0)
perror("ieee80211_mgmt_sa_query_request: send"); wpa_printf(MSG_INFO, "ieee80211_mgmt_sa_query_request: send failed");
} }

View file

@ -453,7 +453,7 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
msg = radius_msg_new(RADIUS_CODE_ACCESS_REQUEST, msg = radius_msg_new(RADIUS_CODE_ACCESS_REQUEST,
sm->radius_identifier); sm->radius_identifier);
if (msg == NULL) { if (msg == NULL) {
printf("Could not create net RADIUS packet\n"); wpa_printf(MSG_INFO, "Could not create new RADIUS packet");
return; return;
} }
@ -462,7 +462,7 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
if (sm->identity && if (sm->identity &&
!radius_msg_add_attr(msg, RADIUS_ATTR_USER_NAME, !radius_msg_add_attr(msg, RADIUS_ATTR_USER_NAME,
sm->identity, sm->identity_len)) { sm->identity, sm->identity_len)) {
printf("Could not add User-Name\n"); wpa_printf(MSG_INFO, "Could not add User-Name");
goto fail; goto fail;
} }
@ -476,12 +476,12 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
if (!hostapd_config_get_radius_attr(hapd->conf->radius_auth_req_attr, if (!hostapd_config_get_radius_attr(hapd->conf->radius_auth_req_attr,
RADIUS_ATTR_FRAMED_MTU) && RADIUS_ATTR_FRAMED_MTU) &&
!radius_msg_add_attr_int32(msg, RADIUS_ATTR_FRAMED_MTU, 1400)) { !radius_msg_add_attr_int32(msg, RADIUS_ATTR_FRAMED_MTU, 1400)) {
printf("Could not add Framed-MTU\n"); wpa_printf(MSG_INFO, "Could not add Framed-MTU");
goto fail; goto fail;
} }
if (eap && !radius_msg_add_eap(msg, eap, len)) { if (eap && !radius_msg_add_eap(msg, eap, len)) {
printf("Could not add EAP-Message\n"); wpa_printf(MSG_INFO, "Could not add EAP-Message");
goto fail; goto fail;
} }
@ -493,8 +493,7 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
int res = radius_msg_copy_attr(msg, sm->last_recv_radius, int res = radius_msg_copy_attr(msg, sm->last_recv_radius,
RADIUS_ATTR_STATE); RADIUS_ATTR_STATE);
if (res < 0) { if (res < 0) {
printf("Could not copy State attribute from previous " wpa_printf(MSG_INFO, "Could not copy State attribute from previous Access-Challenge");
"Access-Challenge\n");
goto fail; goto fail;
} }
if (res > 0) { if (res > 0) {
@ -544,7 +543,7 @@ static void handle_eap_response(struct hostapd_data *hapd,
data = (u8 *) (eap + 1); data = (u8 *) (eap + 1);
if (len < sizeof(*eap) + 1) { if (len < sizeof(*eap) + 1) {
printf("handle_eap_response: too short response data\n"); wpa_printf(MSG_INFO, "handle_eap_response: too short response data");
return; return;
} }
@ -572,7 +571,7 @@ static void handle_eap(struct hostapd_data *hapd, struct sta_info *sta,
u16 eap_len; u16 eap_len;
if (len < sizeof(*eap)) { if (len < sizeof(*eap)) {
printf(" too short EAP packet\n"); wpa_printf(MSG_INFO, " too short EAP packet");
return; return;
} }
@ -665,7 +664,7 @@ void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf,
} }
if (len < sizeof(*hdr)) { if (len < sizeof(*hdr)) {
printf(" too short IEEE 802.1X packet\n"); wpa_printf(MSG_INFO, " too short IEEE 802.1X packet");
return; return;
} }
@ -675,7 +674,7 @@ void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf,
hdr->version, hdr->type, datalen); hdr->version, hdr->type, datalen);
if (len - sizeof(*hdr) < datalen) { if (len - sizeof(*hdr) < datalen) {
printf(" frame too short for this IEEE 802.1X packet\n"); wpa_printf(MSG_INFO, " frame too short for this IEEE 802.1X packet");
if (sta->eapol_sm) if (sta->eapol_sm)
sta->eapol_sm->dot1xAuthEapLengthErrorFramesRx++; sta->eapol_sm->dot1xAuthEapLengthErrorFramesRx++;
return; return;
@ -1277,15 +1276,14 @@ ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
"EAP-Message"); "EAP-Message");
} else if (radius_msg_verify(msg, shared_secret, shared_secret_len, } else if (radius_msg_verify(msg, shared_secret, shared_secret_len,
req, 1)) { req, 1)) {
printf("Incoming RADIUS packet did not have correct " wpa_printf(MSG_INFO, "Incoming RADIUS packet did not have correct Message-Authenticator - dropped");
"Message-Authenticator - dropped\n");
return RADIUS_RX_INVALID_AUTHENTICATOR; return RADIUS_RX_INVALID_AUTHENTICATOR;
} }
if (hdr->code != RADIUS_CODE_ACCESS_ACCEPT && if (hdr->code != RADIUS_CODE_ACCESS_ACCEPT &&
hdr->code != RADIUS_CODE_ACCESS_REJECT && hdr->code != RADIUS_CODE_ACCESS_REJECT &&
hdr->code != RADIUS_CODE_ACCESS_CHALLENGE) { hdr->code != RADIUS_CODE_ACCESS_CHALLENGE) {
printf("Unknown RADIUS message code\n"); wpa_printf(MSG_INFO, "Unknown RADIUS message code");
return RADIUS_RX_UNKNOWN; return RADIUS_RX_UNKNOWN;
} }
@ -1449,7 +1447,7 @@ static int ieee802_1x_rekey_broadcast(struct hostapd_data *hapd)
if (eapol->default_wep_key == NULL || if (eapol->default_wep_key == NULL ||
random_get_bytes(eapol->default_wep_key, random_get_bytes(eapol->default_wep_key,
hapd->conf->default_wep_key_len)) { hapd->conf->default_wep_key_len)) {
printf("Could not generate random WEP key.\n"); wpa_printf(MSG_INFO, "Could not generate random WEP key");
os_free(eapol->default_wep_key); os_free(eapol->default_wep_key);
eapol->default_wep_key = NULL; eapol->default_wep_key = NULL;
return -1; return -1;

View file

@ -157,7 +157,7 @@ static void wmm_send_action(struct hostapd_data *hapd, const u8 *addr,
len = ((u8 *) (t + 1)) - buf; len = ((u8 *) (t + 1)) - buf;
if (hostapd_drv_send_mlme(hapd, m, len, 0) < 0) if (hostapd_drv_send_mlme(hapd, m, len, 0) < 0)
perror("wmm_send_action: send"); wpa_printf(MSG_INFO, "wmm_send_action: send failed");
} }

View file

@ -630,7 +630,7 @@ static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
data->sock = socket(PF_UNIX, SOCK_DGRAM, 0); data->sock = socket(PF_UNIX, SOCK_DGRAM, 0);
if (data->sock < 0) { if (data->sock < 0) {
perror("socket(eap_sim_db)"); wpa_printf(MSG_INFO, "socket(eap_sim_db): %s", strerror(errno));
return -1; return -1;
} }
@ -641,7 +641,7 @@ static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
os_free(data->local_sock); os_free(data->local_sock);
data->local_sock = os_strdup(addr.sun_path); data->local_sock = os_strdup(addr.sun_path);
if (bind(data->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (bind(data->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("bind(eap_sim_db)"); wpa_printf(MSG_INFO, "bind(eap_sim_db): %s", strerror(errno));
close(data->sock); close(data->sock);
data->sock = -1; data->sock = -1;
return -1; return -1;
@ -651,7 +651,8 @@ static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
os_strlcpy(addr.sun_path, data->fname + 5, sizeof(addr.sun_path)); os_strlcpy(addr.sun_path, data->fname + 5, sizeof(addr.sun_path));
if (connect(data->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (connect(data->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("connect(eap_sim_db)"); wpa_printf(MSG_INFO, "connect(eap_sim_db): %s",
strerror(errno));
wpa_hexdump_ascii(MSG_INFO, "HLR/AuC GW socket", wpa_hexdump_ascii(MSG_INFO, "HLR/AuC GW socket",
(u8 *) addr.sun_path, (u8 *) addr.sun_path,
os_strlen(addr.sun_path)); os_strlen(addr.sun_path));
@ -804,7 +805,8 @@ static int eap_sim_db_send(struct eap_sim_db_data *data, const char *msg,
if (send(data->sock, msg, len, 0) < 0) { if (send(data->sock, msg, len, 0) < 0) {
_errno = errno; _errno = errno;
perror("send[EAP-SIM DB UNIX]"); wpa_printf(MSG_INFO, "send[EAP-SIM DB UNIX]: %s",
strerror(errno));
} }
if (_errno == ENOTCONN || _errno == EDESTADDRREQ || _errno == EINVAL || if (_errno == ENOTCONN || _errno == EDESTADDRREQ || _errno == EINVAL ||
@ -816,7 +818,8 @@ static int eap_sim_db_send(struct eap_sim_db_data *data, const char *msg,
wpa_printf(MSG_DEBUG, "EAP-SIM DB: Reconnected to the " wpa_printf(MSG_DEBUG, "EAP-SIM DB: Reconnected to the "
"external server"); "external server");
if (send(data->sock, msg, len, 0) < 0) { if (send(data->sock, msg, len, 0) < 0) {
perror("send[EAP-SIM DB UNIX]"); wpa_printf(MSG_INFO, "send[EAP-SIM DB UNIX]: %s",
strerror(errno));
return -1; return -1;
} }
} }

View file

@ -300,7 +300,7 @@ static void radius_client_handle_send_error(struct radius_client_data *radius,
{ {
#ifndef CONFIG_NATIVE_WINDOWS #ifndef CONFIG_NATIVE_WINDOWS
int _errno = errno; int _errno = errno;
perror("send[RADIUS]"); wpa_printf(MSG_INFO, "send[RADIUS]: %s", strerror(errno));
if (_errno == ENOTCONN || _errno == EDESTADDRREQ || _errno == EINVAL || if (_errno == ENOTCONN || _errno == EDESTADDRREQ || _errno == EINVAL ||
_errno == EBADF) { _errno == EBADF) {
hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS,
@ -361,8 +361,7 @@ static int radius_client_retransmit(struct radius_client_data *radius,
if (entry->next_wait > RADIUS_CLIENT_MAX_WAIT) if (entry->next_wait > RADIUS_CLIENT_MAX_WAIT)
entry->next_wait = RADIUS_CLIENT_MAX_WAIT; entry->next_wait = RADIUS_CLIENT_MAX_WAIT;
if (entry->attempts >= RADIUS_CLIENT_MAX_RETRIES) { if (entry->attempts >= RADIUS_CLIENT_MAX_RETRIES) {
printf("Removing un-ACKed RADIUS message due to too many " wpa_printf(MSG_INFO, "RADIUS: Removing un-ACKed message due to too many failed retransmit attempts");
"failed retransmit attempts\n");
return 1; return 1;
} }
@ -526,7 +525,7 @@ static void radius_client_list_add(struct radius_client_data *radius,
entry = os_zalloc(sizeof(*entry)); entry = os_zalloc(sizeof(*entry));
if (entry == NULL) { if (entry == NULL) {
printf("Failed to add RADIUS packet into retransmit list\n"); wpa_printf(MSG_INFO, "RADIUS: Failed to add packet into retransmit list");
radius_msg_free(msg); radius_msg_free(msg);
return; return;
} }
@ -547,8 +546,7 @@ static void radius_client_list_add(struct radius_client_data *radius,
radius_client_update_timeout(radius); radius_client_update_timeout(radius);
if (radius->num_msgs >= RADIUS_CLIENT_MAX_ENTRIES) { if (radius->num_msgs >= RADIUS_CLIENT_MAX_ENTRIES) {
printf("Removing the oldest un-ACKed RADIUS packet due to " wpa_printf(MSG_INFO, "RADIUS: Removing the oldest un-ACKed packet due to retransmit list limits");
"retransmit list limits.\n");
prev = NULL; prev = NULL;
while (entry->next) { while (entry->next) {
prev = entry; prev = entry;
@ -710,21 +708,20 @@ static void radius_client_receive(int sock, void *eloop_ctx, void *sock_ctx)
len = recv(sock, buf, sizeof(buf), MSG_DONTWAIT); len = recv(sock, buf, sizeof(buf), MSG_DONTWAIT);
if (len < 0) { if (len < 0) {
perror("recv[RADIUS]"); wpa_printf(MSG_INFO, "recv[RADIUS]: %s", strerror(errno));
return; return;
} }
hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS, hostapd_logger(radius->ctx, NULL, HOSTAPD_MODULE_RADIUS,
HOSTAPD_LEVEL_DEBUG, "Received %d bytes from RADIUS " HOSTAPD_LEVEL_DEBUG, "Received %d bytes from RADIUS "
"server", len); "server", len);
if (len == sizeof(buf)) { if (len == sizeof(buf)) {
printf("Possibly too long UDP frame for our buffer - " wpa_printf(MSG_INFO, "RADIUS: Possibly too long UDP frame for our buffer - dropping it");
"dropping it\n");
return; return;
} }
msg = radius_msg_parse(buf, len); msg = radius_msg_parse(buf, len);
if (msg == NULL) { if (msg == NULL) {
printf("Parsing incoming RADIUS frame failed\n"); wpa_printf(MSG_INFO, "RADIUS: Parsing incoming frame failed");
rconf->malformed_responses++; rconf->malformed_responses++;
return; return;
} }
@ -1041,13 +1038,14 @@ radius_change_server(struct radius_client_data *radius,
} }
if (bind(sel_sock, cl_addr, claddrlen) < 0) { if (bind(sel_sock, cl_addr, claddrlen) < 0) {
perror("bind[radius]"); wpa_printf(MSG_INFO, "bind[radius]: %s",
strerror(errno));
return -1; return -1;
} }
} }
if (connect(sel_sock, addr, addrlen) < 0) { if (connect(sel_sock, addr, addrlen) < 0) {
perror("connect[radius]"); wpa_printf(MSG_INFO, "connect[radius]: %s", strerror(errno));
return -1; return -1;
} }
@ -1123,8 +1121,8 @@ static int radius_client_disable_pmtu_discovery(int s)
r = setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER, &action, r = setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER, &action,
sizeof(action)); sizeof(action));
if (r == -1) if (r == -1)
wpa_printf(MSG_ERROR, "Failed to set IP_MTU_DISCOVER: " wpa_printf(MSG_ERROR, "RADIUS: Failed to set IP_MTU_DISCOVER: %s",
"%s", strerror(errno)); strerror(errno));
#endif #endif
return r; return r;
} }
@ -1137,7 +1135,8 @@ static int radius_client_init_auth(struct radius_client_data *radius)
radius->auth_serv_sock = socket(PF_INET, SOCK_DGRAM, 0); radius->auth_serv_sock = socket(PF_INET, SOCK_DGRAM, 0);
if (radius->auth_serv_sock < 0) if (radius->auth_serv_sock < 0)
perror("socket[PF_INET,SOCK_DGRAM]"); wpa_printf(MSG_INFO, "RADIUS: socket[PF_INET,SOCK_DGRAM]: %s",
strerror(errno));
else { else {
radius_client_disable_pmtu_discovery(radius->auth_serv_sock); radius_client_disable_pmtu_discovery(radius->auth_serv_sock);
ok++; ok++;
@ -1146,7 +1145,8 @@ static int radius_client_init_auth(struct radius_client_data *radius)
#ifdef CONFIG_IPV6 #ifdef CONFIG_IPV6
radius->auth_serv_sock6 = socket(PF_INET6, SOCK_DGRAM, 0); radius->auth_serv_sock6 = socket(PF_INET6, SOCK_DGRAM, 0);
if (radius->auth_serv_sock6 < 0) if (radius->auth_serv_sock6 < 0)
perror("socket[PF_INET6,SOCK_DGRAM]"); wpa_printf(MSG_INFO, "RADIUS: socket[PF_INET6,SOCK_DGRAM]: %s",
strerror(errno));
else else
ok++; ok++;
#endif /* CONFIG_IPV6 */ #endif /* CONFIG_IPV6 */
@ -1162,8 +1162,7 @@ static int radius_client_init_auth(struct radius_client_data *radius)
eloop_register_read_sock(radius->auth_serv_sock, eloop_register_read_sock(radius->auth_serv_sock,
radius_client_receive, radius, radius_client_receive, radius,
(void *) RADIUS_AUTH)) { (void *) RADIUS_AUTH)) {
printf("Could not register read socket for authentication " wpa_printf(MSG_INFO, "RADIUS: Could not register read socket for authentication server");
"server\n");
return -1; return -1;
} }
@ -1172,8 +1171,7 @@ static int radius_client_init_auth(struct radius_client_data *radius)
eloop_register_read_sock(radius->auth_serv_sock6, eloop_register_read_sock(radius->auth_serv_sock6,
radius_client_receive, radius, radius_client_receive, radius,
(void *) RADIUS_AUTH)) { (void *) RADIUS_AUTH)) {
printf("Could not register read socket for authentication " wpa_printf(MSG_INFO, "RADIUS: Could not register read socket for authentication server");
"server\n");
return -1; return -1;
} }
#endif /* CONFIG_IPV6 */ #endif /* CONFIG_IPV6 */
@ -1189,7 +1187,8 @@ static int radius_client_init_acct(struct radius_client_data *radius)
radius->acct_serv_sock = socket(PF_INET, SOCK_DGRAM, 0); radius->acct_serv_sock = socket(PF_INET, SOCK_DGRAM, 0);
if (radius->acct_serv_sock < 0) if (radius->acct_serv_sock < 0)
perror("socket[PF_INET,SOCK_DGRAM]"); wpa_printf(MSG_INFO, "RADIUS: socket[PF_INET,SOCK_DGRAM]: %s",
strerror(errno));
else { else {
radius_client_disable_pmtu_discovery(radius->acct_serv_sock); radius_client_disable_pmtu_discovery(radius->acct_serv_sock);
ok++; ok++;
@ -1198,7 +1197,8 @@ static int radius_client_init_acct(struct radius_client_data *radius)
#ifdef CONFIG_IPV6 #ifdef CONFIG_IPV6
radius->acct_serv_sock6 = socket(PF_INET6, SOCK_DGRAM, 0); radius->acct_serv_sock6 = socket(PF_INET6, SOCK_DGRAM, 0);
if (radius->acct_serv_sock6 < 0) if (radius->acct_serv_sock6 < 0)
perror("socket[PF_INET6,SOCK_DGRAM]"); wpa_printf(MSG_INFO, "RADIUS: socket[PF_INET6,SOCK_DGRAM]: %s",
strerror(errno));
else else
ok++; ok++;
#endif /* CONFIG_IPV6 */ #endif /* CONFIG_IPV6 */
@ -1214,8 +1214,7 @@ static int radius_client_init_acct(struct radius_client_data *radius)
eloop_register_read_sock(radius->acct_serv_sock, eloop_register_read_sock(radius->acct_serv_sock,
radius_client_receive, radius, radius_client_receive, radius,
(void *) RADIUS_ACCT)) { (void *) RADIUS_ACCT)) {
printf("Could not register read socket for accounting " wpa_printf(MSG_INFO, "RADIUS: Could not register read socket for accounting server");
"server\n");
return -1; return -1;
} }
@ -1224,8 +1223,7 @@ static int radius_client_init_acct(struct radius_client_data *radius)
eloop_register_read_sock(radius->acct_serv_sock6, eloop_register_read_sock(radius->acct_serv_sock6,
radius_client_receive, radius, radius_client_receive, radius,
(void *) RADIUS_ACCT)) { (void *) RADIUS_ACCT)) {
printf("Could not register read socket for accounting " wpa_printf(MSG_INFO, "RADIUS: Could not register read socket for accounting server");
"server\n");
return -1; return -1;
} }
#endif /* CONFIG_IPV6 */ #endif /* CONFIG_IPV6 */

View file

@ -1,6 +1,6 @@
/* /*
* RADIUS Dynamic Authorization Server (DAS) (RFC 5176) * RADIUS Dynamic Authorization Server (DAS) (RFC 5176)
* Copyright (c) 2012, Jouni Malinen <j@w1.fi> * Copyright (c) 2012-2013, Jouni Malinen <j@w1.fi>
* *
* This software may be distributed under the terms of the BSD license. * This software may be distributed under the terms of the BSD license.
* See README for more details. * See README for more details.
@ -284,7 +284,7 @@ static int radius_das_open_socket(int port)
s = socket(PF_INET, SOCK_DGRAM, 0); s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0) { if (s < 0) {
perror("socket"); wpa_printf(MSG_INFO, "RADIUS DAS: socket: %s", strerror(errno));
return -1; return -1;
} }
@ -292,7 +292,7 @@ static int radius_das_open_socket(int port)
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("bind"); wpa_printf(MSG_INFO, "RADIUS DAS: bind: %s", strerror(errno));
close(s); close(s);
return -1; return -1;
} }

View file

@ -679,7 +679,7 @@ static int radius_server_reject(struct radius_server_data *data,
buf = radius_msg_get_buf(msg); buf = radius_msg_get_buf(msg);
if (sendto(data->auth_sock, wpabuf_head(buf), wpabuf_len(buf), 0, if (sendto(data->auth_sock, wpabuf_head(buf), wpabuf_len(buf), 0,
(struct sockaddr *) from, sizeof(*from)) < 0) { (struct sockaddr *) from, sizeof(*from)) < 0) {
perror("sendto[RADIUS SRV]"); wpa_printf(MSG_INFO, "sendto[RADIUS SRV]: %s", strerror(errno));
ret = -1; ret = -1;
} }
@ -750,7 +750,8 @@ static int radius_server_request(struct radius_server_data *data,
wpabuf_len(buf), 0, wpabuf_len(buf), 0,
(struct sockaddr *) from, fromlen); (struct sockaddr *) from, fromlen);
if (res < 0) { if (res < 0) {
perror("sendto[RADIUS SRV]"); wpa_printf(MSG_INFO, "sendto[RADIUS SRV]: %s",
strerror(errno));
} }
return 0; return 0;
} }
@ -842,7 +843,8 @@ static int radius_server_request(struct radius_server_data *data,
wpabuf_len(buf), 0, wpabuf_len(buf), 0,
(struct sockaddr *) from, fromlen); (struct sockaddr *) from, fromlen);
if (res < 0) { if (res < 0) {
perror("sendto[RADIUS SRV]"); wpa_printf(MSG_INFO, "sendto[RADIUS SRV]: %s",
strerror(errno));
} }
radius_msg_free(sess->last_reply); radius_msg_free(sess->last_reply);
sess->last_reply = reply; sess->last_reply = reply;
@ -897,7 +899,8 @@ static void radius_server_receive_auth(int sock, void *eloop_ctx,
len = recvfrom(sock, buf, RADIUS_MAX_MSG_LEN, 0, len = recvfrom(sock, buf, RADIUS_MAX_MSG_LEN, 0,
(struct sockaddr *) &from.ss, &fromlen); (struct sockaddr *) &from.ss, &fromlen);
if (len < 0) { if (len < 0) {
perror("recvfrom[radius_server]"); wpa_printf(MSG_INFO, "recvfrom[radius_server]: %s",
strerror(errno));
goto fail; goto fail;
} }
@ -1001,7 +1004,7 @@ static int radius_server_open_socket(int port)
s = socket(PF_INET, SOCK_DGRAM, 0); s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0) { if (s < 0) {
perror("socket"); wpa_printf(MSG_INFO, "RADIUS: socket: %s", strerror(errno));
return -1; return -1;
} }
@ -1011,7 +1014,7 @@ static int radius_server_open_socket(int port)
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("bind"); wpa_printf(MSG_INFO, "RADIUS: bind: %s", strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -1028,7 +1031,8 @@ static int radius_server_open_socket6(int port)
s = socket(PF_INET6, SOCK_DGRAM, 0); s = socket(PF_INET6, SOCK_DGRAM, 0);
if (s < 0) { if (s < 0) {
perror("socket[IPv6]"); wpa_printf(MSG_INFO, "RADIUS: socket[IPv6]: %s",
strerror(errno));
return -1; return -1;
} }
@ -1037,7 +1041,7 @@ static int radius_server_open_socket6(int port)
os_memcpy(&addr.sin6_addr, &in6addr_any, sizeof(in6addr_any)); os_memcpy(&addr.sin6_addr, &in6addr_any, sizeof(in6addr_any));
addr.sin6_port = htons(port); addr.sin6_port = htons(port);
if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("bind"); wpa_printf(MSG_INFO, "RADIUS: bind: %s", strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -1248,8 +1252,7 @@ radius_server_init(struct radius_server_conf *conf)
#ifndef CONFIG_IPV6 #ifndef CONFIG_IPV6
if (conf->ipv6) { if (conf->ipv6) {
fprintf(stderr, "RADIUS server compiled without IPv6 " wpa_printf(MSG_ERROR, "RADIUS server compiled without IPv6 support");
"support.\n");
return NULL; return NULL;
} }
#endif /* CONFIG_IPV6 */ #endif /* CONFIG_IPV6 */
@ -1305,7 +1308,7 @@ radius_server_init(struct radius_server_conf *conf)
data->clients = radius_server_read_clients(conf->client_file, data->clients = radius_server_read_clients(conf->client_file,
conf->ipv6); conf->ipv6);
if (data->clients == NULL) { if (data->clients == NULL) {
printf("No RADIUS clients configured.\n"); wpa_printf(MSG_ERROR, "No RADIUS clients configured");
radius_server_deinit(data); radius_server_deinit(data);
return NULL; return NULL;
} }
@ -1317,8 +1320,7 @@ radius_server_init(struct radius_server_conf *conf)
#endif /* CONFIG_IPV6 */ #endif /* CONFIG_IPV6 */
data->auth_sock = radius_server_open_socket(conf->auth_port); data->auth_sock = radius_server_open_socket(conf->auth_port);
if (data->auth_sock < 0) { if (data->auth_sock < 0) {
printf("Failed to open UDP socket for RADIUS authentication " wpa_printf(MSG_ERROR, "Failed to open UDP socket for RADIUS authentication server");
"server\n");
radius_server_deinit(data); radius_server_deinit(data);
return NULL; return NULL;
} }

View file

@ -753,7 +753,8 @@ void eloop_run(void)
timeout ? timeout_ms : -1); timeout ? timeout_ms : -1);
if (res < 0 && errno != EINTR && errno != 0) { if (res < 0 && errno != EINTR && errno != 0) {
perror("poll"); wpa_printf(MSG_INFO, "eloop: poll: %s",
strerror(errno));
goto out; goto out;
} }
#else /* CONFIG_ELOOP_POLL */ #else /* CONFIG_ELOOP_POLL */
@ -763,7 +764,8 @@ void eloop_run(void)
res = select(eloop.max_sock + 1, rfds, wfds, efds, res = select(eloop.max_sock + 1, rfds, wfds, efds,
timeout ? &_tv : NULL); timeout ? &_tv : NULL);
if (res < 0 && errno != EINTR && errno != 0) { if (res < 0 && errno != EINTR && errno != 0) {
perror("select"); wpa_printf(MSG_INFO, "eloop: select: %s",
strerror(errno));
goto out; goto out;
} }
#endif /* CONFIG_ELOOP_POLL */ #endif /* CONFIG_ELOOP_POLL */