struct net_device *alloc_ladoga(int sizeof_priv) { struct ladoga_device *ladoga; struct net_device *dev; int err; LADOGA_DEBUG_INFO("Initializing...\n"); dev = alloc_etherdev(sizeof(struct ladoga_device) + sizeof_priv); if (!dev) { LADOGA_ERROR("Unable to allocate network device.\n"); goto failed; } ladoga = netdev_priv(dev); ladoga->dev = dev; err = ladoga_networks_allocate(ladoga); if (err) { LADOGA_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed_free_netdev; } ladoga_networks_initialize(ladoga); /* Default fragmentation threshold is maximum payload size */ ladoga->fts = DEFAULT_FTS; ladoga->rts = DEFAULT_FTS; ladoga->scan_age = DEFAULT_MAX_SCAN_AGE; ladoga->open_wep = 1; /* Default to enabling full open WEP with host based encrypt/decrypt */ ladoga->host_encrypt = 1; ladoga->host_decrypt = 1; ladoga->host_mc_decrypt = 1; /* Host fragementation in Open mode. Default is enabled. * Note: host fragmentation is always enabled if host encryption * is enabled. For cards can do hardware encryption, they must do * hardware fragmentation as well. So we don't need a variable * like host_enc_frag. */ ladoga->host_open_frag = 1; ladoga->ieee802_1x = 1; /* Default to supporting 802.1x */ spin_lock_init(&ladoga->lock); lib80211_crypt_info_init(&ladoga->crypt_info, dev->name, &ladoga->lock); ladoga->wpa_enabled = 0; ladoga->drop_unencrypted = 0; ladoga->privacy_invoked = 0; return dev; failed_free_netdev: free_netdev(dev); failed: return NULL; }
struct net_device *alloc_rtllib(int sizeof_priv) { struct rtllib_device *ieee = NULL; struct net_device *dev; int i, err; RTLLIB_DEBUG_INFO("Initializing...\n"); dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv); if (!dev) { RTLLIB_ERROR("Unable to network device.\n"); goto failed; } ieee = (struct rtllib_device *)netdev_priv_rsl(dev); memset(ieee, 0, sizeof(struct rtllib_device)+sizeof_priv); ieee->dev = dev; err = rtllib_networks_allocate(ieee); if (err) { RTLLIB_ERROR("Unable to allocate beacon storage: %d\n", err); goto failed; } rtllib_networks_initialize(ieee); /* */ ieee->fts = DEFAULT_FTS; ieee->scan_age = DEFAULT_MAX_SCAN_AGE; ieee->open_wep = 1; /* */ ieee->host_encrypt = 1; ieee->host_decrypt = 1; ieee->ieee802_1x = 1; /* */ ieee->rtllib_ap_sec_type = rtllib_ap_sec_type; spin_lock_init(&ieee->lock); spin_lock_init(&ieee->wpax_suitlist_lock); spin_lock_init(&ieee->bw_spinlock); spin_lock_init(&ieee->reorder_spinlock); atomic_set(&(ieee->atm_chnlop), 0); atomic_set(&(ieee->atm_swbw), 0); /* */ lib80211_crypt_info_init(&ieee->crypt_info, "RTLLIB", &ieee->lock); ieee->bHalfNMode = false; ieee->wpa_enabled = 0; ieee->tkip_countermeasures = 0; ieee->drop_unencrypted = 0; ieee->privacy_invoked = 0; ieee->ieee802_1x = 1; ieee->raw_tx = 0; ieee->hwsec_active = 0; memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32); rtllib_softmac_init(ieee); ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); if (ieee->pHTInfo == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for HTInfo\n"); return NULL; } HTUpdateDefaultSetting(ieee); HTInitializeHTInfo(ieee); TSInitialize(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); for (i = 0; i < 17; i++) { ieee->last_rxseq_num[i] = -1; ieee->last_rxfrag_num[i] = -1; ieee->last_packet_time[i] = 0; } return dev; failed: if (dev) free_netdev(dev); return NULL; }
struct net_device *alloc_rtllib(int sizeof_priv) { struct rtllib_device *ieee = NULL; struct net_device *dev; int i, err; pr_debug("rtllib: Initializing...\n"); dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv); if (!dev) { pr_err("Unable to allocate net_device.\n"); return NULL; } ieee = (struct rtllib_device *)netdev_priv_rsl(dev); memset(ieee, 0, sizeof(struct rtllib_device)+sizeof_priv); ieee->dev = dev; err = rtllib_networks_allocate(ieee); if (err) { pr_err("Unable to allocate beacon storage: %d\n", err); goto failed; } rtllib_networks_initialize(ieee); /* Default fragmentation threshold is maximum payload size */ ieee->fts = DEFAULT_FTS; ieee->scan_age = DEFAULT_MAX_SCAN_AGE; ieee->open_wep = 1; /* Default to enabling full open WEP with host based encrypt/decrypt */ ieee->host_encrypt = 1; ieee->host_decrypt = 1; ieee->ieee802_1x = 1; /* Default to supporting 802.1x */ ieee->rtllib_ap_sec_type = rtllib_ap_sec_type; spin_lock_init(&ieee->lock); spin_lock_init(&ieee->wpax_suitlist_lock); spin_lock_init(&ieee->reorder_spinlock); atomic_set(&(ieee->atm_swbw), 0); /* SAM FIXME */ lib80211_crypt_info_init(&ieee->crypt_info, "RTLLIB", &ieee->lock); ieee->wpa_enabled = 0; ieee->tkip_countermeasures = 0; ieee->drop_unencrypted = 0; ieee->privacy_invoked = 0; ieee->ieee802_1x = 1; ieee->raw_tx = 0; ieee->hwsec_active = 0; memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32); rtllib_softmac_init(ieee); ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); if (!ieee->pHTInfo) return NULL; HTUpdateDefaultSetting(ieee); HTInitializeHTInfo(ieee); TSInitialize(ieee); for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]); for (i = 0; i < 17; i++) { ieee->last_rxseq_num[i] = -1; ieee->last_rxfrag_num[i] = -1; ieee->last_packet_time[i] = 0; } return dev; failed: free_netdev(dev); return NULL; }