/* * 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; }
/* * upap_sresp - Send a response (ack or nak). */ static void upap_sresp(upap_state *u, u_char code, u_char id, char *msg, int msglen) { u_char *outp; int outlen; outlen = UPAP_HEADERLEN + sizeof (u_char) + msglen; outp = outpacket_buf[u->us_unit]; MAKEHEADER(outp, PPP_PAP); PUTCHAR(code, outp); PUTCHAR(id, outp); PUTSHORT(outlen, outp); PUTCHAR(msglen, outp); BCOPY(msg, outp, msglen); pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN); UPAPDEBUG((LOG_INFO, "pap_sresp: Sent code %d, id %d s=%d\n", code, id, u->us_clientstate)); }
/* * fsm_sdata - Send some data. * * Used for all packets sent to our peer by this module. */ void fsm_sdata( fsm *f, u_char code, u_char id, u_char *data, int datalen) { u_char *outp; int outlen; /* Adjust length to be smaller than MTU */ outp = outpacket_buf[f->unit]; if (datalen > peer_mru[f->unit] - (int)HEADERLEN) { datalen = peer_mru[f->unit] - HEADERLEN; } if (datalen && data != outp + PPP_HDRLEN + HEADERLEN) { BCOPY(data, outp + PPP_HDRLEN + HEADERLEN, datalen); } outlen = datalen + HEADERLEN; MAKEHEADER(outp, f->protocol); PUTCHAR(code, outp); PUTCHAR(id, outp); PUTSHORT(outlen, outp); pppWrite(f->unit, outpacket_buf[f->unit], outlen + PPP_HDRLEN); FSMDEBUG(LOG_INFO, ("fsm_sdata(%s): Sent code %d,%d,%d.\n", PROTO_NAME(f), code, id, outlen)); }