Changeset 222

Show
Ignore:
Timestamp:
03/04/10 16:17:14 (5 months ago)
Author:
dragorn
Message:

Add get channel to drv_mac80211
Fix major bug in drv_mac80211 which would crash if setmac used
Add get channel to ruby

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/drv_mac80211.c

    r216 r222  
    7777        if ((parent = nl80211_find_parent(context->vapname)) == NULL) { 
    7878                if (nl80211_createvap(context->ifname, context->vapname, context->errstr) < 0) { 
     79                        free(parent); 
    7980                        return -1; 
    8081                } 
    81         } else { 
    82                 free(parent); 
    83         } 
     82        }  
     83 
     84        free(parent); 
    8485 
    8586        if (ifconfig_delta_flags(context->vapname, context->errstr, 
     
    164165 
    165166        return 0; 
     167} 
     168 
     169int mac80211_getchan_cb(lorcon_t *context) { 
     170        int ch; 
     171 
     172        if ((ch = iwconfig_get_channel(context->vapname, context->errstr)) < 0) { 
     173                // Fall back to parent if vap doesn't act right (mac80211 seems to do this) 
     174                if ((ch = iwconfig_get_channel(context->ifname, context->errstr)) < 0) 
     175                        return -1; 
     176        } 
     177 
     178        return ch; 
    166179} 
    167180 
     
    290303 
    291304        context->setchan_cb = mac80211_setchan_cb; 
     305        context->getchan_cb = mac80211_getchan_cb; 
    292306 
    293307        context->getmac_cb = mac80211_getmac_cb; 
    294         context->setmac_cb = mac80211_setchan_cb; 
     308        context->setmac_cb = mac80211_setmac_cb; 
    295309 
    296310        context->auxptr = extras; 
  • trunk/ruby-lorcon/Lorcon2.c

    r214 r222  
    507507} 
    508508 
     509static VALUE Lorcon_get_channel(VALUE self) { 
     510        struct rldev *rld; 
     511        Data_Get_Struct(self, struct rldev, rld); 
     512        return INT2FIX(lorcon_get_channel(rld->context)); 
     513} 
    509514 
    510515static void rblorcon_pcap_handler(rblorconjob_t *job, struct pcap_pkthdr *hdr, u_char *pkt){ 
     
    632637        rb_define_method(cDevice, "filter=", Lorcon_set_filter, 1); 
    633638        rb_define_method(cDevice, "channel=", Lorcon_set_channel, 1); 
     639        rb_define_method(cDevice, "channel", Lorcon_get_channel, 0); 
    634640 
    635641        rb_define_method(cDevice, "loop", Lorcon_capture_loop, -1);