示例#1
0
/*
 * np_up - a network protocol has come up.
 */
void
np_up(int unit, int proto)
{
    if (num_np_up == 0) {
	/*
	 * At this point we consider that the link has come up successfully.
	 */
	need_holdoff = 0;

	if (idle_time_limit > 0)
	    TIMEOUT(check_idle, NULL, idle_time_limit);

	/*
	 * Set a timeout to close the connection once the maximum
	 * connect time has expired.
	 */
	if (maxconnect > 0)
	    TIMEOUT(connect_time_expired, 0, maxconnect);

	/*
	 * Detach now, if the updetach option was given.
	 */
	if (nodetach == -1)
	    detach();
    }
    ++num_np_up;
}
示例#2
0
/*
 * np_up - a network protocol has come up.
 */
void
np_up(int unit, u16_t proto)
{
  LWIP_UNUSED_ARG(unit);
  LWIP_UNUSED_ARG(proto);

  AUTHDEBUG((LOG_INFO, "np_up: %d proto=%X\n", unit, proto));
  if (num_np_up == 0) {
    AUTHDEBUG((LOG_INFO, "np_up: maxconnect=%d idle_time_limit=%d\n",ppp_settings.maxconnect,ppp_settings.idle_time_limit));
    /*
     * At this point we consider that the link has come up successfully.
     */
    if (ppp_settings.idle_time_limit > 0) {
      TIMEOUT(check_idle, NULL, ppp_settings.idle_time_limit);
    }

    /*
     * Set a timeout to close the connection once the maximum
     * connect time has expired.
     */
    if (ppp_settings.maxconnect > 0) {
      TIMEOUT(connect_time_expired, 0, ppp_settings.maxconnect);
    }
  }
  ++num_np_up;
}
示例#3
0
文件: gprs.c 项目: MarioViara/gprs
/**
 * Send a new command to the modem.
 *
 * @param cmd - Pointer to the command
 * @param eol - Optional EOL char
 * @param timeout - Timeout of the operation in milliseconds.
 */
static void gprs_command_timeout(gprs_t * gprs,const char * cmd,u8_t eol,u32_t timeout)
{
#if GPRS_COMMAND_DELAY
	u32_t delay = sys_now() - gprs->commandTime;
#endif

	gprs->sentCommand = cmd;

#if GPRS_COMMAND_DELAY
	if (delay < GPRS_COMMAND_DELAY)
	{
		delay = GPRS_COMMAND_DELAY - delay;
		timeout += delay;
		TIMEOUT(timeout);
		modem_set_state(gprs,MODEM_STATE_NONE);
		//LWIP_DEBUGF(GPRS_DEBUG,("gprs_command_timeout: Delayed %lu milliseconds\n",delay));
		TIMEOUT1(delay);
		gprs->delayedCommand = cmd;
		gprs->delayedEol = eol;

	}
	else
	{
		TIMEOUT(timeout);
		modem_set_state(gprs,MODEM_STATE_ECHO);
		gprs_raw_send(gprs,cmd,eol);
	}
#else
	TIMEOUT(timeout);
	modem_set_state(gprs,MODEM_STATE_ECHO);
	gprs_raw_send(gprs,cmd,eol);

#endif
}
示例#4
0
/*
 * upap_sauthreq - Send an Authenticate-Request.
 */
static void
upap_sauthreq(upap_state *u)
{
  u_char *outp;
  int outlen;

  outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) 
         + u->us_userlen + u->us_passwdlen;
  outp = outpacket_buf[u->us_unit];

  MAKEHEADER(outp, PPP_PAP);

  PUTCHAR(UPAP_AUTHREQ, outp);
  PUTCHAR(++u->us_id, outp);
  PUTSHORT(outlen, outp);
  PUTCHAR(u->us_userlen, outp);
  BCOPY(u->us_user, outp, u->us_userlen);
  INCPTR(u->us_userlen, outp);
  PUTCHAR(u->us_passwdlen, outp);
  BCOPY(u->us_passwd, outp, u->us_passwdlen);

  pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN);

  UPAPDEBUG((LOG_INFO, "pap_sauth: Sent id %d\n", u->us_id));

  TIMEOUT(upap_timeout, u, u->us_timeouttime);
  ++u->us_transmits;
  u->us_clientstate = UPAPCS_AUTHREQ;
}
/*
 * fsm_rtermreq - Receive Terminate-Req.
 */
static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) {
    ppp_pcb *pcb = f->pcb;

    switch (f->state) {
    case PPP_FSM_ACKRCVD:
    case PPP_FSM_ACKSENT:
	f->state = PPP_FSM_REQSENT;		/* Start over but keep trying */
	break;

    case PPP_FSM_OPENED:
	if (len > 0) {
	    ppp_info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p);
	} else
	    ppp_info("%s terminated by peer", PROTO_NAME(f));
	f->retransmits = 0;
	f->state = PPP_FSM_STOPPING;
	if (f->callbacks->down)
	    (*f->callbacks->down)(f);	/* Inform upper layers */
	TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time);
	break;
    default:
	break;
    }

    fsm_sdata(f, TERMACK, id, NULL, 0);
}
示例#6
0
文件: chap.c 项目: AoLaD/rtems
/* ARGSUSED */
static void
ChapSendResponse(
    chap_state *cstate)
{
    u_char *outp;
    int outlen, md_len, name_len;

    md_len = cstate->resp_length;
    name_len = strlen(cstate->resp_name);
    outlen = CHAP_HEADERLEN + sizeof (u_char) + md_len + name_len;
    outp = outpacket_buf;

    MAKEHEADER(outp, PPP_CHAP);

    PUTCHAR(CHAP_RESPONSE, outp);	/* we are a response */
    PUTCHAR(cstate->resp_id, outp);	/* copy id from challenge packet */
    PUTSHORT(outlen, outp);		/* packet length */

    PUTCHAR(md_len, outp);		/* length of MD */
    BCOPY(cstate->response, outp, md_len);	/* copy MD to buffer */
    INCPTR(md_len, outp);

    BCOPY(cstate->resp_name, outp, name_len); /* append our name */

    /* send the packet */
    output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);

    cstate->clientstate = CHAPCS_RESPONSE;
    TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime);
    ++cstate->resp_transmits;
}
示例#7
0
文件: chap.c 项目: AoLaD/rtems
/*
 * ChapSendChallenge - Send an Authenticate challenge.
 */
static void
ChapSendChallenge(
    chap_state *cstate)
{
    u_char *outp;
    int chal_len, name_len;
    int outlen;

    chal_len = cstate->chal_len;
    name_len = strlen(cstate->chal_name);
    outlen = CHAP_HEADERLEN + sizeof (u_char) + chal_len + name_len;
    outp = outpacket_buf;

    MAKEHEADER(outp, PPP_CHAP);		/* paste in a CHAP header */

    PUTCHAR(CHAP_CHALLENGE, outp);
    PUTCHAR(cstate->chal_id, outp);
    PUTSHORT(outlen, outp);

    PUTCHAR(chal_len, outp);		/* put length of challenge */
    BCOPY(cstate->challenge, outp, chal_len);
    INCPTR(chal_len, outp);

    BCOPY(cstate->chal_name, outp, name_len);	/* append hostname */

    output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN);

    TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime);
    ++cstate->chal_transmits;
}
示例#8
0
/*
 * fsm_rtermreq - Receive Terminate-Req.
 */
static void
fsm_rtermreq(fsm *f, int id, u_char *p, int len)
{
    char str[80];

    FSMDEBUG((LOG_INFO, "fsm_rtermreq(%s): Rcvd id %d.",
	      PROTO_NAME(f), id));

    switch (f->state) {
    case ACKRCVD:
    case ACKSENT:
	f->state = REQSENT;		/* Start over but keep trying */
	break;

    case OPENED:
	if (len > 0) {
	    fmtmsg(str, sizeof(str), "%0.*v", len, p);
	    syslog(LOG_INFO, "%s terminated by peer (%s)", PROTO_NAME(f), str);
	} else
	    syslog(LOG_INFO, "%s terminated by peer", PROTO_NAME(f));
	if (f->callbacks->down)
	    (*f->callbacks->down)(f);	/* Inform upper layers */
	f->retransmits = 0;
	f->state = STOPPING;
	TIMEOUT(fsm_timeout, f, f->timeouttime);
	break;
    }

    fsm_sdata(f, TERMACK, id, NULL, 0);
}
示例#9
0
文件: fsm.c 项目: 0x00dec0de/Rovnix
/*
 * fsm_rtermreq - Receive Terminate-Req.
 */
static void
fsm_rtermreq(fsm *f, int id, u_char *p, int len)
{
  LWIP_UNUSED_ARG(p);

  FSMDEBUG(LOG_INFO, ("fsm_rtermreq(%s): Rcvd id %d state=%d (%s)\n",
        PROTO_NAME(f), id, f->state, ppperr_strerr[f->state]));

  switch (f->state) {
    case LS_ACKRCVD:
    case LS_ACKSENT:
      f->state = LS_REQSENT;    /* Start over but keep trying */
      break;

    case LS_OPENED:
      if (len > 0) {
        FSMDEBUG(LOG_INFO, ("%s terminated by peer (%p)\n", PROTO_NAME(f), p));
      } else {
        FSMDEBUG(LOG_INFO, ("%s terminated by peer\n", PROTO_NAME(f)));
      }
      if (f->callbacks->down) {
        (*f->callbacks->down)(f);  /* Inform upper layers */
      }
      f->retransmits = 0;
      f->state = LS_STOPPING;
      TIMEOUT(fsm_timeout, f, f->timeouttime);
      break;
  }

  fsm_sdata(f, TERMACK, (u_char)id, NULL, 0);
}
示例#10
0
文件: upap.c 项目: crvv/lwip
/*
 * upap_sauthreq - Send an Authenticate-Request.
 */
static void upap_sauthreq(ppp_pcb *pcb) {
    struct pbuf *p;
    u_char *outp;
    int outlen;

    outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) +
             pcb->upap.us_userlen + pcb->upap.us_passwdlen;
    p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +outlen), PPP_CTRL_PBUF_TYPE);
    if(NULL == p)
        return;
    if(p->tot_len != p->len) {
        pbuf_free(p);
        return;
    }

    outp = (u_char*)p->payload;
    MAKEHEADER(outp, PPP_PAP);

    PUTCHAR(UPAP_AUTHREQ, outp);
    PUTCHAR(++pcb->upap.us_id, outp);
    PUTSHORT(outlen, outp);
    PUTCHAR(pcb->upap.us_userlen, outp);
    MEMCPY(outp, pcb->upap.us_user, pcb->upap.us_userlen);
    INCPTR(pcb->upap.us_userlen, outp);
    PUTCHAR(pcb->upap.us_passwdlen, outp);
    MEMCPY(outp, pcb->upap.us_passwd, pcb->upap.us_passwdlen);

    ppp_write(pcb, p);

    TIMEOUT(upap_timeout, pcb, pcb->settings.pap_timeout_time);
    ++pcb->upap.us_transmits;
    pcb->upap.us_clientstate = UPAPCS_AUTHREQ;
}
示例#11
0
文件: fsm.c 项目: AoLaD/rtems
/*
 * fsm_rtermreq - Receive Terminate-Req.
 */
static void
fsm_rtermreq(
    fsm *f,
    int id,
    u_char *p,
    int len)
{
    switch (f->state) {
    case ACKRCVD:
    case ACKSENT:
	f->state = REQSENT;		/* Start over but keep trying */
	break;

    case OPENED:
	if (len > 0) {
	    info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p);
	} else
	    info("%s terminated by peer", PROTO_NAME(f));
	if (f->callbacks->down)
	    (*f->callbacks->down)(f);	/* Inform upper layers */
	f->retransmits = 0;
	f->state = STOPPING;
	TIMEOUT(fsm_timeout, f, f->timeouttime);
	break;
    }

    fsm_sdata(f, TERMACK, id, NULL, 0);
}
示例#12
0
文件: gprs.c 项目: MarioViara/gprs
/**
 * Handle timeout
 */
static void gprs_timeout(void * arg)
{
    gprs_t * gprs = (gprs_t *)arg;


    switch (gprs->state)
    {
        default:
            LWIP_DEBUGF(GPRS_DEBUG,("gprs: Timeout state %d\n",gprs->state));
            gprs_do_start(gprs);
            break;

        case GPRS_STATE_MODEM_OFF:
            gprs_arch_modem_on(gprs->device);
            LWIP_DEBUGF(GPRS_DEBUG,("gprs: set modem on\n"));
            TIMEOUT(GPRS_MODEM_ON_DELAY);
            gprs_set_state(gprs,GPRS_STATE_MODEM_ON);
            break;

        case GPRS_STATE_MODEM_ON:
        case GPRS_STATE_MODEM_WAKEUP:
            do_modem_wakeup(gprs);
            break;

        case GPRS_STATE_MODEM_ALIVE:
        	do_modem_alive(gprs);
        	break;



    }
}
/*
 * terminate_layer - Start process of shutting down the FSM
 *
 * Cancel any timeout running, notify upper layers we're done, and
 * send a terminate-request message as configured.
 */
static void terminate_layer(fsm *f, int nextstate) {
    ppp_pcb *pcb = f->pcb;

    if( f->state != PPP_FSM_OPENED )
	UNTIMEOUT(fsm_timeout, f);	/* Cancel timeout */
    else if( f->callbacks->down )
	(*f->callbacks->down)(f);	/* Inform upper layers we're down */

    /* Init restart counter and send Terminate-Request */
    f->retransmits = pcb->settings.fsm_max_term_transmits;
    fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
	      (const u_char *) f->term_reason, f->term_reason_len);

    if (f->retransmits == 0) {
	/*
	 * User asked for no terminate requests at all; just close it.
	 * We've already fired off one Terminate-Request just to be nice
	 * to the peer, but we're not going to wait for a reply.
	 */
	f->state = nextstate == PPP_FSM_CLOSING ? PPP_FSM_CLOSED : PPP_FSM_STOPPED;
	if( f->callbacks->finished )
	    (*f->callbacks->finished)(f);
	return;
    }

    TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time);
    --f->retransmits;

    f->state = nextstate;
}
示例#14
0
/*
 * chap_timeout - It's time to send another challenge to the peer.
 * This could be either a retransmission of a previous challenge,
 * or a new challenge to start re-authentication.
 */
static void chap_timeout(void *arg) {
	ppp_pcb *pcb = (ppp_pcb*)arg;
	struct pbuf *p;

	pcb->chap_server.flags &= ~TIMEOUT_PENDING;
	if ((pcb->chap_server.flags & CHALLENGE_VALID) == 0) {
		pcb->chap_server.challenge_xmits = 0;
		chap_generate_challenge(pcb);
		pcb->chap_server.flags |= CHALLENGE_VALID;
	} else if (pcb->chap_server.challenge_xmits >= pcb->settings.chap_max_transmits) {
		pcb->chap_server.flags &= ~CHALLENGE_VALID;
		pcb->chap_server.flags |= AUTH_DONE | AUTH_FAILED;
		auth_peer_fail(pcb, PPP_CHAP);
		return;
	}

	p = pbuf_alloc(PBUF_RAW, (u16_t)(pcb->chap_server.challenge_pktlen), PPP_CTRL_PBUF_TYPE);
	if(NULL == p)
		return;
	if(p->tot_len != p->len) {
		pbuf_free(p);
		return;
	}
	MEMCPY(p->payload, pcb->chap_server.challenge, pcb->chap_server.challenge_pktlen);
	ppp_write(pcb, p);
	++pcb->chap_server.challenge_xmits;
	pcb->chap_server.flags |= TIMEOUT_PENDING;
	TIMEOUT(chap_timeout, arg, pcb->settings.chap_timeout_time);
}
示例#15
0
static void
lcp_reset_timeout(void *ctx)
{
	lcp *_this;

	_this = ctx;

	if (_this->echo_interval > 0) {
		if (_this->echo_failures == 0) {
			TIMEOUT(lcp_timeout, _this, _this->echo_interval);
		} else {
			TIMEOUT(lcp_timeout, _this, _this->echo_retry_interval);
		}
	} else {
		UNTIMEOUT(lcp_timeout, _this);
	}
}
示例#16
0
文件: fsm.c 项目: 0x00dec0de/Rovnix
/*
 * fsm_timeout - Timeout expired.
 */
static void
fsm_timeout(void *arg)
{
  fsm *f = (fsm *) arg;

  switch (f->state) {
    case LS_CLOSING:
    case LS_STOPPING:
      if( f->retransmits <= 0 ) {
        FSMDEBUG(LOG_WARNING, ("%s: timeout sending Terminate-Request state=%d (%s)\n",
             PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
        /*
         * We've waited for an ack long enough.  Peer probably heard us.
         */
        f->state = (f->state == LS_CLOSING)? LS_CLOSED: LS_STOPPED;
        if( f->callbacks->finished ) {
          (*f->callbacks->finished)(f);
        }
      } else {
        FSMDEBUG(LOG_WARNING, ("%s: timeout resending Terminate-Requests state=%d (%s)\n",
             PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
        /* Send Terminate-Request */
        fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
            (u_char *) f->term_reason, f->term_reason_len);
        TIMEOUT(fsm_timeout, f, f->timeouttime);
        --f->retransmits;
      }
      break;

    case LS_REQSENT:
    case LS_ACKRCVD:
    case LS_ACKSENT:
      if (f->retransmits <= 0) {
        FSMDEBUG(LOG_WARNING, ("%s: timeout sending Config-Requests state=%d (%s)\n",
         PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
        f->state = LS_STOPPED;
        if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished ) {
          (*f->callbacks->finished)(f);
        }
      } else {
        FSMDEBUG(LOG_WARNING, ("%s: timeout resending Config-Request state=%d (%s)\n",
         PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
        /* Retransmit the configure-request */
        if (f->callbacks->retransmit) {
          (*f->callbacks->retransmit)(f);
        }
        fsm_sconfreq(f, 1);    /* Re-send Configure-Request */
        if( f->state == LS_ACKRCVD ) {
          f->state = LS_REQSENT;
        }
      }
      break;

    default:
      FSMDEBUG(LOG_INFO, ("%s: UNHANDLED timeout event in state %d (%s)!\n",
          PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
  }
}
/*
 * fsm_sconfreq - Send a Configure-Request.
 */
static void fsm_sconfreq(fsm *f, int retransmit) {
    ppp_pcb *pcb = f->pcb;
    struct pbuf *p;
    u_char *outp;
    int cilen;

    if( f->state != PPP_FSM_REQSENT && f->state != PPP_FSM_ACKRCVD && f->state != PPP_FSM_ACKSENT ){
	/* Not currently negotiating - reset options */
	if( f->callbacks->resetci )
	    (*f->callbacks->resetci)(f);
	f->nakloops = 0;
	f->rnakloops = 0;
    }

    if( !retransmit ){
	/* New request - reset retransmission counter, use new ID */
	f->retransmits = pcb->settings.fsm_max_conf_req_transmits;
	f->reqid = ++f->id;
    }

    f->seen_ack = 0;

    /*
     * Make up the request packet
     */
    if( f->callbacks->cilen && f->callbacks->addci ){
	cilen = (*f->callbacks->cilen)(f);
	if( cilen > pcb->peer_mru - HEADERLEN )
	    cilen = pcb->peer_mru - HEADERLEN;
    } else
	cilen = 0;

    p = pbuf_alloc(PBUF_RAW, (u16_t)(cilen + HEADERLEN + PPP_HDRLEN), PPP_CTRL_PBUF_TYPE);
    if(NULL == p)
        return;
    if(p->tot_len != p->len) {
        pbuf_free(p);
        return;
    }

    /* send the request to our peer */
    outp = (u_char*)p->payload;
    MAKEHEADER(outp, f->protocol);
    PUTCHAR(CONFREQ, outp);
    PUTCHAR(f->reqid, outp);
    PUTSHORT(cilen + HEADERLEN, outp);
    if (cilen != 0) {
	(*f->callbacks->addci)(f, outp, &cilen);
	LWIP_ASSERT("cilen == p->len - HEADERLEN - PPP_HDRLEN", cilen == p->len - HEADERLEN - PPP_HDRLEN);
    }

    ppp_write(pcb, p);

    /* start the retransmit timer */
    --f->retransmits;
    TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time);
}
示例#18
0
文件: gprs.c 项目: MarioViara/gprs
/**
 * Start a new gprs connection
 */
static void gprs_do_start(gprs_t * gprs)
{
    UNTIMEOUT();

    LWIP_DEBUGF(GPRS_DEBUG,("gprs: set modem off\n"));

    gprs_arch_modem_off(gprs->device);
    gprs_set_state(gprs,GPRS_STATE_MODEM_OFF);
    TIMEOUT(GPRS_MODEM_OFF_TIME);
}
bool cResources::checkRes( pResource res )
{

	if( TIMEOUT( res->timer ) )
	{
		if( res->consumed>ores.n )
			res->consumed=ores.n;
		for( uint32_t c=0; c<ores.n; c++ ) //Find howmany periods have been by, give 1 more ore for each period.
		{
			if(( TIMEOUT( res->timer+(c* ores.time*SECS)) ) && res->consumed>=ores.rate )
				res->consumed-=ores.rate;//AntiChrist
		}
		res->timer= getClockmSecs() + ores.time*SECS;
		if( res->consumed == 0)
			return true; // delete itself because FULL
	}

	return false;
}
示例#20
0
bool cResources::checkRes( P_RESOURCE res )
{

	if( TIMEOUT( res->timer ) )
	{
		if( res->consumed>ores.n )
			res->consumed=ores.n;
		for( UI32 c=0; c<ores.n; c++ ) //Find howmany periods have been by, give 1 more ore for each period.
		{
			if(( TIMEOUT( res->timer+(c* ores.time*MY_CLOCKS_PER_SEC)) ) && res->consumed>=ores.rate )
				res->consumed-=ores.rate;//AntiChrist
		}
		res->timer= uiCurrentTime + ores.time*MY_CLOCKS_PER_SEC;
		if( res->consumed == 0)
			return true; // delete itself because FULL
	}

	return false;
}
示例#21
0
int rtems_pppd_disconnect(void)
{
  /* need to wait a little time before we can bring the link down */
  /* set up time out in 1 seconds */
  TIMEOUT(timeout_terminate, NULL, 1);

  /* send event to wake up the pppd code */
  /* pretend its a serial interrput */
  rtems_event_send(rtems_pppd_taskid, RTEMS_EVENT_31);

  return ( 0 );
}
示例#22
0
文件: ossLib.c 项目: andy345/vxworks5
STATUS ossSemTake 
    (
    SEM_HANDLE semHandle,	    /* semaphore to take */
    UINT32 blockFlag		    /* specifies blocking action */
    )

    {
    if (semTake ((SEM_ID) semHandle, TIMEOUT (blockFlag)) != OK)
	return ossStatus (translateError ());

    return OK;
    }
示例#23
0
文件: ossLib.c 项目: andy345/vxworks5
STATUS ossMutexTake 
    (
    MUTEX_HANDLE mutexHandle,	    /* Mutex to take */
    UINT32 blockFlag		    /* specifies blocking action */
    )

    {
    if (semTake ((SEM_ID) mutexHandle, TIMEOUT (blockFlag)) != OK)
	return ossStatus (translateError ());

    return OK;
    }
示例#24
0
int main(void){
	return run_suite(
		START_SUITE(test1){
			ADD_CASE(
				START_CASE(core){
					FIXTURE(_setup, _teardown);
					TIMEOUT(5);
					ADD_TEST(test_div_by_zero);
					ADD_TEST(test_div_by_zero2);
				}END_CASE
			);
			ADD_CASE(
				START_CASE(core1){
					FIXTURE(_setup, _teardown);
					TIMEOUT(5);
					ADD_TEST(test_div_by_zero1);
				}END_CASE
			);
		}END_SUITE
	);
}
示例#25
0
文件: d_net.c 项目: HipsterLion/SRB2
static void InitNode(INT32 node)
{
	nodes[node].acktosend_head = nodes[node].acktosend_tail = 0;
#ifndef NEWPING
	nodes[node].ping = PINGDEFAULT;
	nodes[node].varping = VARPINGDEFAULT;
	nodes[node].timeout = TIMEOUT(nodes[node].ping,nodes[node].varping);
#endif
	nodes[node].firstacktosend = 0;
	nodes[node].nextacknum = 1;
	nodes[node].remotefirstack = 0;
	nodes[node].flags = 0;
}
示例#26
0
文件: upap.c 项目: crvv/lwip
/*
 * upap_authpeer - Authenticate our peer (start server).
 *
 * Set new state.
 */
void upap_authpeer(ppp_pcb *pcb) {

    /* Lower layer up yet? */
    if (pcb->upap.us_serverstate == UPAPSS_INITIAL ||
            pcb->upap.us_serverstate == UPAPSS_PENDING) {
        pcb->upap.us_serverstate = UPAPSS_PENDING;
        return;
    }

    pcb->upap.us_serverstate = UPAPSS_LISTEN;
    if (pcb->settings.pap_req_timeout > 0)
        TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout);
}
示例#27
0
/*
 * fsm_timeout - Timeout expired.
 */
static void
fsm_timeout(void *arg)
{
    fsm *f = (fsm *) arg;

    switch (f->state) {
    case CLOSING:
    case STOPPING:
	if( f->retransmits <= 0 ){
	    /*
	     * We've waited for an ack long enough.  Peer probably heard us.
	     */
	    f->state = (f->state == CLOSING)? CLOSED: STOPPED;
	    if( f->callbacks->finished )
		(*f->callbacks->finished)(f);
	} else {
	    /* Send Terminate-Request */
	    fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
		      (u_char *) f->term_reason, f->term_reason_len);
	    TIMEOUT(fsm_timeout, f, f->timeouttime);
	    --f->retransmits;
	}
	break;

    case REQSENT:
    case ACKRCVD:
    case ACKSENT:
	if (f->retransmits <= 0) {
	    syslog(LOG_WARNING, "%s: timeout sending Config-Requests",
		   PROTO_NAME(f));
	    f->state = STOPPED;
	    if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished )
		(*f->callbacks->finished)(f);

	} else {
	    /* Retransmit the configure-request */
	    if (f->callbacks->retransmit)
		(*f->callbacks->retransmit)(f);
	    fsm_sconfreq(f, 1);		/* Re-send Configure-Request */
	    if( f->state == ACKRCVD )
		f->state = REQSENT;
	}
	break;

    default:
	FSMDEBUG((LOG_INFO, "%s: Timeout event in state %d!",
		  PROTO_NAME(f), f->state));
    }
}
示例#28
0
文件: fsm.c 项目: 0x00dec0de/Rovnix
/*
 * fsm_sconfreq - Send a Configure-Request.
 */
static void
fsm_sconfreq(fsm *f, int retransmit)
{
  u_char *outp;
  int cilen;
  
  if( f->state != LS_REQSENT && f->state != LS_ACKRCVD && f->state != LS_ACKSENT ) {
    /* Not currently negotiating - reset options */
    if( f->callbacks->resetci ) {
      (*f->callbacks->resetci)(f);
    }
    f->nakloops = 0;
  }
  
  if( !retransmit ) {
    /* New request - reset retransmission counter, use new ID */
    f->retransmits = f->maxconfreqtransmits;
    f->reqid = ++f->id;
  }
  
  f->seen_ack = 0;
  
  /*
   * Make up the request packet
   */
  outp = outpacket_buf[f->unit] + PPP_HDRLEN + HEADERLEN;
  if( f->callbacks->cilen && f->callbacks->addci ) {
    cilen = (*f->callbacks->cilen)(f);
    if( cilen > peer_mru[f->unit] - (int)HEADERLEN ) {
      cilen = peer_mru[f->unit] - HEADERLEN;
    }
    if (f->callbacks->addci) {
      (*f->callbacks->addci)(f, outp, &cilen);
    }
  } else {
    cilen = 0;
  }

  /* send the request to our peer */
  fsm_sdata(f, CONFREQ, f->reqid, outp, cilen);
  
  /* start the retransmit timer */
  --f->retransmits;
  TIMEOUT(fsm_timeout, f, f->timeouttime);
  
  FSMDEBUG(LOG_INFO, ("%s: sending Configure-Request, id %d\n",
        PROTO_NAME(f), f->reqid));
}
/*
 * fsm_timeout - Timeout expired.
 */
static void fsm_timeout(void *arg) {
    fsm *f = (fsm *) arg;
    ppp_pcb *pcb = f->pcb;

    switch (f->state) {
    case PPP_FSM_CLOSING:
    case PPP_FSM_STOPPING:
	if( f->retransmits <= 0 ){
	    /*
	     * We've waited for an ack long enough.  Peer probably heard us.
	     */
	    f->state = (f->state == PPP_FSM_CLOSING)? PPP_FSM_CLOSED: PPP_FSM_STOPPED;
	    if( f->callbacks->finished )
		(*f->callbacks->finished)(f);
	} else {
	    /* Send Terminate-Request */
	    fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
		      (const u_char *) f->term_reason, f->term_reason_len);
	    TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time);
	    --f->retransmits;
	}
	break;

    case PPP_FSM_REQSENT:
    case PPP_FSM_ACKRCVD:
    case PPP_FSM_ACKSENT:
	if (f->retransmits <= 0) {
	    ppp_warn("%s: timeout sending Config-Requests", PROTO_NAME(f));
	    f->state = PPP_FSM_STOPPED;
	    if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished )
		(*f->callbacks->finished)(f);

	} else {
	    /* Retransmit the configure-request */
	    if (f->callbacks->retransmit)
		(*f->callbacks->retransmit)(f);
	    fsm_sconfreq(f, 1);		/* Re-send Configure-Request */
	    if( f->state == PPP_FSM_ACKRCVD )
		f->state = PPP_FSM_REQSENT;
	}
	break;

    default:
	FSMDEBUG(("%s: Timeout event in state %d!", PROTO_NAME(f), f->state));
	/* no break */
    }
}
示例#30
0
文件: fsm.c 项目: 0x00dec0de/Rovnix
/*
 * fsm_protreject - Peer doesn't speak this protocol.
 *
 * Treat this as a catastrophic error (RXJ-).
 */
void
fsm_protreject(fsm *f)
{
  switch( f->state ) {
    case LS_CLOSING:
      UNTIMEOUT(fsm_timeout, f);  /* Cancel timeout */
      /* fall through */
    case LS_CLOSED:
      f->state = LS_CLOSED;
      if( f->callbacks->finished ) {
        (*f->callbacks->finished)(f);
      }
      break;

    case LS_STOPPING:
    case LS_REQSENT:
    case LS_ACKRCVD:
    case LS_ACKSENT:
      UNTIMEOUT(fsm_timeout, f);  /* Cancel timeout */
      /* fall through */
    case LS_STOPPED:
      f->state = LS_STOPPED;
      if( f->callbacks->finished ) {
        (*f->callbacks->finished)(f);
      }
      break;
    
    case LS_OPENED:
      if( f->callbacks->down ) {
        (*f->callbacks->down)(f);
      }
      /* Init restart counter, send Terminate-Request */
      f->retransmits = f->maxtermtransmits;
      fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
            (u_char *) f->term_reason, f->term_reason_len);
      TIMEOUT(fsm_timeout, f, f->timeouttime);
      --f->retransmits;

      f->state = LS_STOPPING;
      break;
    
    default:
      FSMDEBUG(LOG_INFO, ("%s: Protocol-reject event in state %d (%s)!\n",
            PROTO_NAME(f), f->state, ppperr_strerr[f->state]));
    }
}