Clean up debug prints to use wpa_printf()

This converts most of the remaining perror() and printf() calls from
hostapd and wpa_supplicant to use wpa_printf().

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-12-24 12:43:35 +02:00
parent cad9b88be2
commit a193231dfb
22 changed files with 315 additions and 220 deletions

View File

@ -1809,7 +1809,8 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
res = recvfrom(sock, buf, sizeof(buf) - 1, 0, res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
(struct sockaddr *) &from, &fromlen); (struct sockaddr *) &from, &fromlen);
if (res < 0) { if (res < 0) {
perror("recvfrom(ctrl_iface)"); wpa_printf(MSG_ERROR, "recvfrom(ctrl_iface): %s",
strerror(errno));
return; return;
} }
buf[res] = '\0'; buf[res] = '\0';
@ -2092,7 +2093,8 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
wpa_printf(MSG_DEBUG, "Using existing control " wpa_printf(MSG_DEBUG, "Using existing control "
"interface directory."); "interface directory.");
} else { } else {
perror("mkdir[ctrl_interface]"); wpa_printf(MSG_ERROR, "mkdir[ctrl_interface]: %s",
strerror(errno));
goto fail; goto fail;
} }
} }
@ -2100,7 +2102,8 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
if (hapd->conf->ctrl_interface_gid_set && if (hapd->conf->ctrl_interface_gid_set &&
chown(hapd->conf->ctrl_interface, -1, chown(hapd->conf->ctrl_interface, -1,
hapd->conf->ctrl_interface_gid) < 0) { hapd->conf->ctrl_interface_gid) < 0) {
perror("chown[ctrl_interface]"); wpa_printf(MSG_ERROR, "chown[ctrl_interface]: %s",
strerror(errno));
return -1; return -1;
} }
@ -2108,7 +2111,8 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
hapd->iface->interfaces->ctrl_iface_group && hapd->iface->interfaces->ctrl_iface_group &&
chown(hapd->conf->ctrl_interface, -1, chown(hapd->conf->ctrl_interface, -1,
hapd->iface->interfaces->ctrl_iface_group) < 0) { hapd->iface->interfaces->ctrl_iface_group) < 0) {
perror("chown[ctrl_interface]"); wpa_printf(MSG_ERROR, "chown[ctrl_interface]: %s",
strerror(errno));
return -1; return -1;
} }
@ -2133,7 +2137,7 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
s = socket(PF_UNIX, SOCK_DGRAM, 0); s = socket(PF_UNIX, SOCK_DGRAM, 0);
if (s < 0) { if (s < 0) {
perror("socket(PF_UNIX)"); wpa_printf(MSG_ERROR, "socket(PF_UNIX): %s", strerror(errno));
goto fail; goto fail;
} }
@ -2154,15 +2158,16 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
" allow connections - assuming it was left" " allow connections - assuming it was left"
"over from forced program termination"); "over from forced program termination");
if (unlink(fname) < 0) { if (unlink(fname) < 0) {
perror("unlink[ctrl_iface]"); wpa_printf(MSG_ERROR,
wpa_printf(MSG_ERROR, "Could not unlink " "Could not unlink existing ctrl_iface socket '%s': %s",
"existing ctrl_iface socket '%s'", fname, strerror(errno));
fname);
goto fail; goto fail;
} }
if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) <
0) { 0) {
perror("hostapd-ctrl-iface: bind(PF_UNIX)"); wpa_printf(MSG_ERROR,
"hostapd-ctrl-iface: bind(PF_UNIX): %s",
strerror(errno));
goto fail; goto fail;
} }
wpa_printf(MSG_DEBUG, "Successfully replaced leftover " wpa_printf(MSG_DEBUG, "Successfully replaced leftover "
@ -2180,19 +2185,22 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
if (hapd->conf->ctrl_interface_gid_set && if (hapd->conf->ctrl_interface_gid_set &&
chown(fname, -1, hapd->conf->ctrl_interface_gid) < 0) { chown(fname, -1, hapd->conf->ctrl_interface_gid) < 0) {
perror("chown[ctrl_interface/ifname]"); wpa_printf(MSG_ERROR, "chown[ctrl_interface/ifname]: %s",
strerror(errno));
goto fail; goto fail;
} }
if (!hapd->conf->ctrl_interface_gid_set && if (!hapd->conf->ctrl_interface_gid_set &&
hapd->iface->interfaces->ctrl_iface_group && hapd->iface->interfaces->ctrl_iface_group &&
chown(fname, -1, hapd->iface->interfaces->ctrl_iface_group) < 0) { chown(fname, -1, hapd->iface->interfaces->ctrl_iface_group) < 0) {
perror("chown[ctrl_interface/ifname]"); wpa_printf(MSG_ERROR, "chown[ctrl_interface/ifname]: %s",
strerror(errno));
goto fail; goto fail;
} }
if (chmod(fname, S_IRWXU | S_IRWXG) < 0) { if (chmod(fname, S_IRWXU | S_IRWXG) < 0) {
perror("chmod[ctrl_interface/ifname]"); wpa_printf(MSG_ERROR, "chmod[ctrl_interface/ifname]: %s",
strerror(errno));
goto fail; goto fail;
} }
os_free(fname); os_free(fname);
@ -2305,7 +2313,8 @@ static void hostapd_global_ctrl_iface_receive(int sock, void *eloop_ctx,
res = recvfrom(sock, buf, sizeof(buf) - 1, 0, res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
(struct sockaddr *) &from, &fromlen); (struct sockaddr *) &from, &fromlen);
if (res < 0) { if (res < 0) {
perror("recvfrom(ctrl_iface)"); wpa_printf(MSG_ERROR, "recvfrom(ctrl_iface): %s",
strerror(errno));
return; return;
} }
buf[res] = '\0'; buf[res] = '\0';
@ -2390,13 +2399,15 @@ int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface)
wpa_printf(MSG_DEBUG, "Using existing control " wpa_printf(MSG_DEBUG, "Using existing control "
"interface directory."); "interface directory.");
} else { } else {
perror("mkdir[ctrl_interface]"); wpa_printf(MSG_ERROR, "mkdir[ctrl_interface]: %s",
strerror(errno));
goto fail; goto fail;
} }
} else if (interface->ctrl_iface_group && } else if (interface->ctrl_iface_group &&
chown(interface->global_iface_path, -1, chown(interface->global_iface_path, -1,
interface->ctrl_iface_group) < 0) { interface->ctrl_iface_group) < 0) {
perror("chown[ctrl_interface]"); wpa_printf(MSG_ERROR, "chown[ctrl_interface]: %s",
strerror(errno));
goto fail; goto fail;
} }
@ -2406,7 +2417,7 @@ int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface)
s = socket(PF_UNIX, SOCK_DGRAM, 0); s = socket(PF_UNIX, SOCK_DGRAM, 0);
if (s < 0) { if (s < 0) {
perror("socket(PF_UNIX)"); wpa_printf(MSG_ERROR, "socket(PF_UNIX): %s", strerror(errno));
goto fail; goto fail;
} }
@ -2427,15 +2438,15 @@ int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface)
" allow connections - assuming it was left" " allow connections - assuming it was left"
"over from forced program termination"); "over from forced program termination");
if (unlink(fname) < 0) { if (unlink(fname) < 0) {
perror("unlink[ctrl_iface]"); wpa_printf(MSG_ERROR,
wpa_printf(MSG_ERROR, "Could not unlink " "Could not unlink existing ctrl_iface socket '%s': %s",
"existing ctrl_iface socket '%s'", fname, strerror(errno));
fname);
goto fail; goto fail;
} }
if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) <
0) { 0) {
perror("bind(PF_UNIX)"); wpa_printf(MSG_ERROR, "bind(PF_UNIX): %s",
strerror(errno));
goto fail; goto fail;
} }
wpa_printf(MSG_DEBUG, "Successfully replaced leftover " wpa_printf(MSG_DEBUG, "Successfully replaced leftover "
@ -2453,12 +2464,14 @@ int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface)
if (interface->ctrl_iface_group && if (interface->ctrl_iface_group &&
chown(fname, -1, interface->ctrl_iface_group) < 0) { chown(fname, -1, interface->ctrl_iface_group) < 0) {
perror("chown[ctrl_interface]"); wpa_printf(MSG_ERROR, "chown[ctrl_interface]: %s",
strerror(errno));
goto fail; goto fail;
} }
if (chmod(fname, S_IRWXU | S_IRWXG) < 0) { if (chmod(fname, S_IRWXU | S_IRWXG) < 0) {
perror("chmod[ctrl_interface/ifname]"); wpa_printf(MSG_ERROR, "chmod[ctrl_interface/ifname]: %s",
strerror(errno));
goto fail; goto fail;
} }
os_free(fname); os_free(fname);

View File

@ -408,7 +408,7 @@ static int hostapd_global_run(struct hapd_interfaces *ifaces, int daemonize,
#endif /* EAP_SERVER_TNC */ #endif /* EAP_SERVER_TNC */
if (daemonize && os_daemonize(pid_file)) { if (daemonize && os_daemonize(pid_file)) {
perror("daemon"); wpa_printf(MSG_ERROR, "daemon: %s", strerror(errno));
return -1; return -1;
} }

View File

@ -232,12 +232,8 @@ int random_pool_ready(void)
*/ */
fd = open("/dev/random", O_RDONLY | O_NONBLOCK); fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
if (fd < 0) { if (fd < 0) {
#ifndef CONFIG_NO_STDOUT_DEBUG
int error = errno;
perror("open(/dev/random)");
wpa_printf(MSG_ERROR, "random: Cannot open /dev/random: %s", wpa_printf(MSG_ERROR, "random: Cannot open /dev/random: %s",
strerror(error)); strerror(errno));
#endif /* CONFIG_NO_STDOUT_DEBUG */
return -1; return -1;
} }
@ -417,12 +413,8 @@ void random_init(const char *entropy_file)
random_fd = open("/dev/random", O_RDONLY | O_NONBLOCK); random_fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
if (random_fd < 0) { if (random_fd < 0) {
#ifndef CONFIG_NO_STDOUT_DEBUG
int error = errno;
perror("open(/dev/random)");
wpa_printf(MSG_ERROR, "random: Cannot open /dev/random: %s", wpa_printf(MSG_ERROR, "random: Cannot open /dev/random: %s",
strerror(error)); strerror(errno));
#endif /* CONFIG_NO_STDOUT_DEBUG */
return; return;
} }
wpa_printf(MSG_DEBUG, "random: Trying to read entropy from " wpa_printf(MSG_DEBUG, "random: Trying to read entropy from "

View File

@ -224,10 +224,10 @@ set80211param(struct atheros_driver_data *drv, int op, int arg)
memcpy(iwr.u.name+sizeof(__u32), &arg, sizeof(arg)); memcpy(iwr.u.name+sizeof(__u32), &arg, sizeof(arg));
if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) { if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_SETPARAM, &iwr) < 0) {
perror("ioctl[IEEE80211_IOCTL_SETPARAM]"); wpa_printf(MSG_INFO,
wpa_printf(MSG_DEBUG, "%s: %s: Failed to set parameter (op %d " "%s: %s: Failed to set parameter (op %d (%s) arg %d): ioctl[IEEE80211_IOCTL_SETPARAM]: %s",
"(%s) arg %d)", __func__, drv->iface, op, __func__, drv->iface, op, athr_get_param_name(op),
athr_get_param_name(op), arg); arg, strerror(errno));
return -1; return -1;
} }
return 0; return 0;
@ -290,14 +290,15 @@ atheros_configure_wpa(struct atheros_driver_data *drv,
} }
wpa_printf(MSG_DEBUG, "%s: group key cipher=%d", __func__, v); wpa_printf(MSG_DEBUG, "%s: group key cipher=%d", __func__, v);
if (set80211param(drv, IEEE80211_PARAM_MCASTCIPHER, v)) { if (set80211param(drv, IEEE80211_PARAM_MCASTCIPHER, v)) {
printf("Unable to set group key cipher to %u\n", v); wpa_printf(MSG_INFO, "Unable to set group key cipher to %u", v);
return -1; return -1;
} }
if (v == IEEE80211_CIPHER_WEP) { if (v == IEEE80211_CIPHER_WEP) {
/* key length is done only for specific ciphers */ /* key length is done only for specific ciphers */
v = (params->wpa_group == WPA_CIPHER_WEP104 ? 13 : 5); v = (params->wpa_group == WPA_CIPHER_WEP104 ? 13 : 5);
if (set80211param(drv, IEEE80211_PARAM_MCASTKEYLEN, v)) { if (set80211param(drv, IEEE80211_PARAM_MCASTKEYLEN, v)) {
printf("Unable to set group key length to %u\n", v); wpa_printf(MSG_INFO,
"Unable to set group key length to %u", v);
return -1; return -1;
} }
} }
@ -319,7 +320,8 @@ atheros_configure_wpa(struct atheros_driver_data *drv,
v |= 1<<IEEE80211_CIPHER_NONE; v |= 1<<IEEE80211_CIPHER_NONE;
wpa_printf(MSG_DEBUG, "%s: pairwise key ciphers=0x%x", __func__, v); wpa_printf(MSG_DEBUG, "%s: pairwise key ciphers=0x%x", __func__, v);
if (set80211param(drv, IEEE80211_PARAM_UCASTCIPHERS, v)) { if (set80211param(drv, IEEE80211_PARAM_UCASTCIPHERS, v)) {
printf("Unable to set pairwise key ciphers to 0x%x\n", v); wpa_printf(MSG_INFO,
"Unable to set pairwise key ciphers to 0x%x", v);
return -1; return -1;
} }
@ -327,8 +329,9 @@ atheros_configure_wpa(struct atheros_driver_data *drv,
__func__, params->wpa_key_mgmt); __func__, params->wpa_key_mgmt);
if (set80211param(drv, IEEE80211_PARAM_KEYMGTALGS, if (set80211param(drv, IEEE80211_PARAM_KEYMGTALGS,
params->wpa_key_mgmt)) { params->wpa_key_mgmt)) {
printf("Unable to set key management algorithms to 0x%x\n", wpa_printf(MSG_INFO,
params->wpa_key_mgmt); "Unable to set key management algorithms to 0x%x",
params->wpa_key_mgmt);
return -1; return -1;
} }
@ -345,13 +348,14 @@ atheros_configure_wpa(struct atheros_driver_data *drv,
wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x", __func__, v); wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x", __func__, v);
if (set80211param(drv, IEEE80211_PARAM_RSNCAPS, v)) { if (set80211param(drv, IEEE80211_PARAM_RSNCAPS, v)) {
printf("Unable to set RSN capabilities to 0x%x\n", v); wpa_printf(MSG_INFO, "Unable to set RSN capabilities to 0x%x",
v);
return -1; return -1;
} }
wpa_printf(MSG_DEBUG, "%s: enable WPA=0x%x", __func__, params->wpa); wpa_printf(MSG_DEBUG, "%s: enable WPA=0x%x", __func__, params->wpa);
if (set80211param(drv, IEEE80211_PARAM_WPA, params->wpa)) { if (set80211param(drv, IEEE80211_PARAM_WPA, params->wpa)) {
printf("Unable to set WPA to %u\n", params->wpa); wpa_printf(MSG_INFO, "Unable to set WPA to %u", params->wpa);
return -1; return -1;
} }
return 0; return 0;
@ -518,14 +522,14 @@ atheros_set_key(const char *ifname, void *priv, enum wpa_alg alg,
#endif /* ATH_GCM_SUPPORT */ #endif /* ATH_GCM_SUPPORT */
#endif /* CONFIG_IEEE80211W */ #endif /* CONFIG_IEEE80211W */
default: default:
printf("%s: unknown/unsupported algorithm %d\n", wpa_printf(MSG_INFO, "%s: unknown/unsupported algorithm %d",
__func__, alg); __func__, alg);
return -1; return -1;
} }
if (key_len > sizeof(wk.ik_keydata)) { if (key_len > sizeof(wk.ik_keydata)) {
printf("%s: key length %lu too big\n", __func__, wpa_printf(MSG_INFO, "%s: key length %lu too big", __func__,
(unsigned long) key_len); (unsigned long) key_len);
return -3; return -3;
} }
@ -636,7 +640,8 @@ atheros_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
return 0; return 0;
} }
printf("Failed to get station stats information element.\n"); wpa_printf(MSG_INFO,
"Failed to get station stats information element");
return -1; return -1;
} }
@ -808,9 +813,9 @@ static int atheros_set_qos_map(void *ctx, const u8 *qos_map_set,
} }
if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_DBGREQ, &iwr) < 0) { if (ioctl(drv->ioctl_sock, IEEE80211_IOCTL_DBGREQ, &iwr) < 0) {
perror("ioctl[IEEE80211_IOCTL_DBGREQ]"); wpa_printf(MSG_ERROR,
wpa_printf(MSG_DEBUG, "%s: %s: Failed to set QoS Map", "%s: %s: Failed to set QoS Map: ioctl[IEEE80211_IOCTL_DBGREQ]: %s",
__func__, drv->iface); __func__, drv->iface, strerror(errno));
return -1; return -1;
} }
#endif /* CONFIG_ATHEROS_QOS_MAP */ #endif /* CONFIG_ATHEROS_QOS_MAP */
@ -1495,8 +1500,9 @@ atheros_get_we_version(struct atheros_driver_data *drv)
sizeof(range->enc_capa); sizeof(range->enc_capa);
if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
perror("ioctl[SIOCGIWRANGE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIWRANGE]: %s",
free(range); strerror(errno));
os_free(range);
return -1; return -1;
} else if (iwr.u.data.length >= minlen && } else if (iwr.u.data.length >= minlen &&
range->we_version_compiled >= 18) { range->we_version_compiled >= 18) {
@ -1556,8 +1562,9 @@ atheros_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
if (len > sizeof(buf)) { if (len > sizeof(buf)) {
bp = malloc(len); bp = malloc(len);
if (bp == NULL) { if (bp == NULL) {
printf("EAPOL frame discarded, cannot malloc temp " wpa_printf(MSG_INFO,
"buffer of size %lu!\n", (unsigned long) len); "EAPOL frame discarded, cannot malloc temp buffer of size %lu!",
(unsigned long) len);
return -1; return -1;
} }
} }
@ -1594,14 +1601,16 @@ atheros_init(struct hostapd_data *hapd, struct wpa_init_params *params)
drv = os_zalloc(sizeof(struct atheros_driver_data)); drv = os_zalloc(sizeof(struct atheros_driver_data));
if (drv == NULL) { if (drv == NULL) {
printf("Could not allocate memory for atheros driver data\n"); wpa_printf(MSG_INFO,
"Could not allocate memory for atheros driver data");
return NULL; return NULL;
} }
drv->hapd = hapd; drv->hapd = hapd;
drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
if (drv->ioctl_sock < 0) { if (drv->ioctl_sock < 0) {
perror("socket[PF_INET,SOCK_DGRAM]"); wpa_printf(MSG_ERROR, "socket[PF_INET,SOCK_DGRAM]: %s",
strerror(errno));
goto bad; goto bad;
} }
memcpy(drv->iface, params->ifname, sizeof(drv->iface)); memcpy(drv->iface, params->ifname, sizeof(drv->iface));
@ -1609,7 +1618,8 @@ atheros_init(struct hostapd_data *hapd, struct wpa_init_params *params)
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name)); os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) { if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
perror("ioctl(SIOCGIFINDEX)"); wpa_printf(MSG_ERROR, "ioctl(SIOCGIFINDEX): %s",
strerror(errno));
goto bad; goto bad;
} }
drv->ifindex = ifr.ifr_ifindex; drv->ifindex = ifr.ifr_ifindex;
@ -1645,8 +1655,9 @@ atheros_init(struct hostapd_data *hapd, struct wpa_init_params *params)
iwr.u.mode = IW_MODE_MASTER; iwr.u.mode = IW_MODE_MASTER;
if (ioctl(drv->ioctl_sock, SIOCSIWMODE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWMODE, &iwr) < 0) {
perror("ioctl[SIOCSIWMODE]"); wpa_printf(MSG_ERROR,
printf("Could not set interface to master mode!\n"); "Could not set interface to master mode! ioctl[SIOCSIWMODE]: %s",
strerror(errno));
goto bad; goto bad;
} }
@ -1712,8 +1723,8 @@ atheros_set_ssid(void *priv, const u8 *buf, int len)
iwr.u.essid.length = len + 1; iwr.u.essid.length = len + 1;
if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) {
perror("ioctl[SIOCSIWESSID]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWESSID,len=%d]: %s",
printf("len=%d\n", len); len, strerror(errno));
return -1; return -1;
} }
return 0; return 0;
@ -1733,7 +1744,8 @@ atheros_get_ssid(void *priv, u8 *buf, int len)
IW_ESSID_MAX_SIZE : len; IW_ESSID_MAX_SIZE : len;
if (ioctl(drv->ioctl_sock, SIOCGIWESSID, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCGIWESSID, &iwr) < 0) {
perror("ioctl[SIOCGIWESSID]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIWESSID]: %s",
strerror(errno));
ret = -1; ret = -1;
} else } else
ret = iwr.u.essid.length; ret = iwr.u.essid.length;

View File

@ -264,7 +264,8 @@ bsd_ctrl_iface(void *priv, int enable)
os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name)); os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
if (ioctl(drv->sock, SIOCGIFFLAGS, &ifr) < 0) { if (ioctl(drv->sock, SIOCGIFFLAGS, &ifr) < 0) {
perror("ioctl[SIOCGIFFLAGS]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIFFLAGS]: %s",
strerror(errno));
return -1; return -1;
} }
@ -279,7 +280,8 @@ bsd_ctrl_iface(void *priv, int enable)
} }
if (ioctl(drv->sock, SIOCSIFFLAGS, &ifr) < 0) { if (ioctl(drv->sock, SIOCSIFFLAGS, &ifr) < 0) {
perror("ioctl[SIOCSIFFLAGS]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIFFLAGS]: %s",
strerror(errno));
return -1; return -1;
} }
@ -404,22 +406,24 @@ bsd_configure_wpa(void *priv, struct wpa_bss_params *params)
v = IEEE80211_CIPHER_NONE; v = IEEE80211_CIPHER_NONE;
break; break;
default: default:
printf("Unknown group key cipher %u\n", wpa_printf(MSG_INFO, "Unknown group key cipher %u",
params->wpa_group); params->wpa_group);
return -1; return -1;
} }
wpa_printf(MSG_DEBUG, "%s: group key cipher=%s (%u)", wpa_printf(MSG_DEBUG, "%s: group key cipher=%s (%u)",
__func__, ciphernames[v], v); __func__, ciphernames[v], v);
if (set80211param(priv, IEEE80211_IOC_MCASTCIPHER, v)) { if (set80211param(priv, IEEE80211_IOC_MCASTCIPHER, v)) {
printf("Unable to set group key cipher to %u (%s)\n", wpa_printf(MSG_INFO,
v, ciphernames[v]); "Unable to set group key cipher to %u (%s)",
v, ciphernames[v]);
return -1; return -1;
} }
if (v == IEEE80211_CIPHER_WEP) { if (v == IEEE80211_CIPHER_WEP) {
/* key length is done only for specific ciphers */ /* key length is done only for specific ciphers */
v = (params->wpa_group == WPA_CIPHER_WEP104 ? 13 : 5); v = (params->wpa_group == WPA_CIPHER_WEP104 ? 13 : 5);
if (set80211param(priv, IEEE80211_IOC_MCASTKEYLEN, v)) { if (set80211param(priv, IEEE80211_IOC_MCASTKEYLEN, v)) {
printf("Unable to set group key length to %u\n", v); wpa_printf(MSG_INFO,
"Unable to set group key length to %u", v);
return -1; return -1;
} }
} }
@ -433,7 +437,8 @@ bsd_configure_wpa(void *priv, struct wpa_bss_params *params)
v |= 1<<IEEE80211_CIPHER_NONE; v |= 1<<IEEE80211_CIPHER_NONE;
wpa_printf(MSG_DEBUG, "%s: pairwise key ciphers=0x%x", __func__, v); wpa_printf(MSG_DEBUG, "%s: pairwise key ciphers=0x%x", __func__, v);
if (set80211param(priv, IEEE80211_IOC_UCASTCIPHERS, v)) { if (set80211param(priv, IEEE80211_IOC_UCASTCIPHERS, v)) {
printf("Unable to set pairwise key ciphers to 0x%x\n", v); wpa_printf(MSG_INFO,
"Unable to set pairwise key ciphers to 0x%x", v);
return -1; return -1;
} }
@ -441,8 +446,9 @@ bsd_configure_wpa(void *priv, struct wpa_bss_params *params)
__func__, params->wpa_key_mgmt); __func__, params->wpa_key_mgmt);
if (set80211param(priv, IEEE80211_IOC_KEYMGTALGS, if (set80211param(priv, IEEE80211_IOC_KEYMGTALGS,
params->wpa_key_mgmt)) { params->wpa_key_mgmt)) {
printf("Unable to set key management algorithms to 0x%x\n", wpa_printf(MSG_INFO,
params->wpa_key_mgmt); "Unable to set key management algorithms to 0x%x",
params->wpa_key_mgmt);
return -1; return -1;
} }
@ -452,14 +458,15 @@ bsd_configure_wpa(void *priv, struct wpa_bss_params *params)
wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x", wpa_printf(MSG_DEBUG, "%s: rsn capabilities=0x%x",
__func__, params->rsn_preauth); __func__, params->rsn_preauth);
if (set80211param(priv, IEEE80211_IOC_RSNCAPS, v)) { if (set80211param(priv, IEEE80211_IOC_RSNCAPS, v)) {
printf("Unable to set RSN capabilities to 0x%x\n", v); wpa_printf(MSG_INFO, "Unable to set RSN capabilities to 0x%x",
v);
return -1; return -1;
} }
#endif /* IEEE80211_IOC_APPIE */ #endif /* IEEE80211_IOC_APPIE */
wpa_printf(MSG_DEBUG, "%s: enable WPA= 0x%x", __func__, params->wpa); wpa_printf(MSG_DEBUG, "%s: enable WPA= 0x%x", __func__, params->wpa);
if (set80211param(priv, IEEE80211_IOC_WPA, params->wpa)) { if (set80211param(priv, IEEE80211_IOC_WPA, params->wpa)) {
printf("Unable to set WPA to %u\n", params->wpa); wpa_printf(MSG_INFO, "Unable to set WPA to %u", params->wpa);
return -1; return -1;
} }
return 0; return 0;
@ -507,7 +514,8 @@ bsd_new_sta(void *priv, void *ctx, u8 addr[IEEE80211_ADDR_LEN])
memset(&ie, 0, sizeof(ie)); memset(&ie, 0, sizeof(ie));
memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN); memcpy(ie.wpa_macaddr, addr, IEEE80211_ADDR_LEN);
if (get80211var(priv, IEEE80211_IOC_WPAIE, &ie, sizeof(ie)) < 0) { if (get80211var(priv, IEEE80211_IOC_WPAIE, &ie, sizeof(ie)) < 0) {
printf("Failed to get WPA/RSN information element.\n"); wpa_printf(MSG_INFO,
"Failed to get WPA/RSN information element");
goto no_ie; goto no_ie;
} }
iebuf = ie.wpa_ie; iebuf = ie.wpa_ie;
@ -594,7 +602,7 @@ rtbuf_len(void)
int mib[6] = {CTL_NET, AF_ROUTE, 0, AF_INET, NET_RT_DUMP, 0}; int mib[6] = {CTL_NET, AF_ROUTE, 0, AF_INET, NET_RT_DUMP, 0};
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) { if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
wpa_printf(MSG_WARNING, "%s failed: %s\n", __func__, wpa_printf(MSG_WARNING, "%s failed: %s", __func__,
strerror(errno)); strerror(errno));
len = 2048; len = 2048;
} }
@ -652,7 +660,7 @@ bsd_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
wk.ik_keyix = idx; wk.ik_keyix = idx;
if (get80211var(priv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk)) < 0) { if (get80211var(priv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk)) < 0) {
printf("Failed to get encryption.\n"); wpa_printf(MSG_INFO, "Failed to get encryption");
return -1; return -1;
} }
@ -734,7 +742,7 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
n = read(sock, drv->event_buf, drv->event_buf_len); n = read(sock, drv->event_buf, drv->event_buf_len);
if (n < 0) { if (n < 0) {
if (errno != EINTR && errno != EAGAIN) if (errno != EINTR && errno != EAGAIN)
wpa_printf(MSG_ERROR, "%s read() failed: %s\n", wpa_printf(MSG_ERROR, "%s read() failed: %s",
__func__, strerror(errno)); __func__, strerror(errno));
return; return;
} }
@ -814,7 +822,8 @@ bsd_init(struct hostapd_data *hapd, struct wpa_init_params *params)
drv->hapd = hapd; drv->hapd = hapd;
drv->sock = socket(PF_INET, SOCK_DGRAM, 0); drv->sock = socket(PF_INET, SOCK_DGRAM, 0);
if (drv->sock < 0) { if (drv->sock < 0) {
perror("socket[PF_INET,SOCK_DGRAM]"); wpa_printf(MSG_ERROR, "socket[PF_INET,SOCK_DGRAM]: %s",
strerror(errno));
goto bad; goto bad;
} }
os_strlcpy(drv->ifname, params->ifname, sizeof(drv->ifname)); os_strlcpy(drv->ifname, params->ifname, sizeof(drv->ifname));
@ -832,7 +841,8 @@ bsd_init(struct hostapd_data *hapd, struct wpa_init_params *params)
drv->route = socket(PF_ROUTE, SOCK_RAW, 0); drv->route = socket(PF_ROUTE, SOCK_RAW, 0);
if (drv->route < 0) { if (drv->route < 0) {
perror("socket(PF_ROUTE,SOCK_RAW)"); wpa_printf(MSG_ERROR, "socket(PF_ROUTE,SOCK_RAW): %s",
strerror(errno));
goto bad; goto bad;
} }
eloop_register_read_sock(drv->route, bsd_wireless_event_receive, drv, eloop_register_read_sock(drv->route, bsd_wireless_event_receive, drv,
@ -1189,7 +1199,7 @@ wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx)
n = read(sock, drv->event_buf, drv->event_buf_len); n = read(sock, drv->event_buf, drv->event_buf_len);
if (n < 0) { if (n < 0) {
if (errno != EINTR && errno != EAGAIN) if (errno != EINTR && errno != EAGAIN)
wpa_printf(MSG_ERROR, "%s read() failed: %s\n", wpa_printf(MSG_ERROR, "%s read() failed: %s",
__func__, strerror(errno)); __func__, strerror(errno));
return; return;
} }

View File

@ -214,7 +214,7 @@ static void handle_read(int sock, void *eloop_ctx, void *sock_ctx)
len = recv(sock, buf, sizeof(buf), 0); len = recv(sock, buf, sizeof(buf), 0);
if (len < 0) { if (len < 0) {
perror("recv"); wpa_printf(MSG_ERROR, "recv: %s", strerror(errno));
return; return;
} }
@ -229,19 +229,21 @@ static int hostap_init_sockets(struct hostap_driver_data *drv, u8 *own_addr)
drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (drv->sock < 0) { if (drv->sock < 0) {
perror("socket[PF_PACKET,SOCK_RAW]"); wpa_printf(MSG_ERROR, "socket[PF_PACKET,SOCK_RAW]: %s",
strerror(errno));
return -1; return -1;
} }
if (eloop_register_read_sock(drv->sock, handle_read, drv, NULL)) { if (eloop_register_read_sock(drv->sock, handle_read, drv, NULL)) {
printf("Could not register read socket\n"); wpa_printf(MSG_ERROR, "Could not register read socket");
return -1; return -1;
} }
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%sap", drv->iface); snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%sap", drv->iface);
if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) { if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) {
perror("ioctl(SIOCGIFINDEX)"); wpa_printf(MSG_ERROR, "ioctl(SIOCGIFINDEX): %s",
strerror(errno));
return -1; return -1;
} }
@ -256,7 +258,7 @@ static int hostap_init_sockets(struct hostap_driver_data *drv, u8 *own_addr)
addr.sll_ifindex); addr.sll_ifindex);
if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("bind"); wpa_printf(MSG_ERROR, "bind: %s", strerror(errno));
return -1; return -1;
} }
@ -361,9 +363,9 @@ static int hostap_set_iface_flags(void *priv, int dev_up)
os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
ifr.ifr_mtu = HOSTAPD_MTU; ifr.ifr_mtu = HOSTAPD_MTU;
if (ioctl(drv->ioctl_sock, SIOCSIFMTU, &ifr) != 0) { if (ioctl(drv->ioctl_sock, SIOCSIFMTU, &ifr) != 0) {
perror("ioctl[SIOCSIFMTU]"); wpa_printf(MSG_INFO,
printf("Setting MTU failed - trying to survive with " "Setting MTU failed - trying to survive with current value: ioctl[SIOCSIFMTU]: %s",
"current value\n"); strerror(errno));
} }
} }
@ -383,7 +385,8 @@ static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param,
iwr.u.data.length = len; iwr.u.data.length = len;
if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_HOSTAPD, &iwr) < 0) { if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_HOSTAPD, &iwr) < 0) {
perror("ioctl[PRISM2_IOCTL_HOSTAPD]"); wpa_printf(MSG_ERROR, "ioctl[PRISM2_IOCTL_HOSTAPD]: %s",
strerror(errno));
return -1; return -1;
} }
@ -497,7 +500,8 @@ static int hostap_ioctl_prism2param(void *priv, int param, int value)
*i++ = value; *i++ = value;
if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_PRISM2_PARAM, &iwr) < 0) { if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_PRISM2_PARAM, &iwr) < 0) {
perror("ioctl[PRISM2_IOCTL_PRISM2_PARAM]"); wpa_printf(MSG_ERROR, "ioctl[PRISM2_IOCTL_PRISM2_PARAM]: %s",
strerror(errno));
return -1; return -1;
} }
@ -554,8 +558,8 @@ static int hostap_set_ssid(void *priv, const u8 *buf, int len)
iwr.u.essid.length = len + 1; iwr.u.essid.length = len + 1;
if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) {
perror("ioctl[SIOCSIWESSID]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWESSID,len=%d]: %s",
printf("len=%d\n", len); len, strerror(errno));
return -1; return -1;
} }
@ -919,8 +923,9 @@ static int hostap_get_we_version(struct hostap_driver_data *drv)
sizeof(range->enc_capa); sizeof(range->enc_capa);
if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
perror("ioctl[SIOCGIWRANGE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIWRANGE]: %s",
free(range); strerror(errno));
os_free(range);
return -1; return -1;
} else if (iwr.u.data.length >= minlen && } else if (iwr.u.data.length >= minlen &&
range->we_version_compiled >= 18) { range->we_version_compiled >= 18) {
@ -975,23 +980,25 @@ static void * hostap_init(struct hostapd_data *hapd,
drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
if (drv->ioctl_sock < 0) { if (drv->ioctl_sock < 0) {
perror("socket[PF_INET,SOCK_DGRAM]"); wpa_printf(MSG_ERROR, "socket[PF_INET,SOCK_DGRAM]: %s",
free(drv); strerror(errno));
os_free(drv);
return NULL; return NULL;
} }
if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 1)) { if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 1)) {
printf("Could not enable hostapd mode for interface %s\n", wpa_printf(MSG_ERROR,
drv->iface); "Could not enable hostapd mode for interface %s",
drv->iface);
close(drv->ioctl_sock); close(drv->ioctl_sock);
free(drv); os_free(drv);
return NULL; return NULL;
} }
if (hostap_init_sockets(drv, params->own_addr) || if (hostap_init_sockets(drv, params->own_addr) ||
hostap_wireless_event_init(drv)) { hostap_wireless_event_init(drv)) {
close(drv->ioctl_sock); close(drv->ioctl_sock);
free(drv); os_free(drv);
return NULL; return NULL;
} }
@ -1060,7 +1067,8 @@ static int hostap_set_freq(void *priv, struct hostapd_freq_params *freq)
iwr.u.freq.e = 0; iwr.u.freq.e = 0;
if (ioctl(drv->ioctl_sock, SIOCSIWFREQ, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWFREQ, &iwr) < 0) {
perror("ioctl[SIOCSIWFREQ]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWFREQ]: %s",
strerror(errno));
return -1; return -1;
} }

View File

@ -91,7 +91,7 @@ static int macsec_qca_multicast_membership(int sock, int ifindex,
if (setsockopt(sock, SOL_PACKET, if (setsockopt(sock, SOL_PACKET,
add ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP, add ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP,
&mreq, sizeof(mreq)) < 0) { &mreq, sizeof(mreq)) < 0) {
perror("setsockopt"); wpa_printf(MSG_ERROR, "setsockopt: %s", strerror(errno));
return -1; return -1;
} }
return 0; return 0;
@ -131,14 +131,15 @@ static int macsec_qca_get_ifflags(const char *ifname, int *flags)
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_ERROR, "socket: %s", strerror(errno));
return -1; return -1;
} }
os_memset(&ifr, 0, sizeof(ifr)); os_memset(&ifr, 0, sizeof(ifr));
os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
perror("ioctl[SIOCGIFFLAGS]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIFFLAGS]: %s",
strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -155,7 +156,7 @@ static int macsec_qca_set_ifflags(const char *ifname, int flags)
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_ERROR, "socket: %s", strerror(errno));
return -1; return -1;
} }
@ -163,7 +164,8 @@ static int macsec_qca_set_ifflags(const char *ifname, int flags)
os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
ifr.ifr_flags = flags & 0xffff; ifr.ifr_flags = flags & 0xffff;
if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) { if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
perror("ioctl[SIOCSIFFLAGS]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIFFLAGS]: %s",
strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -180,14 +182,15 @@ static int macsec_qca_get_ifstatus(const char *ifname, int *status)
s = socket(PF_INET, SOCK_DGRAM, 0); s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0) { if (s < 0) {
perror("socket"); wpa_print(MSG_ERROR, "socket: %s", strerror(errno));
return -1; return -1;
} }
os_memset(&ifmr, 0, sizeof(ifmr)); os_memset(&ifmr, 0, sizeof(ifmr));
os_strlcpy(ifmr.ifm_name, ifname, IFNAMSIZ); os_strlcpy(ifmr.ifm_name, ifname, IFNAMSIZ);
if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) { if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
perror("ioctl[SIOCGIFMEDIA]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIFMEDIA]: %s",
strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -211,7 +214,7 @@ static int macsec_qca_multi(const char *ifname, const u8 *addr, int add)
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_ERROR, "socket: %s", strerror(errno));
return -1; return -1;
} }
@ -245,7 +248,8 @@ static int macsec_qca_multi(const char *ifname, const u8 *addr, int add)
#endif /* defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) */ #endif /* defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) */
if (ioctl(s, add ? SIOCADDMULTI : SIOCDELMULTI, (caddr_t) &ifr) < 0) { if (ioctl(s, add ? SIOCADDMULTI : SIOCDELMULTI, (caddr_t) &ifr) < 0) {
perror("ioctl[SIOC{ADD/DEL}MULTI]"); wpa_printf(MSG_ERROR, "ioctl[SIOC{ADD/DEL}MULTI]: %s",
strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -323,7 +327,7 @@ static void * macsec_qca_init(void *ctx, const char *ifname)
#ifdef __linux__ #ifdef __linux__
drv->pf_sock = socket(PF_PACKET, SOCK_DGRAM, 0); drv->pf_sock = socket(PF_PACKET, SOCK_DGRAM, 0);
if (drv->pf_sock < 0) if (drv->pf_sock < 0)
perror("socket(PF_PACKET)"); wpa_printf(MSG_ERROR, "socket(PF_PACKET): %s", strerror(errno));
#else /* __linux__ */ #else /* __linux__ */
drv->pf_sock = -1; drv->pf_sock = -1;
#endif /* __linux__ */ #endif /* __linux__ */

View File

@ -35,7 +35,7 @@ static int wpa_priv_reg_cmd(struct wpa_driver_privsep_data *drv, int cmd)
(struct sockaddr *) &drv->priv_addr, (struct sockaddr *) &drv->priv_addr,
sizeof(drv->priv_addr)); sizeof(drv->priv_addr));
if (res < 0) if (res < 0)
perror("sendto"); wpa_printf(MSG_ERROR, "sendto: %s", strerror(errno));
return res < 0 ? -1 : 0; return res < 0 ? -1 : 0;
} }
@ -59,7 +59,8 @@ static int wpa_priv_cmd(struct wpa_driver_privsep_data *drv, int cmd,
msg.msg_namelen = sizeof(drv->priv_addr); msg.msg_namelen = sizeof(drv->priv_addr);
if (sendmsg(drv->cmd_socket, &msg, 0) < 0) { if (sendmsg(drv->cmd_socket, &msg, 0) < 0) {
perror("sendmsg(cmd_socket)"); wpa_printf(MSG_ERROR, "sendmsg(cmd_socket): %s",
strerror(errno));
return -1; return -1;
} }
@ -74,14 +75,15 @@ static int wpa_priv_cmd(struct wpa_driver_privsep_data *drv, int cmd,
tv.tv_usec = 0; tv.tv_usec = 0;
res = select(drv->cmd_socket + 1, &rfds, NULL, NULL, &tv); res = select(drv->cmd_socket + 1, &rfds, NULL, NULL, &tv);
if (res < 0 && errno != EINTR) { if (res < 0 && errno != EINTR) {
perror("select"); wpa_printf(MSG_ERROR, "select: %s", strerror(errno));
return -1; return -1;
} }
if (FD_ISSET(drv->cmd_socket, &rfds)) { if (FD_ISSET(drv->cmd_socket, &rfds)) {
res = recv(drv->cmd_socket, reply, *reply_len, 0); res = recv(drv->cmd_socket, reply, *reply_len, 0);
if (res < 0) { if (res < 0) {
perror("recv"); wpa_printf(MSG_ERROR, "recv: %s",
strerror(errno));
return -1; return -1;
} }
*reply_len = res; *reply_len = res;
@ -441,7 +443,8 @@ static void wpa_driver_privsep_receive(int sock, void *eloop_ctx,
res = recvfrom(sock, buf, buflen, 0, res = recvfrom(sock, buf, buflen, 0,
(struct sockaddr *) &from, &fromlen); (struct sockaddr *) &from, &fromlen);
if (res < 0) { if (res < 0) {
perror("recvfrom(priv_socket)"); wpa_printf(MSG_ERROR, "recvfrom(priv_socket): %s",
strerror(errno));
os_free(buf); os_free(buf);
return; return;
} }
@ -631,7 +634,7 @@ static int wpa_driver_privsep_set_param(void *priv, const char *param)
drv->priv_socket = socket(PF_UNIX, SOCK_DGRAM, 0); drv->priv_socket = socket(PF_UNIX, SOCK_DGRAM, 0);
if (drv->priv_socket < 0) { if (drv->priv_socket < 0) {
perror("socket(PF_UNIX)"); wpa_printf(MSG_ERROR, "socket(PF_UNIX): %s", strerror(errno));
os_free(drv->own_socket_path); os_free(drv->own_socket_path);
drv->own_socket_path = NULL; drv->own_socket_path = NULL;
return -1; return -1;
@ -642,7 +645,9 @@ static int wpa_driver_privsep_set_param(void *priv, const char *param)
os_strlcpy(addr.sun_path, drv->own_socket_path, sizeof(addr.sun_path)); os_strlcpy(addr.sun_path, drv->own_socket_path, sizeof(addr.sun_path));
if (bind(drv->priv_socket, (struct sockaddr *) &addr, sizeof(addr)) < if (bind(drv->priv_socket, (struct sockaddr *) &addr, sizeof(addr)) <
0) { 0) {
perror("privsep-set-params priv-sock: bind(PF_UNIX)"); wpa_printf(MSG_ERROR,
"privsep-set-params priv-sock: bind(PF_UNIX): %s",
strerror(errno));
close(drv->priv_socket); close(drv->priv_socket);
drv->priv_socket = -1; drv->priv_socket = -1;
unlink(drv->own_socket_path); unlink(drv->own_socket_path);
@ -656,7 +661,7 @@ static int wpa_driver_privsep_set_param(void *priv, const char *param)
drv->cmd_socket = socket(PF_UNIX, SOCK_DGRAM, 0); drv->cmd_socket = socket(PF_UNIX, SOCK_DGRAM, 0);
if (drv->cmd_socket < 0) { if (drv->cmd_socket < 0) {
perror("socket(PF_UNIX)"); wpa_printf(MSG_ERROR, "socket(PF_UNIX): %s", strerror(errno));
os_free(drv->own_cmd_path); os_free(drv->own_cmd_path);
drv->own_cmd_path = NULL; drv->own_cmd_path = NULL;
return -1; return -1;
@ -667,7 +672,9 @@ static int wpa_driver_privsep_set_param(void *priv, const char *param)
os_strlcpy(addr.sun_path, drv->own_cmd_path, sizeof(addr.sun_path)); os_strlcpy(addr.sun_path, drv->own_cmd_path, sizeof(addr.sun_path));
if (bind(drv->cmd_socket, (struct sockaddr *) &addr, sizeof(addr)) < 0) if (bind(drv->cmd_socket, (struct sockaddr *) &addr, sizeof(addr)) < 0)
{ {
perror("privsep-set-params cmd-sock: bind(PF_UNIX)"); wpa_printf(MSG_ERROR,
"privsep-set-params cmd-sock: bind(PF_UNIX): %s",
strerror(errno));
close(drv->cmd_socket); close(drv->cmd_socket);
drv->cmd_socket = -1; drv->cmd_socket = -1;
unlink(drv->own_cmd_path); unlink(drv->own_cmd_path);

View File

@ -91,7 +91,8 @@ static u16 wpa_driver_roboswitch_mdio_read(
mii->reg_num = reg; mii->reg_num = reg;
if (ioctl(drv->fd, SIOCGMIIREG, &drv->ifr) < 0) { if (ioctl(drv->fd, SIOCGMIIREG, &drv->ifr) < 0) {
perror("ioctl[SIOCGMIIREG]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGMIIREG]: %s",
strerror(errno));
return 0x00; return 0x00;
} }
return mii->val_out; return mii->val_out;
@ -108,7 +109,8 @@ static void wpa_driver_roboswitch_mdio_write(
mii->val_in = val; mii->val_in = val;
if (ioctl(drv->fd, SIOCSMIIREG, &drv->ifr) < 0) { if (ioctl(drv->fd, SIOCSMIIREG, &drv->ifr) < 0) {
perror("ioctl[SIOCSMIIREG"); wpa_printf(MSG_ERROR, "ioctl[SIOCSMIIREG]: %s",
strerror(errno));
} }
} }
@ -394,7 +396,8 @@ static void * wpa_driver_roboswitch_init(void *ctx, const char *ifname)
os_memset(&drv->ifr, 0, sizeof(drv->ifr)); os_memset(&drv->ifr, 0, sizeof(drv->ifr));
os_strlcpy(drv->ifr.ifr_name, drv->ifname, IFNAMSIZ); os_strlcpy(drv->ifr.ifr_name, drv->ifname, IFNAMSIZ);
if (ioctl(drv->fd, SIOCGMIIPHY, &drv->ifr) < 0) { if (ioctl(drv->fd, SIOCGMIIPHY, &drv->ifr) < 0) {
perror("ioctl[SIOCGMIIPHY]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGMIIPHY]: %s",
strerror(errno));
os_free(drv); os_free(drv);
return NULL; return NULL;
} }

View File

@ -78,7 +78,7 @@ int wpa_driver_wext_get_bssid(void *priv, u8 *bssid)
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ); os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
if (ioctl(drv->ioctl_sock, SIOCGIWAP, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCGIWAP, &iwr) < 0) {
perror("ioctl[SIOCGIWAP]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIWAP]: %s", strerror(errno));
ret = -1; ret = -1;
} }
os_memcpy(bssid, iwr.u.ap_addr.sa_data, ETH_ALEN); os_memcpy(bssid, iwr.u.ap_addr.sa_data, ETH_ALEN);
@ -108,7 +108,7 @@ int wpa_driver_wext_set_bssid(void *priv, const u8 *bssid)
os_memset(iwr.u.ap_addr.sa_data, 0, ETH_ALEN); os_memset(iwr.u.ap_addr.sa_data, 0, ETH_ALEN);
if (ioctl(drv->ioctl_sock, SIOCSIWAP, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWAP, &iwr) < 0) {
perror("ioctl[SIOCSIWAP]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWAP]: %s", strerror(errno));
ret = -1; ret = -1;
} }
@ -134,7 +134,8 @@ int wpa_driver_wext_get_ssid(void *priv, u8 *ssid)
iwr.u.essid.length = 32; iwr.u.essid.length = 32;
if (ioctl(drv->ioctl_sock, SIOCGIWESSID, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCGIWESSID, &iwr) < 0) {
perror("ioctl[SIOCGIWESSID]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIWESSID]: %s",
strerror(errno));
ret = -1; ret = -1;
} else { } else {
ret = iwr.u.essid.length; ret = iwr.u.essid.length;
@ -192,7 +193,8 @@ int wpa_driver_wext_set_ssid(void *priv, const u8 *ssid, size_t ssid_len)
iwr.u.essid.length = ssid_len; iwr.u.essid.length = ssid_len;
if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWESSID, &iwr) < 0) {
perror("ioctl[SIOCSIWESSID]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWESSID]: %s",
strerror(errno));
ret = -1; ret = -1;
} }
@ -218,7 +220,8 @@ int wpa_driver_wext_set_freq(void *priv, int freq)
iwr.u.freq.e = 1; iwr.u.freq.e = 1;
if (ioctl(drv->ioctl_sock, SIOCSIWFREQ, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWFREQ, &iwr) < 0) {
perror("ioctl[SIOCSIWFREQ]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWFREQ]: %s",
strerror(errno));
ret = -1; ret = -1;
} }
@ -815,7 +818,8 @@ void * wpa_driver_wext_init(void *ctx, const char *ifname)
drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
if (drv->ioctl_sock < 0) { if (drv->ioctl_sock < 0) {
perror("socket(PF_INET,SOCK_DGRAM)"); wpa_printf(MSG_ERROR, "socket(PF_INET,SOCK_DGRAM): %s",
strerror(errno));
goto err1; goto err1;
} }
@ -1027,7 +1031,8 @@ int wpa_driver_wext_scan(void *priv, struct wpa_driver_scan_params *params)
} }
if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
perror("ioctl[SIOCSIWSCAN]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWSCAN]: %s",
strerror(errno));
ret = -1; ret = -1;
} }
@ -1082,7 +1087,8 @@ static u8 * wpa_driver_wext_giwscan(struct wpa_driver_wext_data *drv,
"trying larger buffer (%lu bytes)", "trying larger buffer (%lu bytes)",
(unsigned long) res_buf_len); (unsigned long) res_buf_len);
} else { } else {
perror("ioctl[SIOCGIWSCAN]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIWSCAN]: %s",
strerror(errno));
os_free(res_buf); os_free(res_buf);
return NULL; return NULL;
} }
@ -1533,7 +1539,8 @@ static int wpa_driver_wext_get_range(void *priv)
sizeof(range->enc_capa); sizeof(range->enc_capa);
if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCGIWRANGE, &iwr) < 0) {
perror("ioctl[SIOCGIWRANGE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIWRANGE]: %s",
strerror(errno));
os_free(range); os_free(range);
return -1; return -1;
} else if (iwr.u.data.length >= minlen && } else if (iwr.u.data.length >= minlen &&
@ -1613,7 +1620,8 @@ static int wpa_driver_wext_set_psk(struct wpa_driver_wext_data *drv,
ret = ioctl(drv->ioctl_sock, SIOCSIWENCODEEXT, &iwr); ret = ioctl(drv->ioctl_sock, SIOCSIWENCODEEXT, &iwr);
if (ret < 0) if (ret < 0)
perror("ioctl[SIOCSIWENCODEEXT] PMK"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWENCODEEXT] PMK: %s",
strerror(errno));
os_free(ext); os_free(ext);
return ret; return ret;
@ -1705,7 +1713,8 @@ static int wpa_driver_wext_set_key_ext(void *priv, enum wpa_alg alg,
ret = -2; ret = -2;
} }
perror("ioctl[SIOCSIWENCODEEXT]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWENCODEEXT]: %s",
strerror(errno));
} }
os_free(ext); os_free(ext);
@ -1779,7 +1788,8 @@ int wpa_driver_wext_set_key(const char *ifname, void *priv, enum wpa_alg alg,
iwr.u.encoding.length = key_len; iwr.u.encoding.length = key_len;
if (ioctl(drv->ioctl_sock, SIOCSIWENCODE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWENCODE, &iwr) < 0) {
perror("ioctl[SIOCSIWENCODE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWENCODE]: %s",
strerror(errno));
ret = -1; ret = -1;
} }
@ -1791,7 +1801,9 @@ int wpa_driver_wext_set_key(const char *ifname, void *priv, enum wpa_alg alg,
iwr.u.encoding.pointer = (caddr_t) NULL; iwr.u.encoding.pointer = (caddr_t) NULL;
iwr.u.encoding.length = 0; iwr.u.encoding.length = 0;
if (ioctl(drv->ioctl_sock, SIOCSIWENCODE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWENCODE, &iwr) < 0) {
perror("ioctl[SIOCSIWENCODE] (set_tx)"); wpa_printf(MSG_ERROR,
"ioctl[SIOCSIWENCODE] (set_tx): %s",
strerror(errno));
ret = -1; ret = -1;
} }
} }
@ -1840,7 +1852,8 @@ static int wpa_driver_wext_mlme(struct wpa_driver_wext_data *drv,
iwr.u.data.length = sizeof(mlme); iwr.u.data.length = sizeof(mlme);
if (ioctl(drv->ioctl_sock, SIOCSIWMLME, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWMLME, &iwr) < 0) {
perror("ioctl[SIOCSIWMLME]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWMLME]: %s",
strerror(errno));
ret = -1; ret = -1;
} }
@ -1863,7 +1876,8 @@ static void wpa_driver_wext_disconnect(struct wpa_driver_wext_data *drv)
os_memset(&iwr, 0, sizeof(iwr)); os_memset(&iwr, 0, sizeof(iwr));
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ); os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
if (ioctl(drv->ioctl_sock, SIOCGIWMODE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCGIWMODE, &iwr) < 0) {
perror("ioctl[SIOCGIWMODE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIWMODE]: %s",
strerror(errno));
iwr.u.mode = IW_MODE_INFRA; iwr.u.mode = IW_MODE_INFRA;
} }
@ -1928,7 +1942,8 @@ static int wpa_driver_wext_set_gen_ie(void *priv, const u8 *ie,
iwr.u.data.length = ie_len; iwr.u.data.length = ie_len;
if (ioctl(drv->ioctl_sock, SIOCSIWGENIE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWGENIE, &iwr) < 0) {
perror("ioctl[SIOCSIWGENIE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWGENIE]: %s",
strerror(errno));
ret = -1; ret = -1;
} }
@ -2005,7 +2020,8 @@ wpa_driver_wext_auth_alg_fallback(struct wpa_driver_wext_data *drv,
} }
if (ioctl(drv->ioctl_sock, SIOCSIWENCODE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWENCODE, &iwr) < 0) {
perror("ioctl[SIOCSIWENCODE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWENCODE]: %s",
strerror(errno));
ret = -1; ret = -1;
} }
@ -2182,7 +2198,8 @@ int wpa_driver_wext_set_mode(void *priv, int mode)
} }
if (errno != EBUSY) { if (errno != EBUSY) {
perror("ioctl[SIOCSIWMODE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWMODE]: %s",
strerror(errno));
goto done; goto done;
} }
@ -2191,7 +2208,8 @@ int wpa_driver_wext_set_mode(void *priv, int mode)
* down, try to set the mode again, and bring it back up. * down, try to set the mode again, and bring it back up.
*/ */
if (ioctl(drv->ioctl_sock, SIOCGIWMODE, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCGIWMODE, &iwr) < 0) {
perror("ioctl[SIOCGIWMODE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIWMODE]: %s",
strerror(errno));
goto done; goto done;
} }
@ -2204,7 +2222,8 @@ int wpa_driver_wext_set_mode(void *priv, int mode)
/* Try to set the mode again while the interface is down */ /* Try to set the mode again while the interface is down */
iwr.u.mode = new_mode; iwr.u.mode = new_mode;
if (ioctl(drv->ioctl_sock, SIOCSIWMODE, &iwr) < 0) if (ioctl(drv->ioctl_sock, SIOCSIWMODE, &iwr) < 0)
perror("ioctl[SIOCSIWMODE]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWMODE]: %s",
strerror(errno));
else else
ret = 0; ret = 0;
@ -2237,7 +2256,8 @@ static int wpa_driver_wext_pmksa(struct wpa_driver_wext_data *drv,
if (ioctl(drv->ioctl_sock, SIOCSIWPMKSA, &iwr) < 0) { if (ioctl(drv->ioctl_sock, SIOCSIWPMKSA, &iwr) < 0) {
if (errno != EOPNOTSUPP) if (errno != EOPNOTSUPP)
perror("ioctl[SIOCSIWPMKSA]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIWPMKSA]: %s",
strerror(errno));
ret = -1; ret = -1;
} }

View File

@ -100,7 +100,7 @@ static int wired_multicast_membership(int sock, int ifindex,
if (setsockopt(sock, SOL_PACKET, if (setsockopt(sock, SOL_PACKET,
add ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP, add ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP,
&mreq, sizeof(mreq)) < 0) { &mreq, sizeof(mreq)) < 0) {
perror("setsockopt"); wpa_printf(MSG_ERROR, "setsockopt: %s", strerror(errno));
return -1; return -1;
} }
return 0; return 0;
@ -158,7 +158,7 @@ static void handle_read(int sock, void *eloop_ctx, void *sock_ctx)
len = recv(sock, buf, sizeof(buf), 0); len = recv(sock, buf, sizeof(buf), 0);
if (len < 0) { if (len < 0) {
perror("recv"); wpa_printf(MSG_ERROR, "recv: %s", strerror(errno));
return; return;
} }
@ -176,7 +176,7 @@ static void handle_dhcp(int sock, void *eloop_ctx, void *sock_ctx)
len = recv(sock, buf, sizeof(buf), 0); len = recv(sock, buf, sizeof(buf), 0);
if (len < 0) { if (len < 0) {
perror("recv"); wpa_printf(MSG_ERROR, "recv: %s", strerror(errno));
return; return;
} }
@ -209,19 +209,21 @@ static int wired_init_sockets(struct wpa_driver_wired_data *drv, u8 *own_addr)
drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_PAE)); drv->sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_PAE));
if (drv->sock < 0) { if (drv->sock < 0) {
perror("socket[PF_PACKET,SOCK_RAW]"); wpa_printf(MSG_ERROR, "socket[PF_PACKET,SOCK_RAW]: %s",
strerror(errno));
return -1; return -1;
} }
if (eloop_register_read_sock(drv->sock, handle_read, drv->ctx, NULL)) { if (eloop_register_read_sock(drv->sock, handle_read, drv->ctx, NULL)) {
printf("Could not register read socket\n"); wpa_printf(MSG_INFO, "Could not register read socket");
return -1; return -1;
} }
os_memset(&ifr, 0, sizeof(ifr)); os_memset(&ifr, 0, sizeof(ifr));
os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name)); os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) { if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) {
perror("ioctl(SIOCGIFINDEX)"); wpa_printf(MSG_ERROR, "ioctl(SIOCGIFINDEX): %s",
strerror(errno));
return -1; return -1;
} }
@ -232,7 +234,7 @@ static int wired_init_sockets(struct wpa_driver_wired_data *drv, u8 *own_addr)
addr.sll_ifindex); addr.sll_ifindex);
if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (bind(drv->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("bind"); wpa_printf(MSG_ERROR, "bind: %s", strerror(errno));
return -1; return -1;
} }
@ -247,26 +249,28 @@ static int wired_init_sockets(struct wpa_driver_wired_data *drv, u8 *own_addr)
os_memset(&ifr, 0, sizeof(ifr)); os_memset(&ifr, 0, sizeof(ifr));
os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name)); os_strlcpy(ifr.ifr_name, drv->ifname, sizeof(ifr.ifr_name));
if (ioctl(drv->sock, SIOCGIFHWADDR, &ifr) != 0) { if (ioctl(drv->sock, SIOCGIFHWADDR, &ifr) != 0) {
perror("ioctl(SIOCGIFHWADDR)"); wpa_printf(MSG_ERROR, "ioctl(SIOCGIFHWADDR): %s",
strerror(errno));
return -1; return -1;
} }
if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) { if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
printf("Invalid HW-addr family 0x%04x\n", wpa_printf(MSG_INFO, "Invalid HW-addr family 0x%04x",
ifr.ifr_hwaddr.sa_family); ifr.ifr_hwaddr.sa_family);
return -1; return -1;
} }
os_memcpy(own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN); os_memcpy(own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
/* setup dhcp listen socket for sta detection */ /* setup dhcp listen socket for sta detection */
if ((drv->dhcp_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { if ((drv->dhcp_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
perror("socket call failed for dhcp"); wpa_printf(MSG_ERROR, "socket call failed for dhcp: %s",
strerror(errno));
return -1; return -1;
} }
if (eloop_register_read_sock(drv->dhcp_sock, handle_dhcp, drv->ctx, if (eloop_register_read_sock(drv->dhcp_sock, handle_dhcp, drv->ctx,
NULL)) { NULL)) {
printf("Could not register read socket\n"); wpa_printf(MSG_INFO, "Could not register read socket");
return -1; return -1;
} }
@ -277,12 +281,14 @@ static int wired_init_sockets(struct wpa_driver_wired_data *drv, u8 *own_addr)
if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_REUSEADDR, (char *) &n, if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_REUSEADDR, (char *) &n,
sizeof(n)) == -1) { sizeof(n)) == -1) {
perror("setsockopt[SOL_SOCKET,SO_REUSEADDR]"); wpa_printf(MSG_ERROR, "setsockopt[SOL_SOCKET,SO_REUSEADDR]: %s",
strerror(errno));
return -1; return -1;
} }
if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BROADCAST, (char *) &n, if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BROADCAST, (char *) &n,
sizeof(n)) == -1) { sizeof(n)) == -1) {
perror("setsockopt[SOL_SOCKET,SO_BROADCAST]"); wpa_printf(MSG_ERROR, "setsockopt[SOL_SOCKET,SO_BROADCAST]: %s",
strerror(errno));
return -1; return -1;
} }
@ -290,13 +296,15 @@ static int wired_init_sockets(struct wpa_driver_wired_data *drv, u8 *own_addr)
os_strlcpy(ifr.ifr_ifrn.ifrn_name, drv->ifname, IFNAMSIZ); os_strlcpy(ifr.ifr_ifrn.ifrn_name, drv->ifname, IFNAMSIZ);
if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BINDTODEVICE, if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BINDTODEVICE,
(char *) &ifr, sizeof(ifr)) < 0) { (char *) &ifr, sizeof(ifr)) < 0) {
perror("setsockopt[SOL_SOCKET,SO_BINDTODEVICE]"); wpa_printf(MSG_ERROR,
"setsockopt[SOL_SOCKET,SO_BINDTODEVICE]: %s",
strerror(errno));
return -1; return -1;
} }
if (bind(drv->dhcp_sock, (struct sockaddr *) &addr2, if (bind(drv->dhcp_sock, (struct sockaddr *) &addr2,
sizeof(struct sockaddr)) == -1) { sizeof(struct sockaddr)) == -1) {
perror("bind"); wpa_printf(MSG_ERROR, "bind: %s", strerror(errno));
return -1; return -1;
} }
@ -320,8 +328,9 @@ static int wired_send_eapol(void *priv, const u8 *addr,
len = sizeof(*hdr) + data_len; len = sizeof(*hdr) + data_len;
hdr = os_zalloc(len); hdr = os_zalloc(len);
if (hdr == NULL) { if (hdr == NULL) {
printf("malloc() failed for wired_send_eapol(len=%lu)\n", wpa_printf(MSG_INFO,
(unsigned long) len); "malloc() failed for wired_send_eapol(len=%lu)",
(unsigned long) len);
return -1; return -1;
} }
@ -337,9 +346,9 @@ static int wired_send_eapol(void *priv, const u8 *addr,
os_free(hdr); os_free(hdr);
if (res < 0) { if (res < 0) {
perror("wired_send_eapol: send"); wpa_printf(MSG_ERROR,
printf("wired_send_eapol - packet len: %lu - failed\n", "wired_send_eapol - packet len: %lu - failed: send: %s",
(unsigned long) len); (unsigned long) len, strerror(errno));
} }
return res; return res;
@ -353,7 +362,8 @@ static void * wired_driver_hapd_init(struct hostapd_data *hapd,
drv = os_zalloc(sizeof(struct wpa_driver_wired_data)); drv = os_zalloc(sizeof(struct wpa_driver_wired_data));
if (drv == NULL) { if (drv == NULL) {
printf("Could not allocate memory for wired driver data\n"); wpa_printf(MSG_INFO,
"Could not allocate memory for wired driver data");
return NULL; return NULL;
} }
@ -418,14 +428,15 @@ static int wpa_driver_wired_get_ifflags(const char *ifname, int *flags)
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_ERROR, "socket: %s", strerror(errno));
return -1; return -1;
} }
os_memset(&ifr, 0, sizeof(ifr)); os_memset(&ifr, 0, sizeof(ifr));
os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
perror("ioctl[SIOCGIFFLAGS]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIFFLAGS]: %s",
strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -442,7 +453,7 @@ static int wpa_driver_wired_set_ifflags(const char *ifname, int flags)
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_ERROR, "socket: %s", strerror(errno));
return -1; return -1;
} }
@ -450,7 +461,8 @@ static int wpa_driver_wired_set_ifflags(const char *ifname, int flags)
os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
ifr.ifr_flags = flags & 0xffff; ifr.ifr_flags = flags & 0xffff;
if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) { if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
perror("ioctl[SIOCSIFFLAGS]"); wpa_printf(MSG_ERROR, "ioctl[SIOCSIFFLAGS]: %s",
strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -467,14 +479,15 @@ static int wpa_driver_wired_get_ifstatus(const char *ifname, int *status)
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_ERROR, "socket: %s", strerror(errno));
return -1; return -1;
} }
os_memset(&ifmr, 0, sizeof(ifmr)); os_memset(&ifmr, 0, sizeof(ifmr));
os_strlcpy(ifmr.ifm_name, ifname, IFNAMSIZ); os_strlcpy(ifmr.ifm_name, ifname, IFNAMSIZ);
if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) { if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
perror("ioctl[SIOCGIFMEDIA]"); wpa_printf(MSG_ERROR, "ioctl[SIOCGIFMEDIA]: %s",
strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -498,7 +511,7 @@ static int wpa_driver_wired_multi(const char *ifname, const u8 *addr, int add)
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_ERROR, "socket: %s", strerror(errno));
return -1; return -1;
} }
@ -532,7 +545,8 @@ static int wpa_driver_wired_multi(const char *ifname, const u8 *addr, int add)
#endif /* defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) */ #endif /* defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) */
if (ioctl(s, add ? SIOCADDMULTI : SIOCDELMULTI, (caddr_t) &ifr) < 0) { if (ioctl(s, add ? SIOCADDMULTI : SIOCDELMULTI, (caddr_t) &ifr) < 0) {
perror("ioctl[SIOC{ADD/DEL}MULTI]"); wpa_printf(MSG_ERROR, "ioctl[SIOC{ADD/DEL}MULTI]: %s",
strerror(errno));
close(s); close(s);
return -1; return -1;
} }
@ -555,7 +569,7 @@ static void * wpa_driver_wired_init(void *ctx, const char *ifname)
#ifdef __linux__ #ifdef __linux__
drv->pf_sock = socket(PF_PACKET, SOCK_DGRAM, 0); drv->pf_sock = socket(PF_PACKET, SOCK_DGRAM, 0);
if (drv->pf_sock < 0) if (drv->pf_sock < 0)
perror("socket(PF_PACKET)"); wpa_printf(MSG_ERROR, "socket(PF_PACKET): %s", strerror(errno));
#else /* __linux__ */ #else /* __linux__ */
drv->pf_sock = -1; drv->pf_sock = -1;
#endif /* __linux__ */ #endif /* __linux__ */

View File

@ -54,15 +54,16 @@ static int l2_packet_init_libdnet(struct l2_packet_data *l2)
l2->eth = eth_open(l2->ifname); l2->eth = eth_open(l2->ifname);
if (!l2->eth) { if (!l2->eth) {
printf("Failed to open interface '%s'.\n", l2->ifname); wpa_printf(MSG_ERROR,
perror("eth_open"); "Failed to open interface '%s' - eth_open: %s",
l2->ifname, strerror(errno));
return -1; return -1;
} }
if (eth_get(l2->eth, &own_addr) < 0) { if (eth_get(l2->eth, &own_addr) < 0) {
printf("Failed to get own hw address from interface '%s'.\n", wpa_printf(MSG_ERROR,
l2->ifname); "Failed to get own hw address from interface '%s' - eth_get: %s",
perror("eth_get"); l2->ifname, strerror(errno));
eth_close(l2->eth); eth_close(l2->eth);
l2->eth = NULL; l2->eth = NULL;
return -1; return -1;

View File

@ -44,7 +44,7 @@ static int wpa_priv_cmd(struct l2_packet_data *l2, int cmd,
msg.msg_namelen = sizeof(l2->priv_addr); msg.msg_namelen = sizeof(l2->priv_addr);
if (sendmsg(l2->fd, &msg, 0) < 0) { if (sendmsg(l2->fd, &msg, 0) < 0) {
perror("L2: sendmsg(cmd)"); wpa_printf(MSG_ERROR, "L2: sendmsg(cmd): %s", strerror(errno));
return -1; return -1;
} }
@ -82,7 +82,8 @@ int l2_packet_send(struct l2_packet_data *l2, const u8 *dst_addr, u16 proto,
msg.msg_namelen = sizeof(l2->priv_addr); msg.msg_namelen = sizeof(l2->priv_addr);
if (sendmsg(l2->fd, &msg, 0) < 0) { if (sendmsg(l2->fd, &msg, 0) < 0) {
perror("L2: sendmsg(packet_send)"); wpa_printf(MSG_ERROR, "L2: sendmsg(packet_send): %s",
strerror(errno));
return -1; return -1;
} }
@ -102,7 +103,8 @@ static void l2_packet_receive(int sock, void *eloop_ctx, void *sock_ctx)
res = recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr *) &from, res = recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr *) &from,
&fromlen); &fromlen);
if (res < 0) { if (res < 0) {
perror("l2_packet_receive - recvfrom"); wpa_printf(MSG_ERROR, "l2_packet_receive - recvfrom: %s",
strerror(errno));
return; return;
} }
if (res < ETH_ALEN) { if (res < ETH_ALEN) {
@ -162,7 +164,7 @@ struct l2_packet_data * l2_packet_init(
l2->fd = socket(PF_UNIX, SOCK_DGRAM, 0); l2->fd = socket(PF_UNIX, SOCK_DGRAM, 0);
if (l2->fd < 0) { if (l2->fd < 0) {
perror("socket(PF_UNIX)"); wpa_printf(MSG_ERROR, "socket(PF_UNIX): %s", strerror(errno));
os_free(l2->own_socket_path); os_free(l2->own_socket_path);
l2->own_socket_path = NULL; l2->own_socket_path = NULL;
os_free(l2); os_free(l2);
@ -173,7 +175,8 @@ struct l2_packet_data * l2_packet_init(
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
os_strlcpy(addr.sun_path, l2->own_socket_path, sizeof(addr.sun_path)); os_strlcpy(addr.sun_path, l2->own_socket_path, sizeof(addr.sun_path));
if (bind(l2->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (bind(l2->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("l2-pkt-privsep: bind(PF_UNIX)"); wpa_printf(MSG_ERROR, "l2-pkt-privsep: bind(PF_UNIX): %s",
strerror(errno));
goto fail; goto fail;
} }
@ -191,14 +194,14 @@ struct l2_packet_data * l2_packet_init(
tv.tv_usec = 0; tv.tv_usec = 0;
res = select(l2->fd + 1, &rfds, NULL, NULL, &tv); res = select(l2->fd + 1, &rfds, NULL, NULL, &tv);
if (res < 0 && errno != EINTR) { if (res < 0 && errno != EINTR) {
perror("select"); wpa_printf(MSG_ERROR, "select: %s", strerror(errno));
goto fail; goto fail;
} }
if (FD_ISSET(l2->fd, &rfds)) { if (FD_ISSET(l2->fd, &rfds)) {
res = recv(l2->fd, reply, sizeof(reply), 0); res = recv(l2->fd, reply, sizeof(reply), 0);
if (res < 0) { if (res < 0) {
perror("recv"); wpa_printf(MSG_ERROR, "recv: %s", strerror(errno));
goto fail; goto fail;
} }
} else { } else {

View File

@ -87,7 +87,7 @@ int hs20_web_browser(const char *url)
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
perror("fork"); wpa_printf(MSG_ERROR, "fork: %s", strerror(errno));
http_server_deinit(http); http_server_deinit(http);
eloop_destroy(); eloop_destroy();
return -1; return -1;
@ -108,7 +108,7 @@ int hs20_web_browser(const char *url)
argv[8] = NULL; argv[8] = NULL;
execv("/system/bin/am", argv); execv("/system/bin/am", argv);
perror("execv"); wpa_printf(MSG_ERROR, "execv: %s", strerror(errno));
exit(0); exit(0);
return -1; return -1;
} }

View File

@ -87,7 +87,7 @@ int hs20_web_browser(const char *url)
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
perror("fork"); wpa_printf(MSG_ERROR, "fork: %s", strerror(errno));
http_server_deinit(http); http_server_deinit(http);
eloop_destroy(); eloop_destroy();
return -1; return -1;
@ -102,7 +102,7 @@ int hs20_web_browser(const char *url)
argv[2] = NULL; argv[2] = NULL;
execv("/usr/bin/x-www-browser", argv); execv("/usr/bin/x-www-browser", argv);
perror("execv"); wpa_printf(MSG_ERROR, "execv: %s", strerror(errno));
exit(0); exit(0);
return -1; return -1;
} }

View File

@ -88,7 +88,7 @@ int hs20_web_browser(const char *url)
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
perror("fork"); wpa_printf(MSG_ERROR, "fork: %s", strerror(errno));
http_server_deinit(http); http_server_deinit(http);
eloop_destroy(); eloop_destroy();
return -1; return -1;
@ -112,7 +112,7 @@ int hs20_web_browser(const char *url)
argv[11] = NULL; argv[11] = NULL;
execv("/system/bin/am", argv); execv("/system/bin/am", argv);
perror("execv"); wpa_printf(MSG_ERROR, "execv: %s", strerror(errno));
exit(0); exit(0);
return -1; return -1;
} }

View File

@ -98,7 +98,7 @@ int os_gmtime(os_time_t t, struct os_tm *tm)
int os_daemonize(const char *pid_file) int os_daemonize(const char *pid_file)
{ {
if (daemon(0, 0)) { if (daemon(0, 0)) {
perror("daemon"); wpa_printf(MSG_ERROR, "daemon: %s", strerror(errno));
return -1; return -1;
} }

View File

@ -33,7 +33,7 @@ static void get_prg_fname(void)
os_snprintf(exe, sizeof(exe) - 1, "/proc/%u/exe", getpid()); os_snprintf(exe, sizeof(exe) - 1, "/proc/%u/exe", getpid());
len = readlink(exe, fname, sizeof(fname) - 1); len = readlink(exe, fname, sizeof(fname) - 1);
if (len < 0 || len >= (int) sizeof(fname)) { if (len < 0 || len >= (int) sizeof(fname)) {
perror("readlink"); wpa_printf(MSG_ERROR, "readlink: %s", strerror(errno));
return; return;
} }
fname[len] = '\0'; fname[len] = '\0';

View File

@ -50,7 +50,7 @@ static int inject_frame(int s, const void *data, size_t len)
ret = sendmsg(s, &msg, 0); ret = sendmsg(s, &msg, 0);
if (ret < 0) if (ret < 0)
perror("sendmsg"); wpa_printf(MSG_ERROR, "sendmsg: %s", strerror(errno));
return ret; return ret;
} }

View File

@ -218,7 +218,8 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
res = recvfrom(sock, buf, sizeof(buf) - 1, 0, res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
(struct sockaddr *) &from, &fromlen); (struct sockaddr *) &from, &fromlen);
if (res < 0) { if (res < 0) {
perror("recvfrom(ctrl_iface)"); wpa_printf(MSG_ERROR, "recvfrom(ctrl_iface): %s",
strerror(errno));
return; return;
} }
@ -356,7 +357,7 @@ wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s)
priv->sock = socket(domain, SOCK_DGRAM, 0); priv->sock = socket(domain, SOCK_DGRAM, 0);
if (priv->sock < 0) { if (priv->sock < 0) {
perror("socket(PF_INET)"); wpa_printf(MSG_ERROR, "socket(PF_INET): %s", strerror(errno));
goto fail; goto fail;
} }
@ -386,7 +387,7 @@ try_again:
port--; port--;
if ((WPA_CTRL_IFACE_PORT - port) < WPA_CTRL_IFACE_PORT_LIMIT) if ((WPA_CTRL_IFACE_PORT - port) < WPA_CTRL_IFACE_PORT_LIMIT)
goto try_again; goto try_again;
perror("bind(AF_INET)"); wpa_printf(MSG_ERROR, "bind(AF_INET): %s", strerror(errno));
goto fail; goto fail;
} }
@ -482,7 +483,9 @@ static void wpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv,
if (sendto(priv->sock, sbuf, llen + len, 0, if (sendto(priv->sock, sbuf, llen + len, 0,
(struct sockaddr *) &dst->addr, (struct sockaddr *) &dst->addr,
sizeof(dst->addr)) < 0) { sizeof(dst->addr)) < 0) {
perror("sendto(CTRL_IFACE monitor)"); wpa_printf(MSG_ERROR,
"sendto(CTRL_IFACE monitor): %s",
strerror(errno));
dst->errors++; dst->errors++;
if (dst->errors > 10) { if (dst->errors > 10) {
wpa_supplicant_ctrl_iface_detach( wpa_supplicant_ctrl_iface_detach(
@ -551,7 +554,8 @@ static void wpa_supplicant_global_ctrl_iface_receive(int sock, void *eloop_ctx,
res = recvfrom(sock, buf, sizeof(buf) - 1, 0, res = recvfrom(sock, buf, sizeof(buf) - 1, 0,
(struct sockaddr *) &from, &fromlen); (struct sockaddr *) &from, &fromlen);
if (res < 0) { if (res < 0) {
perror("recvfrom(ctrl_iface)"); wpa_printf(MSG_ERROR, "recvfrom(ctrl_iface): %s",
strerror(errno));
return; return;
} }
@ -634,7 +638,7 @@ wpa_supplicant_global_ctrl_iface_init(struct wpa_global *global)
priv->sock = socket(PF_INET, SOCK_DGRAM, 0); priv->sock = socket(PF_INET, SOCK_DGRAM, 0);
if (priv->sock < 0) { if (priv->sock < 0) {
perror("socket(PF_INET)"); wpa_printf(MSG_ERROR, "socket(PF_INET): %s", strerror(errno));
goto fail; goto fail;
} }
@ -652,7 +656,7 @@ try_again:
if ((port - WPA_GLOBAL_CTRL_IFACE_PORT) < if ((port - WPA_GLOBAL_CTRL_IFACE_PORT) <
WPA_GLOBAL_CTRL_IFACE_PORT_LIMIT) WPA_GLOBAL_CTRL_IFACE_PORT_LIMIT)
goto try_again; goto try_again;
perror("bind(AF_INET)"); wpa_printf(MSG_ERROR, "bind(AF_INET): %s", strerror(errno));
goto fail; goto fail;
} }

View File

@ -315,7 +315,8 @@ static void mesh_rsn_send_auth(struct wpa_supplicant *wpa_s,
" auth_transaction=%d resp=%d (IE len=%lu)", " auth_transaction=%d resp=%d (IE len=%lu)",
MAC2STR(dst), auth_transaction, resp, (unsigned long) ielen); MAC2STR(dst), auth_transaction, resp, (unsigned long) ielen);
if (wpa_drv_send_mlme(wpa_s, buf, len, 0) < 0) if (wpa_drv_send_mlme(wpa_s, buf, len, 0) < 0)
perror("send_auth_reply: send"); wpa_printf(MSG_INFO, "send_auth_reply: send_mlme failed: %s",
strerror(errno));
os_free(buf); os_free(buf);
} }

View File

@ -335,7 +335,7 @@ static void wpa_priv_l2_rx(void *ctx, const u8 *src_addr, const u8 *buf,
msg.msg_namelen = sizeof(iface->l2_addr); msg.msg_namelen = sizeof(iface->l2_addr);
if (sendmsg(iface->fd, &msg, 0) < 0) { if (sendmsg(iface->fd, &msg, 0) < 0) {
perror("sendmsg(l2 rx)"); wpa_printf(MSG_ERROR, "sendmsg(l2 rx): %s", strerror(errno));
} }
} }
@ -467,7 +467,7 @@ static void wpa_priv_receive(int sock, void *eloop_ctx, void *sock_ctx)
res = recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr *) &from, res = recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr *) &from,
&fromlen); &fromlen);
if (res < 0) { if (res < 0) {
perror("recvfrom"); wpa_printf(MSG_ERROR, "recvfrom: %s", strerror(errno));
return; return;
} }
@ -615,7 +615,7 @@ wpa_priv_interface_init(const char *dir, const char *params)
iface->fd = socket(PF_UNIX, SOCK_DGRAM, 0); iface->fd = socket(PF_UNIX, SOCK_DGRAM, 0);
if (iface->fd < 0) { if (iface->fd < 0) {
perror("socket(PF_UNIX)"); wpa_printf(MSG_ERROR, "socket(PF_UNIX): %s", strerror(errno));
wpa_priv_interface_deinit(iface); wpa_priv_interface_deinit(iface);
return NULL; return NULL;
} }
@ -633,15 +633,16 @@ wpa_priv_interface_init(const char *dir, const char *params)
"allow connections - assuming it was " "allow connections - assuming it was "
"leftover from forced program termination"); "leftover from forced program termination");
if (unlink(iface->sock_name) < 0) { if (unlink(iface->sock_name) < 0) {
perror("unlink[ctrl_iface]"); wpa_printf(MSG_ERROR,
wpa_printf(MSG_ERROR, "Could not unlink " "Could not unlink existing ctrl_iface socket '%s': %s",
"existing ctrl_iface socket '%s'", iface->sock_name, strerror(errno));
iface->sock_name);
goto fail; goto fail;
} }
if (bind(iface->fd, (struct sockaddr *) &addr, if (bind(iface->fd, (struct sockaddr *) &addr,
sizeof(addr)) < 0) { sizeof(addr)) < 0) {
perror("wpa-priv-iface-init: bind(PF_UNIX)"); wpa_printf(MSG_ERROR,
"wpa-priv-iface-init: bind(PF_UNIX): %s",
strerror(errno));
goto fail; goto fail;
} }
wpa_printf(MSG_DEBUG, "Successfully replaced leftover " wpa_printf(MSG_DEBUG, "Successfully replaced leftover "
@ -656,7 +657,7 @@ wpa_priv_interface_init(const char *dir, const char *params)
} }
if (chmod(iface->sock_name, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { if (chmod(iface->sock_name, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
perror("chmod"); wpa_printf(MSG_ERROR, "chmod: %s", strerror(errno));
goto fail; goto fail;
} }
@ -688,7 +689,8 @@ static int wpa_priv_send_event(struct wpa_priv_interface *iface, int event,
msg.msg_namelen = sizeof(iface->drv_addr); msg.msg_namelen = sizeof(iface->drv_addr);
if (sendmsg(iface->fd, &msg, 0) < 0) { if (sendmsg(iface->fd, &msg, 0) < 0) {
perror("sendmsg(wpas_socket)"); wpa_printf(MSG_ERROR, "sendmsg(wpas_socket): %s",
strerror(errno));
return -1; return -1;
} }
@ -903,7 +905,8 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
msg.msg_namelen = sizeof(iface->drv_addr); msg.msg_namelen = sizeof(iface->drv_addr);
if (sendmsg(iface->fd, &msg, 0) < 0) if (sendmsg(iface->fd, &msg, 0) < 0)
perror("sendmsg(wpas_socket)"); wpa_printf(MSG_ERROR, "sendmsg(wpas_socket): %s",
strerror(errno));
} }