static void PPPFSM_sendtermreq ( PPPFSM_CFG_PTR fsm, /* [IN/OUT] - State Machine */ PCB_PTR packet /* [IN] - free packet */ ) { /* Body */ PPP_CFG_PTR ppp_ptr = fsm->HANDLE; /* Stop the retransmission timer if necessary */ if (fsm->STATE > PPP_STATE_STOPPED && fsm->STATE < PPP_STATE_OPENED) { PPP_send_stop(ppp_ptr, fsm->CALL->PROTOCOL); } /* Endif */ /* Allocate a packet if necessary */ if (!packet) { packet = PPP_pcballoc(fsm->CALL->PROTOCOL, CP_HDR_LEN); if (!packet) { ++fsm->ST_CP_NOBUFS; /* Nonfatal error */ return; } /* Endif */ } /* Endif */ PPPFSM_buildheader(fsm, packet, CP_CODE_TERM_REQ, FALSE, 0); PPP_send_rexmit(ppp_ptr, fsm->CALL->PROTOCOL, packet, _PPP_MAX_TERM_RETRIES, PPPFSM_timeout, fsm); } /* Endbody */
void PAP_send ( _ppp_handle handle /* [IN] - the PPP state structure */ ) { /* Body */ #if RTCSCFG_ENABLE_IP4 PPP_CFG_PTR ppp_ptr = handle; PAP_DATA_PTR pap_ptr = &ppp_ptr->PAP_STATE; PCB_PTR pcb; unsigned char *outp; uint16_t len; pap_ptr->CLIENT_STATE = PAP_STATE_INITIAL; pap_ptr->CURID = RTCS_rand() & 0xFF; /* Acquire a PCB */ len = PAP_HDR_LEN + 2 /* Start CR 2207 */ + PPP_SECRET(ppp_ptr,_PPP_PAP_LSECRET->PPP_ID_LENGTH) + PPP_SECRET(ppp_ptr,_PPP_PAP_LSECRET->PPP_PW_LENGTH); /* End CR 2207 */ pcb = PPP_pcballoc(PPP_PROT_PAP, len); if (pcb == NULL) { return; } /* Endif */ /* Build an Authenticate-Request packet */ outp = pcb->FRAG[0].FRAGMENT + 2; *outp++ = PAP_CODE_AUTH_REQ; *outp++ = pap_ptr->CURID; *outp++ = (len >> 8) & 0xFF; *outp++ = len & 0xFF; /* Start CR 2207 */ *outp++ = len = PPP_SECRET(ppp_ptr,_PPP_PAP_LSECRET->PPP_ID_LENGTH); PPP_memcopy(PPP_SECRET(ppp_ptr,_PPP_PAP_LSECRET->PPP_ID_PTR), outp, len); outp += len; *outp++ = len = PPP_SECRET(ppp_ptr,_PPP_PAP_LSECRET->PPP_PW_LENGTH); PPP_memcopy(PPP_SECRET(ppp_ptr,_PPP_PAP_LSECRET->PPP_PW_PTR), outp, len); /* End CR 2207 */ /* Send the PCB */ PPP_send_rexmit(ppp_ptr, PPP_PROT_PAP, pcb, 0, PAP_timeout, pap_ptr); #endif /* RTCSCFG_ENABLE_IP4 */ } /* Endbody */
static void PPPFSM_sendconfreq ( PPPFSM_CFG_PTR fsm, /* [IN/OUT] - State Machine */ PCB_PTR packet /* [IN] - free packet */ ) { /* Body */ PPP_CFG_PTR ppp_ptr = fsm->HANDLE; unsigned char *outp; uint32_t size; if (fsm->STATE <= PPP_STATE_STOPPING || fsm->STATE >= PPP_STATE_OPENED) { /* Not currently negotiating -- reset options */ if (fsm->CALL->resetreq) { fsm->CALL->resetreq(fsm); } /* Endif */ fsm->NAKS = 0; } /* Endif */ /* Stop the retransmission timer if necessary */ if (fsm->STATE > PPP_STATE_STOPPED && fsm->STATE < PPP_STATE_OPENED) { PPP_send_stop(ppp_ptr, fsm->CALL->PROTOCOL); } /* Endif */ /* Allocate a packet if necessary */ if (!packet) { packet = PPP_pcballoc(fsm->CALL->PROTOCOL, ppp_ptr->SEND_OPTIONS->MRU); if (!packet) { ++fsm->ST_CP_NOBUFS; /* Nonfatal error */ return; } /* Endif */ } /* Endif */ /* Build the request packet */ outp = packet->FRAG[0].FRAGMENT + 2; size = packet->FRAG[0].LENGTH - 2 - CP_HDR_LEN; if (fsm->CALL->buildreq) { size = fsm->CALL->buildreq(fsm, outp + CP_HDR_LEN, size); } /* Endif */ fsm->REQID = fsm->CURID; PPPFSM_buildheader(fsm, packet, CP_CODE_CONF_REQ, FALSE, size); /* Send the request */ PPP_send_rexmit(ppp_ptr, fsm->CALL->PROTOCOL, packet, _PPP_MAX_CONF_RETRIES, PPPFSM_timeout, fsm); } /* Endbody */
void CHAP_challenge ( _ppp_handle handle /* [IN] - the PPP state structure */ ) { /* Body */ PPP_CFG_PTR ppp_ptr = handle; CHAP_DATA_PTR chap_ptr = &ppp_ptr->CHAP_STATE; PCB_PTR pcb; uchar_ptr outp; uint_16 len; uint_16 i, idlen; chap_ptr->SERVER_STATE = CHAP_STATE_INITIAL; chap_ptr->CURID = RTCS_rand() & 0xFF; /* Acquire a message buffer */ /* Start CR 2207 */ idlen = strlen(PPP_SECRET(ppp_ptr,_PPP_CHAP_LNAME)); /* End CR 2207 */ len = CHAP_HDR_LEN + 1 + CHAP_CHALLENGE_LEN + idlen; pcb = PPP_pcballoc(PPP_PROT_CHAP, len); if (pcb == NULL) { return; } /* Endif */ /* Build a Challenge packet */ outp = pcb->FRAG[0].FRAGMENT + 2; *outp++ = CHAP_CODE_CHALLENGE; *outp++ = chap_ptr->CURID; *outp++ = (len >> 8) & 0xFF; *outp++ = len & 0xFF; *outp++ = CHAP_CHALLENGE_LEN; for (i=0; i<CHAP_CHALLENGE_LEN; i++) { *outp++ = chap_ptr->MD5[i] = RTCS_rand() & 0xFF; } /* Endfor */ /* Start CR 2207 */ PPP_memcopy(PPP_SECRET(ppp_ptr,_PPP_CHAP_LNAME), outp, idlen); /* End CR 2207 */ /* Send the PCB */ PPP_send_rexmit(ppp_ptr, PPP_PROT_CHAP, pcb, 0, CHAP_timeout, chap_ptr); } /* Endbody */