88fafc14675eb2a3b1aeee29e31681bceb80f986
3 char const *cvs_id_ppp
= "$Id: ppp.c,v 1.11 2004/08/02 06:06:28 fred_nerk Exp $";
11 #include "constants.h"
17 extern tunnelt
*tunnel
;
18 extern sessiont
*session
;
19 extern radiust
*radius
;
21 extern char hostname
[];
23 extern time_t time_now
;
24 extern struct configt
*config
;
26 void sendccp(tunnelidt t
, sessionidt s
);
28 // Process PAP messages
29 void processpap(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
35 CSTAT(call_processpap
);
37 log_hex(5, "PAP", p
, l
);
40 log(1, 0, s
, t
, "Short PAP %u bytes\n", l
);
41 STAT(tunnel_rx_errors
);
46 log(1, 0, s
, t
, "Unexpected PAP code %d\n", *p
);
47 STAT(tunnel_rx_errors
);
50 if (ntohs(*(u16
*) (p
+ 2)) > l
)
52 log(1, 0, s
, t
, "Length mismatch PAP %d/%d\n", ntohs(*(u16
*) (p
+ 2)), l
);
53 STAT(tunnel_rx_errors
);
59 if (*b
&& *b
< sizeof(user
))
60 memcpy(user
, b
+ 1, *b
);
63 if (*b
&& *b
< sizeof(pass
))
64 memcpy(pass
, b
+ 1, *b
);
66 log(3, 0, s
, t
, "PAP login %s/%s\n", user
, pass
);
68 if (session
[s
].ip
|| !session
[s
].radius
)
70 // respond now, either no RADIUS available or already authenticated
73 u8
*p
= makeppp(b
, sizeof(b
), 0, 0, t
, s
, PPPPAP
);
74 if (!p
) { // Failed to make ppp header!
75 log(1,0,0,0, "Failed to make PPP header in process pap!\n");
81 *p
= 3; // cant authorise
83 *(u16
*) (p
+ 2) = htons(5); // length
84 p
[4] = 0; // no message
87 log(3, session
[s
].ip
, s
, t
, "%d Already an IP allocated: %s (%d)\n", getpid(), inet_toa(htonl(session
[s
].ip
)), session
[s
].ip_pool_index
);
88 session
[s
].flags
&= ~SF_IPCP_ACKED
;
92 log(1, 0, s
, t
, "No radius session available to authenticate session...\n");
94 log(3, 0, s
, t
, "Fallback response to PAP (%s)\n", (session
[s
].ip
) ? "ACK" : "NAK");
95 tunnelsend(b
, 5 + (p
- b
), t
); // send it
98 { // set up RADIUS request
99 u16 r
= session
[s
].radius
;
101 // Run PRE_AUTH plugins
102 struct param_pre_auth packet
= { &tunnel
[t
], &session
[s
], strdup(user
), strdup(pass
), PPPPAP
, 1 };
103 run_plugins(PLUGIN_PRE_AUTH
, &packet
);
104 if (!packet
.continue_auth
)
106 log(3, 0, s
, t
, "A plugin rejected PRE_AUTH\n");
107 if (packet
.username
) free(packet
.username
);
108 if (packet
.password
) free(packet
.password
);
112 strncpy(session
[s
].user
, packet
.username
, sizeof(session
[s
].user
) - 1);
113 strncpy(radius
[r
].pass
, packet
.password
, sizeof(radius
[r
].pass
) - 1);
115 free(packet
.username
);
116 free(packet
.password
);
119 log(3, 0, s
, t
, "Sending login for %s/%s to radius\n", user
, pass
);
120 radiussend(r
, RADIUSAUTH
);
124 // Process CHAP messages
125 void processchap(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
131 CSTAT(call_processchap
);
133 log_hex(5, "CHAP", p
, l
);
134 r
= session
[s
].radius
;
137 log(1, 0, s
, t
, "Unexpected CHAP message\n");
139 // FIXME: Need to drop the session here.
141 STAT(tunnel_rx_errors
);
146 log(1, 0, s
, t
, "Unexpected CHAP response code %d\n", *p
);
147 STAT(tunnel_rx_errors
);
150 if (p
[1] != radius
[r
].id
)
152 log(1, 0, s
, t
, "Wrong CHAP response ID %d (should be %d) (%d)\n", p
[1], radius
[r
].id
, r
);
153 STAT(tunnel_rx_errors
);
156 len
= ntohs(*(u16
*) (p
+ 2));
159 log(1, 0, s
, t
, "Bad CHAP length %d\n", len
);
160 STAT(tunnel_rx_errors
);
165 log(1, 0, s
, t
, "Bad CHAP response length %d\n", p
[4]);
166 STAT(tunnel_rx_errors
);
169 if (len
- 21 >= sizeof(session
[s
].user
))
171 log(1, 0, s
, t
, "CHAP user too long %d\n", len
- 21);
172 STAT(tunnel_rx_errors
);
176 // Run PRE_AUTH plugins
178 struct param_pre_auth packet
= { &tunnel
[t
], &session
[s
], NULL
, NULL
, PPPCHAP
, 1 };
180 packet
.username
= calloc(len
-20, 1);
181 packet
.password
= calloc(16, 1);
182 memcpy(packet
.username
, p
+ 21, len
- 21);
183 memcpy(packet
.password
, p
+ 5, 16);
185 run_plugins(PLUGIN_PRE_AUTH
, &packet
);
186 if (!packet
.continue_auth
)
188 log(3, 0, s
, t
, "A plugin rejected PRE_AUTH\n");
189 if (packet
.username
) free(packet
.username
);
190 if (packet
.password
) free(packet
.password
);
194 strncpy(session
[s
].user
, packet
.username
, sizeof(session
[s
].user
) - 1);
195 memcpy(radius
[r
].pass
, packet
.password
, 16);
197 free(packet
.username
);
198 free(packet
.password
);
202 log(3, 0, s
, t
, "CHAP login %s\n", session
[s
].user
);
203 radiussend(r
, RADIUSAUTH
);
206 char *ppp_lcp_types
[] = {
222 void dumplcp(u8
*p
, int l
)
224 signed int x
= l
- 4;
227 log_hex(5, "PPP LCP Packet", p
, l
);
228 log(4, 0, 0, 0, "PPP LCP Packet type %d (%s len %d)\n", *p
, ppp_lcp_types
[(int)*p
], ntohs( ((u16
*) p
)[1]) );
229 log(4, 0, 0, 0, "Length: %d\n", l
);
230 if (*p
!= ConfigReq
&& *p
!= ConfigRej
&& *p
!= ConfigAck
)
239 log(4, 0, 0, 0, " Option length is %d...\n", length
);
244 log(4, 0, 0, 0, " Option type is 0...\n");
251 case 1: // Maximum-Receive-Unit
253 log(4, 0, 0, 0, " %s %d\n", lcp_types
[type
], ntohs(*(u16
*)(o
+ 2)));
255 log(4, 0, 0, 0, " %s odd length %d\n", lcp_types
[type
], length
);
257 case 3: // Authentication-Protocol
261 int proto
= ntohs(*(u16
*)(o
+ 2));
262 log(4, 0, 0, 0, " %s 0x%x (%s)\n", lcp_types
[type
], proto
,
263 proto
== 0xC223 ? "CHAP" :
264 proto
== 0xC023 ? "PAP" : "UNKNOWN");
267 log(4, 0, 0, 0, " %s odd length %d\n", lcp_types
[type
], length
);
270 case 4: // Quality-Protocol
272 u32 qp
= ntohl(*(u32
*)(o
+ 2));
273 log(4, 0, 0, 0, " %s %x\n", lcp_types
[type
], qp
);
276 case 5: // Magic-Number
280 u32 magicno
= ntohl(*(u32
*)(o
+ 2));
281 log(4, 0, 0, 0, " %s %x\n", lcp_types
[type
], magicno
);
284 log(4, 0, 0, 0, " %s odd length %d\n", lcp_types
[type
], length
);
287 case 7: // Protocol-Field-Compression
289 log(4, 0, 0, 0, " %s\n", lcp_types
[type
]);
292 case 8: // Address-And-Control-Field-Compression
294 log(4, 0, 0, 0, " %s\n", lcp_types
[type
]);
298 log(2, 0, 0, 0, " Unknown PPP LCP Option type %d\n", type
);
306 // Process LCP messages
307 void processlcp(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
314 CSTAT(call_processlcp
);
316 log_hex(5, "LCP", p
, l
);
319 log(1, session
[s
].ip
, s
, t
, "Short LCP %d bytes\n", l
);
320 STAT(tunnel_rx_errors
);
325 log(3, session
[s
].ip
, s
, t
, "LCP: Discarding ConfigAck\n");
326 session
[s
].flags
|= SESSIONLCPACK
;
328 else if (*p
== ConfigReq
)
330 signed int x
= l
- 4;
333 log(3, session
[s
].ip
, s
, t
, "LCP: ConfigReq (%d bytes)...\n", l
);
340 if (length
== 0 || type
== 0) break;
343 case 1: // Maximum-Receive-Unit
344 session
[s
].mru
= ntohs(*(u16
*)(o
+ 2));
347 log_hex(2, "PPP LCP Packet", p
, l
);
348 log(2, 0, 0, 0, "PPP LCP Packet type %d (%s len %d)\n", *p
, ppp_lcp_types
[(int)*p
], ntohs( ((u16
*) p
)[1]) );
350 case 3: // Authentication-Protocol
352 int proto
= ntohs(*(u16
*)(o
+ 2));
355 log(2, session
[s
].ip
, s
, t
, " Remote end is trying to do CHAP. Rejecting it.\n");
359 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
361 log(2, session
[s
].ip
, s
, t
, " Failed to send packet.\n");
366 memcpy(q
, o
, length
);
367 *(u16
*)(q
+= 2) = htons(0xC023); // NAK -> Use PAP instead
372 case 5: // Magic-Number
374 magicno
= ntohl(*(u32
*)(o
+ 2));
377 case 4: // Quality-Protocol
378 case 7: // Protocol-Field-Compression
379 case 8: // Address-And-Control-Field-Compression
381 case 13: // CallBack option for LCP extention of win2000/routers L2TP client
385 // Reject LCP CallBack
386 log(2, session
[s
].ip
, s
, t
, " PPP LCP Option type %d, len=%d\n", type
, length
);
387 memcpy(p
+ 4, o
, length
);
388 *(u16
*)(p
+ 2) = htons(length
+ 4);
390 q
= makeppp(b
,sizeof(b
), p
, length
+ 4, t
, s
, PPPLCP
);
391 tunnelsend(b
, 12 + length
+ 4, t
);
396 // Reject Unknown LCP Option to stop to send it again
397 log(2, session
[s
].ip
, s
, t
, " Unknown PPP LCP Option type %d\n", type
);
398 memcpy(p
+ 4, o
, length
);
399 *(u16
*)(p
+ 2) = htons(length
+ 4);
401 q
= makeppp(b
,sizeof(b
), p
, length
+ 4, t
, s
, PPPLCP
);
402 tunnelsend(b
, 12 + length
+ 4, t
);
411 // Send back a ConfigAck
412 log(3, session
[s
].ip
, s
, t
, "ConfigReq accepted, sending as Ack\n");
413 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
415 log(3, session
[s
].ip
, s
, t
, " failed to create packet.\n");
419 tunnelsend(b
, l
+ (q
- b
), t
);
420 // For win2k L2TP clients, LCP should be initiated by the LNS
421 if (magicno
) initlcp(t
, s
);
425 // Already built a ConfigNak... send it
426 log(3, session
[s
].ip
, s
, t
, "Sending ConfigNak\n");
427 tunnelsend(b
, l
+ (q
- b
), t
);
430 if (!(session
[s
].flags
& SESSIONLCPACK
))
433 else if (*p
== ConfigNak
)
435 log(1, session
[s
].ip
, s
, t
, "Remote end sent a ConfigNak. Ignoring\n");
439 else if (*p
== TerminateReq
)
441 *p
= TerminateAck
; // close
442 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
444 log(3, session
[s
].ip
, s
, t
, "Failed to create PPP packet in processlcp.\n");
447 log(3, session
[s
].ip
, s
, t
, "LCP: Received TerminateReq. Sending TerminateAck\n");
448 sessionshutdown(s
, "Remote end closed connection.");
449 tunnelsend(b
, l
+ (q
- b
), t
); // send it
451 else if (*p
== TerminateAck
)
453 sessionshutdown(s
, "Connection closed.");
455 else if (*p
== EchoReq
)
457 *p
= EchoReply
; // reply
458 *(u32
*) (p
+ 4) = htonl(session
[s
].magic
); // our magic number
459 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
461 log(3, session
[s
].ip
, s
, t
, " failed to send EchoReply.\n");
464 log(5, session
[s
].ip
, s
, t
, "LCP: Received EchoReq. Sending EchoReply\n");
465 tunnelsend(b
, l
+ (q
- b
), t
); // send it
467 else if (*p
== EchoReply
)
469 // Ignore it, last_packet time is set earlier than this.
471 else if (*p
== IdentRequest
)
476 log(1, 0, s
, t
, "Truncated Ident Packet (length=%d) to 1400 bytes\n", l
);
479 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
482 log(3, session
[s
].ip
, s
, t
, "Failed to create IdentRej.\n");
485 log_hex(5, "LCPIdentRej", q
, l
+ 4);
486 tunnelsend(b
, 12 + 4 + l
, t
);
490 log(1, session
[s
].ip
, s
, t
, "Unexpected LCP code %d\n", *p
);
491 STAT(tunnel_rx_errors
);
496 // Process IPCP messages
497 void processipcp(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
500 CSTAT(call_processipcp
);
502 log_hex(5, "IPCP", p
, l
);
505 log(1, 0, s
, t
, "Short IPCP %d bytes\n", l
);
506 STAT(tunnel_rx_errors
);
511 // happy with our IPCP
512 u16 r
= session
[s
].radius
;
513 if ((!r
|| radius
[r
].state
== RADIUSIPCP
) && !session
[s
].walled_garden
) {
517 radiussend(r
, RADIUSSTART
); // send radius start, having got IPCP at last
519 session
[s
].flags
|= SF_IPCP_ACKED
;
521 log(3, session
[s
].ip
, s
, t
, "IPCP Acked, session is now active\n");
526 log(1, 0, s
, t
, "Unexpected IPCP code %d\n", *p
);
527 STAT(tunnel_rx_errors
);
530 log(4, session
[s
].ip
, s
, t
, "IPCP ConfigReq received\n");
531 if (ntohs(*(u16
*) (p
+ 2)) > l
)
533 log(1, 0, s
, t
, "Length mismatch IPCP %d/%d\n", ntohs(*(u16
*) (p
+ 2)), l
);
534 STAT(tunnel_rx_errors
);
539 log(3, 0, s
, t
, "Waiting on radius reply\n");
540 return ; // have to wait on RADIUS reply
542 // form a config reply quoting the IP in the session
548 l
= ntohs(*(u16
*) (p
+ 2)); // We must use length from IPCP len field
551 while (q
< i
&& q
[1])
553 if (*q
!= 0x81 && *q
!= 0x83 && *q
!= 3)
562 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPIPCP
)))
564 log(2, 0, s
, t
, "Failed to send IPCP ConfigRej\n");
569 while (p
< i
&& p
[1])
571 if (*p
!= 0x81 && *p
!= 0x83 && *p
!= 3)
573 log(2, 0, s
, t
, "IPCP reject %d\n", *p
);
574 memcpy(q
+ n
, p
, p
[1]);
579 *(u16
*) (q
+ 2) = htons(n
);
580 log(4, session
[s
].ip
, s
, t
, "Sending ConfigRej\n");
581 tunnelsend(b
, n
+ (q
- b
), t
); // send it
585 log(4, session
[s
].ip
, s
, t
, "Sending ConfigAck\n");
587 if ((i
= findppp(p
, 0x81))) // Primary DNS address
589 if (*(u32
*) (i
+ 2) != htonl(session
[s
].dns1
))
591 *(u32
*) (i
+ 2) = htonl(session
[s
].dns1
);
593 log(5, session
[s
].ip
, s
, t
, " DNS1 = %s\n", inet_toa(session
[s
].dns1
));
596 if ((i
= findppp(p
, 0x83))) // Secondary DNS address (TBA, is it)
598 if (*(u32
*) (i
+ 2) != htonl(session
[s
].dns2
))
600 *(u32
*) (i
+ 2) = htonl(session
[s
].dns2
);
602 log(5, session
[s
].ip
, s
, t
, " DNS2 = %s\n", inet_toa(session
[s
].dns1
));
605 i
= findppp(p
, 3); // IP address
608 log(1, 0, s
, t
, "No IP in IPCP request\n");
609 STAT(tunnel_rx_errors
);
612 if (*(u32
*) (i
+ 2) != htonl(session
[s
].ip
))
614 *(u32
*) (i
+ 2) = htonl(session
[s
].ip
);
616 log(4, session
[s
].ip
, s
, t
, " No, a ConfigNak, client is requesting IP - sending %s\n",
617 inet_toa(htonl(session
[s
].ip
)));
619 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPIPCP
)))
621 log(2, 0, s
, t
, " Failed to send IPCP packet.\n");
624 tunnelsend(b
, l
+ (q
- b
), t
); // send it
629 // process IP packet received
631 // This MUST be called with at least 4 byte behind 'p'.
632 // (i.e. this routine writes to p[-4]).
633 void processipin(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
638 CSTAT(call_processipin
);
640 log_hex(5, "IP", p
, l
);
642 ip
= ntohl(*(u32
*)(p
+ 12));
646 log(1, ip
, s
, t
, "IP packet too long %d\n", l
);
647 STAT(tunnel_rx_errors
);
651 // no spoof (do sessionbyip to handled statically routed subnets)
652 if (ip
!= session
[s
].ip
&& sessionbyip(htonl(ip
)) != s
)
654 log(5, ip
, s
, t
, "Dropping packet with spoofed IP %s\n", inet_toa(htonl(ip
)));
658 // Add on the tun header
660 *(u32
*)p
= htonl(0x00000800);
663 if (session
[s
].tbf_in
&& !config
->cluster_iam_master
) { // Are we throttled and a slave?
664 master_throttle_packet(session
[s
].tbf_in
, p
, l
); // Pass it to the master for handling.
668 session
[s
].cin
+= l
- 4;
669 session
[s
].total_cin
+= l
- 4;
670 sess_count
[s
].cin
+= l
- 4;
675 if (session
[s
].snoop_ip
&& session
[s
].snoop_port
)
677 // Snooping this session, send it to ASIO
678 snoop_send_packet(p
, l
, session
[s
].snoop_ip
, session
[s
].snoop_port
);
680 STAT(tun_tx_packets
);
681 INC_STAT(tun_tx_bytes
, l
);
683 if (session
[s
].tbf_in
&& config
->cluster_iam_master
) { // Are we throttled and a master?? actually handle the throttled packets.
684 tbf_queue_packet(session
[s
].tbf_in
, p
, l
);
689 if (tun_write(p
, l
) < 0)
692 log(0, 0, s
, t
, "Error writing %d bytes to TUN device: %s (tunfd=%d, p=%p)\n",
693 l
, strerror(errno
), tunfd
, p
);
699 // Helper routine for the TBF filters.
700 // Used to send queued data in from the user.
702 void send_ipin(sessionidt s
, u8
*buf
, int len
)
704 log_hex(5, "IP in throttled", buf
, len
);
705 if (write(tunfd
, buf
, len
) < 0)
708 log(0, 0, 0, 0, "Error writing %d bytes to TUN device: %s (tunfd=%d, p=%p)\n",
709 len
, strerror(errno
), tunfd
, buf
);
712 // Increment packet counters
713 session
[s
].cin
+= len
- 4;
714 session
[s
].total_cin
+= len
- 4;
715 sess_count
[s
].cin
+= len
- 4;
722 // Process LCP messages
723 void processccp(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
726 CSTAT(call_processccp
);
728 log_hex(5, "CCP", p
, l
);
729 if (l
< 2 || (*p
!= ConfigReq
&& *p
!= TerminateReq
))
731 log(1, 0, s
, t
, "Unexpecetd CCP request code %d\n", *p
);
732 STAT(tunnel_rx_errors
);
743 *p
= ConfigAck
; // accept no compression
747 *p
= ConfigRej
; // reject
752 *p
= TerminateAck
; // close
753 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPCCP
)))
755 log(1,0,0,0, "Failed to send CCP packet.\n");
758 tunnelsend(b
, l
+ (q
- b
), t
); // send it
762 // send a CHAP PP packet
763 void sendchap(tunnelidt t
, sessionidt s
)
766 u16 r
= session
[s
].radius
;
769 CSTAT(call_sendchap
);
773 log(1, 0, s
, t
, "No RADIUS to send challenge\n");
774 STAT(tunnel_tx_errors
);
777 log(1, 0, s
, t
, "Send CHAP challenge\n");
780 for (n
= 0; n
< 15; n
++)
781 radius
[r
].auth
[n
] = rand();
783 radius
[r
].chap
= 1; // CHAP not PAP
785 if (radius
[r
].state
!= RADIUSCHAP
)
787 radius
[r
].state
= RADIUSCHAP
;
788 radius
[r
].retry
= backoff(radius
[r
].try++);
789 if (radius
[r
].try > 5)
791 sessionshutdown(s
, "Timeout CHAP");
792 STAT(tunnel_tx_errors
);
795 q
= makeppp(b
, sizeof(b
), 0, 0, t
, s
, PPPCHAP
);
797 log(1, 0, s
, t
, "failed to send CHAP challenge.\n");
801 q
[1] = radius
[r
].id
; // ID
803 memcpy(q
+ 5, radius
[r
].auth
, 16); // challenge
804 strcpy(q
+ 21, hostname
); // our name
805 *(u16
*) (q
+ 2) = htons(strlen(hostname
) + 21); // length
806 tunnelsend(b
, strlen(hostname
) + 21 + (q
- b
), t
); // send it
809 // fill in a L2TP message with a PPP frame,
810 // copies existing PPP message and changes magic number if seen
811 // returns start of PPP frame
812 u8
*makeppp(u8
* b
, int size
, u8
* p
, int l
, tunnelidt t
, sessionidt s
, u16 mtype
)
816 return NULL
; // Need more space than this!!
818 *(u16
*) (b
+ 0) = htons(0x0002); // L2TP with no options
819 *(u16
*) (b
+ 2) = htons(tunnel
[t
].far
); // tunnel
820 *(u16
*) (b
+ 4) = htons(session
[s
].far
); // session
822 if (mtype
&& !(session
[s
].l2tp_flags
& SESSIONACFC
))
824 *(u16
*) b
= htons(0xFF03); // HDLC header
827 if (mtype
< 0x100 && session
[s
].l2tp_flags
& SESSIONPFC
)
831 *(u16
*) b
= htons(mtype
);
836 log(3,0,0,0, "Would have overflowed the buffer in makeppp: size %d, len %d.\n", size
, l
);
837 return NULL
; // Run out of room to hold the packet!
844 // find a PPP option, returns point to option, or 0 if not found
845 u8
*findppp(u8
* b
, u8 mtype
)
847 u16 l
= ntohs(*(u16
*) (b
+ 2));
854 if (l
< b
[1] || !b
[1])
864 // Send initial LCP ConfigReq
865 void initlcp(tunnelidt t
, sessionidt s
)
867 char b
[500] = {0}, *q
;
869 q
= makeppp(b
, sizeof(b
), NULL
, 0, t
, s
, PPPLCP
);
871 log(1, 0, s
, t
, "Failed to send LCP ConfigReq.\n");
874 log(4, 0, s
, t
, "Sending LCP ConfigReq for PAP\n");
876 *(u8
*)(q
+ 1) = (time_now
% 255) + 1; // ID
877 *(u16
*)(q
+ 2) = htons(8); // Length
880 *(u16
*)(q
+ 6) = htons(0xC023); // PAP
881 tunnelsend(b
, 12 + 8, t
);
885 void sendccp(tunnelidt t
, sessionidt s
)
887 char *q
, b
[500] = {0};
889 q
= makeppp(b
, sizeof(b
), NULL
, 0, t
, s
, PPPCCP
);
891 *(u8
*)(q
+ 1) = (time_now
% 255) + 1; // ID
892 *(u16
*)(q
+ 2) = htons(4); // Length
893 log_hex(5, "PPPCCP", q
, 4);
894 tunnelsend(b
, (q
- b
) + 4 , t
);