Disassociation support...

Dan Williams dcbw
Wed Dec 12 08:47:30 PST 2007


On Thu, 2007-12-13 at 00:43 +0900, Raghavendra. S wrote:
> Hi Dan,
> 
>  My doubts are inline..
> 
> On 12/12/07, Dan Williams <dcbw at redhat.com> wrote:
> > On Wed, 2007-12-12 at 06:03 +0530, Raghavendra. S wrote:
> > > Hi,
> > >     My requirement is something like this...let me explain with small
> > > piece of code.
> > >
> > > int main()
> > > {
> > >      printf("1- scan\n
> > >                 2 - enable esecurity\n
> > >                 3 - disable security\n
> > >                 4 - edit config\n");
> > >
> > >     //after taking input from user - say 'choice'
> > >
> > >   switch(choice)
> > > {
> > >
> > > case SCAN:
> > >                  // here i want to scan using wpa supplicant. and get result.
> > >                 break;
> > >
> > > case EDIT_CONFIG:
> > >                 // user will enter inputs after seeing scan result and
> > > then i will configure wpa_supplicant.conf as per users requirement.
> > >                 break;
> > >
> > > case ENABLE_SECURITY:
> > >              // here i will enable supplicant. as below
> > >             system("./wpa_supplicant -c ./wpa_supplicant.conf");
> > > //assume I will enable successfully with required command line
> > > parameter.
> > >             //if successfully enabled i will work here...say getting
> > > ip...ping etc..
> > >              break;
> > >
> > > case DISABLE_SECURITY:
> > >             //here i should disable to do that...
> > >             // I have to disassociate first.
> > >             // then i will kill wpa supplicant.
> > >     break;
> > >
> > > }
> > >
> > > return 0;
> > > }
> > >
> > > My code will look as above. I would like to understand following things here.
> > >
> > >  1. for scanning - I will modify wpa supplicant code to take command
> > > line argument say  '-s' which indicates enable wpa supplicant only to
> > > scan. so I will enable wpa supplicant like this,
> > > system("./wpa_supplicant   -s  -c ./dummy_wpa_supplicant.conf"). I
> > > think using this I will get scan result. Let me know if there's any
> > > better approach. My objective here is to get scan result and i should
> > > fill this scan result in some structure.
> >
> > Yes, there is.  Take the scanning code in driver_wext.c, and put it into
> > the same file in which your main.c is.  Do the scanning from _your_
> > program.  You don't need wpa_supplicant running to scan.
> >
> > Or, talk to wpa_supplicant over the control socket.
> 
> 
> [Raghu]: Here I think first I should initialize driver using
>              void * wpa_driver_wext_init(void *ctx, const char *ifname)
> 
>              Here whether "ctx" stands for some callbackname?  I mean,
> whether I have to pass some callback above init function or just
> passing NULL will be fine.
> 
>               after this i will call scan function
>               int wpa_driver_wext_scan(void *priv, const u8 *ssid,
> size_t ssid_len)
>                where priv is value returned by init call rt?

You don't need to initialize the driver or anything.  You just need to
be able to do ioctls, which requires root.  So either your program must
be root, or you must have some other tool do this.  Beyond that, the
only two ioctls you care about are SIOCSIWSCAN and SIOCGIWSCAN.  That's
it.  You don't need to init the driver or anything like that, beyond
ensuring that the interface is marked UP.

> >
> > > 2. For disable security. - First I will disassociate. problem here is
> > > how i will get control on socket opened by wpa_supplicant, to
> > > disassociate it? If I able to to that then...my problem is solved.
> > > After this I will simply kill wpa supplicant.
> >
> > You specify the control interface in the config file you pass to the
> > supplicant.
> 
> [Raghu]: Here if I mention say crtl_interface=/var/run/wpa_supplicant
> and if I enable wpa supplicant on "eth0", I can see some control
> socket in  "/var/run/wpa_supplicant/eth0" right? I observed that
> wpa_cli uses socket to talk with these control socket "eth0". Is there
> any simpler way to issue "disassociate" command to control socket...I
> mean some other IPC mechanism.

There are two ways to talk to wpa_supplicant:  the control socket, or
D-Bus.  I doubt you want to use D-Bus here.  So you can:

1) use the control socket like wpa_cli does

2) kill wpa_supplicant with -TERM, which will cause it to disassociate

Seriously, let wpa_supplicant do the work _for_ you, instead of trying
to program around it.  Your life will be easier :)

Dan

> 
> > Dan
> >
> > > I am not planning to use, wpa_cli.
> > >
> > > -Raghu.
> > >
> > > On 12/11/07, Jouni Malinen <j at w1.fi> wrote:
> > > > On Tue, Dec 11, 2007 at 06:51:01AM +0530, Raghavendra. S wrote:
> > > >
> > > > >     In below mailing list link you have mentioned that wpa supplicant
> > > > > snapshot version has provided command to disassociate.
> > > > >
> > > > >     http://lists.shmoo.com/pipermail/hostap/2003-November/004852.html
> > > >
> > > > That message has nothing to do with wpa_supplicant (it was about the
> > > > Host AP driver).
> > > >
> > > > >    I downloaded snapshot 0.6.0. But could not find command for
> > > > > disassociation. Will you plz tell me where can I get wpa supplicant code
> > > > > that supports disassociation command.
> > > >
> > > > What exactly do you mean with "disassociation command"? Would 'wpa_cli
> > > > disconnect' meet your needs?
> > > >
> > > > --
> > > > Jouni Malinen                                            PGP id EFC895FA
> > > > _______________________________________________
> > > > HostAP mailing list
> > > > HostAP at shmoo.com
> > > > http://lists.shmoo.com/mailman/listinfo/hostap
> > > >
> > >
> > >
> > >
> >
> >
> 
> 





More information about the Hostap mailing list