summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrian <brian@openbsd.org>2001-02-04 22:53:12 +0000
committerbrian <brian@openbsd.org>2001-02-04 22:53:12 +0000
commit5f3dfabb8cf63973e11f33ec746aa7f91aa11061 (patch)
treeaada6c055ccbdabdce0c569cc42274c93f7b7c2d
parentThis is OpenBSD, not 4.2BSD (diff)
downloadwireguard-openbsd-5f3dfabb8cf63973e11f33ec746aa7f91aa11061.tar.xz
wireguard-openbsd-5f3dfabb8cf63973e11f33ec746aa7f91aa11061.zip
Add a ``Usable'' function to the ccp switch. The function
is called prior to sending a CCP configure request for a given protocol. The default is to send the request, but this is overridden for MPPE which checks to see if the lcp negotiations agreed CHAP81, and if not fails. Use the same function to decide if we should reject peer requests for MPPE. This should get rid of those boring messages about not being able to initialise MPPE when we don't negotiate CHAP81.
-rw-r--r--usr.sbin/ppp/ppp/ccp.c12
-rw-r--r--usr.sbin/ppp/ppp/ccp.h4
-rw-r--r--usr.sbin/ppp/ppp/deflate.c6
-rw-r--r--usr.sbin/ppp/ppp/mppe.c22
-rw-r--r--usr.sbin/ppp/ppp/pred.c3
5 files changed, 40 insertions, 7 deletions
diff --git a/usr.sbin/ppp/ppp/ccp.c b/usr.sbin/ppp/ppp/ccp.c
index 794c81dd564..3b670104f40 100644
--- a/usr.sbin/ppp/ppp/ccp.c
+++ b/usr.sbin/ppp/ppp/ccp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $OpenBSD: ccp.c,v 1.17 2000/11/22 02:13:08 brian Exp $
+ * $OpenBSD: ccp.c,v 1.18 2001/02/04 22:53:12 brian Exp $
*
* TODO:
* o Support other compression protocols
@@ -268,7 +268,8 @@ CcpSendConfigReq(struct fsm *fp)
ccp->out.algorithm = -1;
for (f = 0; f < NALGORITHMS; f++)
if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) &&
- !REJECTED(ccp, algorithm[f]->id)) {
+ !REJECTED(ccp, algorithm[f]->id) &&
+ (*algorithm[f]->Usable)(fp)) {
if (!alloc)
for (o = &ccp->out.opt; *o != NULL; o = &(*o)->next)
@@ -491,6 +492,7 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
switch (mode_type) {
case MODE_REQ:
if (IsAccepted(ccp->cfg.neg[algorithm[f]->Neg]) &&
+ (*algorithm[f]->Usable)(fp) &&
ccp->in.algorithm == -1) {
memcpy(&ccp->in.opt, cp, length);
switch ((*algorithm[f]->i.Set)(&ccp->in.opt, &ccp->cfg)) {
@@ -697,4 +699,10 @@ ccp_SetOpenMode(struct ccp *ccp)
return 0; /* No CCP at all */
}
+int
+ccp_IsUsable(struct fsm *fp)
+{
+ return 1;
+}
+
struct layer ccplayer = { LAYER_CCP, "ccp", ccp_LayerPush, ccp_LayerPull };
diff --git a/usr.sbin/ppp/ppp/ccp.h b/usr.sbin/ppp/ppp/ccp.h
index 5127a33614e..fb660e22726 100644
--- a/usr.sbin/ppp/ppp/ccp.h
+++ b/usr.sbin/ppp/ppp/ccp.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $OpenBSD: ccp.h,v 1.7 2000/11/07 23:32:04 brian Exp $
+ * $OpenBSD: ccp.h,v 1.8 2001/02/04 22:53:12 brian Exp $
*
* TODO:
*/
@@ -106,6 +106,7 @@ struct ccp_algorithm {
int id;
int Neg; /* ccp_config neg array item */
const char *(*Disp)(struct lcp_opt *); /* Use result immediately ! */
+ int (*Usable)(struct fsm *); /* Ok to negotiate ? */
struct {
int (*Set)(struct lcp_opt *, const struct ccp_config *);
void *(*Init)(struct lcp_opt *);
@@ -135,5 +136,6 @@ extern int ccp_ReportStatus(struct cmdargs const *);
extern u_short ccp_Proto(struct ccp *);
extern void ccp_SetupCallbacks(struct ccp *);
extern int ccp_SetOpenMode(struct ccp *);
+extern int ccp_IsUsable(struct fsm *);
extern struct layer ccplayer;
diff --git a/usr.sbin/ppp/ppp/deflate.c b/usr.sbin/ppp/ppp/deflate.c
index 8e98ccdfb7f..2181b1fb9ec 100644
--- a/usr.sbin/ppp/ppp/deflate.c
+++ b/usr.sbin/ppp/ppp/deflate.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: deflate.c,v 1.10 2000/07/19 11:06:33 brian Exp $
+ * $OpenBSD: deflate.c,v 1.11 2001/02/04 22:53:13 brian Exp $
*/
#include <sys/types.h>
@@ -551,9 +551,10 @@ DeflateTermOutput(void *v)
}
const struct ccp_algorithm PppdDeflateAlgorithm = {
- TY_PPPD_DEFLATE, /* pppd (wrongly) expects this ``type'' field */
+ TY_PPPD_DEFLATE, /* Older versions of pppd expected this ``type'' */
CCP_NEG_DEFLATE24,
DeflateDispOpts,
+ ccp_IsUsable,
{
DeflateSetOptsInput,
DeflateInitInput,
@@ -576,6 +577,7 @@ const struct ccp_algorithm DeflateAlgorithm = {
TY_DEFLATE, /* rfc 1979 */
CCP_NEG_DEFLATE,
DeflateDispOpts,
+ ccp_IsUsable,
{
DeflateSetOptsInput,
DeflateInitInput,
diff --git a/usr.sbin/ppp/ppp/mppe.c b/usr.sbin/ppp/ppp/mppe.c
index f6a78aad8fb..97e03a6edff 100644
--- a/usr.sbin/ppp/ppp/mppe.c
+++ b/usr.sbin/ppp/ppp/mppe.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: mppe.c,v 1.4 2001/02/04 01:14:28 brian Exp $
+ * $OpenBSD: mppe.c,v 1.5 2001/02/04 22:53:13 brian Exp $
*/
#include <sys/types.h>
@@ -47,7 +47,11 @@
#include "hdlc.h"
#include "lcp.h"
#include "ccp.h"
+#include "throughput.h"
+#include "layer.h"
+#include "link.h"
#include "chap_ms.h"
+#include "proto.h"
#include "mppe.h"
/*
@@ -223,6 +227,21 @@ MPPEDispOpts(struct lcp_opt *o)
return buf;
}
+static int
+MPPEUsable(struct fsm *fp)
+{
+ struct lcp *lcp;
+ int ok;
+
+ lcp = &fp->link->lcp;
+ ok = (lcp->want_auth == PROTO_CHAP && lcp->want_authtype == 0x81) ||
+ (lcp->his_auth == PROTO_CHAP && lcp->his_authtype == 0x81);
+ if (!ok)
+ log_Printf(LogCCP, "MPPE: Not usable without CHAP81\n");
+
+ return ok;
+}
+
static void
MPPEInitOptsOutput(struct lcp_opt *o, const struct ccp_config *cfg)
{
@@ -414,6 +433,7 @@ const struct ccp_algorithm MPPEAlgorithm = {
TY_MPPE,
CCP_NEG_MPPE,
MPPEDispOpts,
+ MPPEUsable,
{
MPPESetOptsInput,
MPPEInitInput,
diff --git a/usr.sbin/ppp/ppp/pred.c b/usr.sbin/ppp/ppp/pred.c
index 3fa856eb777..5645b53cba9 100644
--- a/usr.sbin/ppp/ppp/pred.c
+++ b/usr.sbin/ppp/ppp/pred.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: pred.c,v 1.9 2000/02/27 01:38:28 brian Exp $
+ * $OpenBSD: pred.c,v 1.10 2001/02/04 22:53:13 brian Exp $
*/
#include <sys/types.h>
@@ -323,6 +323,7 @@ const struct ccp_algorithm Pred1Algorithm = {
TY_PRED1,
CCP_NEG_PRED1,
Pred1DispOpts,
+ ccp_IsUsable,
{
Pred1SetOptsInput,
Pred1InitInput,