* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: ipv6cp.c,v 1.18 2003/07/28 12:25:41 carlsonj Exp $
+ * $Id: ipv6cp.c,v 1.21 2005/08/25 23:59:34 paulus Exp $
*/
-#define RCSID "$Id: ipv6cp.c,v 1.18 2003/07/28 12:25:41 carlsonj Exp $"
+#define RCSID "$Id: ipv6cp.c,v 1.21 2005/08/25 23:59:34 paulus Exp $"
/*
* TODO:
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
/* local vars */
static int ipv6cp_is_up;
+/* Hook for a plugin to know when IPv6 protocol has come up */
+void (*ipv6_up_hook) __P((void)) = NULL;
+
+/* Hook for a plugin to know when IPv6 protocol has come down */
+void (*ipv6_down_hook) __P((void)) = NULL;
+
+/* Notifiers for when IPCPv6 goes up and down */
+struct notifier *ipv6_up_notifier = NULL;
+struct notifier *ipv6_down_notifier = NULL;
+
/*
* Callbacks for fsm code. (CI = Configuration Information)
*/
static int ipv6cp_cilen __P((fsm *)); /* Return length of our CI */
static void ipv6cp_addci __P((fsm *, u_char *, int *)); /* Add our CI */
static int ipv6cp_ackci __P((fsm *, u_char *, int)); /* Peer ack'd our CI */
-static int ipv6cp_nakci __P((fsm *, u_char *, int)); /* Peer nak'd our CI */
+static int ipv6cp_nakci __P((fsm *, u_char *, int, int));/* Peer nak'd our CI */
static int ipv6cp_rejci __P((fsm *, u_char *, int)); /* Peer rej'd our CI */
static int ipv6cp_reqci __P((fsm *, u_char *, int *, int)); /* Rcv CI */
static void ipv6cp_up __P((fsm *)); /* We're UP */
* 1 - Nak was good.
*/
static int
-ipv6cp_nakci(f, p, len)
+ipv6cp_nakci(f, p, len, treat_as_reject)
fsm *f;
u_char *p;
int len;
+ int treat_as_reject;
{
ipv6cp_options *go = &ipv6cp_gotoptions[f->unit];
u_char citype, cilen, *next;
* from our idea, only if the accept_{local,remote} flag is set.
*/
NAKCIIFACEID(CI_IFACEID, neg_ifaceid,
- if (go->accept_local) {
- while (eui64_iszero(ifaceid) ||
- eui64_equals(ifaceid, go->hisid)) /* bad luck */
- eui64_magic(ifaceid);
- try.ourid = ifaceid;
- IPV6CPDEBUG(("local LL address %s", llv6_ntoa(ifaceid)));
- }
- );
+ if (treat_as_reject) {
+ try.neg_ifaceid = 0;
+ } else if (go->accept_local) {
+ while (eui64_iszero(ifaceid) ||
+ eui64_equals(ifaceid, go->hisid)) /* bad luck */
+ eui64_magic(ifaceid);
+ try.ourid = ifaceid;
+ IPV6CPDEBUG(("local LL address %s", llv6_ntoa(ifaceid)));
+ }
+ );
#ifdef IPV6CP_COMP
NAKCIVJ(CI_COMPRESSTYPE, neg_vj,
{
- if (cishort == IPV6CP_COMP) {
+ if (cishort == IPV6CP_COMP && !treat_as_reject) {
try.vj_protocol = cishort;
} else {
try.neg_vj = 0;
if (demand && (eui64_iszero(wo->ourid) || eui64_iszero(wo->hisid))) {
option_error("local/remote LL address required for demand-dialling\n");
- exit(1);
+ exit(EXIT_OPTION_ERROR);
}
}
np_up(f->unit, PPP_IPV6);
ipv6cp_is_up = 1;
+ notify(ipv6_up_notifier, 0);
+ if (ipv6_up_hook)
+ ipv6_up_hook();
+
/*
* Execute the ipv6-up script, like this:
* /etc/ppp/ipv6-up interface tty speed local-LL remote-LL
{
IPV6CPDEBUG(("ipv6cp: down"));
update_link_stats(f->unit);
+ notify(ipv6_down_notifier, 0);
+ if (ipv6_down_hook)
+ ipv6_down_hook();
if (ipv6cp_is_up) {
ipv6cp_is_up = 0;
np_down(f->unit, PPP_IPV6);
argv[6] = ipparam;
argv[7] = NULL;
- ipv6cp_script_pid = run_program(script, argv, 0, ipv6cp_script_done, NULL);
+ ipv6cp_script_pid = run_program(script, argv, 0, ipv6cp_script_done,
+ NULL, 0);
}
/*
*/
#define IP6_HDRLEN 40 /* bytes */
#define IP6_NHDR_FRAG 44 /* fragment IPv6 header */
-#define IPPROTO_TCP 6
#define TCP_HDRLEN 20
#define TH_FIN 0x01