cd51e37908a750e829a2fcbcf78994afb83365a4
3 char const *cvs_id_ppp
= "$Id: ppp.c,v 1.12 2004/08/13 00:02:50 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
99 // set up RADIUS request
100 u16 r
= session
[s
].radius
;
102 // Run PRE_AUTH plugins
103 struct param_pre_auth packet
= { &tunnel
[t
], &session
[s
], strdup(user
), strdup(pass
), PPPPAP
, 1 };
104 run_plugins(PLUGIN_PRE_AUTH
, &packet
);
105 if (!packet
.continue_auth
)
107 log(3, 0, s
, t
, "A plugin rejected PRE_AUTH\n");
108 if (packet
.username
) free(packet
.username
);
109 if (packet
.password
) free(packet
.password
);
113 strncpy(session
[s
].user
, packet
.username
, sizeof(session
[s
].user
) - 1);
114 strncpy(radius
[r
].pass
, packet
.password
, sizeof(radius
[r
].pass
) - 1);
116 free(packet
.username
);
117 free(packet
.password
);
120 log(3, 0, s
, t
, "Sending login for %s/%s to radius\n", user
, pass
);
121 radiussend(r
, RADIUSAUTH
);
125 // Process CHAP messages
126 void processchap(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
132 CSTAT(call_processchap
);
134 log_hex(5, "CHAP", p
, l
);
135 r
= session
[s
].radius
;
138 log(1, 0, s
, t
, "Unexpected CHAP message\n");
140 // FIXME: Need to drop the session here.
142 STAT(tunnel_rx_errors
);
147 log(1, 0, s
, t
, "Unexpected CHAP response code %d\n", *p
);
148 STAT(tunnel_rx_errors
);
151 if (p
[1] != radius
[r
].id
)
153 log(1, 0, s
, t
, "Wrong CHAP response ID %d (should be %d) (%d)\n", p
[1], radius
[r
].id
, r
);
154 STAT(tunnel_rx_errors
);
157 len
= ntohs(*(u16
*) (p
+ 2));
160 log(1, 0, s
, t
, "Bad CHAP length %d\n", len
);
161 STAT(tunnel_rx_errors
);
166 log(1, 0, s
, t
, "Bad CHAP response length %d\n", p
[4]);
167 STAT(tunnel_rx_errors
);
170 if (len
- 21 >= sizeof(session
[s
].user
))
172 log(1, 0, s
, t
, "CHAP user too long %d\n", len
- 21);
173 STAT(tunnel_rx_errors
);
177 // Run PRE_AUTH plugins
179 struct param_pre_auth packet
= { &tunnel
[t
], &session
[s
], NULL
, NULL
, PPPCHAP
, 1 };
181 packet
.username
= calloc(len
-20, 1);
182 packet
.password
= calloc(16, 1);
183 memcpy(packet
.username
, p
+ 21, len
- 21);
184 memcpy(packet
.password
, p
+ 5, 16);
186 run_plugins(PLUGIN_PRE_AUTH
, &packet
);
187 if (!packet
.continue_auth
)
189 log(3, 0, s
, t
, "A plugin rejected PRE_AUTH\n");
190 if (packet
.username
) free(packet
.username
);
191 if (packet
.password
) free(packet
.password
);
195 strncpy(session
[s
].user
, packet
.username
, sizeof(session
[s
].user
) - 1);
196 memcpy(radius
[r
].pass
, packet
.password
, 16);
198 free(packet
.username
);
199 free(packet
.password
);
203 log(3, 0, s
, t
, "CHAP login %s\n", session
[s
].user
);
204 radiussend(r
, RADIUSAUTH
);
207 char *ppp_lcp_types
[] = {
223 void dumplcp(u8
*p
, int l
)
225 signed int x
= l
- 4;
228 log_hex(5, "PPP LCP Packet", p
, l
);
229 log(4, 0, 0, 0, "PPP LCP Packet type %d (%s len %d)\n", *p
, ppp_lcp_types
[(int)*p
], ntohs( ((u16
*) p
)[1]) );
230 log(4, 0, 0, 0, "Length: %d\n", l
);
231 if (*p
!= ConfigReq
&& *p
!= ConfigRej
&& *p
!= ConfigAck
)
240 log(4, 0, 0, 0, " Option length is %d...\n", length
);
245 log(4, 0, 0, 0, " Option type is 0...\n");
252 case 1: // Maximum-Receive-Unit
254 log(4, 0, 0, 0, " %s %d\n", lcp_types
[type
], ntohs(*(u16
*)(o
+ 2)));
256 log(4, 0, 0, 0, " %s odd length %d\n", lcp_types
[type
], length
);
258 case 3: // Authentication-Protocol
262 int proto
= ntohs(*(u16
*)(o
+ 2));
263 log(4, 0, 0, 0, " %s 0x%x (%s)\n", lcp_types
[type
], proto
,
264 proto
== 0xC223 ? "CHAP" :
265 proto
== 0xC023 ? "PAP" : "UNKNOWN");
268 log(4, 0, 0, 0, " %s odd length %d\n", lcp_types
[type
], length
);
271 case 4: // Quality-Protocol
273 u32 qp
= ntohl(*(u32
*)(o
+ 2));
274 log(4, 0, 0, 0, " %s %x\n", lcp_types
[type
], qp
);
277 case 5: // Magic-Number
281 u32 magicno
= ntohl(*(u32
*)(o
+ 2));
282 log(4, 0, 0, 0, " %s %x\n", lcp_types
[type
], magicno
);
285 log(4, 0, 0, 0, " %s odd length %d\n", lcp_types
[type
], length
);
288 case 7: // Protocol-Field-Compression
290 log(4, 0, 0, 0, " %s\n", lcp_types
[type
]);
293 case 8: // Address-And-Control-Field-Compression
295 log(4, 0, 0, 0, " %s\n", lcp_types
[type
]);
299 log(2, 0, 0, 0, " Unknown PPP LCP Option type %d\n", type
);
307 // Process LCP messages
308 void processlcp(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
315 CSTAT(call_processlcp
);
317 log_hex(5, "LCP", p
, l
);
320 log(1, session
[s
].ip
, s
, t
, "Short LCP %d bytes\n", l
);
321 STAT(tunnel_rx_errors
);
326 log(3, session
[s
].ip
, s
, t
, "LCP: Discarding ConfigAck\n");
327 session
[s
].flags
|= SESSIONLCPACK
;
329 else if (*p
== ConfigReq
)
331 signed int x
= l
- 4;
334 log(3, session
[s
].ip
, s
, t
, "LCP: ConfigReq (%d bytes)...\n", l
);
341 if (length
== 0 || type
== 0) break;
344 case 1: // Maximum-Receive-Unit
345 session
[s
].mru
= ntohs(*(u16
*)(o
+ 2));
348 log_hex(2, "PPP LCP Packet", p
, l
);
349 log(2, 0, 0, 0, "PPP LCP Packet type %d (%s len %d)\n", *p
, ppp_lcp_types
[(int)*p
], ntohs( ((u16
*) p
)[1]) );
351 case 3: // Authentication-Protocol
353 int proto
= ntohs(*(u16
*)(o
+ 2));
356 log(2, session
[s
].ip
, s
, t
, " Remote end is trying to do CHAP. Rejecting it.\n");
360 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
362 log(2, session
[s
].ip
, s
, t
, " Failed to send packet.\n");
367 memcpy(q
, o
, length
);
368 *(u16
*)(q
+= 2) = htons(0xC023); // NAK -> Use PAP instead
373 case 5: // Magic-Number
375 magicno
= ntohl(*(u32
*)(o
+ 2));
378 case 4: // Quality-Protocol
379 case 7: // Protocol-Field-Compression
380 case 8: // Address-And-Control-Field-Compression
382 case 13: // CallBack option for LCP extention of win2000/routers L2TP client
386 // Reject LCP CallBack
387 log(2, session
[s
].ip
, s
, t
, " PPP LCP Option type %d, len=%d\n", type
, length
);
388 memcpy(p
+ 4, o
, length
);
389 *(u16
*)(p
+ 2) = htons(length
+ 4);
391 q
= makeppp(b
,sizeof(b
), p
, length
+ 4, t
, s
, PPPLCP
);
392 tunnelsend(b
, 12 + length
+ 4, t
);
397 // Reject Unknown LCP Option to stop to send it again
398 log(2, session
[s
].ip
, s
, t
, " Unknown PPP LCP Option type %d\n", type
);
399 memcpy(p
+ 4, o
, length
);
400 *(u16
*)(p
+ 2) = htons(length
+ 4);
402 q
= makeppp(b
,sizeof(b
), p
, length
+ 4, t
, s
, PPPLCP
);
403 tunnelsend(b
, 12 + length
+ 4, t
);
412 // Send back a ConfigAck
413 log(3, session
[s
].ip
, s
, t
, "ConfigReq accepted, sending as Ack\n");
414 // for win2k L2TP clientis and LCP renegotiation of alive session
415 if (magicno
|| l
== 4) initlcp(t
, s
);
416 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
419 log(3, session
[s
].ip
, s
, t
, " failed to create packet.\n");
423 tunnelsend(b
, l
+ (q
- b
), t
);
427 // Already built a ConfigNak... send it
428 log(3, session
[s
].ip
, s
, t
, "Sending ConfigNak\n");
429 tunnelsend(b
, l
+ (q
- b
), t
);
432 if (!(session
[s
].flags
& SESSIONLCPACK
))
435 else if (*p
== ConfigNak
)
437 log(1, session
[s
].ip
, s
, t
, "Remote end sent a ConfigNak. Ignoring\n");
441 else if (*p
== TerminateReq
)
443 *p
= TerminateAck
; // close
444 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
446 log(3, session
[s
].ip
, s
, t
, "Failed to create PPP packet in processlcp.\n");
449 log(3, session
[s
].ip
, s
, t
, "LCP: Received TerminateReq. Sending TerminateAck\n");
450 sessionshutdown(s
, "Remote end closed connection.");
451 tunnelsend(b
, l
+ (q
- b
), t
); // send it
453 else if (*p
== TerminateAck
)
455 sessionshutdown(s
, "Connection closed.");
457 else if (*p
== EchoReq
)
459 *p
= EchoReply
; // reply
460 *(u32
*) (p
+ 4) = htonl(session
[s
].magic
); // our magic number
461 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
463 log(3, session
[s
].ip
, s
, t
, " failed to send EchoReply.\n");
466 log(5, session
[s
].ip
, s
, t
, "LCP: Received EchoReq. Sending EchoReply\n");
467 tunnelsend(b
, l
+ (q
- b
), t
); // send it
469 else if (*p
== EchoReply
)
471 // Ignore it, last_packet time is set earlier than this.
473 else if (*p
== IdentRequest
)
478 log(1, 0, s
, t
, "Truncated Ident Packet (length=%d) to 1400 bytes\n", l
);
481 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
484 log(3, session
[s
].ip
, s
, t
, "Failed to create IdentRej.\n");
487 log_hex(5, "LCPIdentRej", q
, l
+ 4);
488 tunnelsend(b
, 12 + 4 + l
, t
);
492 log(1, session
[s
].ip
, s
, t
, "Unexpected LCP code %d\n", *p
);
493 STAT(tunnel_rx_errors
);
498 // Process IPCP messages
499 void processipcp(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
502 CSTAT(call_processipcp
);
504 log_hex(5, "IPCP", p
, l
);
507 log(1, 0, s
, t
, "Short IPCP %d bytes\n", l
);
508 STAT(tunnel_rx_errors
);
513 // happy with our IPCP
514 u16 r
= session
[s
].radius
;
515 if ((!r
|| radius
[r
].state
== RADIUSIPCP
) && !session
[s
].walled_garden
) {
519 radiussend(r
, RADIUSSTART
); // send radius start, having got IPCP at last
521 session
[s
].flags
|= SF_IPCP_ACKED
;
523 log(3, session
[s
].ip
, s
, t
, "IPCP Acked, session is now active\n");
528 log(1, 0, s
, t
, "Unexpected IPCP code %d\n", *p
);
529 STAT(tunnel_rx_errors
);
532 log(4, session
[s
].ip
, s
, t
, "IPCP ConfigReq received\n");
533 if (ntohs(*(u16
*) (p
+ 2)) > l
)
535 log(1, 0, s
, t
, "Length mismatch IPCP %d/%d\n", ntohs(*(u16
*) (p
+ 2)), l
);
536 STAT(tunnel_rx_errors
);
541 log(3, 0, s
, t
, "Waiting on radius reply\n");
542 return; // have to wait on RADIUS reply
544 // form a config reply quoting the IP in the session
550 l
= ntohs(*(u16
*) (p
+ 2)); // We must use length from IPCP len field
553 while (q
< i
&& q
[1])
555 if (*q
!= 0x81 && *q
!= 0x83 && *q
!= 3)
564 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPIPCP
)))
566 log(2, 0, s
, t
, "Failed to send IPCP ConfigRej\n");
571 while (p
< i
&& p
[1])
573 if (*p
!= 0x81 && *p
!= 0x83 && *p
!= 3)
575 log(2, 0, s
, t
, "IPCP reject %d\n", *p
);
576 memcpy(q
+ n
, p
, p
[1]);
581 *(u16
*) (q
+ 2) = htons(n
);
582 log(4, session
[s
].ip
, s
, t
, "Sending ConfigRej\n");
583 tunnelsend(b
, n
+ (q
- b
), t
); // send it
587 log(4, session
[s
].ip
, s
, t
, "Sending ConfigAck\n");
589 if ((i
= findppp(p
, 0x81))) // Primary DNS address
591 if (*(u32
*) (i
+ 2) != htonl(session
[s
].dns1
))
593 *(u32
*) (i
+ 2) = htonl(session
[s
].dns1
);
595 log(5, session
[s
].ip
, s
, t
, " DNS1 = %s\n", inet_toa(session
[s
].dns1
));
598 if ((i
= findppp(p
, 0x83))) // Secondary DNS address (TBA, is it)
600 if (*(u32
*) (i
+ 2) != htonl(session
[s
].dns2
))
602 *(u32
*) (i
+ 2) = htonl(session
[s
].dns2
);
604 log(5, session
[s
].ip
, s
, t
, " DNS2 = %s\n", inet_toa(session
[s
].dns1
));
607 i
= findppp(p
, 3); // IP address
610 log(1, 0, s
, t
, "No IP in IPCP request\n");
611 STAT(tunnel_rx_errors
);
614 if (*(u32
*) (i
+ 2) != htonl(session
[s
].ip
))
616 *(u32
*) (i
+ 2) = htonl(session
[s
].ip
);
618 log(4, session
[s
].ip
, s
, t
, " No, a ConfigNak, client is requesting IP - sending %s\n",
619 inet_toa(htonl(session
[s
].ip
)));
621 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPIPCP
)))
623 log(2, 0, s
, t
, " Failed to send IPCP packet.\n");
626 tunnelsend(b
, l
+ (q
- b
), t
); // send it
631 // process IP packet received
633 // This MUST be called with at least 4 byte behind 'p'.
634 // (i.e. this routine writes to p[-4]).
635 void processipin(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
640 CSTAT(call_processipin
);
642 log_hex(5, "IP", p
, l
);
644 ip
= ntohl(*(u32
*)(p
+ 12));
648 log(1, ip
, s
, t
, "IP packet too long %d\n", l
);
649 STAT(tunnel_rx_errors
);
653 // no spoof (do sessionbyip to handled statically routed subnets)
654 if (ip
!= session
[s
].ip
&& sessionbyip(htonl(ip
)) != s
)
656 log(5, ip
, s
, t
, "Dropping packet with spoofed IP %s\n", inet_toa(htonl(ip
)));
660 // Add on the tun header
662 *(u32
*)p
= htonl(0x00000800);
665 if (session
[s
].tbf_in
&& !config
->cluster_iam_master
) { // Are we throttled and a slave?
666 master_throttle_packet(session
[s
].tbf_in
, p
, l
); // Pass it to the master for handling.
670 session
[s
].cin
+= l
- 4;
671 session
[s
].total_cin
+= l
- 4;
672 sess_count
[s
].cin
+= l
- 4;
677 if (session
[s
].snoop_ip
&& session
[s
].snoop_port
)
679 // Snooping this session, send it to ASIO
680 snoop_send_packet(p
, l
, session
[s
].snoop_ip
, session
[s
].snoop_port
);
682 STAT(tun_tx_packets
);
683 INC_STAT(tun_tx_bytes
, l
);
685 if (session
[s
].tbf_in
&& config
->cluster_iam_master
) { // Are we throttled and a master?? actually handle the throttled packets.
686 tbf_queue_packet(session
[s
].tbf_in
, p
, l
);
691 if (tun_write(p
, l
) < 0)
694 log(0, 0, s
, t
, "Error writing %d bytes to TUN device: %s (tunfd=%d, p=%p)\n",
695 l
, strerror(errno
), tunfd
, p
);
701 // Helper routine for the TBF filters.
702 // Used to send queued data in from the user.
704 void send_ipin(sessionidt s
, u8
*buf
, int len
)
706 log_hex(5, "IP in throttled", buf
, len
);
707 if (write(tunfd
, buf
, len
) < 0)
710 log(0, 0, 0, 0, "Error writing %d bytes to TUN device: %s (tunfd=%d, p=%p)\n",
711 len
, strerror(errno
), tunfd
, buf
);
714 // Increment packet counters
715 session
[s
].cin
+= len
- 4;
716 session
[s
].total_cin
+= len
- 4;
717 sess_count
[s
].cin
+= len
- 4;
724 // Process LCP messages
725 void processccp(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
728 CSTAT(call_processccp
);
730 log_hex(5, "CCP", p
, l
);
731 if (l
< 2 || (*p
!= ConfigReq
&& *p
!= TerminateReq
))
733 log(1, 0, s
, t
, "Unexpecetd CCP request code %d\n", *p
);
734 STAT(tunnel_rx_errors
);
745 *p
= ConfigAck
; // accept no compression
749 *p
= ConfigRej
; // reject
754 *p
= TerminateAck
; // close
755 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPCCP
)))
757 log(1,0,0,0, "Failed to send CCP packet.\n");
760 tunnelsend(b
, l
+ (q
- b
), t
); // send it
764 // send a CHAP PP packet
765 void sendchap(tunnelidt t
, sessionidt s
)
768 u16 r
= session
[s
].radius
;
771 CSTAT(call_sendchap
);
775 log(1, 0, s
, t
, "No RADIUS to send challenge\n");
776 STAT(tunnel_tx_errors
);
779 log(1, 0, s
, t
, "Send CHAP challenge\n");
783 for (n
= 0; n
< 15; n
++)
784 radius
[r
].auth
[n
] = rand();
786 radius
[r
].chap
= 1; // CHAP not PAP
788 if (radius
[r
].state
!= RADIUSCHAP
)
790 radius
[r
].state
= RADIUSCHAP
;
791 radius
[r
].retry
= backoff(radius
[r
].try++);
792 if (radius
[r
].try > 5)
794 sessionshutdown(s
, "Timeout CHAP");
795 STAT(tunnel_tx_errors
);
798 q
= makeppp(b
, sizeof(b
), 0, 0, t
, s
, PPPCHAP
);
800 log(1, 0, s
, t
, "failed to send CHAP challenge.\n");
804 q
[1] = radius
[r
].id
; // ID
806 memcpy(q
+ 5, radius
[r
].auth
, 16); // challenge
807 strcpy(q
+ 21, hostname
); // our name
808 *(u16
*) (q
+ 2) = htons(strlen(hostname
) + 21); // length
809 tunnelsend(b
, strlen(hostname
) + 21 + (q
- b
), t
); // send it
812 // fill in a L2TP message with a PPP frame,
813 // copies existing PPP message and changes magic number if seen
814 // returns start of PPP frame
815 u8
*makeppp(u8
* b
, int size
, u8
* p
, int l
, tunnelidt t
, sessionidt s
, u16 mtype
)
819 return NULL
; // Need more space than this!!
821 *(u16
*) (b
+ 0) = htons(0x0002); // L2TP with no options
822 *(u16
*) (b
+ 2) = htons(tunnel
[t
].far
); // tunnel
823 *(u16
*) (b
+ 4) = htons(session
[s
].far
); // session
825 if (mtype
&& !(session
[s
].l2tp_flags
& SESSIONACFC
))
827 *(u16
*) b
= htons(0xFF03); // HDLC header
830 if (mtype
< 0x100 && session
[s
].l2tp_flags
& SESSIONPFC
)
834 *(u16
*) b
= htons(mtype
);
839 log(3,0,0,0, "Would have overflowed the buffer in makeppp: size %d, len %d.\n", size
, l
);
840 return NULL
; // Run out of room to hold the packet!
847 // find a PPP option, returns point to option, or 0 if not found
848 u8
*findppp(u8
* b
, u8 mtype
)
850 u16 l
= ntohs(*(u16
*) (b
+ 2));
857 if (l
< b
[1] || !b
[1])
867 // Send initial LCP ConfigReq
868 void initlcp(tunnelidt t
, sessionidt s
)
870 char b
[500] = {0}, *q
;
872 q
= makeppp(b
, sizeof(b
), NULL
, 0, t
, s
, PPPLCP
);
874 log(1, 0, s
, t
, "Failed to send LCP ConfigReq.\n");
877 log(4, 0, s
, t
, "Sending LCP ConfigReq for PAP\n");
879 *(u8
*)(q
+ 1) = (time_now
% 255) + 1; // ID
880 *(u16
*)(q
+ 2) = htons(14); // Length
883 *(u32
*)(q
+ 6) = htonl(session
[s
].magic
);
886 *(u16
*)(q
+ 12) = htons(0xC023); // PAP
887 tunnelsend(b
, 12 + 14, t
);
891 void sendccp(tunnelidt t
, sessionidt s
)
893 char *q
, b
[500] = {0};
895 q
= makeppp(b
, sizeof(b
), NULL
, 0, t
, s
, PPPCCP
);
897 *(u8
*)(q
+ 1) = (time_now
% 255) + 1; // ID
898 *(u16
*)(q
+ 2) = htons(4); // Length
899 log_hex(5, "PPPCCP", q
, 4);
900 tunnelsend(b
, (q
- b
) + 4 , t
);