• Home
  • Raw
  • Download

Lines Matching +full:check +full:- +full:ci +full:- +full:script

2  * ipv6cp.c - PPP IPV6 Control Protocol.
41 Jean-Luc.Richier@imag.fr, IMAG-LSR.
45 Jean-Luc.Richier@imag.fr, IMAG-LSR.
51 usuelles dans la recherche, c'est-à-dire qu'il peut
98 * ipcp.c - PPP IP Control Protocol.
100 * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
121 * Pittsburgh, PA 15213-3890
122 * (412) 268-4387, fax: (412) 268-7395
123 * tech-transfer@andrew.cmu.edu
177 * Callbacks for fsm code. (CI = Configuration Information)
179 static void ipv6cp_resetci(fsm *f); /* Reset our CI */
180 static int ipv6cp_cilen(fsm *f); /* Return length of our CI */
181 static void ipv6cp_addci(fsm *f, u_char *ucp, int *lenp); /* Add our CI */
182 static int ipv6cp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */
183 static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject); /* Peer nak'd our CI */
184 static int ipv6cp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */
185 static int ipv6cp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree); /* Rcv CI */
202 NULL, /* Called when Protocol-Reject received */
204 NULL, /* Called to handle protocol-specific codes */
210 * Command-line options.
225 { "-ipv6", o_bool, &ipv6cp_protent.enabled_flag,
228 { "ipv6cp-accept-local", o_bool, &ipv6cp_allowoptions[0].accept_local,
231 { "ipv6cp-use-ipaddr", o_bool, &ipv6cp_allowoptions[0].use_ip,
234 { "ipv6cp-use-persistent", o_bool, &ipv6cp_wantoptions[0].use_persistent,
235 "Use uniquely-available persistent value for link local address", 1 },
237 { "ipv6cp-restart", o_int, &ipv6cp_fsm[0].timeouttime,
239 { "ipv6cp-max-terminate", o_int, &ipv6cp_fsm[0].maxtermtransmits,
240 "Set max #xmits for term-reqs", OPT_PRIO },
241 { "ipv6cp-max-configure", o_int, &ipv6cp_fsm[0].maxconfreqtransmits,
242 "Set max #xmits for conf-reqs", OPT_PRIO },
243 { "ipv6cp-max-failure", o_int, &ipv6cp_fsm[0].maxnakloops,
244 "Set max #conf-naks for IPv6CP", OPT_PRIO },
322 * run an ipcp-up/down script while one is already running.
335 * setifaceid - set the interface identifiers manually
366 eui64_copy(addr.s6_addr32[2], wo->ourid);
367 wo->opt_local = 1;
382 eui64_copy(addr.s6_addr32[2], wo->hisid);
383 wo->opt_remote = 1;
401 if (wo->opt_local)
402 printer(arg, "%s", llv6_ntoa(wo->ourid));
404 if (wo->opt_remote)
405 printer(arg, "%s", llv6_ntoa(wo->hisid));
426 * ipv6cp_init - Initialize IPV6CP.
429 fsm *f = &pcb->ipv6cp_fsm;
430 ipv6cp_options *wo = &pcb->ipv6cp_wantoptions;
431 ipv6cp_options *ao = &pcb->ipv6cp_allowoptions;
433 f->pcb = pcb;
434 f->protocol = PPP_IPV6CP;
435 f->callbacks = &ipv6cp_callbacks;
443 wo->accept_local = 1;
444 wo->neg_ifaceid = 1;
445 ao->neg_ifaceid = 1;
448 wo->neg_vj = 1;
449 ao->neg_vj = 1;
450 wo->vj_protocol = IPV6CP_COMP;
457 * ipv6cp_open - IPV6CP is allowed to come up.
460 fsm_open(&pcb->ipv6cp_fsm);
465 * ipv6cp_close - Take IPV6CP down.
468 fsm_close(&pcb->ipv6cp_fsm, reason);
473 * ipv6cp_lowerup - The lower layer is up.
476 fsm_lowerup(&pcb->ipv6cp_fsm);
481 * ipv6cp_lowerdown - The lower layer is down.
484 fsm_lowerdown(&pcb->ipv6cp_fsm);
489 * ipv6cp_input - Input IPV6CP packet.
492 fsm_input(&pcb->ipv6cp_fsm, p, len);
497 * ipv6cp_protrej - A Protocol-Reject was received for IPV6CP.
502 fsm_lowerdown(&pcb->ipv6cp_fsm);
507 * ipv6cp_resetci - Reset our CI.
510 ppp_pcb *pcb = f->pcb;
511 ipv6cp_options *wo = &pcb->ipv6cp_wantoptions;
512 ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
513 ipv6cp_options *ao = &pcb->ipv6cp_allowoptions;
515 wo->req_ifaceid = wo->neg_ifaceid && ao->neg_ifaceid;
517 if (!wo->opt_local) {
518 eui64_magic_nz(wo->ourid);
522 eui64_zero(go->hisid); /* last proposed interface identifier */
527 * ipv6cp_cilen - Return length of our CI.
530 ppp_pcb *pcb = f->pcb;
531 ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
538 return (LENCIIFACEID(go->neg_ifaceid) +
540 LENCIVJ(go->neg_vj) +
547 * ipv6cp_addci - Add our desired CIs to a packet.
550 ppp_pcb *pcb = f->pcb;
551 ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
562 len -= vjlen; \
575 len -= idlen; \
580 ADDCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid);
583 ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol);
586 *lenp -= len;
591 * ipv6cp_ackci - Ack our CIs.
594 * 0 - Ack was bad.
595 * 1 - Ack was good.
598 ppp_pcb *pcb = f->pcb;
599 ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
608 * Check packet length and CI length at each step.
616 if ((len -= vjlen) < 0) \
632 if ((len -= idlen) < 0) \
644 ACKCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid);
647 ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol);
663 * ipv6cp_nakci - Peer has sent a NAK for some of our CIs.
668 * 0 - Nak was bad.
669 * 1 - Nak was good.
672 ppp_pcb *pcb = f->pcb;
673 ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
687 * Check packet length and CI length at each step.
691 if (go->neg && \
695 len -= cilen; \
704 if (go->neg && \
708 len -= cilen; \
723 } else if (go->accept_local) {
725 eui64_equals(ifaceid, go->hisid)) /* bad luck */
753 if ( cilen < CILEN_VOID || (len -= cilen) < 0 )
755 next = p + cilen - 2;
760 if (go->neg_vj || no.neg_vj ||
767 if (go->neg_ifaceid || no.neg_ifaceid || cilen != CILEN_IFACEID)
771 if (go->accept_local) {
773 eui64_equals(ifaceid, go->hisid)) /* bad luck */
792 if (f->state != PPP_FSM_OPENED)
804 * ipv6cp_rejci - Reject some of our CIs.
807 ppp_pcb *pcb = f->pcb;
808 ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
819 * Check packet length and CI length at each step.
823 if (go->neg && \
827 len -= cilen; \
830 /* Check rejected value. */ \
838 if (go->neg && \
842 len -= p[1]; \
845 /* Check rejected value. */ \
852 REJCIIFACEID(CI_IFACEID, neg_ifaceid, go->ourid);
855 REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol);
866 if (f->state != PPP_FSM_OPENED)
877 * ipv6cp_reqci - Check the peer's requested CIs and send appropriate response.
880 * appropriately. If reject_if_disagree is non-zero, doesn't return
888 ppp_pcb *pcb = f->pcb;
889 ipv6cp_options *wo = &pcb->ipv6cp_wantoptions;
890 ipv6cp_options *ho = &pcb->ipv6cp_hisoptions;
891 ipv6cp_options *ao = &pcb->ipv6cp_allowoptions;
892 ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
916 cip = p = next; /* Remember begining of CI */
917 if (l < 2 || /* Not enough data for CI header or */
918 p[1] < 2 || /* CI length too small or */
919 p[1] > l) { /* CI length too big? */
920 IPV6CPDEBUG(("ipv6cp_reqci: bad CI length!"));
921 orc = CONFREJ; /* Reject bad CI */
926 GETCHAR(citype, p); /* Parse CI type */
927 GETCHAR(cilen, p); /* Parse CI length */
928 l -= cilen; /* Adjust remaining length */
929 next += cilen; /* Step to next CI */
931 switch (citype) { /* Check CI type */
935 if (!ao->neg_ifaceid ||
936 cilen != CILEN_IFACEID) { /* Check CI length */
937 orc = CONFREJ; /* Reject CI */
949 if (eui64_iszero(ifaceid) && eui64_iszero(go->ourid)) {
950 orc = CONFREJ; /* Reject CI */
953 if (!eui64_iszero(wo->hisid) &&
954 !eui64_equals(ifaceid, wo->hisid) &&
955 eui64_iszero(go->hisid)) {
958 ifaceid = wo->hisid;
959 go->hisid = ifaceid;
963 if (eui64_iszero(ifaceid) || eui64_equals(ifaceid, go->ourid)) {
965 if (eui64_iszero(go->hisid)) /* first time, try option */
966 ifaceid = wo->hisid;
968 eui64_equals(ifaceid, go->ourid)) /* bad luck */
970 go->hisid = ifaceid;
975 ho->neg_ifaceid = 1;
976 ho->hisid = ifaceid;
982 if (!ao->neg_vj ||
995 ho->neg_vj = 1;
996 ho->vj_protocol = cishort;
1008 if (orc == CONFACK && /* Good CI */
1009 rc != CONFACK) /* but prior CI wasnt? */
1012 if (orc == CONFNAK) { /* Nak this CI? */
1016 if (rc == CONFREJ) /* Rejecting prior CI? */
1025 if (orc == CONFREJ && /* Reject this CI */
1031 /* Need to move CI? */
1046 if (rc != CONFREJ && !ho->neg_ifaceid &&
1047 wo->req_ifaceid && !reject_if_disagree) {
1051 wo->req_ifaceid = 0; /* don't ask again */
1055 eui64_put(wo->hisid, ucp);
1058 *len = ucp - inp; /* Compute output length */
1059 IPV6CPDEBUG(("ipv6cp: returning Configure-%s", CODENAME(rc)));
1065 * ipv6_check_options - check that any IP-related options are OK,
1075 * Persistent link-local id is only used when user has not explicitly
1076 * configure/hard-code the id
1078 if ((wo->use_persistent) && (!wo->opt_local) && (!wo->opt_remote)) {
1084 * an EUI-48 from MAC address can't be obtained. Other possibilities
1089 if (ether_to_eui64(&wo->ourid)) {
1090 wo->opt_local = 1;
1094 if (!wo->opt_local) { /* init interface identifier */
1095 if (wo->use_ip && eui64_iszero(wo->ourid)) {
1096 eui64_setlo32(wo->ourid, lwip_ntohl(ipcp_wantoptions[0].ouraddr));
1097 if (!eui64_iszero(wo->ourid))
1098 wo->opt_local = 1;
1101 while (eui64_iszero(wo->ourid))
1102 eui64_magic(wo->ourid);
1105 if (!wo->opt_remote) {
1106 if (wo->use_ip && eui64_iszero(wo->hisid)) {
1107 eui64_setlo32(wo->hisid, lwip_ntohl(ipcp_wantoptions[0].hisaddr));
1108 if (!eui64_iszero(wo->hisid))
1109 wo->opt_remote = 1;
1113 if (demand && (eui64_iszero(wo->ourid) || eui64_iszero(wo->hisid))) {
1114 option_error("local/remote LL address required for demand-dialling\n");
1122 * ipv6_demand_conf - configure the interface as though
1123 * IPV6CP were up, for use with dial-on-demand.
1131 if (!sif6addr(u, wo->ourid, wo->hisid))
1138 ppp_notice("local LL address %s", llv6_ntoa(wo->ourid));
1139 ppp_notice("remote LL address %s", llv6_ntoa(wo->hisid));
1147 * ipv6cp_up - IPV6CP has come UP.
1152 ppp_pcb *pcb = f->pcb;
1153 ipv6cp_options *wo = &pcb->ipv6cp_wantoptions;
1154 ipv6cp_options *ho = &pcb->ipv6cp_hisoptions;
1155 ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
1160 * We must have a non-zero LL address for both ends of the link.
1162 if (!ho->neg_ifaceid)
1163 ho->hisid = wo->hisid;
1168 if (eui64_iszero(ho->hisid)) {
1170 ipv6cp_close(f->pcb, "Could not determine remote LL address");
1173 if (eui64_iszero(go->ourid)) {
1175 ipv6cp_close(f->pcb, "Could not determine local LL address");
1178 if (eui64_equals(go->ourid, ho->hisid)) {
1180 ipv6cp_close(f->pcb, "local and remote LL addresses are equal");
1187 script_setenv("LLLOCAL", llv6_ntoa(go->ourid), 0);
1188 script_setenv("LLREMOTE", llv6_ntoa(ho->hisid), 0);
1193 sif6comp(f->unit, ho->neg_vj);
1198 * If we are doing dial-on-demand, the interface is already
1199 * configured, so we put out any saved-up packets, then set the
1203 if (! eui64_equals(go->ourid, wo->ourid) ||
1204 ! eui64_equals(ho->hisid, wo->hisid)) {
1205 if (! eui64_equals(go->ourid, wo->ourid))
1207 llv6_ntoa(go->ourid));
1208 if (! eui64_equals(ho->hisid, wo->hisid))
1210 llv6_ntoa(ho->hisid));
1211 ipv6cp_clear_addrs(f->pcb, go->ourid, ho->hisid);
1214 if (!sif6addr(f->pcb, go->ourid, ho->hisid)) {
1217 ipv6cp_close(f->unit, "Interface configuration failed");
1223 sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
1231 if (!sif6addr(f->pcb, go->ourid, ho->hisid)) {
1233 ipv6cp_close(f->pcb, "Interface configuration failed");
1238 if (!sif6up(f->pcb)) {
1240 ipv6cp_close(f->pcb, "Interface configuration failed");
1244 sifnpmode(f->pcb, PPP_IPV6, NPMODE_PASS);
1247 ppp_notice("local LL address %s", llv6_ntoa(go->ourid));
1248 ppp_notice("remote LL address %s", llv6_ntoa(ho->hisid));
1251 np_up(f->pcb, PPP_IPV6);
1252 pcb->ipv6cp_is_up = 1;
1256 * Execute the ipv6-up script, like this:
1257 * /etc/ppp/ipv6-up interface tty speed local-LL remote-LL
1268 * ipv6cp_down - IPV6CP has gone DOWN.
1274 ppp_pcb *pcb = f->pcb;
1275 ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
1276 ipv6cp_options *ho = &pcb->ipv6cp_hisoptions;
1280 update_link_stats(f->unit);
1282 if (pcb->ipv6cp_is_up) {
1283 pcb->ipv6cp_is_up = 0;
1284 np_down(f->pcb, PPP_IPV6);
1287 sif6comp(f->unit, 0);
1292 * If we are doing dial-on-demand, set the interface
1296 sifnpmode(f->pcb, PPP_IPV6, NPMODE_QUEUE);
1301 sifnpmode(f->pcb, PPP_IPV6, NPMODE_DROP);
1303 ipv6cp_clear_addrs(f->pcb,
1304 go->ourid,
1305 ho->hisid);
1306 sif6down(f->pcb);
1310 /* Execute the ipv6-down script */
1320 * ipv6cp_clear_addrs() - clear the interface addresses, routes,
1329 * ipv6cp_finished - possibly shut down the lower layers.
1332 np_finished(f->pcb, PPP_IPV6);
1338 * ipv6cp_script_done - called when the ipv6-up or ipv6-down script
1364 * ipv6cp_script - Execute a script with arguments
1365 * interface-name tty-name speed local-LL remote-LL.
1368 ipv6cp_script(script)
1369 char *script;
1378 argv[0] = script;
1387 ipv6cp_script_pid = run_program(script, argv, 0, ipv6cp_script_done,
1394 * ipv6cp_printpkt - print the contents of an IPV6CP packet.
1420 printer(arg, " %s", ipv6cp_codenames[code-1]);
1424 len -= HEADERLEN;
1434 p -= 2;
1439 len -= olen;
1484 for (; len > 0; --len) {
1489 return p - pstart;
1495 * ipv6_active_pkt - see if this IP packet is worth bringing the link up for.
1516 len -= PPP_HDRLEN;