Annotation of embedtools/src/vap.c, revision 1.1.2.2
1.1.2.1 misho 1: #include "global.h"
2: #include "dwds.h"
3:
4:
1.1.2.2 ! misho 5: inline int
! 6: wifi_getParent(const char *csVAP, char *psParent, size_t plen)
! 7: {
! 8: char szOID[STRSIZ] = { 0 };
! 9:
! 10: FTRACE(5);
! 11:
! 12: assert(csVAP);
! 13: assert(psParent);
! 14:
! 15: memset(psParent, 0, plen);
! 16: snprintf(szOID, STRSIZ, "net.wlan.%s.%%parent", csVAP + 4);
! 17: if (sysctlbyname(szOID, psParent, &plen, NULL, 0) == -1) {
! 18: syslog(LOG_ERR, "Error:: can`t get parent #%d - %s\n", errno, strerror(errno));
! 19: return -1;
! 20: } else
! 21: psParent[plen] = 0;
! 22:
! 23: return 0;
! 24: }
! 25:
! 26: inline int
! 27: wifi_chkIface(const char *csIface, char **ppsIF, int nIF)
! 28: {
! 29: char szParent[IFNAMSIZ];
! 30: register int i;
! 31:
! 32: FTRACE(5);
! 33:
! 34: assert(csIface);
! 35:
! 36: if (wifi_getParent(csIface, szParent, IFNAMSIZ) == -1)
! 37: return -1;
! 38:
! 39: for (i = 0; i < nIF; i++)
! 40: if (!strcasecmp(ppsIF[i], "any") || !strcmp(ppsIF[i], szParent))
! 41: return 1; /* OK, vap is child */
! 42:
! 43: syslog(LOG_ERR, "Error:: Interface %s parent %s not being monitored", csIface, szParent);
! 44: return 0;
! 45: }
! 46:
! 47: inline int
! 48: wifi_isWDS(int fd, const char *csVAP)
! 49: {
! 50: struct ifmediareq ifmr;
! 51:
! 52: FTRACE(5);
! 53:
! 54: assert(csVAP);
! 55:
! 56: memset(&ifmr, 0, sizeof ifmr);
! 57: strlcpy(ifmr.ifm_name, csVAP, sizeof ifmr.ifm_name);
! 58: if (ioctl(fd, SIOCGIFMEDIA, &ifmr) == -1) {
! 59: syslog(LOG_ERR, "Error:: can`t get media for %s #%d - %s\n", csVAP,
! 60: errno, strerror(errno));
! 61: return -1;
! 62: }
! 63:
! 64: return (ifmr.ifm_current & IFM_IEEE80211_WDS) != 0;
! 65: }
! 66:
! 67: inline int
! 68: wifi_getBSSID(int fd, const char *csVAP, uint8_t *psBSSID, int len)
! 69: {
! 70: struct ieee80211req ireq;
! 71:
! 72: FTRACE(5);
! 73:
! 74: assert(csVAP);
! 75: assert(psBSSID);
! 76:
! 77: memset(&ireq, 0, sizeof ireq);
! 78: strlcpy(ireq.i_name, csVAP, sizeof ireq.i_name);
! 79: ireq.i_type = IEEE80211_IOC_BSSID;
! 80: ireq.i_data = psBSSID;
! 81: ireq.i_len = len;
! 82: if (ioctl(fd, SIOCG80211, &ireq) == -1) {
! 83: syslog(LOG_ERR, "Error:: can`t get BSSID for %s #%d - %s\n", csVAP,
! 84: errno, strerror(errno));
! 85: return -1;
! 86: }
! 87:
! 88: return 0;
! 89: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>