/*
 * WfaStaWaitStop(): This function sends the stop packet on behalf of the
 *                   station, the idea is to keep sending the Stop
 *                   till a stop is recd from the console,the functions
 *                   quits after stop threshold reaches.
 */
int WfaStaWaitStop(char psave,int sleep_period,int *state)
{
    int myid=wmmps_info.ps_thread;
    PRINTF("\n Entering Sendwait");
    wUSLEEP(sleep_period);
    if(!num_stops)
    {
        wfaSetDUTPwrMgmt(psave);
        wfaTGSetPrio(psSockfd, TG_WMM_AC_BE);
    }

    num_stops++;
    create_apts_msg(APTS_STOP, psTxMsg,wmmps_info.my_sta_id);
    wSENDTO(psSockfd, psTxMsg, msgsize, 0, (struct sockaddr *)&wmmps_info.psToAddr, sizeof(struct sockaddr));
    mpx("STA msg",psTxMsg,64);

    wmm_thr[myid].stop_flag = 1;
    wPT_MUTEX_LOCK(&wmm_thr[myid].thr_stop_mutex);
    wPT_COND_SIGNAL(&wmm_thr[myid].thr_stop_cond);
    wPT_MUTEX_UNLOCK(&wmm_thr[myid].thr_stop_mutex);

    if(num_stops > MAX_STOPS)
    {
        DPRINT_ERR(WFA_ERR, "Too many stops sent\n");
        gtgWmmPS = 0;
        if(psSockfd != -1)
        {
            wCLOSE(psSockfd);
            psSockfd = -1;
        }
        wSIGNAL(SIGALRM, SIG_IGN);
    }

    return 0;
}
예제 #2
0
파일: wfa_sock.c 프로젝트: freshcoder/TDLS
/*
 * wfaTrafficSendTo(): Send Traffic through through traffic interface. 
 *  Note: the function used to wfaUdpSendTo().
 */
int wfaTrafficSendTo(int sock, char *buf, int bufLen, struct sockaddr *to) 
{
   int bytesSent;

   bytesSent = wSENDTO(sock, buf, bufLen, 0, to, sizeof(struct sockaddr));

   return bytesSent;
}
/*
 * sender(): This is a generic function to send a packed for the given dsc
 *               (ac:VI/VO/BE/BK), before sending the packet the function
 *               puts the station into the PS mode indicated by psave and
 *               sends the packet after sleeping for sllep_period
 */
int sender(char psave,int sleep_period, int userPriority)
{
    int r;

    PRINTF("\nsender::sleeping for %d userPriority=%d psSockFd=%d",sleep_period, userPriority, psSockfd);
    wfaSetDUTPwrMgmt(psave);
    wUSLEEP(sleep_period);
    create_apts_msg(APTS_DEFAULT, psTxMsg,wmmps_info.my_sta_id);
    wfaTGSetPrio(psSockfd, userPriority);
    r = wSENDTO(psSockfd, psTxMsg, msgsize, 0, (struct sockaddr *)&wmmps_info.psToAddr, sizeof(struct sockaddr));
    return r;
}
/*
 * wfaStaSndConfirm(): This function sends the confirm packet
 *                which is sent after the console sends the
 *                test name to the station
 */
int WfaStaSndConfirm(char psave,int sleep_period,int *state)
{
    static int num_hello=0;
    wfaSetDUTPwrMgmt(psave);
    if(!num_hello)
        create_apts_msg(APTS_CONFIRM, psTxMsg,0);
    wSENDTO(psSockfd, psTxMsg, msgsize, 0, (struct sockaddr *)&wmmps_info.psToAddr, sizeof(struct sockaddr));
    mpx("STA msg",psTxMsg,64);
    printf("Confirm Sent\n");

    (*state)++;

    return 0;
}
/*
 * WfaStaSnd2VO(): This function sends two AC_VO packets
 *                after the time specified by sleep_period
 *                and advances to the next state for the given test case
 */
int WfaStaSnd2VO(char psave,int sleep_period,int *state)
{
    int r;
    static int en=1;

    PRINTF("\r\nEnterring WfastasndVO %d",en++);
    if ((r=sender(psave,sleep_period,TG_WMM_AC_VO))>=0)
    {
        r = wSENDTO(psSockfd, psTxMsg, msgsize, 0, (struct sockaddr *)&wmmps_info.psToAddr, sizeof(struct sockaddr));
        mpx("STA msg",psTxMsg,64);
        (*state)++;
    }
    else
        PRINTF("\r\nError\n");

    return 0;
}
/*
 * wfaStaSndHello(): This function sends a Hello packet
 *                and sleeps for sleep_period, the idea is
 *                to keep sending hello packets till the console
 *                responds, the function keeps a check on the MAX
 *                Hellos and if number of Hellos exceed that it quits
 */
int WfaStaSndHello(char psave,int sleep_period,int *state)
{
    tgWMM_t *my_wmm = &wmm_thr[wmmps_info.ps_thread];

    usleep(sleep_period);
    wfaSetDUTPwrMgmt(psave);
    if(!(num_hello++))
        create_apts_msg(APTS_HELLO, psTxMsg,0);
    wfaTGSetPrio(psSockfd, 0);
    wSENDTO(psSockfd, psTxMsg, msgsize, 0, (struct sockaddr *)&wmmps_info.psToAddr, sizeof(struct sockaddr));


    wPT_MUTEX_LOCK(&my_wmm->thr_flag_mutex);
    if(my_wmm->thr_flag)
    {
        (*state)++;
        num_hello=0;
        my_wmm->thr_flag=0;
    }

    wPT_MUTEX_UNLOCK(&my_wmm->thr_flag_mutex);
    if(num_hello > MAXHELLO)
    {
        DPRINT_ERR(WFA_ERR, "Too many Hellos sent\n");
        gtgWmmPS = 0;
        num_hello=0;
        if(psSockfd != -1)
        {
            wCLOSE(psSockfd);
            psSockfd = -1;
        }
        wSIGNAL(SIGALRM, SIG_IGN);
    }

    return 0;
}