Skip to content

x/sys/unix: add wireless iwreq support from Linux kernel #48338

@ghost

Description

Currently x/sys/unix has type Ifreq and function IoctlIfreq, but it would be nice if somebody added wireless support (linux/wireless.h), since the kernel has a couple of useful functions for that.

For example, here is a sample C code to get SSID of a wireless connection:

...
#include <linux/wireless.h>
...
	struct iwreq req;
	strcpy(req.ifr_ifrn.ifrn_name, argv[1]);
	int fd, status;
	fd = socket(AF_INET, SOCK_DGRAM, 0);
	char* buffer;
	buffer = calloc(32, sizeof(char));
	req.u.essid.pointer = buffer;
	req.u.essid.length = 32;
	if (ioctl(fd, SIOCGIWESSID, &req) == -1) {
		fprintf(stderr, "Failed ESSID get on interface %s: %s\n", argv[1], strerror(errno));
	} else {
		printf("%s", (char*)req.u.essid.pointer);
	}
	free(buffer);
...

As far as of now, i don't know a way to reproduce the same thing in Go, apart from using import "C" in place. A library functions for that sort of thing would be great.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Triage Backlog

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions