DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 26th November 2012
munchiez munchiez is offline
New User
 
Join Date: Nov 2012
Posts: 7
Thanked 0 Times in 0 Posts
Default scanning network using ioctl problem

hi, i'm making a network manager type program for openBSD. I'm using ioctl's to try scan for wireless networks the same way ifconfig does it, but it seems that i cant scan unless i'm already connected to a network. Why does my code fail when i'm not connected..?

Code:
void getNodes(char *name)
{

	struct ieee80211_nodereq_all na;
	struct ieee80211_nodereq nr[512];
	struct ifreq ifr;
	
	bzero(&ifr, sizeof(ifr));
	strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));

	if (ioctl(s, SIOCS80211SCAN, (caddr_t)&ifr) != 0) {
		
			printf("\t\tno permission to scan\n");
		//goto done;
	}   

	bzero(&na, sizeof(na));
	bzero(&nr, sizeof(nr));
	na.na_node = nr;
	na.na_size = sizeof(nr);
	strlcpy(na.na_ifname, name, sizeof(na.na_ifname));
	
	if (ioctl(s, SIOCG80211ALLNODES, &na) != 0) {
		warn("SIOCG80211ALLNODES");
		//goto done;
	}

	if (!na.na_nodes)
		printf("\t\tnone\n");
	int i;
	for (i = 0; i < na.na_nodes; i++) {
		printf("\t\t");
		printNode(&nr[i]);
		putchar('\n');
	}
}

both SIOCG80211ALLNODES and SIOCS80211SCAN requests will fail in this instance. most of this code is from ifconfig ive missed something out but cant figure out what...

any insight would be good.
Reply With Quote
  #2   (View Single Post)  
Old 26th November 2012
munchiez munchiez is offline
New User
 
Join Date: Nov 2012
Posts: 7
Thanked 0 Times in 0 Posts
Default

never mind i figured it out. Just needed to make another call with SIOCSIFFLAGS and set all the flags up or something
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scanning network neighbors badguy OpenBSD General 2 7th December 2011 11:51 PM
Problem Network (3.1, 4, 5) ahlsner NetBSD General 13 6th August 2009 09:29 PM
Odd network performance problem dewarrn1 FreeBSD General 6 27th January 2009 12:13 AM
Strange network problem mururoa FreeBSD General 15 5th November 2008 08:25 AM
Weird network problem rex FreeBSD General 5 16th September 2008 02:05 AM


All times are GMT. The time now is 12:27 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick