Solaris: Add support for wired IEEE 802.1X client

This patch adds support for wired IEEE 802.1X client on the Solaris.

I have tested with these:
OS : OpenSolaris 2009.06
EAP : EAP-MD5
Switch : Cisco Catalyst 2950
This commit is contained in:
Masashi Honma 2010-08-28 11:40:07 +03:00 committed by Jouni Malinen
parent 9ff80a10e8
commit 60da5e0f3f
5 changed files with 46 additions and 4 deletions

View file

@ -81,7 +81,7 @@ struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path)
counter++; counter++;
try_again: try_again:
ret = os_snprintf(ctrl->local.sun_path, sizeof(ctrl->local.sun_path), ret = os_snprintf(ctrl->local.sun_path, sizeof(ctrl->local.sun_path),
"/tmp/wpa_ctrl_%d-%d", getpid(), counter); "/tmp/wpa_ctrl_%d-%d", (int) getpid(), counter);
if (ret < 0 || (size_t) ret >= sizeof(ctrl->local.sun_path)) { if (ret < 0 || (size_t) ret >= sizeof(ctrl->local.sun_path)) {
close(ctrl->s); close(ctrl->s);
os_free(ctrl); os_free(ctrl);

View file

@ -24,6 +24,9 @@
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
#include <net/if_dl.h> #include <net/if_dl.h>
#endif /* defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) */ #endif /* defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) */
#ifdef __sun__
#include <sys/sockio.h>
#endif /* __sun__ */
#include "common.h" #include "common.h"
#include "eloop.h" #include "eloop.h"
@ -462,6 +465,10 @@ static int wpa_driver_wired_multi(const char *ifname, const u8 *addr, int add)
struct ifreq ifr; struct ifreq ifr;
int s; int s;
#ifdef __sun__
return -1;
#endif /* __sun__ */
s = socket(PF_INET, SOCK_DGRAM, 0); s = socket(PF_INET, SOCK_DGRAM, 0);
if (s < 0) { if (s < 0) {
perror("socket"); perror("socket");

View file

@ -20,7 +20,11 @@
#include <pcap.h> #include <pcap.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#ifdef __sun__
#include <libdlpi.h>
#else /* __sun__ */
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif /* __sun__ */
#include <net/if.h> #include <net/if.h>
#include <net/if_dl.h> #include <net/if_dl.h>
@ -139,6 +143,7 @@ static int l2_packet_init_libpcap(struct l2_packet_data *l2,
} }
pcap_freecode(&pcap_fp); pcap_freecode(&pcap_fp);
#ifndef __sun__
/* /*
* When libpcap uses BPF we must enable "immediate mode" to * When libpcap uses BPF we must enable "immediate mode" to
* receive frames right away; otherwise the system may * receive frames right away; otherwise the system may
@ -153,6 +158,7 @@ static int l2_packet_init_libpcap(struct l2_packet_data *l2,
/* XXX should we fail? */ /* XXX should we fail? */
} }
} }
#endif /* __sun__ */
eloop_register_read_sock(pcap_get_selectable_fd(l2->pcap), eloop_register_read_sock(pcap_get_selectable_fd(l2->pcap),
l2_packet_receive, l2, l2->pcap); l2_packet_receive, l2, l2->pcap);
@ -163,6 +169,30 @@ static int l2_packet_init_libpcap(struct l2_packet_data *l2,
static int eth_get(const char *device, u8 ea[ETH_ALEN]) static int eth_get(const char *device, u8 ea[ETH_ALEN])
{ {
#ifdef __sun__
dlpi_handle_t dh;
u32 physaddrlen = DLPI_PHYSADDR_MAX;
u8 physaddr[DLPI_PHYSADDR_MAX];
int retval;
retval = dlpi_open(device, &dh, 0);
if (retval != DLPI_SUCCESS) {
wpa_printf(MSG_ERROR, "dlpi_open error: %s",
dlpi_strerror(retval));
return -1;
}
retval = dlpi_get_physaddr(dh, DL_CURR_PHYS_ADDR, physaddr,
&physaddrlen);
if (retval != DLPI_SUCCESS) {
wpa_printf(MSG_ERROR, "dlpi_get_physaddr error: %s",
dlpi_strerror(retval));
dlpi_close(dh);
return -1;
}
os_memcpy(ea, physaddr, ETH_ALEN);
dlpi_close(dh);
#else /* __sun__ */
struct if_msghdr *ifm; struct if_msghdr *ifm;
struct sockaddr_dl *sdl; struct sockaddr_dl *sdl;
u_char *p, *buf; u_char *p, *buf;
@ -195,6 +225,7 @@ static int eth_get(const char *device, u8 ea[ETH_ALEN])
errno = ESRCH; errno = ESRCH;
return -1; return -1;
} }
#endif /* __sun__ */
return 0; return 0;
} }

View file

@ -135,9 +135,9 @@ static int os_daemon(int nochdir, int noclose)
int os_daemonize(const char *pid_file) int os_daemonize(const char *pid_file)
{ {
#ifdef __uClinux__ #if defined(__uClinux__) || defined(__sun__)
return -1; return -1;
#else /* __uClinux__ */ #else /* defined(__uClinux__) || defined(__sun__) */
if (os_daemon(0, 0)) { if (os_daemon(0, 0)) {
perror("daemon"); perror("daemon");
return -1; return -1;
@ -152,7 +152,7 @@ int os_daemonize(const char *pid_file)
} }
return -0; return -0;
#endif /* __uClinux__ */ #endif /* defined(__uClinux__) || defined(__sun__) */
} }

View file

@ -123,6 +123,10 @@ CONFIG_DRIVER_WIRED=y
# Driver interface for no driver (e.g., WPS ER only) # Driver interface for no driver (e.g., WPS ER only)
#CONFIG_DRIVER_NONE=y #CONFIG_DRIVER_NONE=y
# Solaris libraries
#LIBS += -lsocket -ldlpi -lnsl
#LIBS_c += -lsocket
# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is # Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
# included) # included)
CONFIG_IEEE8021X_EAPOL=y CONFIG_IEEE8021X_EAPOL=y