Lines Matching +full:re +full:- +full:configurable
5 /*-
6 * Copyright (c) 1996-2000 Whistle Communications, Inc.
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
101 * When packets are lost with MPPE, we may have to re-key arbitrarily
102 * many times to 'catch up' to the new jumped-ahead sequence number.
103 * Since this can be expensive, we pose a limit on how many re-keyings
105 * This should instead be a configurable parameter.
114 &mppe_block_on_max_rekey, 0, "Block node on max MPPE key re-calculations");
118 &mppe_log_max_rekey, 0, "Log max MPPE key re-calculations event");
122 &mppe_max_rekey, 0, "Maximum number of MPPE key re-calculations");
133 #define MPPE_UPDATE_MASK 0xff /* coherency count when we're */
240 hookPtr = &priv->xmit.hook; in ng_mppc_newhook()
242 hookPtr = &priv->recv.hook; in ng_mppc_newhook()
267 switch (msg->header.typecookie) { in ng_mppc_rcvmsg()
269 switch (msg->header.cmd) { in ng_mppc_rcvmsg()
274 = (struct ng_mppc_config *)msg->data; in ng_mppc_rcvmsg()
276 msg->header.cmd == NGM_MPPC_CONFIG_COMP; in ng_mppc_rcvmsg()
278 &priv->xmit : &priv->recv; in ng_mppc_rcvmsg()
281 if (msg->header.arglen != sizeof(*cfg)) in ng_mppc_rcvmsg()
283 if (cfg->enable) { in ng_mppc_rcvmsg()
284 if ((cfg->bits & ~MPPC_VALID_BITS) != 0) in ng_mppc_rcvmsg()
287 if ((cfg->bits & MPPC_BIT) != 0) in ng_mppc_rcvmsg()
291 if ((cfg->bits & MPPE_BITS) != 0) in ng_mppc_rcvmsg()
295 cfg->bits = 0; in ng_mppc_rcvmsg()
297 /* Save return address so we can send reset-req's */ in ng_mppc_rcvmsg()
299 priv->ctrlnode = NGI_RETADDR(item); in ng_mppc_rcvmsg()
302 d->cfg = *cfg; in ng_mppc_rcvmsg()
306 if (d->history != NULL) { in ng_mppc_rcvmsg()
307 free(d->history, M_NETGRAPH_MPPC); in ng_mppc_rcvmsg()
308 d->history = NULL; in ng_mppc_rcvmsg()
310 if ((cfg->bits & MPPC_BIT) != 0) { in ng_mppc_rcvmsg()
311 d->history = malloc(isComp ? in ng_mppc_rcvmsg()
315 if (d->history == NULL) in ng_mppc_rcvmsg()
318 MPPC_InitCompressionHistory(d->history); in ng_mppc_rcvmsg()
321 d->history); in ng_mppc_rcvmsg()
328 if ((cfg->bits & MPPE_BITS) != 0) { in ng_mppc_rcvmsg()
329 const int keylen = KEYLEN(cfg->bits); in ng_mppc_rcvmsg()
331 bcopy(cfg->startkey, d->key, keylen); in ng_mppc_rcvmsg()
332 ng_mppc_getkey(cfg->startkey, d->key, keylen); in ng_mppc_rcvmsg()
333 if ((cfg->bits & MPPE_40) != 0) in ng_mppc_rcvmsg()
334 bcopy(&ng_mppe_weakenkey, d->key, 3); in ng_mppc_rcvmsg()
335 else if ((cfg->bits & MPPE_56) != 0) in ng_mppc_rcvmsg()
336 bcopy(&ng_mppe_weakenkey, d->key, 1); in ng_mppc_rcvmsg()
337 rc4_init(&d->rc4, d->key, keylen); in ng_mppc_rcvmsg()
342 d->cc = 0; in ng_mppc_rcvmsg()
343 d->flushed = 0; in ng_mppc_rcvmsg()
379 if (hook == priv->xmit.hook) { in ng_mppc_rcvdata()
380 if (!priv->xmit.cfg.enable) { in ng_mppc_rcvdata()
389 NG_FWD_NEW_DATA(error, item, priv->xmit.hook, m); in ng_mppc_rcvdata()
394 if (hook == priv->recv.hook) { in ng_mppc_rcvdata()
395 if (!priv->recv.cfg.enable) { in ng_mppc_rcvdata()
402 if (error == EINVAL && priv->ctrlnode != 0) { in ng_mppc_rcvdata()
405 /* Need to send a reset-request */ in ng_mppc_rcvdata()
411 priv->ctrlnode, 0); in ng_mppc_rcvdata()
415 NG_FWD_NEW_DATA(error, item, priv->recv.hook, m); in ng_mppc_rcvdata()
433 if (priv->xmit.history != NULL) in ng_mppc_shutdown()
434 free(priv->xmit.history, M_NETGRAPH_MPPC); in ng_mppc_shutdown()
435 if (priv->recv.history != NULL) in ng_mppc_shutdown()
436 free(priv->recv.history, M_NETGRAPH_MPPC); in ng_mppc_shutdown()
455 if (hook == priv->xmit.hook) in ng_mppc_disconnect()
456 priv->xmit.hook = NULL; in ng_mppc_disconnect()
457 if (hook == priv->recv.hook) in ng_mppc_disconnect()
458 priv->recv.hook = NULL; in ng_mppc_disconnect()
479 struct ng_mppc_dir *const d = &priv->xmit; in ng_mppc_compress()
489 header = d->cc; in ng_mppc_compress()
492 if (d->flushed || ((d->cfg.bits & MPPE_STATELESS) != 0)) { in ng_mppc_compress()
494 d->flushed = 0; in ng_mppc_compress()
499 if ((d->cfg.bits & MPPC_BIT) != 0) { in ng_mppc_compress()
508 inlen = m->m_pkthdr.len; in ng_mppc_compress()
509 if (m->m_next == NULL) { in ng_mppc_compress()
527 MPPC_InitCompressionHistory(d->history); in ng_mppc_compress()
528 d->flushed = 1; in ng_mppc_compress()
537 if ((d->cfg.bits & MPPE_STATELESS) == 0) in ng_mppc_compress()
542 &destCnt, d->history, flags, 0); in ng_mppc_compress()
548 outlen -= destCnt; in ng_mppc_compress()
555 if (m->m_pkthdr.len < outlen) { in ng_mppc_compress()
558 } else if (outlen < m->m_pkthdr.len) in ng_mppc_compress()
559 m_adj(m, outlen - m->m_pkthdr.len); in ng_mppc_compress()
561 d->flushed = (rtn & MPPC_EXPANDED) != 0 in ng_mppc_compress()
570 if (!d->flushed) { in ng_mppc_compress()
571 MPPC_InitCompressionHistory(d->history); in ng_mppc_compress()
572 d->flushed = 1; in ng_mppc_compress()
581 if ((d->cfg.bits & MPPE_BITS) != 0) { in ng_mppc_compress()
588 if ((d->cfg.bits & MPPE_STATELESS) != 0 in ng_mppc_compress()
589 || (d->cc & MPPE_UPDATE_MASK) == MPPE_UPDATE_FLAG) { in ng_mppc_compress()
590 ng_mppc_updatekey(d->cfg.bits, in ng_mppc_compress()
591 d->cfg.startkey, d->key, &d->rc4); in ng_mppc_compress()
595 rc4_init(&d->rc4, d->key, KEYLEN(d->cfg.bits)); in ng_mppc_compress()
601 rc4_crypt(&d->rc4, mtod(m1, u_char *), in ng_mppc_compress()
602 mtod(m1, u_char *), m1->m_len); in ng_mppc_compress()
603 m1 = m1->m_next; in ng_mppc_compress()
609 MPPC_CCOUNT_INC(d->cc); in ng_mppc_compress()
628 struct ng_mppc_dir *const d = &priv->recv; in ng_mppc_decompress()
639 if (m->m_pkthdr.len < MPPC_HDRLEN) { in ng_mppc_decompress()
648 numLost = ((cc - d->cc) & MPPC_CCOUNT_MASK); in ng_mppc_decompress()
653 if (d->history != NULL) in ng_mppc_decompress()
654 MPPC_InitDecompressionHistory(d->history); in ng_mppc_decompress()
657 if ((d->cfg.bits & MPPE_BITS) != 0) { in ng_mppc_decompress()
660 /* How many times are we going to have to re-key? */ in ng_mppc_decompress()
661 rekey = ((d->cfg.bits & MPPE_STATELESS) != 0) ? in ng_mppc_decompress()
670 priv->recv.cfg.enable = 0; in ng_mppc_decompress()
682 /* Re-key as necessary to catch up to peer */ in ng_mppc_decompress()
683 while (d->cc != cc) { in ng_mppc_decompress()
684 if ((d->cfg.bits & MPPE_STATELESS) != 0 in ng_mppc_decompress()
685 || (d->cc & MPPE_UPDATE_MASK) in ng_mppc_decompress()
687 ng_mppc_updatekey(d->cfg.bits, in ng_mppc_decompress()
688 d->cfg.startkey, d->key, &d->rc4); in ng_mppc_decompress()
690 MPPC_CCOUNT_INC(d->cc); in ng_mppc_decompress()
694 if ((d->cfg.bits & MPPE_STATELESS) == 0) in ng_mppc_decompress()
695 rc4_init(&d->rc4, d->key, KEYLEN(d->cfg.bits)); in ng_mppc_decompress()
698 d->cc = cc; /* skip over lost seq numbers */ in ng_mppc_decompress()
702 /* Can't decode non-sequential packets without a flushed bit */ in ng_mppc_decompress()
713 if ((d->cfg.bits & MPPE_BITS) == 0) { in ng_mppc_decompress()
721 if ((d->cfg.bits & MPPE_STATELESS) != 0 in ng_mppc_decompress()
722 || (d->cc & MPPE_UPDATE_MASK) == MPPE_UPDATE_FLAG) { in ng_mppc_decompress()
723 ng_mppc_updatekey(d->cfg.bits, in ng_mppc_decompress()
724 d->cfg.startkey, d->key, &d->rc4); in ng_mppc_decompress()
730 rc4_crypt(&d->rc4, mtod(m1, u_char *), in ng_mppc_decompress()
731 mtod(m1, u_char *), m1->m_len); in ng_mppc_decompress()
732 m1 = m1->m_next; in ng_mppc_decompress()
737 if ((d->cfg.bits & MPPE_BITS) != 0) { in ng_mppc_decompress()
745 MPPC_CCOUNT_INC(d->cc); in ng_mppc_decompress()
749 && (d->cfg.bits & MPPC_BIT) == 0) { in ng_mppc_decompress()
768 inlen = m->m_pkthdr.len; in ng_mppc_decompress()
769 if (m->m_next == NULL) { in ng_mppc_decompress()
803 &sourceCnt, &destCnt, d->history, flags); in ng_mppc_decompress()
820 outlen -= destCnt; in ng_mppc_decompress()
823 if (m->m_pkthdr.len < outlen) { in ng_mppc_decompress()
826 } else if (outlen < m->m_pkthdr.len) in ng_mppc_decompress()
827 m_adj(m, outlen - m->m_pkthdr.len); in ng_mppc_decompress()
844 struct ng_mppc_dir *const d = &priv->xmit; in ng_mppc_reset_req()
847 if (d->history != NULL) in ng_mppc_reset_req()
848 MPPC_InitCompressionHistory(d->history); in ng_mppc_reset_req()
851 if ((d->cfg.bits & MPPE_STATELESS) == 0) in ng_mppc_reset_req()
852 rc4_init(&d->rc4, d->key, KEYLEN(d->cfg.bits)); in ng_mppc_reset_req()
854 d->flushed = 1; in ng_mppc_reset_req()