201-mppe_mppc_1.1.patch 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587
  1. diff -ruN ppp-2.4.3.orig/include/linux/ppp-comp.h ppp-2.4.3/include/linux/ppp-comp.h
  2. --- ppp-2.4.3.orig/include/linux/ppp-comp.h 2002-12-06 10:49:15.000000000 +0100
  3. +++ ppp-2.4.3/include/linux/ppp-comp.h 2004-11-21 13:54:09.000000000 +0100
  4. @@ -36,7 +36,7 @@
  5. */
  6. /*
  7. - * ==FILEVERSION 20020319==
  8. + * ==FILEVERSION 20020715==
  9. *
  10. * NOTE TO MAINTAINERS:
  11. * If you modify this file at all, please set the above date.
  12. @@ -86,7 +86,7 @@
  13. /* Compress a packet */
  14. int (*compress) (void *state, unsigned char *rptr,
  15. - unsigned char *obuf, int isize, int osize);
  16. + unsigned char *obuf, int isize, int osize);
  17. /* Return compression statistics */
  18. void (*comp_stat) (void *state, struct compstat *stats);
  19. @@ -107,7 +107,7 @@
  20. /* Decompress a packet. */
  21. int (*decompress) (void *state, unsigned char *ibuf, int isize,
  22. - unsigned char *obuf, int osize);
  23. + unsigned char *obuf, int osize);
  24. /* Update state for an incompressible packet received */
  25. void (*incomp) (void *state, unsigned char *ibuf, int icnt);
  26. @@ -288,6 +288,33 @@
  27. opts |= MPPE_OPT_UNKNOWN; \
  28. } while (/* CONSTCOND */ 0)
  29. +/* MPPE/MPPC definitions by J.D.*/
  30. +#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
  31. +#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
  32. +#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
  33. +#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
  34. +#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
  35. +
  36. +/*
  37. + * Definitions for Stac LZS.
  38. + */
  39. +
  40. +#define CI_LZS 17 /* config option for Stac LZS */
  41. +#define CILEN_LZS 5 /* length of config option */
  42. +
  43. +#define LZS_OVHD 4 /* max. LZS overhead */
  44. +#define LZS_HIST_LEN 2048 /* LZS history size */
  45. +#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
  46. +
  47. +#define LZS_MODE_NONE 0
  48. +#define LZS_MODE_LCB 1
  49. +#define LZS_MODE_CRC 2
  50. +#define LZS_MODE_SEQ 3
  51. +#define LZS_MODE_EXT 4
  52. +
  53. +#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
  54. +#define LZS_EXT_BIT_COMP 0x20 /* bit C */
  55. +
  56. /*
  57. * Definitions for other, as yet unsupported, compression methods.
  58. */
  59. diff -ruN ppp-2.4.3.orig/include/net/ppp-comp.h ppp-2.4.3/include/net/ppp-comp.h
  60. --- ppp-2.4.3.orig/include/net/ppp-comp.h 2002-12-06 10:49:15.000000000 +0100
  61. +++ ppp-2.4.3/include/net/ppp-comp.h 2004-11-21 13:54:09.000000000 +0100
  62. @@ -255,6 +255,33 @@
  63. opts |= MPPE_OPT_UNKNOWN; \
  64. } while (/* CONSTCOND */ 0)
  65. +/* MPPE/MPPC definitions by J.D.*/
  66. +#define MPPE_STATELESS MPPE_H_BIT /* configuration bit H */
  67. +#define MPPE_40BIT MPPE_L_BIT /* configuration bit L */
  68. +#define MPPE_56BIT MPPE_M_BIT /* configuration bit M */
  69. +#define MPPE_128BIT MPPE_S_BIT /* configuration bit S */
  70. +#define MPPE_MPPC MPPE_C_BIT /* configuration bit C */
  71. +
  72. +/*
  73. + * Definitions for Stac LZS.
  74. + */
  75. +
  76. +#define CI_LZS 17 /* config option for Stac LZS */
  77. +#define CILEN_LZS 5 /* length of config option */
  78. +
  79. +#define LZS_OVHD 4 /* max. LZS overhead */
  80. +#define LZS_HIST_LEN 2048 /* LZS history size */
  81. +#define LZS_MAX_CCOUNT 0x0FFF /* max. coherency counter value */
  82. +
  83. +#define LZS_MODE_NONE 0
  84. +#define LZS_MODE_LCB 1
  85. +#define LZS_MODE_CRC 2
  86. +#define LZS_MODE_SEQ 3
  87. +#define LZS_MODE_EXT 4
  88. +
  89. +#define LZS_EXT_BIT_FLUSHED 0x80 /* bit A */
  90. +#define LZS_EXT_BIT_COMP 0x20 /* bit C */
  91. +
  92. /*
  93. * Definitions for other, as yet unsupported, compression methods.
  94. */
  95. --- ppp-2.4.4/pppd/ccp.c.orig 2005-07-09 02:23:05.000000000 +0200
  96. +++ ppp-2.4.4/pppd/ccp.c 2006-07-21 23:34:12.121546000 +0200
  97. @@ -62,12 +62,10 @@
  98. static char bsd_value[8];
  99. static char deflate_value[8];
  100. -/*
  101. - * Option variables.
  102. - */
  103. #ifdef MPPE
  104. -bool refuse_mppe_stateful = 1; /* Allow stateful mode? */
  105. -#endif
  106. +static int setmppe(char **);
  107. +static int setnomppe(void);
  108. +#endif /* MPPE */
  109. static option_t ccp_option_list[] = {
  110. { "noccp", o_bool, &ccp_protent.enabled_flag,
  111. @@ -108,54 +106,36 @@
  112. "don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
  113. &ccp_allowoptions[0].predictor_1 },
  114. + { "lzs", o_bool, &ccp_wantoptions[0].lzs,
  115. + "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_PRIO },
  116. + { "+lzs", o_bool, &ccp_wantoptions[0].lzs,
  117. + "request Stac LZS", 1, &ccp_allowoptions[0].lzs, OPT_ALIAS | OPT_PRIO },
  118. + { "nolzs", o_bool, &ccp_wantoptions[0].lzs,
  119. + "don't allow Stac LZS", OPT_PRIOSUB | OPT_A2CLR,
  120. + &ccp_allowoptions[0].lzs },
  121. + { "-lzs", o_bool, &ccp_wantoptions[0].lzs,
  122. + "don't allow Stac LZS", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
  123. + &ccp_allowoptions[0].lzs },
  124. +
  125. #ifdef MPPE
  126. - /* MPPE options are symmetrical ... we only set wantoptions here */
  127. - { "require-mppe", o_bool, &ccp_wantoptions[0].mppe,
  128. - "require MPPE encryption",
  129. - OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
  130. - { "+mppe", o_bool, &ccp_wantoptions[0].mppe,
  131. - "require MPPE encryption",
  132. - OPT_ALIAS | OPT_PRIO | MPPE_OPT_40 | MPPE_OPT_128 },
  133. - { "nomppe", o_bool, &ccp_wantoptions[0].mppe,
  134. - "don't allow MPPE encryption", OPT_PRIO },
  135. - { "-mppe", o_bool, &ccp_wantoptions[0].mppe,
  136. - "don't allow MPPE encryption", OPT_ALIAS | OPT_PRIO },
  137. -
  138. - /* We use ccp_allowoptions[0].mppe as a junk var ... it is reset later */
  139. - { "require-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
  140. - "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
  141. - &ccp_wantoptions[0].mppe },
  142. - { "+mppe-40", o_bool, &ccp_allowoptions[0].mppe,
  143. - "require MPPE 40-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_40,
  144. - &ccp_wantoptions[0].mppe },
  145. - { "nomppe-40", o_bool, &ccp_allowoptions[0].mppe,
  146. - "don't allow MPPE 40-bit encryption",
  147. - OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40, &ccp_wantoptions[0].mppe },
  148. - { "-mppe-40", o_bool, &ccp_allowoptions[0].mppe,
  149. - "don't allow MPPE 40-bit encryption",
  150. - OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_40,
  151. - &ccp_wantoptions[0].mppe },
  152. -
  153. - { "require-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
  154. - "require MPPE 128-bit encryption", OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
  155. - &ccp_wantoptions[0].mppe },
  156. - { "+mppe-128", o_bool, &ccp_allowoptions[0].mppe,
  157. - "require MPPE 128-bit encryption",
  158. - OPT_ALIAS | OPT_PRIO | OPT_A2OR | MPPE_OPT_128,
  159. - &ccp_wantoptions[0].mppe },
  160. - { "nomppe-128", o_bool, &ccp_allowoptions[0].mppe,
  161. - "don't allow MPPE 128-bit encryption",
  162. - OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128, &ccp_wantoptions[0].mppe },
  163. - { "-mppe-128", o_bool, &ccp_allowoptions[0].mppe,
  164. - "don't allow MPPE 128-bit encryption",
  165. - OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLRB | MPPE_OPT_128,
  166. - &ccp_wantoptions[0].mppe },
  167. -
  168. - /* strange one; we always request stateless, but will we allow stateful? */
  169. - { "mppe-stateful", o_bool, &refuse_mppe_stateful,
  170. - "allow MPPE stateful mode", OPT_PRIO },
  171. - { "nomppe-stateful", o_bool, &refuse_mppe_stateful,
  172. - "disallow MPPE stateful mode", OPT_PRIO | 1 },
  173. + { "mppc", o_bool, &ccp_wantoptions[0].mppc,
  174. + "request MPPC compression", 1, &ccp_allowoptions[0].mppc },
  175. + { "+mppc", o_bool, &ccp_wantoptions[0].mppc,
  176. + "request MPPC compression", 1, &ccp_allowoptions[0].mppc, OPT_ALIAS },
  177. + { "nomppc", o_bool, &ccp_wantoptions[0].mppc,
  178. + "don't allow MPPC compression", OPT_PRIOSUB | OPT_A2CLR,
  179. + &ccp_allowoptions[0].mppc },
  180. + { "-mppc", o_bool, &ccp_wantoptions[0].mppc,
  181. + "don't allow MPPC compression", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
  182. + &ccp_allowoptions[0].mppc },
  183. + { "mppe", o_special, (void *)setmppe,
  184. + "request MPPE encryption" },
  185. + { "+mppe", o_special, (void *)setmppe,
  186. + "request MPPE encryption" },
  187. + { "nomppe", o_special_noarg, (void *)setnomppe,
  188. + "don't allow MPPE encryption" },
  189. + { "-mppe", o_special_noarg, (void *)setnomppe,
  190. + "don't allow MPPE encryption" },
  191. #endif /* MPPE */
  192. { NULL }
  193. @@ -241,7 +221,7 @@
  194. */
  195. #define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
  196. || (opt).predictor_1 || (opt).predictor_2 \
  197. - || (opt).mppe)
  198. + || (opt).lzs || (opt).mppc || (opt).mppe)
  199. /*
  200. * Local state (mainly for handling reset-reqs and reset-acks).
  201. @@ -344,6 +324,100 @@
  202. return 1;
  203. }
  204. +#ifdef MPPE
  205. +/*
  206. + * Functions called from config options
  207. + */
  208. +/*
  209. + MPPE suboptions:
  210. + required - require MPPE; disconnect if peer doesn't support it
  211. + stateless - use stateless mode
  212. + no40 - disable 40 bit keys
  213. + no56 - disable 56 bit keys
  214. + no128 - disable 128 bit keys
  215. +*/
  216. +int setmppe(char **argv)
  217. +{
  218. + int i;
  219. + char *str, cmdbuf[16];
  220. +
  221. + ccp_allowoptions[0].mppe = 1;
  222. + ccp_allowoptions[0].mppe_40 = 1;
  223. + ccp_allowoptions[0].mppe_56 = 1;
  224. + ccp_allowoptions[0].mppe_128 = 1;
  225. + ccp_allowoptions[0].mppe_stateless = 0;
  226. + ccp_wantoptions[0].mppe = 0;
  227. +
  228. + str = *argv;
  229. +
  230. + while (1) {
  231. + i = 0;
  232. + memset(cmdbuf, '\0', 16);
  233. + while ((i < 16) && (*str != ',') && (*str != '\0'))
  234. + cmdbuf[i++] = *str++;
  235. + cmdbuf[i] = '\0';
  236. + if (!strncasecmp(cmdbuf, "no40", strlen("no40"))) {
  237. + ccp_allowoptions[0].mppe_40 = 0;
  238. + goto next_param;
  239. + } else if (!strncasecmp(cmdbuf, "no56", strlen("no56"))) {
  240. + ccp_allowoptions[0].mppe_56 = 0;
  241. + goto next_param;
  242. + } else if (!strncasecmp(cmdbuf, "no128", strlen("no128"))) {
  243. + ccp_allowoptions[0].mppe_128 = 0;
  244. + goto next_param;
  245. + } else if (!strncasecmp(cmdbuf, "stateless", strlen("stateless"))) {
  246. + ccp_allowoptions[0].mppe_stateless = 1;
  247. + goto next_param;
  248. + } else if (!strncasecmp(cmdbuf, "required", strlen("required"))) {
  249. + ccp_wantoptions[0].mppe = 1;
  250. + goto next_param;
  251. + } else {
  252. + option_error("invalid parameter '%s' for mppe option", cmdbuf);
  253. + return 0;
  254. + }
  255. +
  256. + next_param:
  257. + if (*str == ',') {
  258. + str++;
  259. + continue;
  260. + }
  261. + if (*str == '\0') {
  262. + if (!(ccp_allowoptions[0].mppe_40 || ccp_allowoptions[0].mppe_56 ||
  263. + ccp_allowoptions[0].mppe_128)) {
  264. + if (ccp_wantoptions[0].mppe == 1) {
  265. + option_error("You require MPPE but you have switched off "
  266. + "all encryption key lengths.");
  267. + return 0;
  268. + }
  269. + ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
  270. + ccp_wantoptions[0].mppe_stateless =
  271. + ccp_allowoptions[0].mppe_stateless = 0;
  272. + } else {
  273. + ccp_allowoptions[0].mppe = 1;
  274. + ccp_wantoptions[0].mppe_stateless =
  275. + ccp_allowoptions[0].mppe_stateless;
  276. + if (ccp_wantoptions[0].mppe == 1) {
  277. + ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40;
  278. + ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56;
  279. + ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128;
  280. + }
  281. + }
  282. + return 1;
  283. + }
  284. + }
  285. +}
  286. +
  287. +int setnomppe(void)
  288. +{
  289. + ccp_wantoptions[0].mppe = ccp_allowoptions[0].mppe = 0;
  290. + ccp_wantoptions[0].mppe_40 = ccp_allowoptions[0].mppe_40 = 0;
  291. + ccp_wantoptions[0].mppe_56 = ccp_allowoptions[0].mppe_56 = 0;
  292. + ccp_wantoptions[0].mppe_128 = ccp_allowoptions[0].mppe_128 = 0;
  293. + ccp_wantoptions[0].mppe_stateless = ccp_allowoptions[0].mppe_stateless = 0;
  294. + return 1;
  295. +}
  296. +#endif /* MPPE */
  297. +
  298. /*
  299. * ccp_init - initialize CCP.
  300. */
  301. @@ -378,6 +452,30 @@
  302. ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
  303. ccp_allowoptions[0].predictor_1 = 1;
  304. +
  305. + ccp_wantoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
  306. + ccp_wantoptions[0].lzs_mode = LZS_MODE_SEQ;
  307. + ccp_wantoptions[0].lzs_hists = 1;
  308. + ccp_allowoptions[0].lzs = 0; /* Stac LZS - will be enabled in the future */
  309. + ccp_allowoptions[0].lzs_mode = LZS_MODE_SEQ;
  310. + ccp_allowoptions[0].lzs_hists = 1;
  311. +
  312. +#ifdef MPPE
  313. + /* by default allow and request MPPC... */
  314. + ccp_wantoptions[0].mppc = ccp_allowoptions[0].mppc = 1;
  315. +
  316. + /* ... and allow but don't request MPPE */
  317. + ccp_allowoptions[0].mppe = 1;
  318. + ccp_allowoptions[0].mppe_40 = 1;
  319. + ccp_allowoptions[0].mppe_56 = 1;
  320. + ccp_allowoptions[0].mppe_128 = 1;
  321. + ccp_allowoptions[0].mppe_stateless = 1;
  322. + ccp_wantoptions[0].mppe = 0;
  323. + ccp_wantoptions[0].mppe_40 = 0;
  324. + ccp_wantoptions[0].mppe_56 = 0;
  325. + ccp_wantoptions[0].mppe_128 = 0;
  326. + ccp_wantoptions[0].mppe_stateless = 0;
  327. +#endif /* MPPE */
  328. }
  329. /*
  330. @@ -455,11 +553,11 @@
  331. if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED) {
  332. notice("Compression disabled by peer.");
  333. #ifdef MPPE
  334. - if (ccp_gotoptions[unit].mppe) {
  335. + if (ccp_wantoptions[unit].mppe) {
  336. error("MPPE disabled, closing LCP");
  337. lcp_close(unit, "MPPE disabled by peer");
  338. }
  339. -#endif
  340. +#endif /* MPPE */
  341. }
  342. /*
  343. @@ -487,6 +585,15 @@
  344. break;
  345. /* send a reset-ack, which the transmitter will see and
  346. reset its compression state. */
  347. +
  348. + /* In case of MPPE/MPPC or LZS we shouldn't send CCP_RESETACK,
  349. + but we do it in order to reset compressor; CCP_RESETACK is
  350. + then silently discarded. See functions ppp_send_frame and
  351. + ppp_ccp_peek in ppp_generic.c (Linux only !!!). All the
  352. + confusion is caused by the fact that CCP code is splited
  353. + into two parts - one part is handled by pppd, the other one
  354. + is handled by kernel. */
  355. +
  356. fsm_sdata(f, CCP_RESETACK, id, NULL, 0);
  357. break;
  358. @@ -515,12 +622,11 @@
  359. fsm_lowerdown(&ccp_fsm[unit]);
  360. #ifdef MPPE
  361. - if (ccp_gotoptions[unit].mppe) {
  362. + if (ccp_wantoptions[unit].mppe) {
  363. error("MPPE required but peer negotiation failed");
  364. lcp_close(unit, "MPPE required but peer negotiation failed");
  365. }
  366. -#endif
  367. -
  368. +#endif /* MPPE */
  369. }
  370. /*
  371. @@ -537,7 +643,7 @@
  372. all_rejected[f->unit] = 0;
  373. #ifdef MPPE
  374. - if (go->mppe) {
  375. + if (go->mppe || go->mppc) {
  376. ccp_options *ao = &ccp_allowoptions[f->unit];
  377. int auth_mschap_bits = auth_done[f->unit];
  378. int numbits;
  379. @@ -551,80 +657,109 @@
  380. * NB: If MPPE is required, all other compression opts are invalid.
  381. * So, we return right away if we can't do it.
  382. */
  383. + if (ccp_wantoptions[f->unit].mppe) {
  384. + /* Leave only the mschap auth bits set */
  385. + auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
  386. + CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
  387. + /* Count the mschap auths */
  388. + auth_mschap_bits >>= CHAP_MS_SHIFT;
  389. + numbits = 0;
  390. + do {
  391. + numbits += auth_mschap_bits & 1;
  392. + auth_mschap_bits >>= 1;
  393. + } while (auth_mschap_bits);
  394. + if (numbits > 1) {
  395. + error("MPPE required, but auth done in both directions.");
  396. + lcp_close(f->unit, "MPPE required but not available");
  397. + return;
  398. + }
  399. + if (!numbits) {
  400. + error("MPPE required, but MS-CHAP[v2] auth not performed.");
  401. + lcp_close(f->unit, "MPPE required but not available");
  402. + return;
  403. + }
  404. - /* Leave only the mschap auth bits set */
  405. - auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER |
  406. - CHAP_MS2_WITHPEER | CHAP_MS2_PEER);
  407. - /* Count the mschap auths */
  408. - auth_mschap_bits >>= CHAP_MS_SHIFT;
  409. - numbits = 0;
  410. - do {
  411. - numbits += auth_mschap_bits & 1;
  412. - auth_mschap_bits >>= 1;
  413. - } while (auth_mschap_bits);
  414. - if (numbits > 1) {
  415. - error("MPPE required, but auth done in both directions.");
  416. - lcp_close(f->unit, "MPPE required but not available");
  417. - return;
  418. - }
  419. - if (!numbits) {
  420. - error("MPPE required, but MS-CHAP[v2] auth not performed.");
  421. - lcp_close(f->unit, "MPPE required but not available");
  422. - return;
  423. - }
  424. -
  425. - /* A plugin (eg radius) may not have obtained key material. */
  426. - if (!mppe_keys_set) {
  427. - error("MPPE required, but keys are not available. "
  428. - "Possible plugin problem?");
  429. - lcp_close(f->unit, "MPPE required but not available");
  430. - return;
  431. - }
  432. -
  433. - /* LM auth not supported for MPPE */
  434. - if (auth_done[f->unit] & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) {
  435. - /* This might be noise */
  436. - if (go->mppe & MPPE_OPT_40) {
  437. - notice("Disabling 40-bit MPPE; MS-CHAP LM not supported");
  438. - go->mppe &= ~MPPE_OPT_40;
  439. - ccp_wantoptions[f->unit].mppe &= ~MPPE_OPT_40;
  440. + /* A plugin (eg radius) may not have obtained key material. */
  441. + if (!mppe_keys_set) {
  442. + error("MPPE required, but keys are not available. "
  443. + "Possible plugin problem?");
  444. + lcp_close(f->unit, "MPPE required but not available");
  445. + return;
  446. }
  447. }
  448. - /* Last check: can we actually negotiate something? */
  449. - if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) {
  450. - /* Could be misconfig, could be 40-bit disabled above. */
  451. - error("MPPE required, but both 40-bit and 128-bit disabled.");
  452. - lcp_close(f->unit, "MPPE required but not available");
  453. - return;
  454. + /*
  455. + * Check whether the kernel knows about the various
  456. + * compression methods we might request. Key material
  457. + * unimportant here.
  458. + */
  459. + if (go->mppc) {
  460. + opt_buf[0] = CI_MPPE;
  461. + opt_buf[1] = CILEN_MPPE;
  462. + opt_buf[2] = 0;
  463. + opt_buf[3] = 0;
  464. + opt_buf[4] = 0;
  465. + opt_buf[5] = MPPE_MPPC;
  466. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 0) <= 0)
  467. + go->mppc = 0;
  468. + }
  469. + if (go->mppe_40) {
  470. + opt_buf[0] = CI_MPPE;
  471. + opt_buf[1] = CILEN_MPPE;
  472. + opt_buf[2] = MPPE_STATELESS;
  473. + opt_buf[3] = 0;
  474. + opt_buf[4] = 0;
  475. + opt_buf[5] = MPPE_40BIT;
  476. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
  477. + go->mppe_40 = 0;
  478. + }
  479. + if (go->mppe_56) {
  480. + opt_buf[0] = CI_MPPE;
  481. + opt_buf[1] = CILEN_MPPE;
  482. + opt_buf[2] = MPPE_STATELESS;
  483. + opt_buf[3] = 0;
  484. + opt_buf[4] = 0;
  485. + opt_buf[5] = MPPE_56BIT;
  486. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
  487. + go->mppe_56 = 0;
  488. + }
  489. + if (go->mppe_128) {
  490. + opt_buf[0] = CI_MPPE;
  491. + opt_buf[1] = CILEN_MPPE;
  492. + opt_buf[2] = MPPE_STATELESS;
  493. + opt_buf[3] = 0;
  494. + opt_buf[4] = 0;
  495. + opt_buf[5] = MPPE_128BIT;
  496. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0)
  497. + go->mppe_128 = 0;
  498. + }
  499. + if (!go->mppe_40 && !go->mppe_56 && !go->mppe_128) {
  500. + if (ccp_wantoptions[f->unit].mppe) {
  501. + error("MPPE required, but kernel has no support.");
  502. + lcp_close(f->unit, "MPPE required but not available");
  503. + }
  504. + go->mppe = go->mppe_stateless = 0;
  505. + } else {
  506. + /* MPPE is not compatible with other compression types */
  507. + if (ccp_wantoptions[f->unit].mppe) {
  508. + ao->bsd_compress = go->bsd_compress = 0;
  509. + ao->predictor_1 = go->predictor_1 = 0;
  510. + ao->predictor_2 = go->predictor_2 = 0;
  511. + ao->deflate = go->deflate = 0;
  512. + ao->lzs = go->lzs = 0;
  513. + }
  514. }
  515. -
  516. - /* sync options */
  517. - ao->mppe = go->mppe;
  518. - /* MPPE is not compatible with other compression types */
  519. - ao->bsd_compress = go->bsd_compress = 0;
  520. - ao->predictor_1 = go->predictor_1 = 0;
  521. - ao->predictor_2 = go->predictor_2 = 0;
  522. - ao->deflate = go->deflate = 0;
  523. }
  524. #endif /* MPPE */
  525. -
  526. - /*
  527. - * Check whether the kernel knows about the various
  528. - * compression methods we might request.
  529. - */
  530. -#ifdef MPPE
  531. - if (go->mppe) {
  532. - opt_buf[0] = CI_MPPE;
  533. - opt_buf[1] = CILEN_MPPE;
  534. - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
  535. - /* Key material unimportant here. */
  536. - if (ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0) <= 0) {
  537. - error("MPPE required, but kernel has no support.");
  538. - lcp_close(f->unit, "MPPE required but not available");
  539. - }
  540. + if (go->lzs) {
  541. + opt_buf[0] = CI_LZS;
  542. + opt_buf[1] = CILEN_LZS;
  543. + opt_buf[2] = go->lzs_hists >> 8;
  544. + opt_buf[3] = go->lzs_hists & 0xff;
  545. + opt_buf[4] = LZS_MODE_SEQ;
  546. + if (ccp_test(f->unit, opt_buf, CILEN_LZS, 0) <= 0)
  547. + go->lzs = 0;
  548. }
  549. -#endif
  550. if (go->bsd_compress) {
  551. opt_buf[0] = CI_BSD_COMPRESS;
  552. opt_buf[1] = CILEN_BSD_COMPRESS;
  553. @@ -679,7 +814,8 @@
  554. + (go->deflate? CILEN_DEFLATE: 0)
  555. + (go->predictor_1? CILEN_PREDICTOR_1: 0)
  556. + (go->predictor_2? CILEN_PREDICTOR_2: 0)
  557. - + (go->mppe? CILEN_MPPE: 0);
  558. + + (go->lzs? CILEN_LZS: 0)
  559. + + ((go->mppe || go->mppc)? CILEN_MPPE: 0);
  560. }
  561. /*
  562. @@ -693,6 +829,8 @@
  563. {
  564. int res;
  565. ccp_options *go = &ccp_gotoptions[f->unit];
  566. + ccp_options *ao = &ccp_allowoptions[f->unit];
  567. + ccp_options *wo = &ccp_wantoptions[f->unit];
  568. u_char *p0 = p;
  569. /*
  570. @@ -701,22 +839,43 @@
  571. * in case it gets Acked.
  572. */
  573. #ifdef MPPE
  574. - if (go->mppe) {
  575. + if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
  576. u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
  577. - p[0] = opt_buf[0] = CI_MPPE;
  578. - p[1] = opt_buf[1] = CILEN_MPPE;
  579. - MPPE_OPTS_TO_CI(go->mppe, &p[2]);
  580. - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
  581. + p[0] = CI_MPPE;
  582. + p[1] = CILEN_MPPE;
  583. + p[2] = (go->mppe_stateless ? MPPE_STATELESS : 0);
  584. + p[3] = 0;
  585. + p[4] = 0;
  586. + p[5] = (go->mppe_40 ? MPPE_40BIT : 0) | (go->mppe_56 ? MPPE_56BIT : 0) |
  587. + (go->mppe_128 ? MPPE_128BIT : 0) | (go->mppc ? MPPE_MPPC : 0);
  588. +
  589. + BCOPY(p, opt_buf, CILEN_MPPE);
  590. BCOPY(mppe_recv_key, &opt_buf[CILEN_MPPE], MPPE_MAX_KEY_LEN);
  591. res = ccp_test(f->unit, opt_buf, CILEN_MPPE + MPPE_MAX_KEY_LEN, 0);
  592. - if (res > 0)
  593. + if (res > 0) {
  594. p += CILEN_MPPE;
  595. - else
  596. + } else {
  597. /* This shouldn't happen, we've already tested it! */
  598. - lcp_close(f->unit, "MPPE required but not available in kernel");
  599. + go->mppe = go->mppe_40 = go->mppe_56 = go->mppe_128 =
  600. + go->mppe_stateless = go->mppc = 0;
  601. + if (ccp_wantoptions[f->unit].mppe)
  602. + lcp_close(f->unit, "MPPE required but not available in kernel");
  603. + }
  604. + }
  605. +#endif /* MPPE */
  606. + if (go->lzs) {
  607. + p[0] = CI_LZS;
  608. + p[1] = CILEN_LZS;
  609. + p[2] = go->lzs_hists >> 8;
  610. + p[3] = go->lzs_hists & 0xff;
  611. + p[4] = LZS_MODE_SEQ;
  612. + res = ccp_test(f->unit, p, CILEN_LZS, 0);
  613. + if (res > 0) {
  614. + p += CILEN_LZS;
  615. + } else
  616. + go->lzs = 0;
  617. }
  618. -#endif
  619. if (go->deflate) {
  620. p[0] = go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT;
  621. p[1] = CILEN_DEFLATE;
  622. @@ -802,7 +961,7 @@
  623. /*
  624. * ccp_ackci - process a received configure-ack, and return
  625. - * 1 iff the packet was OK.
  626. + * 1 if the packet was OK.
  627. */
  628. static int
  629. ccp_ackci(f, p, len)
  630. @@ -811,24 +970,44 @@
  631. int len;
  632. {
  633. ccp_options *go = &ccp_gotoptions[f->unit];
  634. + ccp_options *ao = &ccp_allowoptions[f->unit];
  635. + ccp_options *wo = &ccp_wantoptions[f->unit];
  636. u_char *p0 = p;
  637. #ifdef MPPE
  638. - if (go->mppe) {
  639. - u_char opt_buf[CILEN_MPPE];
  640. -
  641. - opt_buf[0] = CI_MPPE;
  642. - opt_buf[1] = CILEN_MPPE;
  643. - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]);
  644. - if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE))
  645. + if (go->mppe || go->mppc || (!wo->mppe && ao->mppe)) {
  646. + if (len < CILEN_MPPE
  647. + || p[1] != CILEN_MPPE || p[0] != CI_MPPE
  648. + || p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0)
  649. + || p[3] != 0
  650. + || p[4] != 0
  651. + || (p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
  652. + (go->mppc ? MPPE_MPPC : 0))
  653. + && p[5] != ((go->mppe_56 ? MPPE_56BIT : 0) |
  654. + (go->mppc ? MPPE_MPPC : 0))
  655. + && p[5] != ((go->mppe_128 ? MPPE_128BIT : 0) |
  656. + (go->mppc ? MPPE_MPPC : 0))))
  657. return 0;
  658. + if (go->mppe_40 || go->mppe_56 || go->mppe_128)
  659. + go->mppe = 1;
  660. p += CILEN_MPPE;
  661. len -= CILEN_MPPE;
  662. + /* Cope with first/fast ack */
  663. + if (p == p0 && len == 0)
  664. + return 1;
  665. + }
  666. +#endif /* MPPE */
  667. + if (go->lzs) {
  668. + if (len < CILEN_LZS || p[0] != CI_LZS || p[1] != CILEN_LZS
  669. + || p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
  670. + || p[4] != LZS_MODE_SEQ)
  671. + return 0;
  672. + p += CILEN_LZS;
  673. + len -= CILEN_LZS;
  674. /* XXX Cope with first/fast ack */
  675. - if (len == 0)
  676. + if (p == p0 && len == 0)
  677. return 1;
  678. }
  679. -#endif
  680. if (go->deflate) {
  681. if (len < CILEN_DEFLATE
  682. || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
  683. @@ -891,7 +1070,7 @@
  684. /*
  685. * ccp_nakci - process received configure-nak.
  686. - * Returns 1 iff the nak was OK.
  687. + * Returns 1 if the nak was OK.
  688. */
  689. static int
  690. ccp_nakci(f, p, len, treat_as_reject)
  691. @@ -901,6 +1080,8 @@
  692. int treat_as_reject;
  693. {
  694. ccp_options *go = &ccp_gotoptions[f->unit];
  695. + ccp_options *ao = &ccp_allowoptions[f->unit];
  696. + ccp_options *wo = &ccp_wantoptions[f->unit];
  697. ccp_options no; /* options we've seen already */
  698. ccp_options try; /* options to ask for next time */
  699. @@ -908,28 +1089,100 @@
  700. try = *go;
  701. #ifdef MPPE
  702. - if (go->mppe && len >= CILEN_MPPE
  703. - && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
  704. - no.mppe = 1;
  705. - /*
  706. - * Peer wants us to use a different strength or other setting.
  707. - * Fail if we aren't willing to use his suggestion.
  708. - */
  709. - MPPE_CI_TO_OPTS(&p[2], try.mppe);
  710. - if ((try.mppe & MPPE_OPT_STATEFUL) && refuse_mppe_stateful) {
  711. - error("Refusing MPPE stateful mode offered by peer");
  712. - try.mppe = 0;
  713. - } else if (((go->mppe | MPPE_OPT_STATEFUL) & try.mppe) != try.mppe) {
  714. - /* Peer must have set options we didn't request (suggest) */
  715. - try.mppe = 0;
  716. - }
  717. + if ((go->mppe || go->mppc || (!wo->mppe && ao->mppe)) &&
  718. + len >= CILEN_MPPE && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
  719. - if (!try.mppe) {
  720. - error("MPPE required but peer negotiation failed");
  721. - lcp_close(f->unit, "MPPE required but peer negotiation failed");
  722. + if (go->mppc) {
  723. + no.mppc = 1;
  724. + if (!(p[5] & MPPE_MPPC))
  725. + try.mppc = 0;
  726. + }
  727. +
  728. + if (go->mppe)
  729. + no.mppe = 1;
  730. + if (go->mppe_40)
  731. + no.mppe_40 = 1;
  732. + if (go->mppe_56)
  733. + no.mppe_56 = 1;
  734. + if (go->mppe_128)
  735. + no.mppe_128 = 1;
  736. + if (go->mppe_stateless)
  737. + no.mppe_stateless = 1;
  738. +
  739. + if (ao->mppe_40) {
  740. + if ((p[5] & MPPE_40BIT))
  741. + try.mppe_40 = 1;
  742. + else
  743. + try.mppe_40 = (p[5] == 0) ? 1 : 0;
  744. + }
  745. + if (ao->mppe_56) {
  746. + if ((p[5] & MPPE_56BIT))
  747. + try.mppe_56 = 1;
  748. + else
  749. + try.mppe_56 = (p[5] == 0) ? 1 : 0;
  750. + }
  751. + if (ao->mppe_128) {
  752. + if ((p[5] & MPPE_128BIT))
  753. + try.mppe_128 = 1;
  754. + else
  755. + try.mppe_128 = (p[5] == 0) ? 1 : 0;
  756. + }
  757. +
  758. + if (ao->mppe_stateless) {
  759. + if ((p[2] & MPPE_STATELESS) || wo->mppe_stateless)
  760. + try.mppe_stateless = 1;
  761. + else
  762. + try.mppe_stateless = 0;
  763. + }
  764. +
  765. + if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128) {
  766. + try.mppe = try.mppe_stateless = 0;
  767. + if (wo->mppe) {
  768. + /* we require encryption, but peer doesn't support it
  769. + so we close connection */
  770. + wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
  771. + wo->mppe_56 = wo->mppe_128 = 0;
  772. + lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
  773. + "key length");
  774. + }
  775. + }
  776. + if (wo->mppe && (wo->mppe_40 != try.mppe_40) &&
  777. + (wo->mppe_56 != try.mppe_56) && (wo->mppe_128 != try.mppe_128)) {
  778. + /* cannot negotiate key length */
  779. + wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
  780. + wo->mppe_56 = wo->mppe_128 = 0;
  781. + lcp_close(f->unit, "Cannot negotiate MPPE key length");
  782. }
  783. + if (try.mppe_40 && try.mppe_56 && try.mppe_128)
  784. + try.mppe_40 = try.mppe_56 = 0;
  785. + else
  786. + if (try.mppe_56 && try.mppe_128)
  787. + try.mppe_56 = 0;
  788. + else
  789. + if (try.mppe_40 && try.mppe_128)
  790. + try.mppe_40 = 0;
  791. + else
  792. + if (try.mppe_40 && try.mppe_56)
  793. + try.mppe_40 = 0;
  794. +
  795. + p += CILEN_MPPE;
  796. + len -= CILEN_MPPE;
  797. }
  798. #endif /* MPPE */
  799. +
  800. + if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
  801. + no.lzs = 1;
  802. + if (((p[2]<<8)|p[3]) > 1 || (p[4] != LZS_MODE_SEQ &&
  803. + p[4] != LZS_MODE_EXT))
  804. + try.lzs = 0;
  805. + else {
  806. + try.lzs_mode = p[4];
  807. + try.lzs_hists = (p[2] << 8) | p[3];
  808. + }
  809. + p += CILEN_LZS;
  810. + len -= CILEN_LZS;
  811. + }
  812. +
  813. if (go->deflate && len >= CILEN_DEFLATE
  814. && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT)
  815. && p[1] == CILEN_DEFLATE) {
  816. @@ -1002,14 +1255,50 @@
  817. return -1;
  818. #ifdef MPPE
  819. - if (go->mppe && len >= CILEN_MPPE
  820. + if ((go->mppe || go->mppc) && len >= CILEN_MPPE
  821. && p[0] == CI_MPPE && p[1] == CILEN_MPPE) {
  822. - error("MPPE required but peer refused");
  823. - lcp_close(f->unit, "MPPE required but peer refused");
  824. + ccp_options *wo = &ccp_wantoptions[f->unit];
  825. + if (p[2] != (go->mppe_stateless ? MPPE_STATELESS : 0) ||
  826. + p[3] != 0 ||
  827. + p[4] != 0 ||
  828. + p[5] != ((go->mppe_40 ? MPPE_40BIT : 0) |
  829. + (go->mppe_56 ? MPPE_56BIT : 0) |
  830. + (go->mppe_128 ? MPPE_128BIT : 0) |
  831. + (go->mppc ? MPPE_MPPC : 0)))
  832. + return 0;
  833. + if (go->mppc)
  834. + try.mppc = 0;
  835. + if (go->mppe) {
  836. + try.mppe = 0;
  837. + if (go->mppe_40)
  838. + try.mppe_40 = 0;
  839. + if (go->mppe_56)
  840. + try.mppe_56 = 0;
  841. + if (go->mppe_128)
  842. + try.mppe_128 = 0;
  843. + if (go->mppe_stateless)
  844. + try.mppe_stateless = 0;
  845. + if (!try.mppe_56 && !try.mppe_40 && !try.mppe_128)
  846. + try.mppe = try.mppe_stateless = 0;
  847. + if (wo->mppe) { /* we want MPPE but cannot negotiate key length */
  848. + wo->mppc = wo->mppe = wo->mppe_stateless = wo->mppe_40 =
  849. + wo->mppe_56 = wo->mppe_128 = 0;
  850. + lcp_close(f->unit, "MPPE required but cannot negotiate MPPE "
  851. + "key length");
  852. + }
  853. + }
  854. p += CILEN_MPPE;
  855. len -= CILEN_MPPE;
  856. }
  857. -#endif
  858. +#endif /* MPPE */
  859. + if (go->lzs && len >= CILEN_LZS && p[0] == CI_LZS && p[1] == CILEN_LZS) {
  860. + if (p[2] != go->lzs_hists>>8 || p[3] != (go->lzs_hists&0xff)
  861. + || p[4] != go->lzs_mode)
  862. + return 0;
  863. + try.lzs = 0;
  864. + p += CILEN_LZS;
  865. + len -= CILEN_LZS;
  866. + }
  867. if (go->deflate_correct && len >= CILEN_DEFLATE
  868. && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) {
  869. if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size)
  870. @@ -1073,14 +1362,15 @@
  871. int dont_nak;
  872. {
  873. int ret, newret, res;
  874. - u_char *p0, *retp;
  875. + u_char *p0, *retp, p2, p5;
  876. int len, clen, type, nb;
  877. ccp_options *ho = &ccp_hisoptions[f->unit];
  878. ccp_options *ao = &ccp_allowoptions[f->unit];
  879. + ccp_options *wo = &ccp_wantoptions[f->unit];
  880. #ifdef MPPE
  881. - bool rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */
  882. - /* CI_MPPE, or due to other options? */
  883. -#endif
  884. + u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
  885. +/* int mtu; */
  886. +#endif /* MPPE */
  887. ret = CONFACK;
  888. retp = p0 = p;
  889. @@ -1103,106 +1393,307 @@
  890. switch (type) {
  891. #ifdef MPPE
  892. case CI_MPPE:
  893. - if (!ao->mppe || clen != CILEN_MPPE) {
  894. + if ((!ao->mppc && !ao->mppe) || clen != CILEN_MPPE) {
  895. newret = CONFREJ;
  896. break;
  897. }
  898. - MPPE_CI_TO_OPTS(&p[2], ho->mppe);
  899. - /* Nak if anything unsupported or unknown are set. */
  900. - if (ho->mppe & MPPE_OPT_UNSUPPORTED) {
  901. - newret = CONFNAK;
  902. - ho->mppe &= ~MPPE_OPT_UNSUPPORTED;
  903. - }
  904. - if (ho->mppe & MPPE_OPT_UNKNOWN) {
  905. + p2 = p[2];
  906. + p5 = p[5];
  907. + /* not sure what they want, tell 'em what we got */
  908. + if (((p[2] & ~MPPE_STATELESS) != 0 || p[3] != 0 || p[4] != 0 ||
  909. + (p[5] & ~(MPPE_40BIT | MPPE_56BIT | MPPE_128BIT |
  910. + MPPE_MPPC)) != 0 || p[5] == 0) ||
  911. + (p[2] == 0 && p[3] == 0 && p[4] == 0 && p[5] == 0)) {
  912. newret = CONFNAK;
  913. - ho->mppe &= ~MPPE_OPT_UNKNOWN;
  914. + p[2] = (wo->mppe_stateless ? MPPE_STATELESS : 0);
  915. + p[3] = 0;
  916. + p[4] = 0;
  917. + p[5] = (wo->mppe_40 ? MPPE_40BIT : 0) |
  918. + (wo->mppe_56 ? MPPE_56BIT : 0) |
  919. + (wo->mppe_128 ? MPPE_128BIT : 0) |
  920. + (wo->mppc ? MPPE_MPPC : 0);
  921. + break;
  922. }
  923. - /* Check state opt */
  924. - if (ho->mppe & MPPE_OPT_STATEFUL) {
  925. - /*
  926. - * We can Nak and request stateless, but it's a
  927. - * lot easier to just assume the peer will request
  928. - * it if he can do it; stateful mode is bad over
  929. - * the Internet -- which is where we expect MPPE.
  930. - */
  931. - if (refuse_mppe_stateful) {
  932. - error("Refusing MPPE stateful mode offered by peer");
  933. + if ((p[5] & MPPE_MPPC)) {
  934. + if (ao->mppc) {
  935. + ho->mppc = 1;
  936. + BCOPY(p, opt_buf, CILEN_MPPE);
  937. + opt_buf[2] = opt_buf[3] = opt_buf[4] = 0;
  938. + opt_buf[5] = MPPE_MPPC;
  939. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE, 1) <= 0) {
  940. + ho->mppc = 0;
  941. + p[5] &= ~MPPE_MPPC;
  942. + newret = CONFNAK;
  943. + }
  944. + } else {
  945. newret = CONFREJ;
  946. - break;
  947. + if (wo->mppe || ao->mppe) {
  948. + p[5] &= ~MPPE_MPPC;
  949. + newret = CONFNAK;
  950. + }
  951. + }
  952. + }
  953. +
  954. + if (ao->mppe)
  955. + ho->mppe = 1;
  956. +
  957. + if ((p[2] & MPPE_STATELESS)) {
  958. + if (ao->mppe_stateless) {
  959. + if (wo->mppe_stateless)
  960. + ho->mppe_stateless = 1;
  961. + else {
  962. + newret = CONFNAK;
  963. + if (!dont_nak)
  964. + p[2] &= ~MPPE_STATELESS;
  965. + }
  966. + } else {
  967. + newret = CONFNAK;
  968. + if (!dont_nak)
  969. + p[2] &= ~MPPE_STATELESS;
  970. + }
  971. + } else {
  972. + if (wo->mppe_stateless && !dont_nak) {
  973. + wo->mppe_stateless = 0;
  974. + newret = CONFNAK;
  975. + p[2] |= MPPE_STATELESS;
  976. }
  977. }
  978. - /* Find out which of {S,L} are set. */
  979. - if ((ho->mppe & MPPE_OPT_128)
  980. - && (ho->mppe & MPPE_OPT_40)) {
  981. - /* Both are set, negotiate the strongest. */
  982. + if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT|MPPE_128BIT)) {
  983. newret = CONFNAK;
  984. - if (ao->mppe & MPPE_OPT_128)
  985. - ho->mppe &= ~MPPE_OPT_40;
  986. - else if (ao->mppe & MPPE_OPT_40)
  987. - ho->mppe &= ~MPPE_OPT_128;
  988. - else {
  989. - newret = CONFREJ;
  990. - break;
  991. + if (ao->mppe_128) {
  992. + ho->mppe_128 = 1;
  993. + p[5] &= ~(MPPE_40BIT|MPPE_56BIT);
  994. + BCOPY(p, opt_buf, CILEN_MPPE);
  995. + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
  996. + MPPE_MAX_KEY_LEN);
  997. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
  998. + MPPE_MAX_KEY_LEN, 1) <= 0) {
  999. + ho->mppe_128 = 0;
  1000. + p[5] |= (MPPE_40BIT|MPPE_56BIT);
  1001. + p[5] &= ~MPPE_128BIT;
  1002. + goto check_mppe_56_40;
  1003. + }
  1004. + goto check_mppe;
  1005. }
  1006. - } else if (ho->mppe & MPPE_OPT_128) {
  1007. - if (!(ao->mppe & MPPE_OPT_128)) {
  1008. - newret = CONFREJ;
  1009. - break;
  1010. + p[5] &= ~MPPE_128BIT;
  1011. + goto check_mppe_56_40;
  1012. + }
  1013. + if ((p[5] & ~MPPE_MPPC) == (MPPE_56BIT|MPPE_128BIT)) {
  1014. + newret = CONFNAK;
  1015. + if (ao->mppe_128) {
  1016. + ho->mppe_128 = 1;
  1017. + p[5] &= ~MPPE_56BIT;
  1018. + BCOPY(p, opt_buf, CILEN_MPPE);
  1019. + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
  1020. + MPPE_MAX_KEY_LEN);
  1021. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
  1022. + MPPE_MAX_KEY_LEN, 1) <= 0) {
  1023. + ho->mppe_128 = 0;
  1024. + p[5] |= MPPE_56BIT;
  1025. + p[5] &= ~MPPE_128BIT;
  1026. + goto check_mppe_56;
  1027. + }
  1028. + goto check_mppe;
  1029. }
  1030. - } else if (ho->mppe & MPPE_OPT_40) {
  1031. - if (!(ao->mppe & MPPE_OPT_40)) {
  1032. - newret = CONFREJ;
  1033. - break;
  1034. + p[5] &= ~MPPE_128BIT;
  1035. + goto check_mppe_56;
  1036. + }
  1037. + if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_128BIT)) {
  1038. + newret = CONFNAK;
  1039. + if (ao->mppe_128) {
  1040. + ho->mppe_128 = 1;
  1041. + p[5] &= ~MPPE_40BIT;
  1042. + BCOPY(p, opt_buf, CILEN_MPPE);
  1043. + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
  1044. + MPPE_MAX_KEY_LEN);
  1045. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
  1046. + MPPE_MAX_KEY_LEN, 1) <= 0) {
  1047. + ho->mppe_128 = 0;
  1048. + p[5] |= MPPE_40BIT;
  1049. + p[5] &= ~MPPE_128BIT;
  1050. + goto check_mppe_40;
  1051. + }
  1052. + goto check_mppe;
  1053. + }
  1054. + p[5] &= ~MPPE_128BIT;
  1055. + goto check_mppe_40;
  1056. + }
  1057. + if ((p[5] & ~MPPE_MPPC) == MPPE_128BIT) {
  1058. + if (ao->mppe_128) {
  1059. + ho->mppe_128 = 1;
  1060. + BCOPY(p, opt_buf, CILEN_MPPE);
  1061. + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
  1062. + MPPE_MAX_KEY_LEN);
  1063. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
  1064. + MPPE_MAX_KEY_LEN, 1) <= 0) {
  1065. + ho->mppe_128 = 0;
  1066. + p[5] &= ~MPPE_128BIT;
  1067. + newret = CONFNAK;
  1068. + }
  1069. + goto check_mppe;
  1070. + }
  1071. + p[5] &= ~MPPE_128BIT;
  1072. + newret = CONFNAK;
  1073. + goto check_mppe;
  1074. + }
  1075. + check_mppe_56_40:
  1076. + if ((p[5] & ~MPPE_MPPC) == (MPPE_40BIT|MPPE_56BIT)) {
  1077. + newret = CONFNAK;
  1078. + if (ao->mppe_56) {
  1079. + ho->mppe_56 = 1;
  1080. + p[5] &= ~MPPE_40BIT;
  1081. + BCOPY(p, opt_buf, CILEN_MPPE);
  1082. + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
  1083. + MPPE_MAX_KEY_LEN);
  1084. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
  1085. + MPPE_MAX_KEY_LEN, 1) <= 0) {
  1086. + ho->mppe_56 = 0;
  1087. + p[5] |= MPPE_40BIT;
  1088. + p[5] &= ~MPPE_56BIT;
  1089. + newret = CONFNAK;
  1090. + goto check_mppe_40;
  1091. + }
  1092. + goto check_mppe;
  1093. + }
  1094. + p[5] &= ~MPPE_56BIT;
  1095. + goto check_mppe_40;
  1096. + }
  1097. + check_mppe_56:
  1098. + if ((p[5] & ~MPPE_MPPC) == MPPE_56BIT) {
  1099. + if (ao->mppe_56) {
  1100. + ho->mppe_56 = 1;
  1101. + BCOPY(p, opt_buf, CILEN_MPPE);
  1102. + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
  1103. + MPPE_MAX_KEY_LEN);
  1104. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
  1105. + MPPE_MAX_KEY_LEN, 1) <= 0) {
  1106. + ho->mppe_56 = 0;
  1107. + p[5] &= ~MPPE_56BIT;
  1108. + newret = CONFNAK;
  1109. + }
  1110. + goto check_mppe;
  1111. + }
  1112. + p[5] &= ~MPPE_56BIT;
  1113. + newret = CONFNAK;
  1114. + goto check_mppe;
  1115. + }
  1116. + check_mppe_40:
  1117. + if ((p[5] & ~MPPE_MPPC) == MPPE_40BIT) {
  1118. + if (ao->mppe_40) {
  1119. + ho->mppe_40 = 1;
  1120. + BCOPY(p, opt_buf, CILEN_MPPE);
  1121. + BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
  1122. + MPPE_MAX_KEY_LEN);
  1123. + if (ccp_test(f->unit, opt_buf, CILEN_MPPE +
  1124. + MPPE_MAX_KEY_LEN, 1) <= 0) {
  1125. + ho->mppe_40 = 0;
  1126. + p[5] &= ~MPPE_40BIT;
  1127. + newret = CONFNAK;
  1128. + }
  1129. + goto check_mppe;
  1130. + }
  1131. + p[5] &= ~MPPE_40BIT;
  1132. + }
  1133. +
  1134. + check_mppe:
  1135. + if (!ho->mppe_40 && !ho->mppe_56 && !ho->mppe_128) {
  1136. + if (wo->mppe_40 || wo->mppe_56 || wo->mppe_128) {
  1137. + newret = CONFNAK;
  1138. + p[2] |= (wo->mppe_stateless ? MPPE_STATELESS : 0);
  1139. + p[5] |= (wo->mppe_40 ? MPPE_40BIT : 0) |
  1140. + (wo->mppe_56 ? MPPE_56BIT : 0) |
  1141. + (wo->mppe_128 ? MPPE_128BIT : 0) |
  1142. + (wo->mppc ? MPPE_MPPC : 0);
  1143. + } else {
  1144. + ho->mppe = ho->mppe_stateless = 0;
  1145. }
  1146. } else {
  1147. - /* Neither are set. */
  1148. - /* We cannot accept this. */
  1149. + /* MPPE is not compatible with other compression types */
  1150. + if (wo->mppe) {
  1151. + ao->bsd_compress = 0;
  1152. + ao->predictor_1 = 0;
  1153. + ao->predictor_2 = 0;
  1154. + ao->deflate = 0;
  1155. + ao->lzs = 0;
  1156. + }
  1157. + }
  1158. + if ((!ho->mppc || !ao->mppc) && !ho->mppe) {
  1159. + p[2] = p2;
  1160. + p[5] = p5;
  1161. newret = CONFNAK;
  1162. /* Give the peer our idea of what can be used,
  1163. so it can choose and confirm */
  1164. ho->mppe = ao->mppe;
  1165. }
  1166. - /* rebuild the opts */
  1167. - MPPE_OPTS_TO_CI(ho->mppe, &p[2]);
  1168. - if (newret == CONFACK) {
  1169. - u_char opt_buf[CILEN_MPPE + MPPE_MAX_KEY_LEN];
  1170. - int mtu;
  1171. -
  1172. - BCOPY(p, opt_buf, CILEN_MPPE);
  1173. - BCOPY(mppe_send_key, &opt_buf[CILEN_MPPE],
  1174. - MPPE_MAX_KEY_LEN);
  1175. - if (ccp_test(f->unit, opt_buf,
  1176. - CILEN_MPPE + MPPE_MAX_KEY_LEN, 1) <= 0) {
  1177. - /* This shouldn't happen, we've already tested it! */
  1178. - error("MPPE required, but kernel has no support.");
  1179. - lcp_close(f->unit, "MPPE required but not available");
  1180. - newret = CONFREJ;
  1181. - break;
  1182. - }
  1183. - /*
  1184. - * We need to decrease the interface MTU by MPPE_PAD
  1185. - * because MPPE frames **grow**. The kernel [must]
  1186. - * allocate MPPE_PAD extra bytes in xmit buffers.
  1187. - */
  1188. - mtu = netif_get_mtu(f->unit);
  1189. - if (mtu)
  1190. - netif_set_mtu(f->unit, mtu - MPPE_PAD);
  1191. - else
  1192. - newret = CONFREJ;
  1193. - }
  1194. + /*
  1195. + * I have commented the code below because according to RFC1547
  1196. + * MTU is only information for higher level protocols about
  1197. + * "the maximum allowable length for a packet (q.v.) transmitted
  1198. + * over a point-to-point link without incurring network layer
  1199. + * fragmentation." Of course a PPP implementation should be able
  1200. + * to handle overhead added by MPPE - in our case apropriate code
  1201. + * is located in drivers/net/ppp_generic.c in the kernel sources.
  1202. + *
  1203. + * According to RFC1661:
  1204. + * - when negotiated MRU is less than 1500 octets, a PPP
  1205. + * implementation must still be able to receive at least 1500
  1206. + * octets,
  1207. + * - when PFC is negotiated, a PPP implementation is still
  1208. + * required to receive frames with uncompressed protocol field.
  1209. + *
  1210. + * So why not to handle MPPE overhead without changing MTU value?
  1211. + * I am sure that RFC3078, unfortunately silently, assumes that.
  1212. + */
  1213. /*
  1214. - * We have accepted MPPE or are willing to negotiate
  1215. - * MPPE parameters. A CONFREJ is due to subsequent
  1216. - * (non-MPPE) processing.
  1217. + * We need to decrease the interface MTU by MPPE_PAD
  1218. + * because MPPE frames **grow**. The kernel [must]
  1219. + * allocate MPPE_PAD extra bytes in xmit buffers.
  1220. */
  1221. - rej_for_ci_mppe = 0;
  1222. +/*
  1223. + mtu = netif_get_mtu(f->unit);
  1224. + if (mtu) {
  1225. + netif_set_mtu(f->unit, mtu - MPPE_PAD);
  1226. + } else {
  1227. + newret = CONFREJ;
  1228. + if (ccp_wantoptions[f->unit].mppe) {
  1229. + error("Cannot adjust MTU needed by MPPE.");
  1230. + lcp_close(f->unit, "Cannot adjust MTU needed by MPPE.");
  1231. + }
  1232. + }
  1233. +*/
  1234. break;
  1235. #endif /* MPPE */
  1236. +
  1237. + case CI_LZS:
  1238. + if (!ao->lzs || clen != CILEN_LZS) {
  1239. + newret = CONFREJ;
  1240. + break;
  1241. + }
  1242. +
  1243. + ho->lzs = 1;
  1244. + ho->lzs_hists = (p[2] << 8) | p[3];
  1245. + ho->lzs_mode = p[4];
  1246. + if ((ho->lzs_hists != ao->lzs_hists) ||
  1247. + (ho->lzs_mode != ao->lzs_mode)) {
  1248. + newret = CONFNAK;
  1249. + if (!dont_nak) {
  1250. + p[2] = ao->lzs_hists >> 8;
  1251. + p[3] = ao->lzs_hists & 0xff;
  1252. + p[4] = ao->lzs_mode;
  1253. + } else
  1254. + break;
  1255. + }
  1256. +
  1257. + if (p == p0 && ccp_test(f->unit, p, CILEN_LZS, 1) <= 0) {
  1258. + newret = CONFREJ;
  1259. + }
  1260. + break;
  1261. +
  1262. case CI_DEFLATE:
  1263. case CI_DEFLATE_DRAFT:
  1264. if (!ao->deflate || clen != CILEN_DEFLATE
  1265. @@ -1344,12 +1835,6 @@
  1266. else
  1267. *lenp = retp - p0;
  1268. }
  1269. -#ifdef MPPE
  1270. - if (ret == CONFREJ && ao->mppe && rej_for_ci_mppe) {
  1271. - error("MPPE required but peer negotiation failed");
  1272. - lcp_close(f->unit, "MPPE required but peer negotiation failed");
  1273. - }
  1274. -#endif
  1275. return ret;
  1276. }
  1277. @@ -1371,24 +1856,35 @@
  1278. char *p = result;
  1279. char *q = result + sizeof(result); /* 1 past result */
  1280. - slprintf(p, q - p, "MPPE ");
  1281. - p += 5;
  1282. - if (opt->mppe & MPPE_OPT_128) {
  1283. - slprintf(p, q - p, "128-bit ");
  1284. - p += 8;
  1285. - }
  1286. - if (opt->mppe & MPPE_OPT_40) {
  1287. - slprintf(p, q - p, "40-bit ");
  1288. - p += 7;
  1289. - }
  1290. - if (opt->mppe & MPPE_OPT_STATEFUL)
  1291. - slprintf(p, q - p, "stateful");
  1292. - else
  1293. - slprintf(p, q - p, "stateless");
  1294. -
  1295. + if (opt->mppe) {
  1296. + if (opt->mppc) {
  1297. + slprintf(p, q - p, "MPPC/MPPE ");
  1298. + p += 10;
  1299. + } else {
  1300. + slprintf(p, q - p, "MPPE ");
  1301. + p += 5;
  1302. + }
  1303. + if (opt->mppe_128) {
  1304. + slprintf(p, q - p, "128-bit ");
  1305. + p += 8;
  1306. + } else if (opt->mppe_56) {
  1307. + slprintf(p, q - p, "56-bit ");
  1308. + p += 7;
  1309. + } else if (opt->mppe_40) {
  1310. + slprintf(p, q - p, "40-bit ");
  1311. + p += 7;
  1312. + }
  1313. + if (opt->mppe_stateless)
  1314. + slprintf(p, q - p, "stateless");
  1315. + else
  1316. + slprintf(p, q - p, "stateful");
  1317. + } else if (opt->mppc)
  1318. + slprintf(p, q - p, "MPPC");
  1319. break;
  1320. }
  1321. -#endif
  1322. +#endif /* MPPE */
  1323. + case CI_LZS:
  1324. + return "Stac LZS";
  1325. case CI_DEFLATE:
  1326. case CI_DEFLATE_DRAFT:
  1327. if (opt2 != NULL && opt2->deflate_size != opt->deflate_size)
  1328. @@ -1444,12 +1940,12 @@
  1329. } else if (ANY_COMPRESS(*ho))
  1330. notice("%s transmit compression enabled", method_name(ho, NULL));
  1331. #ifdef MPPE
  1332. - if (go->mppe) {
  1333. + if (go->mppe || go->mppc) {
  1334. BZERO(mppe_recv_key, MPPE_MAX_KEY_LEN);
  1335. BZERO(mppe_send_key, MPPE_MAX_KEY_LEN);
  1336. continue_networks(f->unit); /* Bring up IP et al */
  1337. }
  1338. -#endif
  1339. +#endif /* MPPE */
  1340. }
  1341. /*
  1342. @@ -1472,7 +1968,7 @@
  1343. lcp_close(f->unit, "MPPE disabled");
  1344. }
  1345. }
  1346. -#endif
  1347. +#endif /* MPPE */
  1348. }
  1349. /*
  1350. @@ -1532,24 +2028,28 @@
  1351. #ifdef MPPE
  1352. case CI_MPPE:
  1353. if (optlen >= CILEN_MPPE) {
  1354. - u_char mppe_opts;
  1355. -
  1356. - MPPE_CI_TO_OPTS(&p[2], mppe_opts);
  1357. - printer(arg, "mppe %s %s %s %s %s %s%s",
  1358. - (p[2] & MPPE_H_BIT)? "+H": "-H",
  1359. - (p[5] & MPPE_M_BIT)? "+M": "-M",
  1360. - (p[5] & MPPE_S_BIT)? "+S": "-S",
  1361. - (p[5] & MPPE_L_BIT)? "+L": "-L",
  1362. + printer(arg, "mppe %s %s %s %s %s %s",
  1363. + (p[2] & MPPE_STATELESS)? "+H": "-H",
  1364. + (p[5] & MPPE_56BIT)? "+M": "-M",
  1365. + (p[5] & MPPE_128BIT)? "+S": "-S",
  1366. + (p[5] & MPPE_40BIT)? "+L": "-L",
  1367. (p[5] & MPPE_D_BIT)? "+D": "-D",
  1368. - (p[5] & MPPE_C_BIT)? "+C": "-C",
  1369. - (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": "");
  1370. - if (mppe_opts & MPPE_OPT_UNKNOWN)
  1371. + (p[5] & MPPE_MPPC)? "+C": "-C");
  1372. + if ((p[5] & ~(MPPE_56BIT | MPPE_128BIT | MPPE_40BIT |
  1373. + MPPE_D_BIT | MPPE_MPPC)) ||
  1374. + (p[2] & ~MPPE_STATELESS))
  1375. printer(arg, " (%.2x %.2x %.2x %.2x)",
  1376. p[2], p[3], p[4], p[5]);
  1377. p += CILEN_MPPE;
  1378. }
  1379. break;
  1380. -#endif
  1381. +#endif /* MPPE */
  1382. + case CI_LZS:
  1383. + if (optlen >= CILEN_LZS) {
  1384. + printer(arg, "lzs %.2x %.2x %.2x", p[2], p[3], p[4]);
  1385. + p += CILEN_LZS;
  1386. + }
  1387. + break;
  1388. case CI_DEFLATE:
  1389. case CI_DEFLATE_DRAFT:
  1390. if (optlen >= CILEN_DEFLATE) {
  1391. @@ -1635,6 +2135,7 @@
  1392. error("Lost compression sync: disabling compression");
  1393. ccp_close(unit, "Lost compression sync");
  1394. #ifdef MPPE
  1395. + /* My module dosn't need this. J.D., 2003-07-06 */
  1396. /*
  1397. * If we were doing MPPE, we must also take the link down.
  1398. */
  1399. @@ -1642,9 +2143,18 @@
  1400. error("Too many MPPE errors, closing LCP");
  1401. lcp_close(unit, "Too many MPPE errors");
  1402. }
  1403. -#endif
  1404. +#endif /* MPPE */
  1405. } else {
  1406. /*
  1407. + * When LZS or MPPE/MPPC is negotiated we just send CCP_RESETREQ
  1408. + * and don't wait for CCP_RESETACK
  1409. + */
  1410. + if ((ccp_gotoptions[f->unit].method == CI_LZS) ||
  1411. + (ccp_gotoptions[f->unit].method == CI_MPPE)) {
  1412. + fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0);
  1413. + return;
  1414. + }
  1415. + /*
  1416. * Send a reset-request to reset the peer's compressor.
  1417. * We don't do that if we are still waiting for an
  1418. * acknowledgement to a previous reset-request.
  1419. @@ -1675,4 +2185,3 @@
  1420. } else
  1421. ccp_localstate[f->unit] &= ~RACK_PENDING;
  1422. }
  1423. -
  1424. diff -ruN ppp-2.4.3.orig/pppd/ccp.h ppp-2.4.3/pppd/ccp.h
  1425. --- ppp-2.4.3.orig/pppd/ccp.h 2004-11-04 11:02:26.000000000 +0100
  1426. +++ ppp-2.4.3/pppd/ccp.h 2004-11-21 13:54:09.000000000 +0100
  1427. @@ -37,9 +37,17 @@
  1428. bool predictor_2; /* do Predictor-2? */
  1429. bool deflate_correct; /* use correct code for deflate? */
  1430. bool deflate_draft; /* use draft RFC code for deflate? */
  1431. + bool lzs; /* do Stac LZS? */
  1432. + bool mppc; /* do MPPC? */
  1433. bool mppe; /* do MPPE? */
  1434. + bool mppe_40; /* allow 40 bit encryption? */
  1435. + bool mppe_56; /* allow 56 bit encryption? */
  1436. + bool mppe_128; /* allow 128 bit encryption? */
  1437. + bool mppe_stateless; /* allow stateless encryption */
  1438. u_short bsd_bits; /* # bits/code for BSD Compress */
  1439. u_short deflate_size; /* lg(window size) for Deflate */
  1440. + u_short lzs_mode; /* LZS check mode */
  1441. + u_short lzs_hists; /* number of LZS histories */
  1442. short method; /* code for chosen compression method */
  1443. } ccp_options;
  1444. diff -ruN ppp-2.4.3.orig/pppd/chap_ms.c ppp-2.4.3/pppd/chap_ms.c
  1445. --- ppp-2.4.3.orig/pppd/chap_ms.c 2004-11-12 10:57:43.000000000 +0100
  1446. +++ ppp-2.4.3/pppd/chap_ms.c 2004-11-21 13:54:09.000000000 +0100
  1447. @@ -895,13 +895,17 @@
  1448. /*
  1449. * Disable undesirable encryption types. Note that we don't ENABLE
  1450. * any encryption types, to avoid overriding manual configuration.
  1451. + *
  1452. + * It seems that 56 bit keys are unsupported in MS-RADIUS (see RFC 2548)
  1453. */
  1454. switch(types) {
  1455. case MPPE_ENC_TYPES_RC4_40:
  1456. - ccp_wantoptions[0].mppe &= ~MPPE_OPT_128; /* disable 128-bit */
  1457. + ccp_wantoptions[0].mppe_128 = 0; /* disable 128-bit */
  1458. + ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
  1459. break;
  1460. case MPPE_ENC_TYPES_RC4_128:
  1461. - ccp_wantoptions[0].mppe &= ~MPPE_OPT_40; /* disable 40-bit */
  1462. + ccp_wantoptions[0].mppe_56 = 0; /* disable 56-bit */
  1463. + ccp_wantoptions[0].mppe_40 = 0; /* disable 40-bit */
  1464. break;
  1465. default:
  1466. break;
  1467. diff -ruN ppp-2.4.3.orig/pppd/pppd.8 ppp-2.4.3/pppd/pppd.8
  1468. --- ppp-2.4.3.orig/pppd/pppd.8 2004-11-13 13:22:49.000000000 +0100
  1469. +++ ppp-2.4.3/pppd/pppd.8 2004-11-21 14:24:47.000000000 +0100
  1470. @@ -622,9 +622,29 @@
  1471. Enables the use of PPP multilink; this is an alias for the `multilink'
  1472. option. This option is currently only available under Linux.
  1473. .TP
  1474. -.B mppe\-stateful
  1475. -Allow MPPE to use stateful mode. Stateless mode is still attempted first.
  1476. -The default is to disallow stateful mode.
  1477. +.B mppc
  1478. +Enables MPPC (Microsoft Point to Point Compression). This is the default.
  1479. +.TP
  1480. +.B mppe \fIsubopt1[,subopt2[,subopt3[..]]]
  1481. +Modify MPPE (Microsoft Point to Point Encryption) parameters. In order
  1482. +for MPPE to successfully come up, you must have authenticated with either
  1483. +MS-CHAP or MS-CHAPv2. By default MPPE is optional, it means that pppd will
  1484. +not propose MPPE to the peer, but will negotiate MPPE if peer wants that.
  1485. +You can change this using \fIrequired\fR suboption.
  1486. +This option is presently only supported under Linux, and only if your
  1487. +kernel has been configured to include MPPE support.
  1488. +.IP
  1489. +MPPE suboptions:
  1490. +.br
  1491. +\fIrequired\fR - require MPPE; disconnect if peer doesn't support it,
  1492. +.br
  1493. +\fIstateless\fR - try to negotiate stateless mode; default is stateful,
  1494. +.br
  1495. +\fIno40\fR - disable 40 bit keys,
  1496. +.br
  1497. +\fIno56\fR - disable 56 bit keys,
  1498. +.br
  1499. +\fIno128\fR - disable 128 bit keys
  1500. .TP
  1501. .B mpshortseq
  1502. Enables the use of short (12-bit) sequence numbers in multilink
  1503. @@ -757,17 +777,11 @@
  1504. Disables the use of PPP multilink. This option is currently only
  1505. available under Linux.
  1506. .TP
  1507. -.B nomppe
  1508. -Disables MPPE (Microsoft Point to Point Encryption). This is the default.
  1509. -.TP
  1510. -.B nomppe\-40
  1511. -Disable 40-bit encryption with MPPE.
  1512. +.B nomppc
  1513. +Disables MPPC (Microsoft Point to Point Compression).
  1514. .TP
  1515. -.B nomppe\-128
  1516. -Disable 128-bit encryption with MPPE.
  1517. -.TP
  1518. -.B nomppe\-stateful
  1519. -Disable MPPE stateful mode. This is the default.
  1520. +.B nomppe
  1521. +Disables MPPE (Microsoft Point to Point Encryption).
  1522. .TP
  1523. .B nompshortseq
  1524. Disables the use of short (12-bit) sequence numbers in the PPP
  1525. @@ -948,19 +962,6 @@
  1526. Require the peer to authenticate itself using CHAP [Challenge
  1527. Handshake Authentication Protocol] authentication.
  1528. .TP
  1529. -.B require\-mppe
  1530. -Require the use of MPPE (Microsoft Point to Point Encryption). This
  1531. -option disables all other compression types. This option enables
  1532. -both 40-bit and 128-bit encryption. In order for MPPE to successfully
  1533. -come up, you must have authenticated with either MS\-CHAP or MS\-CHAPv2.
  1534. -This option is presently only supported under Linux, and only if your
  1535. -kernel has been configured to include MPPE support.
  1536. -.TP
  1537. -.B require\-mppe\-40
  1538. -Require the use of MPPE, with 40-bit encryption.
  1539. -.TP
  1540. -.B require\-mppe\-128
  1541. -Require the use of MPPE, with 128-bit encryption.
  1542. .TP
  1543. .B require\-mschap
  1544. Require the peer to authenticate itself using MS\-CHAP [Microsoft Challenge