201-mppe_mppc_1.1.patch 46 KB

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