void ConfUnit::insert(const std::string& key, ConfUnit* punit) { if (is_group()) { _map.insert(std::make_pair(key, punit)); } else { throw std::exception(); } }
int32_t ConfUnit::size() const { if (is_array()) { return (int32_t)_vector.size(); } else if (is_group()) { return (int32_t)_map.size(); } else { return 0; } }
std::vector< std::string > Groups::group_get_child_tree(std::string m_name, std::vector< std::string > data) { if (is_group(m_name)) { bool exists = false; for ( unsigned int i = 0 ; i < data.size(); i++ ) { if (boost::iequals(data[i],m_name)) { exists = true; } } if (!exists) { std::vector< std::string > childs = group_get_childs(m_name); for (unsigned int childs_it = 0; childs_it < childs.size(); childs_it++) { std::string child = childs[childs_it]; if (is_group(child)) { data.push_back(child); std::vector< std::string > tmpdata = group_get_child_tree(child, data); for (unsigned int tmpdata_it = 0; tmpdata_it < tmpdata.size(); tmpdata_it++) { if (is_group(tmpdata[tmpdata_it])) { data.push_back(tmpdata[tmpdata_it]); } } } } } return data; } return NULLvector; }
void ConfUnit::erase(const std::string& key) { if (is_group()) { std::map<std::string, ConfUnit*>::iterator itr; itr = _map.find(key); if (itr != _map.end()) { if (NULL != itr->second) { delete itr->second; } _map.erase(itr); } } else { throw std::exception(); } }
ConfUnit* ConfUnit::operator[](const std::string& index) { if (is_group()) { std::map<std::string, ConfUnit*>::iterator itr; itr = _map.find(index); if (itr != _map.end()) { return itr->second; } else { return NULL; } } else { throw std::exception(); } }
void Groups::build_child_tree() { /*for (unsigned int group_it = 0; group_it < g.size(); group_it++) { std::string current_group = g[group_it]->get_name(); for (unsigned int group_it2 = 0; group_it2 < g.size(); group_it2++) { std::vector< std::string > parents = g[group_it2]->get_parents(); for (unsigned int parents_it = 0; parents_it < parents.size(); parents_it++) { if (boost::iequals(current_group, parents[parents_it])) { g[group_it2]->add_parent(current_group); cout << g[group_it2]->get_name() << " has parent " << current_group << endl; } } } }*/ for (unsigned int group_it = 0; group_it < g.size(); group_it++) { std::string current_group = g[group_it]->get_name(); std::vector< std::string > members_group; members_group.push_back(current_group); std::string parent = group_get_parent(current_group); while (is_group(parent) == true) { bool exists = false; for ( unsigned int i = 0 ; i < members_group.size(); i++ ) { if (!boost::iequals(members_group[i],parent)) { exists = true; } } if (!exists) { members_group.push_back(parent); cout << parent << endl; } parent = group_get_parent(parent); cout << current_group << " has parents: " << parent << endl; } } }
ConfUnit::~ConfUnit() { if (is_array()) { iterator itr; for (itr = _vector.begin(); itr != _vector.end(); ++itr) { if (*itr) { delete (*itr); } } _vector.clear(); } else if (is_group()) { std::map<std::string, ConfUnit*>::iterator itr; for (itr = _map.begin(); itr != _map.end(); ++itr) { if (itr->second) { delete itr->second; } } _map.clear(); } }
void ConfUnit::clear() { if (is_array()) { std::vector<ConfUnit*>::iterator itr; for (itr = _vector.begin(); itr != _vector.end(); ++itr) { if (NULL != *itr) { delete *itr; } } _vector.clear(); } else if (is_group()) { std::map<std::string, ConfUnit*>::iterator itr; for (itr = _map.begin(); itr != _map.end(); ++itr) { if (NULL != itr->second) { delete itr->second; } } _map.clear(); } else { throw std::exception(); } }
void sta_enabled_rx_data(mac_struct_t *mac, UWORD8 *msg) { wlan_rx_t *wlan_rx = (wlan_rx_t *)msg; UWORD8 priority_rx = wlan_rx->priority_val; UWORD8 *msa = wlan_rx->msa; sta_entry_t *se = (sta_entry_t *)wlan_rx->sa_entry; msdu_desc_t *frame_desc = 0; msdu_indicate_t msdu = {{0},}; msdu_proc_state_t msdu_state = {0}; MSDU_PROC_STATUS_T status = PROC_ERROR; BOOL_T sta_ps_check_done = BFALSE; UWORD32 phy_rate = 0; phy_rate = get_rx_dscr_data_rate(wlan_rx->base_dscr); #if 0 if(IS_RATE_MCS(phy_rate) == BFALSE) { g_ap_last_rate_integer = phy_rate; g_ap_last_rate_decimal = 0; } else #endif { int j=0; for( j = 0; j < sizeof(rate_table_chenq)/sizeof(rate_table_t); j++ ) { if(rate_table_chenq[j].rate_index == phy_rate) { g_ap_last_rate_integer = rate_table_chenq[j].rate; if(rate_table_chenq[j].point5) { g_ap_last_rate_decimal = 1; } else { g_ap_last_rate_decimal = 0; } break; } } if( j >= sizeof(rate_table_chenq)/sizeof(rate_table_t) ) { g_ap_last_rate_integer = 0; g_ap_last_rate_decimal = 0; } } //printk("chenq: rx rate is: index %02x,%d.%d Mb/s\n",phy_rate, g_ap_last_rate_integer,(g_ap_last_rate_decimal ==0) ? 0 : 5); TROUT_FUNC_ENTER; #ifdef TROUT_WIFI_NPI //UWORD32 data_rate = 0; //UWORD8 user_rate = 0; UWORD32 rx_len = 0; //UWORD32 phy_rate = 0; print_log_debug_level_1("\n[DL1][INFO][Rx] {MAC API for WLAN Rx Data}"); rx_len = get_rx_dscr_frame_len(wlan_rx->base_dscr); //printk("rx len is: %u\n", rx_len); phy_rate = get_rx_dscr_data_rate(wlan_rx->base_dscr); // printk("phy rate is: 0x%x\n", phy_rate); g_ap_last_rate = get_rx_rate(phy_rate); printk("npi: rx rate is: %u Mb/s\n", g_ap_last_rate); #endif #ifdef WAKE_LOW_POWER_POLICY #if 1 if(!wlan_rx->is_grp_addr) g_low_power_flow_ctrl.rx_pkt_num += wlan_rx->num_dscr; #endif #endif // 20120709 caisf mod, merged ittiam mac v1.2 code #if 0 if(NULL_FRAME == wlan_rx->sub_type) { return; } #else /* No NULL frames should be sent to the host */ if((NULL_FRAME == wlan_rx->sub_type) || (QOS_NULL_FRAME == wlan_rx->sub_type)) { /* Handle any power save related functionality for NULL frame */ /* reception */ psm_handle_rx_packet_sta(msa, priority_rx); TROUT_FUNC_EXIT; return; } #endif /* make sure we set all filed 0 by zhao */ memset((void *)&msdu, 0, sizeof(msdu_indicate_t)); memset((void *)&msdu_state, 0, sizeof(msdu_proc_state_t)); /* Update the MSDU priority value */ msdu.priority = priority_rx; /* Create the MSDU descriptors for the received frame */ do { /* Create the MSDU descriptor */ status = update_msdu_info(wlan_rx, &msdu, &msdu_state); if(PROC_ERROR == status) break; /* Get the frame descriptor pointer */ frame_desc = &(msdu.frame_desc); /* Before forwarding the packet across to the HOST interface security */ /* checks needs to performed on the states of the transmitting station */ if(sta_check_sec_tx_sta_state(se, frame_desc, (CIPHER_T)(wlan_rx->ct)) != BTRUE) { TROUT_FUNC_EXIT; return; } /* Check for SNAP header at the beginning of the data and set the */ /* data pointer and length accordingly. */ if(BTRUE == is_snap_header_present(frame_desc)) { /* If the message is a unicast packet, search for the STA entry */ if(is_group(msdu.da) == BFALSE) { /* If the received packet is a security handshake packet */ /* process it in the security layer */ if(is_sec_handshake_pkt_sta(se, frame_desc->buffer_addr, frame_desc->data_offset, frame_desc->data_len, (CIPHER_T)(wlan_rx->ct)) == BTRUE) { continue; } #ifdef WIFI_SLEEP_POLICY if(check_11i_frame(frame_desc->buffer_addr + frame_desc->data_offset) || check_wapi_frame(frame_desc->buffer_addr + frame_desc->data_offset)) { #if 0 if(wake_lock_active(&handshake_frame_lock)) { pr_info("%s-%d: release wake_lock %s\n", __func__, __LINE__, handshake_frame_lock.name); wake_unlock(&handshake_frame_lock); } wake_lock_timeout(&handshake_frame_lock,msecs_to_jiffies(2000)); /*Keep 2s awake when HK, by caisf 20131004*/ pr_info("%s-%d: acquire wake_lock %s\n", __func__, __LINE__, handshake_frame_lock.name); #else if(wake_lock_active(&handshake_frame_lock)) { stop_hs_wake_timer(); /*Keep 2s awake when HK, by caisf 20131004*/ start_hs_wake_timer(); pr_info("%s-%d: refresh timer wake_lock %s\n", __func__, __LINE__, handshake_frame_lock.name); } else { wake_lock(&handshake_frame_lock); /*Keep 2s awake when HK, by caisf 20131004*/ start_hs_wake_timer(); pr_info("%s-%d: acquire wake_lock %s\n", __func__, __LINE__, handshake_frame_lock.name); } #endif } #endif } /* Adjust the frame to account for the SNAP header */ adjust_for_snap_header(frame_desc); } /* Reset the link loss count if a valid frame is received */ g_link_loss_count = 0; //printk("rx_data: link_lost = %d\n", g_link_loss_count); update_connection_cnt(se); /* Handle packet reception for power save */ if(sta_ps_check_done == BFALSE) { sta_ps_check_done = BTRUE; psm_handle_rx_packet_sta(msa, priority_rx); } //chenq add for wapi 2012-09-29 #ifdef MAC_WAPI_SUPP if( wlan_rx->wapi_mode == 1 ) { msdu.frame_desc.wapi_mode = 1; } else { msdu.frame_desc.wapi_mode = 0; } #endif //chenq add for auto set tx rx power 2013-07-29 #ifdef TROUT2_WIFI_IC /* Update the RSSI information */ if(msdu_state.curr_dscr == 0) { update_rssi(wlan_rx->base_dscr); } else { update_rssi(msdu_state.curr_dscr); } uptate_rssi4_auto_set_tx_rx_power(); #ifdef AUTORATE_PING //ping.jiang add for calculating statistics 2013-10-31 ar_rssi_value_add(); #endif /* AUTORATE_PING */ #endif //chenq add end rssi_value_add(); // for set_aci /* Call MSDU Indicate API with the MSDU to be sent to the host */ msdu_indicate_sta(&msdu); } while(PROC_MORE_MSDU == status); /* Handle packet reception for power save */ if(sta_ps_check_done == BFALSE) { sta_ps_check_done = BTRUE; psm_handle_rx_packet_sta(msa, priority_rx); } TROUT_FUNC_EXIT; }
void sud_process(struct conf *cfp, int fd, int pipefd) { #if defined(HAVE_GETPEEREID) || defined(SO_PEERCRED) uid_t euid; gid_t egid; #endif #if defined(HAVE_GETPEEREID) if (getpeereid(fd, &euid, &egid) < 0) { syslog(LOG_ERR, "getpeereid failed: %m"); if (cfp->haveauthgroup) _exit(1); } #endif #if defined(SO_PEERCRED) && !defined(HAVE_GETPEEREID) struct ucred peercred; #ifdef HAVE_SOCKLEN_T socklen_t olen = sizeof(struct ucred); #else int olen = sizeof(struct ucred); #endif if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &olen) < 0) { syslog(LOG_ERR, "can't get credential via SO_PEERCRED"); if (cfp->haveauthgroup) _exit(1); } euid = peercred.uid; egid = peercred.gid; #endif #if defined(HAVE_GETPEEREID) || defined(SO_PEERCRED) /* * XXX: LOG_INFO should be LOG_AUTH */ if (cfp->haveauthgroup && is_group(euid, cfp->authgroup) != 1) { syslog(LOG_INFO, "[%s] auth failed u: %s [%lu] g: %s [%lu]", cfp->session, get_pwentry(euid)->pw_name, (unsigned long)euid, get_group(egid)->gr_name, (unsigned long)egid); _exit(1); } if (cfp->log) syslog(LOG_INFO,"[%s] auth req u: %s [%lu] g: %s [%lu]", cfp->session, get_pwentry(euid)->pw_name, (unsigned long)euid, get_group(egid)->gr_name, (unsigned long)egid); set_id(cfp->havesetuser, cfp->setuser, euid); set_id(cfp->haveseteuser, cfp->seteuser, euid); set_id(cfp->havesetgroup, cfp->setgroup, egid); set_id(cfp->havesetegroup, cfp->setegroup, egid); #endif if (cfp->terminal) (void)setenv("TERM", cfp->terminal, 1); else (void)setenv("TERM", default_term ? default_term : "vt100", default_term ? 1 : 0); switch (cfp->mode) { case INTERACTIVE: exec_shell(cfp, fd, pipefd); break; case READ: case BLIND: case READWRITE: exec_command(cfp, fd, pipefd); break; } _exit(1); }
int main (int argc, char **argv) { /* Check arguments. */ progname = argv[0]; if (argc != 2 || argv[1][0] != '-' || !strchr ("co", argv[1][1]) || argv[1][2]) fatal ("usage: %s [-c|-o] > file", progname); int type = argv[1][1]; /* Collect the set of built-in and internal functions. */ string_set builtins; string_set internal_fns; add_to_set (&builtins, builtin_names); add_to_set (&internal_fns, internal_fn_flt_names); add_to_set (&internal_fns, internal_fn_int_names); /* Check the functions. */ for (unsigned int i = 0; internal_fn_flt_names[i]; ++i) { const char *name = internal_fn_flt_names[i]; if (!is_group (&builtins, name, flt_suffixes)) error ("DEF_INTERNAL_FLT_FN (%s) has no associated built-in" " functions", name); } for (unsigned int i = 0; internal_fn_int_names[i]; ++i) { const char *name = internal_fn_int_names[i]; if (!is_group (&builtins, name, int_suffixes)) error ("DEF_INTERNAL_INT_FN (%s) has no associated built-in" " functions", name); } /* Go through the built-in functions in declaration order, outputting definitions as appropriate. */ for (unsigned int i = 0; builtin_names[i]; ++i) { const char *name = builtin_names[i]; if (strncmp (name, "BUILT_IN_", 9) == 0) { const char *root = name + 9; for (unsigned int j = 0; suffix_lists[j]; ++j) { const char *const *const suffix = suffix_lists[j]; if (is_group (&builtins, root, suffix)) { bool internal_p = internal_fns.contains (root); if (type == 'c') print_case_cfn (root, internal_p, suffix, ""); else print_define_operator_list (root, internal_p, suffix, ""); /* Support the _Float<N> and _Float<N>X math functions if they exist. We put these out as a separate CFN or operator macro, so code can add support or not as needed. We also put out a combined CFN or operator macro that includes both the traditional names and the _Float<N> and _Float<N>X versions. */ if (suffix == flt_suffixes && is_group (&builtins, root, fltfn_suffixes)) { if (type == 'c') { print_case_cfn (root, false, fltfn_suffixes, "_FN"); print_case_cfn (root, false, fltall_suffixes, "_ALL"); } else { print_define_operator_list (root, false, fltfn_suffixes, "_FN"); print_define_operator_list (root, internal_p, fltall_suffixes, "_ALL"); } } } } } } if (fflush (stdout) || fclose (stdout) || have_error) return FATAL_EXIT_CODE; return SUCCESS_EXIT_CODE; }
void ap_enabled_rx_data(mac_struct_t *mac, UWORD8 *msg) { UWORD8 priority_rx = 0; STA_PS_STATE_T ps = ACTIVE_PS; UWORD8 data_trailer = 0; wlan_rx_t *wlan_rx = (wlan_rx_t *)msg; UWORD8 *msa = wlan_rx->msa; asoc_entry_t *da_ae = 0; asoc_entry_t *sa_ae = 0; msdu_desc_t *frame_desc = 0; CIPHER_T ct = (CIPHER_T)wlan_rx->ct; MSDU_PROC_STATUS_T status = PROC_ERROR; TYPESUBTYPE_T frm_type = DATA; msdu_indicate_t msdu = {{0},}; msdu_proc_state_t msdu_state = {0}; /* Get association entry for the source address */ sa_ae = (asoc_entry_t *)wlan_rx->sa_entry; /* Power management checks */ ps = (STA_PS_STATE_T)get_pwr_mgt(msa); frm_type = (TYPESUBTYPE_T)wlan_rx->sub_type; /* Check for WMM-PS trigger frame and process accordingly */ pwr_mgt_handle_prot(sa_ae, ps, priority_rx, msa); /* Check the Power Save Bit in the receive frame */ check_ps_state(sa_ae, ps); /* Check if the received function is the Null function Packet */ if((frm_type == NULL_FRAME) || (is_sub_type_null_prot(frm_type) == BTRUE)) { // 20120709 caisf add, merged ittiam mac v1.2 code check_ps_state(sa_ae, ps); #ifdef DEBUG_MODE g_mac_stats.pewrxnf++; #endif /* DEBUG_MODE */ return; } /* Get the priority of the incoming frame */ priority_rx = wlan_rx->priority_val; msdu.priority = priority_rx; /* Create the MSDU descriptors for the received frame */ do { /* Create the MSDU decsriptor */ status = update_msdu_info(wlan_rx, &msdu, &msdu_state); if(PROC_ERROR == status) break; /* Get the frame descriptor pointer */ frame_desc = &(msdu.frame_desc); /* Get association entry based on the source address to determine */ /* the next path of the packet. */ sa_ae = (asoc_entry_t* )find_entry(msdu.sa); da_ae = (asoc_entry_t* )find_entry(msdu.da); if((da_ae != 0) && (BTRUE == get_p2p_intra_bss_prot())) { UWORD8 key_type = 0; BOOL_T wlan2wlan = BFALSE; BOOL_T use_same_buffer = BTRUE; /* CipherType is reset to no encryption and is set as per the */ /* policy used for the out going sta */ ct = NO_ENCRYP; /* Set the Key type required for transmission */ key_type = UCAST_KEY_TYPE; /* If the station is associated with the AP, the packet is put */ /* onto the wireless network. */ if(da_ae->state == ASOC) { #ifndef TX_MACHDR_IN_DSCR_MEM /* If the received frame is not a QoS frame, create a */ /* copy of the frame in a separate buffer to fit the QoS */ /* header. */ if(is_qos_bit_set(msa) == BFALSE) use_same_buffer = BFALSE; /* The MAC Header offset field in TX-Dscr is 8 bits long. */ /* Hence a frame copy is created if the MAC Header field */ /* exceeds 256 when it is created in place. */ #if 0 //shield by chengwg. if(frame_desc->data_offset > 255) use_same_buffer = BFALSE; #else //because rx frame is alloced by ourself, so we mustn't use the buffer in tx frame!!! use_same_buffer = BFALSE; #endif #endif /* TX_MACHDR_IN_DSCR_MEM */ /* Before forwarding the packet onto the WLAN interface */ /* security checks needs to performed on the states of the */ /* transmitting and receiving stations */ wlan2wlan = check_sec_ucast_wlan_2_wlan_ap(da_ae, sa_ae, &ct, &data_trailer); /* Update length of the frame to accommodate the security */ /* trailers if any. */ update_frame_length(frame_desc, data_trailer); if(wlan2wlan == BTRUE) { wlan_to_wlan(&msdu, ct, key_type, da_ae->sta_index, frm_type, da_ae, use_same_buffer); } #ifdef DEBUG_MODE g_mac_stats.pewrxu++; #endif /* DEBUG_MODE */ } } else { /* Broadcast/Multicast frames need to be forwarded on WLAN also */ if((is_group(msdu.da) == BTRUE) && (BTRUE == get_p2p_intra_bss_prot())) { CIPHER_T grp_ct = NO_ENCRYP; /* Before forwarding the packet on WLAN and HOST interface */ /* security checks needs to performed on the states of the */ /* transmitting station */ if(ap_check_sec_tx_sta_state(sa_ae) != BTRUE) { continue; } #ifdef DEBUG_MODE g_mac_stats.pewrxb++; #endif /* DEBUG_MODE */ /* Before forwarding the packet on the WLAN interface */ /* security checks needs to performed on the states of the */ /* transmitting station */ data_trailer = check_sec_bcast_wlan_2_wlan_ap(&grp_ct); /* Update the length of the frame to accommodate the */ /* security trailers if any. */ update_frame_length(frame_desc, data_trailer); wlan_to_wlan(&msdu, grp_ct, BCAST_KEY_TYPE, 0, frm_type, NULL, BFALSE); } else { /* Packet is a Unicast packet to the AP */ #ifdef DEBUG_MODE g_mac_stats.pewrxu++; #endif /* DEBUG_MODE */ } /* Check for SNAP header at beginning of the data and set the */ /* data pointer and length accordingly. */ if(BTRUE == is_snap_header_present(frame_desc)) { /* If received packet is a security handshake packet process */ /* it in the security layer */ if(is_sec_handshake_pkt_ap(sa_ae, frame_desc->buffer_addr, frame_desc->data_offset, frame_desc->data_len, (CIPHER_T)wlan_rx->ct) == BTRUE) { continue; } /* Adjust the frame to account for the SNAP header */ adjust_for_snap_header(frame_desc); } else { /* Before forwarding the packet on WLAN and HOST interface */ /* security checks needs to performed on the states of the */ /* transmitting station */ if(ap_check_sec_tx_sta_state(sa_ae) != BTRUE) { continue; } } /* Call MSDU Indicate API with the MSDU to be sent to the host */ msdu_indicate_ap(&msdu); } } while(PROC_MORE_MSDU == status); }
void wlan_to_wlan(msdu_indicate_t *msdu, CIPHER_T ct, UWORD8 key_type, UWORD8 key_index, TYPESUBTYPE_T frm_type, asoc_entry_t *ae, BOOL_T use_same_buffer) { UWORD8 q_num = 0; UWORD8 tx_rate = 0; UWORD8 pream = 0; UWORD8 service_class= 0; UWORD8 *mac_hdr = 0; UWORD8 *tx_dscr = 0; UWORD16 mac_hdr_len = 0; void *amsdu_ctxt = NULL; UWORD8 is_amsdu = 0; BOOL_T is_qos = BFALSE; BOOL_T is_htc = BFALSE; msdu_desc_t *buff_desc = &(msdu->frame_desc); UWORD32 phy_tx_mode = 0; UWORD32 sta_index = INVALID_ID; buffer_desc_t buffer_desc = {0}; UWORD32 retry_set[2] = {0}; #ifdef DEBUG_MODE g_mac_stats.w2w++; #endif /* DEBUG_MODE */ /* Find the queue to which this packet needs to be added */ q_num = get_w2w_txq_num_ap(msdu->priority); if(ae != NULL) sta_index = ae->sta_index; /* If the queue for which this packet belongs is full, then return */ if(is_txq_full(q_num, sta_index) == BTRUE) { return; } /* Prepare the buffer descriptor for the payload based on the flag to */ /* use the same buffer. If the frame is to be sent on both WLAN as well */ /* as the host there may be cases in which the payload portion needs to */ /* be modified to be sent to the host. This causes the packet being sent */ /* on WLAN to be altered if the same buffer is used. As a result the */ /* same buffer cannot be used for transmitting on WLAN in this case. */ /* However if the packet is to be sent only on WLAN this problem does */ /* not occur and hence the same buffer can be used. */ if(use_same_buffer == BTRUE) { /* Add one user to the incoming buffer. This ensures that the buffer */ /* will remain allocated even after the process rx frame function */ /* frees it. */ mem_add_users(g_shared_pkt_mem_handle, buff_desc->buffer_addr, 1); /* Prepare a buffer descriptor with required information */ buffer_desc.buff_hdl = buff_desc->buffer_addr; buffer_desc.data_offset = buff_desc->data_offset; buffer_desc.data_length = buff_desc->data_len; } else { UWORD8 *out_data = 0; /* Allocate a new buffer for the payload outgoing on WLAN */ out_data = (UWORD8*)pkt_mem_alloc(MEM_PRI_TX); if(out_data == NULL) return; /* Prepare a buffer descriptor with required information */ buffer_desc.buff_hdl = out_data; buffer_desc.data_offset = MAX_MAC_HDR_LEN; buffer_desc.data_length = buff_desc->data_len; if(buffer_desc.data_offset + buff_desc->data_len > SHARED_PKT_MEM_BUFFER_SIZE){ printk("@@@:BUG! bad memcpy offset:%d, len:%d\n", buffer_desc.data_offset, buff_desc->data_len); } /* Copy the payload from the incoming packet to the outgoing buffer */ memcpy(buffer_desc.buff_hdl + buffer_desc.data_offset, buff_desc->buffer_addr + buff_desc->data_offset, buff_desc->data_len); } /* Set the transmit rate to the required value. To support Multi-Rate */ /* the transmit rate is set to the maximum basic rate and the preamble */ /* is set to Long. */ if(is_group(msdu->da) == BTRUE) { /* For multicast frames send frames at maximum rate */ tx_rate = get_max_basic_rate(); pream = 1; service_class = BCAST_NO_ACK; /* Update the retry set information for this frame */ update_retry_rate_set(0, tx_rate, 0, retry_set); } else { /* Get the transmit rate for the associated station based on the */ /* auto-rate, multi-rate or user-rate settings. The preamble must be */ /* set accordingly. */ if(!ae) printk("@@@:BUG ae==NULL to get rate\n"); tx_rate = get_tx_rate_to_sta(ae); pream = get_preamble(tx_rate); service_class = g_ack_policy; /* Update the retry set information for this frame */ update_retry_rate_set(1, tx_rate, ae, retry_set); } /* AMSDU on WLAN-WLAN path is disabled since no space currently exists */ /* in the RX-Buffer to add the sub-MSDU header */ #ifdef TX_MACHDR_IN_DSCR_MEM /* Check whether AMSDU aggregation is possible */ amsdu_ctxt = get_amsdu_handle(msdu->da, msdu->priority, q_num, ae, buff_desc->data_len, 1, tx_rate); #endif /* TX_MACHDR_IN_DSCR_MEM */ /* Check whether AMSDU option is enabled */ is_amsdu = (amsdu_ctxt != NULL); /* Check whether AMSDU aggregation is not supported or if this is the */ /* first sub-MSDU of an AMSDU. */ if((0 == is_amsdu) || (NULL == amsdu_get_tx_dscr(amsdu_ctxt))) { /* Check whether QoS option is implemented */ is_qos = is_qos_required(sta_index); /* Check whether the receiver is HT capable */ is_htc = is_htc_capable(ae); /* Create the transmit descriptor and set default contents */ tx_dscr = create_default_tx_dscr(is_qos, msdu->priority, is_amsdu); if(tx_dscr == NULL) { if(is_amsdu == 1) { /* If allocation of the AMSDU decriptor has failed, then */ /* attempt transmission of the MSDU as a normal-MSDU. */ free_amsdu_handle(amsdu_ctxt); is_amsdu = 0; amsdu_ctxt = NULL; tx_dscr = create_default_tx_dscr(is_qos, msdu->priority, is_amsdu); } if(tx_dscr == NULL) { //caisf add 2013-02-15 if(g_mac_net_stats) g_mac_net_stats->tx_dropped++; pkt_mem_free(buffer_desc.buff_hdl); return; } } /* Update the AMSDU handle with the tx descriptor */ if(1 == is_amsdu) amsdu_set_tx_dscr(amsdu_ctxt, tx_dscr); /* Create the MAC header of the out-going frame */ #ifdef TX_MACHDR_IN_DSCR_MEM mac_hdr = mem_alloc(g_shared_dscr_mem_handle, MAX_MAC_HDR_LEN); if(NULL == mac_hdr) { free_tx_dscr((UWORD32 *)tx_dscr); //caisf add 2013-02-15 if(g_mac_net_stats) g_mac_net_stats->tx_dropped++; pkt_mem_free(buffer_desc.buff_hdl); free_amsdu_handle(amsdu_ctxt); return; } #else /* TX_MACHDR_IN_DSCR_MEM */ mac_hdr = buffer_desc.buff_hdl + buffer_desc.data_offset - MAX_MAC_HDR_LEN; #endif /* TX_MACHDR_IN_DSCR_MEM */ /* Reset the frame control field. Set type/subtype extracted from the */ /* incoming frame and set 'from_ds' bit in the outgoing frame. */ /* Also set the Security type for the outgoing frame based on cipher type*/ mac_hdr_len = set_mac_hdr_prot(mac_hdr, msdu->priority, service_class, is_qos, is_htc, is_amsdu); set_from_ds(mac_hdr, 1); if(ct != NO_ENCRYP) set_wep(mac_hdr, 1); /* Set Destination Address (DA), BSSID and Source Address (SA) in the */ /* outgoing frame. */ set_address1(mac_hdr, msdu->da); set_address2(mac_hdr, mget_bssid()); set_address3(mac_hdr, msdu->sa); /* Set the mac header related parameters in the Tx descriptor */ set_tx_dscr_buffer_addr((UWORD32 *)tx_dscr, (UWORD32)mac_hdr); set_tx_dscr_mh_len((UWORD32 *)tx_dscr, mac_hdr_len); set_tx_dscr_mh_offset((UWORD32 *)tx_dscr, 0); /* Get the PHY transmit mode based on the transmit rate and preamble */ phy_tx_mode = get_dscr_phy_tx_mode(tx_rate, pream, (void *)ae); /* Set the Tx-descriptor parameters */ set_tx_params(tx_dscr, tx_rate, pream, service_class, phy_tx_mode, retry_set); set_tx_dscr_q_num((UWORD32 *)tx_dscr, q_num); /* Set Security Parameters for the frame */ set_tx_security(tx_dscr, ct, key_type, key_index); /* Set the HT power save parameters */ set_ht_ps_params(tx_dscr, (void *)ae, tx_rate); /* Set the receiver address LUT index */ set_ht_ra_lut_index(tx_dscr, get_ht_handle_entry((void *)ae), msdu->priority, tx_rate); } else tx_dscr = amsdu_get_tx_dscr(amsdu_ctxt); /* Set the sub-MSDU info table in the Tx-Descriptor */ set_submsdu_info(tx_dscr, &buffer_desc, 1, buffer_desc.data_length, mac_hdr_len, msdu->sa, msdu->da, amsdu_ctxt); /* Update the TSF timestamp */ update_tx_dscr_tsf_ts((UWORD32 *)tx_dscr); /* Transmit the MSDU */ if(BTRUE == is_tx_ready(amsdu_ctxt)) { // 20120709 caisf mod, merged ittiam mac v1.2 code if(BTRUE == tx_data_packet((UWORD8 *)ae, msdu->da, msdu->priority, q_num, tx_dscr, amsdu_ctxt)) { /* Increment count indicating packet added to Hw queue */ /* Check if packet Bcast/Mcast or Unicast */ if(is_group(msdu->da) == BTRUE) { g_num_mc_bc_qd_pkt++; } else { ae->num_qd_pkt++; } } } }