무선 네트워크 하시는분들 좀 도와줘요 [활성화(연결)된 ap macaddr 가져오기 - 같이 고민하면서 해결해봐요^^] ㅠㅠ

sunyata01의 이미지

아래 소스는 원래 연결된 eth0에 대한 mac 주소를 가져오는 함수를 변형해서 구성해봤습니다.
그리고 무선은 #include , , 파일에 등록된 SIOCGIWAP 를 사용해서 활성화된 acess point의 macaddr을 가져오는건데,
막상 해보니잘안됩니다. ㅠㅠ
아래에 보시면 wireless_send_event()라는 함수가 있는데, 이건 커널모듈에서 사용하는 건데, ioctl() 함수 말고, 이걸 쓰는지도 헷갈리기도하고 아니면 아래 함수가 영 아니다. 더쉬운방법이 있으면 가르쳐 주세요.
예를 들면 /proc/net/wireless , /proc/net/dev 이런쪽에 정보를 얻을수 있는 파일좀 가르쳐 주세요.ㅠㅠ

#include <linux/if_arp.h>
#include <linux/sockios.h>
#include <linux/wireless.h>
 
/*
 * int ap_macaddr(char* strMacAddr)
 */
int
ap_macaddr(char* strMacAddr)
{
	int size;
	int fd, len;
 
	union iwreq_data wreq;
	unsigned char *mac;
 
	fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
 
	if (fd == (-1))
		goto __end__;
 
	wreq.ap_addr.sa_family = ARPHRD_ETHER;
	//wireless_send_event(dev, SIOCGIWAP, &wreq, NULL);
	if (ioctl(fd, SIOCGIWAP, &wreq) < 0)
	{
		goto __end__;
	}
 
	mac = (unsigned char *)wreq.addr.sa_data;
 
	fprintf(stderr, "get data%s\n", mac);
 
	memset(strMacAddr, 0, MACSIZE);
 
	size = sprintf(strMacAddr, "%02x%02x%02x%02x%02x%02x",
			mac[0],
			mac[1],
			mac[2],
			mac[3],
			mac[4],	
			mac[5]);
 
	fprintf(stderr, "ap_macaddr:%s\n", strMacAddr);
 
__end__:
 
	if (fd != (-1)) close(fd);
	return size;
}
sunyata01의 이미지

linux/wireless.h
linux/if_arp.h
linux/sockios.h
입니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.