diff --git a/net/wmwave/Makefile b/net/wmwave/Makefile index 622f3e71ea5a..1bcc8487881e 100644 --- a/net/wmwave/Makefile +++ b/net/wmwave/Makefile @@ -1,31 +1,31 @@ PORTNAME= wmwave DISTVERSION= 0-4 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= net MASTER_SITES= SF/${PORTNAME}/${PORTNAME}/${PORTNAME}-${PORTVERSION} EXTRACT_SUFX= .tgz MAINTAINER= benjsc@FreeBSD.org COMMENT= Display 802.11 status in the WindowMaker Dock -WWW= http://www.schuermann.org/~dockapps/ +WWW= https://sourceforge.net/projects/wmwave/ -BROKEN_FreeBSD_13= ld: error: duplicate symbol: display -BROKEN_FreeBSD_14= ld: error: duplicate symbol: display +LICENSE= GPLv2 +LICENSE_FILE= ${WRKSRC}/COPYING -USES= xorg -USE_XORG= xpm +USES= localbase:ldflags xorg +USE_XORG= x11 xext xpm PLIST_FILES= bin/wmwave man/man1/wmwave.1.gz WRKSRC= ${WRKDIR}/${PORTNAME} -CFLAGS+= -DWICACHE -I${PREFIX}/include -LDFLAGS+= -L${PREFIX}/lib -lX11 -lXpm -lXext -lm +CFLAGS+= -DWICACHE +LDFLAGS+= -lX11 -lXpm -lXext -lm do-build: ${CC} ${CFLAGS} ${LDFLAGS} ${WRKSRC}/${PORTNAME}.c ${WRKSRC}/wmgeneral.c \ -o ${WRKSRC}/${PORTNAME} do-install: ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin ${INSTALL_MAN} ${WRKSRC}/wmwave.1 ${STAGEDIR}${MANPREFIX}/man/man1 .include diff --git a/net/wmwave/files/patch-wmgeneral.c b/net/wmwave/files/patch-wmgeneral.c new file mode 100644 index 000000000000..3e9c321ee2d4 --- /dev/null +++ b/net/wmwave/files/patch-wmgeneral.c @@ -0,0 +1,13 @@ +--- wmgeneral.c.orig 2022-11-06 10:29:50 UTC ++++ wmgeneral.c +@@ -65,8 +65,9 @@ + /* X11 Variables */ + /*****************/ + ++Display *display; + Window Root; +-int screen; ++extern int screen; + int x_fd; + int d_depth; + XSizeHints mysizehints; diff --git a/net/wmwave/files/patch-wmgeneral.h b/net/wmwave/files/patch-wmgeneral.h new file mode 100644 index 000000000000..0a12cdfd6304 --- /dev/null +++ b/net/wmwave/files/patch-wmgeneral.h @@ -0,0 +1,11 @@ +--- wmgeneral.h.orig 2022-11-06 10:29:16 UTC ++++ wmgeneral.h +@@ -36,7 +36,7 @@ typedef struct { + /* Global variable */ + /*******************/ + +-Display *display; ++extern Display *display; + + /***********************/ + /* Function Prototypes */ diff --git a/net/wmwave/files/patch-wmwave.c b/net/wmwave/files/patch-wmwave.c index 3e4d6832d4f7..984d32f0ad0a 100644 --- a/net/wmwave/files/patch-wmwave.c +++ b/net/wmwave/files/patch-wmwave.c @@ -1,234 +1,242 @@ ---- wmwave.c.orig 2008-02-27 09:24:06.628732284 +1030 -+++ wmwave.c 2008-02-27 09:32:07.088117765 +1030 +--- wmwave.c.orig 1999-08-20 13:44:21 UTC ++++ wmwave.c @@ -29,6 +29,18 @@ * * Revision 1.1 1999/08/15 15:39:18 carsten * Added wmwave project to repository + * + * Authors (in reverse chronological order): + * Benjamin Close + * Hendrik Scholz + * Bruce M. Simpson + * Carsten Schuermann + * Dan Piponi + * Dave Clark + * + * The FreeBSD version of this software is released under the GNU GPL, and + * forms part of the Consume Project . + * * */ -@@ -57,6 +69,23 @@ +@@ -45,6 +57,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -57,6 +70,23 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "wmgeneral.h" -@@ -66,7 +94,9 @@ +@@ -66,7 +96,9 @@ char wmwave_mask_bits[64*64]; int wmwave_mask_width = 64; int wmwave_mask_height = 64; -#define WMWAVE_VERSION "0.4" +#define WMWAVE_VERSION "0.4_FreeBSD-2" +#define WMWAVE_DEFAULT_INTERFACE "wi0" +char *iface = WMWAVE_DEFAULT_INTERFACE; int update_rate=100000; -@@ -125,65 +155,100 @@ +@@ -125,65 +157,100 @@ float min (float x, float y) { } /* - * Find CPU times for all processes + * XXX: Fetch OS-specific wireless statistics. + * + * These are: quality, signal, noise. On NetBSD, the + * statistics kept on an AP-basis for the driver are valid. + * On FreeBSD, we make use of the net80211 layer to display the + * required stats. */ -void DisplayWireless(void) { - FILE *wireless; // File handle for /proc/net/wireless - - char line[255]; - char iface[5]; - char status [3]; - float link = 0; - float level = 0; - float noise = 0; - int nwid = 0; - int crypt = 0; - int misc = 0; - - if ((wireless = fopen ("/proc/net/wireless", "r")) != NULL) - { - fgets(line,sizeof(line),wireless); - fgets(line,sizeof(line),wireless); - if (fgets(line,sizeof(line),wireless) == NULL) { - mode = 0; - } - else { - sscanf(line,"%s %s %f %f %f %d %d %d", - iface,status,&link,&level,&noise,&nwid,&crypt,&misc); - mode = 1; - } - fclose(wireless); - - - /* Print channel information, and signal ratio */ - - switch (mode) { - case 1: BlitString("Quality",4,4); - if (link<=10) {DrawRedDot ();} - else if (link<=20) {DrawYellowDot ();} - else {DrawGreenDot();}; - BlitString("Link ", 4,18); - DrawBar(min ((int)(link * 1.8), 100.0), 4, 27); - BlitString("Level ", 4,32); - DrawGreenBar(min ((int)(level * 0.3), 100.0), 4, 41); - BlitString("Noise ", 4,46); - DrawGreenBar(min ((int)(noise * 0.3), 100.0), 4, 55); - break; - case 0: BlitString("NO CARD",4,4); - DrawEmptyDot(); - BlitString(" ", 4,18); - DrawBar(0.0, 4, 27); - BlitString(" ", 4,32); - DrawGreenBar(0.0, 4, 41); - BlitString(" ", 4,46); - DrawGreenBar(0.0, 4, 55); - break; - }; +void DisplayWireless(void) +{ + struct ifreq ifr; + struct ieee80211req ireq; + union { + struct ieee80211req_sta_req stareq; + uint8_t buf[24*1024]; + } u; + int s, mode, err; + float link, level, noise; + enum { + MODE_NO_CARD = 0, + MODE_HAVE_CARD = 1 + }; + + s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (s == -1) + errx(errno, "socket"); + bzero(&ifr, sizeof(ifr)); + strncpy(ifr.ifr_name, iface, strlen(iface)); + + memset(&ireq, 0, sizeof(ireq)); + strncpy(ireq.i_name, iface, sizeof(ireq.i_name)); + + // Get the currently associated ap + ireq.i_type = IEEE80211_IOC_BSSID; + ireq.i_data = u.stareq.is_u.macaddr; + ireq.i_len = IEEE80211_ADDR_LEN; + err = ioctl(s, SIOCG80211, &ireq); + if ( err >= 0 ){ + + // Get the station info for the ap + memset(&ireq, 0, sizeof(ireq)); + strncpy(ireq.i_name, iface, sizeof(ireq.i_name)); + ireq.i_type = IEEE80211_IOC_STA_INFO; + ireq.i_data = &u; + ireq.i_len = sizeof(u); + err = ioctl(s, SIOCG80211, &ireq); + if ( err >= 0 ){ + const struct ieee80211req_sta_info *si = u.stareq.info; + mode = MODE_HAVE_CARD; + // net80211 doesn't have a link quality field so we base it on the + // noise/signal level + link = (si->isi_rssi-si->isi_noise)/2; + level = si->isi_rssi/2; + noise = abs(si->isi_noise); + } } - else { - printf ("Wirless device /proc/net/wireless not found\nEnable radio networking and recompile your kernel\n"); - exit (0); - } + + if (err < 0) { + mode = MODE_NO_CARD; + } + +draw: + /* + * Print channel information, and signal ratio + */ + switch (mode) { + case MODE_HAVE_CARD: + BlitString("Quality", 4, 4); + if (link <= 10) { + DrawRedDot(); + } else if (link <= 20) { + DrawYellowDot(); + } else { + DrawGreenDot(); + }; + BlitString("Quality ", 4, 18); + DrawBar(min((int)(link * 1.8), 100.0), 4, 27); + BlitString("Signal ", 4, 32); + DrawGreenBar(min((int)(level * 0.3), 100.0), 4, 41); + BlitString("Noise ", 4, 46); + DrawGreenBar(min((int)(noise * 0.3), 100.0), 4, 55); + break; + case MODE_NO_CARD: + default: + BlitString("NO CARD", 4, 4); + DrawEmptyDot(); + BlitString(" ", 4, 18); + DrawBar(0.0, 4, 27); + BlitString(" ", 4, 32); + DrawGreenBar(0.0, 4, 41); + BlitString(" ", 4, 46); + DrawGreenBar(0.0, 4, 55); + break; + }; + close(s); } /* SIGCHLD handler */ -@@ -208,6 +273,11 @@ +@@ -208,6 +275,11 @@ int main(int argc, char *argv[]) { if (*arg=='-') { switch (arg[1]) { + case 'i': + if (argc > (i + 1)) { + iface = argv[i+1]; + } + break; case 'd' : if (strcmp(arg+1, "display")) { usage(); -@@ -345,6 +415,7 @@ +@@ -345,6 +417,7 @@ void usage(void) { fprintf(stderr, "\nWmwave - Carsten Schuermann http://www.schuermann.org/~dockapps\n\n"); fprintf(stderr, "usage:\n"); fprintf(stderr, " -display \n"); + fprintf(stderr, " -i interface to use (default to wi0)\n"); fprintf(stderr, " -r update rate in milliseconds (default:100)\n"); fprintf(stderr, "\n"); }