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,
radius_client_get_id(hapd->radius));
if (msg == NULL) {
printf("Could not create net RADIUS packet\n");
wpa_printf(MSG_INFO, "Could not create new RADIUS packet");
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);
if (!radius_msg_add_attr(msg, RADIUS_ATTR_ACCT_SESSION_ID,
(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;
}
} 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,
status_type)) {
printf("Could not add Acct-Status-Type\n");
wpa_printf(MSG_INFO, "Could not add Acct-Status-Type");
goto fail;
}
@ -74,7 +74,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
hapd->conf->ieee802_1x ?
RADIUS_ACCT_AUTHENTIC_RADIUS :
RADIUS_ACCT_AUTHENTIC_LOCAL)) {
printf("Could not add Acct-Authentic\n");
wpa_printf(MSG_INFO, "Could not add Acct-Authentic");
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,
len)) {
printf("Could not add User-Name\n");
wpa_printf(MSG_INFO, "Could not add User-Name");
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,
val, len)) {
printf("Could not add Class\n");
wpa_printf(MSG_INFO, "Could not add Class");
goto fail;
}
}
@ -254,14 +254,14 @@ static void accounting_sta_report(struct hostapd_data *hapd,
stop ? RADIUS_ACCT_STATUS_TYPE_STOP :
RADIUS_ACCT_STATUS_TYPE_INTERIM_UPDATE);
if (!msg) {
printf("Could not create RADIUS Accounting message\n");
wpa_printf(MSG_INFO, "Could not create RADIUS Accounting message");
return;
}
os_get_time(&now);
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_SESSION_TIME,
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;
}
@ -269,19 +269,19 @@ static void accounting_sta_report(struct hostapd_data *hapd,
if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_INPUT_PACKETS,
data.rx_packets)) {
printf("Could not add Acct-Input-Packets\n");
wpa_printf(MSG_INFO, "Could not add Acct-Input-Packets");
goto fail;
}
if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_OUTPUT_PACKETS,
data.tx_packets)) {
printf("Could not add Acct-Output-Packets\n");
wpa_printf(MSG_INFO, "Could not add Acct-Output-Packets");
goto fail;
}
if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_INPUT_OCTETS,
data.rx_bytes)) {
printf("Could not add Acct-Input-Octets\n");
wpa_printf(MSG_INFO, "Could not add Acct-Input-Octets");
goto fail;
}
gigawords = sta->acct_input_gigawords;
@ -292,13 +292,13 @@ static void accounting_sta_report(struct hostapd_data *hapd,
!radius_msg_add_attr_int32(
msg, RADIUS_ATTR_ACCT_INPUT_GIGAWORDS,
gigawords)) {
printf("Could not add Acct-Input-Gigawords\n");
wpa_printf(MSG_INFO, "Could not add Acct-Input-Gigawords");
goto fail;
}
if (!radius_msg_add_attr_int32(msg,
RADIUS_ATTR_ACCT_OUTPUT_OCTETS,
data.tx_bytes)) {
printf("Could not add Acct-Output-Octets\n");
wpa_printf(MSG_INFO, "Could not add Acct-Output-Octets");
goto fail;
}
gigawords = sta->acct_output_gigawords;
@ -309,14 +309,14 @@ static void accounting_sta_report(struct hostapd_data *hapd,
!radius_msg_add_attr_int32(
msg, RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS,
gigawords)) {
printf("Could not add Acct-Output-Gigawords\n");
wpa_printf(MSG_INFO, "Could not add Acct-Output-Gigawords");
goto fail;
}
}
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_EVENT_TIMESTAMP,
now.sec)) {
printf("Could not add Event-Timestamp\n");
wpa_printf(MSG_INFO, "Could not add Event-Timestamp");
goto fail;
}
@ -326,7 +326,7 @@ static void accounting_sta_report(struct hostapd_data *hapd,
if (stop && cause &&
!radius_msg_add_attr_int32(msg, RADIUS_ATTR_ACCT_TERMINATE_CAUSE,
cause)) {
printf("Could not add Acct-Terminate-Cause\n");
wpa_printf(MSG_INFO, "Could not add Acct-Terminate-Cause");
goto fail;
}
@ -400,13 +400,12 @@ accounting_receive(struct radius_msg *msg, struct radius_msg *req,
void *data)
{
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;
}
if (radius_msg_verify(msg, shared_secret, shared_secret_len, req, 0)) {
printf("Incoming RADIUS packet did not have correct "
"Authenticator - dropped\n");
wpa_printf(MSG_INFO, "Incoming RADIUS packet did not have correct Authenticator - dropped");
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,
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);
return;
}

View file

@ -540,7 +540,7 @@ void handle_probe_req(struct hostapd_data *hapd,
is_broadcast_ether_addr(mgmt->da));
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);

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);
if (sendto(iapp->udp_sock, buf, (char *) (add + 1) - buf, 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? */
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,7 +276,7 @@ static void iapp_process_add_notify(struct iapp_data *iapp,
struct sta_info *sta;
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));
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,
(struct sockaddr *) &from, &fromlen);
if (len < 0) {
perror("recvfrom");
wpa_printf(MSG_INFO, "iapp_receive_udp - recvfrom: %s",
strerror(errno));
return;
}
@ -350,16 +351,17 @@ static void iapp_receive_udp(int sock, void *eloop_ctx, void *sock_ctx)
hdr->version, hdr->command,
be_to_host16(hdr->identifier), hlen);
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);
return;
}
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;
}
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;
}
@ -376,7 +378,7 @@ static void iapp_receive_udp(int sock, void *eloop_ctx, void *sock_ctx)
/* TODO: process */
break;
default:
printf("Unknown IAPP command %d\n", hdr->command);
wpa_printf(MSG_INFO, "Unknown IAPP command %d", hdr->command);
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);
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);
return NULL;
}
@ -411,20 +414,22 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
os_memset(&ifr, 0, sizeof(ifr));
os_strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
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);
return NULL;
}
ifindex = ifr.ifr_ifindex;
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);
return NULL;
}
paddr = (struct sockaddr_in *) &ifr.ifr_addr;
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);
iapp_deinit(iapp);
return NULL;
@ -432,13 +437,14 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
iapp->own.s_addr = paddr->sin_addr.s_addr;
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);
return NULL;
}
paddr = (struct sockaddr_in *) &ifr.ifr_addr;
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);
iapp_deinit(iapp);
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);
if (bind(iapp->udp_sock, (struct sockaddr *) &uaddr,
sizeof(uaddr)) < 0) {
perror("bind[UDP]");
wpa_printf(MSG_INFO, "iapp_init - bind[UDP]: %s",
strerror(errno));
iapp_deinit(iapp);
return NULL;
}
@ -461,14 +468,16 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
mreq.imr_ifindex = 0;
if (setsockopt(iapp->udp_sock, SOL_IP, IP_ADD_MEMBERSHIP, &mreq,
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);
return NULL;
}
iapp->packet_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
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);
return NULL;
}
@ -478,19 +487,20 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
addr.sll_ifindex = ifindex;
if (bind(iapp->packet_sock, (struct sockaddr *) &addr,
sizeof(addr)) < 0) {
perror("bind[PACKET]");
wpa_printf(MSG_INFO, "iapp_init - bind[PACKET]: %s",
strerror(errno));
iapp_deinit(iapp);
return NULL;
}
if (eloop_register_read_sock(iapp->udp_sock, iapp_receive_udp,
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);
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
* 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;
if (setsockopt(iapp->udp_sock, SOL_IP, IP_DROP_MEMBERSHIP,
&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);

View file

@ -286,7 +286,7 @@ static void send_auth_reply(struct hostapd_data *hapd,
MAC2STR(dst), auth_alg, auth_transaction,
resp, (unsigned long) ies_len);
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);
}
@ -552,7 +552,7 @@ static void handle_auth(struct hostapd_data *hapd,
char *radius_cui = NULL;
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);
return;
}
@ -601,7 +601,7 @@ static void handle_auth(struct hostapd_data *hapd,
#endif /* CONFIG_SAE */
((hapd->conf->auth_algs & WPA_AUTH_ALG_SHARED) &&
auth_alg == WLAN_AUTH_SHARED_KEY))) {
printf("Unsupported authentication algorithm (%d)\n",
wpa_printf(MSG_INFO, "Unsupported authentication algorithm (%d)",
auth_alg);
resp = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
goto fail;
@ -609,14 +609,14 @@ static void handle_auth(struct hostapd_data *hapd,
if (!(auth_transaction == 1 || auth_alg == WLAN_AUTH_SAE ||
(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);
resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;
goto fail;
}
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));
resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
goto fail;
@ -628,7 +628,7 @@ static void handle_auth(struct hostapd_data *hapd,
&psk, &identity, &radius_cui);
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));
resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
goto fail;
@ -1255,8 +1255,8 @@ static void handle_assoc(struct hostapd_data *hapd,
if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
sizeof(mgmt->u.assoc_req))) {
printf("handle_assoc(reassoc=%d) - too short payload (len=%lu)"
"\n", reassoc, (unsigned long) len);
wpa_printf(MSG_INFO, "handle_assoc(reassoc=%d) - too short payload (len=%lu)",
reassoc, (unsigned long) len);
return;
}
@ -1442,7 +1442,7 @@ static void handle_disassoc(struct hostapd_data *hapd,
struct sta_info *sta;
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);
return;
}
@ -1453,8 +1453,8 @@ static void handle_disassoc(struct hostapd_data *hapd,
sta = ap_get_sta(hapd, mgmt->sa);
if (sta == NULL) {
printf("Station " MACSTR " trying to disassociate, but it "
"is not associated.\n", MAC2STR(mgmt->sa));
wpa_printf(MSG_INFO, "Station " MACSTR " trying to disassociate, but it is not associated",
MAC2STR(mgmt->sa));
return;
}
@ -1528,7 +1528,7 @@ static void handle_beacon(struct hostapd_data *hapd,
struct ieee802_11_elems elems;
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);
return;
}
@ -1749,7 +1749,7 @@ void ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
stype == WLAN_FC_STYPE_ACTION) &&
#endif /* CONFIG_P2P */
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));
return;
}
@ -1817,7 +1817,7 @@ static void handle_auth_cb(struct hostapd_data *hapd,
}
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);
return;
}
@ -1828,7 +1828,7 @@ static void handle_auth_cb(struct hostapd_data *hapd,
sta = ap_get_sta(hapd, mgmt->da);
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));
return;
}
@ -1879,14 +1879,14 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_resp) :
sizeof(mgmt->u.assoc_resp))) {
printf("handle_assoc_cb(reassoc=%d) - too short payload "
"(len=%lu)\n", reassoc, (unsigned long) len);
wpa_printf(MSG_INFO, "handle_assoc_cb(reassoc=%d) - too short payload (len=%lu)",
reassoc, (unsigned long) len);
return;
}
sta = ap_get_sta(hapd, mgmt->da);
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));
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");
break;
default:
printf("unknown mgmt cb frame subtype %d\n", stype);
wpa_printf(MSG_INFO, "unknown mgmt cb frame subtype %d", stype);
break;
}
}

View file

@ -69,7 +69,7 @@ void ieee802_11_send_sa_query_req(struct hostapd_data *hapd,
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)
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);
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)
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,
sm->radius_identifier);
if (msg == NULL) {
printf("Could not create net RADIUS packet\n");
wpa_printf(MSG_INFO, "Could not create new RADIUS packet");
return;
}
@ -462,7 +462,7 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
if (sm->identity &&
!radius_msg_add_attr(msg, RADIUS_ATTR_USER_NAME,
sm->identity, sm->identity_len)) {
printf("Could not add User-Name\n");
wpa_printf(MSG_INFO, "Could not add User-Name");
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,
RADIUS_ATTR_FRAMED_MTU) &&
!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;
}
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;
}
@ -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,
RADIUS_ATTR_STATE);
if (res < 0) {
printf("Could not copy State attribute from previous "
"Access-Challenge\n");
wpa_printf(MSG_INFO, "Could not copy State attribute from previous Access-Challenge");
goto fail;
}
if (res > 0) {
@ -544,7 +543,7 @@ static void handle_eap_response(struct hostapd_data *hapd,
data = (u8 *) (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;
}
@ -572,7 +571,7 @@ static void handle_eap(struct hostapd_data *hapd, struct sta_info *sta,
u16 eap_len;
if (len < sizeof(*eap)) {
printf(" too short EAP packet\n");
wpa_printf(MSG_INFO, " too short EAP packet");
return;
}
@ -665,7 +664,7 @@ void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf,
}
if (len < sizeof(*hdr)) {
printf(" too short IEEE 802.1X packet\n");
wpa_printf(MSG_INFO, " too short IEEE 802.1X packet");
return;
}
@ -675,7 +674,7 @@ void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf,
hdr->version, hdr->type, 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)
sta->eapol_sm->dot1xAuthEapLengthErrorFramesRx++;
return;
@ -1277,15 +1276,14 @@ ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
"EAP-Message");
} else if (radius_msg_verify(msg, shared_secret, shared_secret_len,
req, 1)) {
printf("Incoming RADIUS packet did not have correct "
"Message-Authenticator - dropped\n");
wpa_printf(MSG_INFO, "Incoming RADIUS packet did not have correct Message-Authenticator - dropped");
return RADIUS_RX_INVALID_AUTHENTICATOR;
}
if (hdr->code != RADIUS_CODE_ACCESS_ACCEPT &&
hdr->code != RADIUS_CODE_ACCESS_REJECT &&
hdr->code != RADIUS_CODE_ACCESS_CHALLENGE) {
printf("Unknown RADIUS message code\n");
wpa_printf(MSG_INFO, "Unknown RADIUS message code");
return RADIUS_RX_UNKNOWN;
}
@ -1449,7 +1447,7 @@ static int ieee802_1x_rekey_broadcast(struct hostapd_data *hapd)
if (eapol->default_wep_key == NULL ||
random_get_bytes(eapol->default_wep_key,
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);
eapol->default_wep_key = NULL;
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;
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);
if (data->sock < 0) {
perror("socket(eap_sim_db)");
wpa_printf(MSG_INFO, "socket(eap_sim_db): %s", strerror(errno));
return -1;
}
@ -641,7 +641,7 @@ static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
os_free(data->local_sock);
data->local_sock = os_strdup(addr.sun_path);
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);
data->sock = -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;
os_strlcpy(addr.sun_path, data->fname + 5, sizeof(addr.sun_path));
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",
(u8 *) 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) {
_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 ||
@ -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 "
"external server");
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;
}
}

View file

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

View file

@ -1,6 +1,6 @@
/*
* 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.
* See README for more details.
@ -284,7 +284,7 @@ static int radius_das_open_socket(int port)
s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0) {
perror("socket");
wpa_printf(MSG_INFO, "RADIUS DAS: socket: %s", strerror(errno));
return -1;
}
@ -292,7 +292,7 @@ static int radius_das_open_socket(int port)
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("bind");
wpa_printf(MSG_INFO, "RADIUS DAS: bind: %s", strerror(errno));
close(s);
return -1;
}

View file

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

View file

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