c2c3379057481ef40d95a2cf9d34ec57100a9026
3 char const *cvs_id_ppp
= "$Id: ppp.c,v 1.17 2004-10-29 04:01:53 bodea 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 l
= ntohs(*(u16
*)(p
+ 2));
332 signed int x
= l
- 4;
335 log(3, session
[s
].ip
, s
, t
, "LCP: ConfigReq (%d bytes)...\n", l
);
342 if (length
== 0 || type
== 0) break;
345 case 1: // Maximum-Receive-Unit
346 session
[s
].mru
= ntohs(*(u16
*)(o
+ 2));
349 log_hex(2, "PPP LCP Packet", p
, l
);
350 log(2, 0, 0, 0, "PPP LCP Packet type %d (%s len %d)\n", *p
, ppp_lcp_types
[(int)*p
], ntohs( ((u16
*) p
)[1]) );
352 case 3: // Authentication-Protocol
354 int proto
= ntohs(*(u16
*)(o
+ 2));
357 log(2, session
[s
].ip
, s
, t
, " Remote end is trying to do CHAP. Rejecting it.\n");
361 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
363 log(2, session
[s
].ip
, s
, t
, " Failed to send packet.\n");
368 memcpy(q
, o
, length
);
369 *(u16
*)(q
+= 2) = htons(0xC023); // NAK -> Use PAP instead
374 case 5: // Magic-Number
376 magicno
= ntohl(*(u32
*)(o
+ 2));
379 case 4: // Quality-Protocol
380 case 7: // Protocol-Field-Compression
381 case 8: // Address-And-Control-Field-Compression
383 case 13: // CallBack option for LCP extention of win2000/routers L2TP client
387 // Reject LCP CallBack
388 log(2, session
[s
].ip
, s
, t
, " PPP LCP Option type %d, len=%d\n", type
, length
);
389 memcpy(p
+ 4, o
, length
);
390 *(u16
*)(p
+ 2) = htons(length
+ 4);
392 q
= makeppp(b
,sizeof(b
), p
, length
+ 4, t
, s
, PPPLCP
);
393 tunnelsend(b
, 12 + length
+ 4, t
);
398 // Reject Unknown LCP Option to stop to send it again
399 log(2, session
[s
].ip
, s
, t
, " Unknown PPP LCP Option type %d\n", type
);
400 memcpy(p
+ 4, o
, length
);
401 *(u16
*)(p
+ 2) = htons(length
+ 4);
403 q
= makeppp(b
,sizeof(b
), p
, length
+ 4, t
, s
, PPPLCP
);
404 tunnelsend(b
, 12 + length
+ 4, t
);
413 // Send back a ConfigAck
414 log(3, session
[s
].ip
, s
, t
, "ConfigReq accepted, sending as Ack\n");
415 // for win2k L2TP clients and LCP renegotiation of alive session
416 if (magicno
|| l
== 4 || (session
[s
].mru
&& l
== 8)) initlcp(t
, s
);
417 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
420 log(3, session
[s
].ip
, s
, t
, " failed to create packet.\n");
424 tunnelsend(b
, l
+ (q
- b
), t
);
428 // Already built a ConfigNak... send it
429 log(3, session
[s
].ip
, s
, t
, "Sending ConfigNak\n");
430 tunnelsend(b
, l
+ (q
- b
), t
);
433 if (!(session
[s
].flags
& SESSIONLCPACK
))
436 else if (*p
== ConfigNak
)
438 log(1, session
[s
].ip
, s
, t
, "Remote end sent a ConfigNak. Ignoring\n");
442 else if (*p
== TerminateReq
)
444 *p
= TerminateAck
; // close
445 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
447 log(3, session
[s
].ip
, s
, t
, "Failed to create PPP packet in processlcp.\n");
450 log(3, session
[s
].ip
, s
, t
, "LCP: Received TerminateReq. Sending TerminateAck\n");
451 sessionshutdown(s
, "Remote end closed connection.");
452 tunnelsend(b
, l
+ (q
- b
), t
); // send it
454 else if (*p
== TerminateAck
)
456 sessionshutdown(s
, "Connection closed.");
458 else if (*p
== EchoReq
)
460 *p
= EchoReply
; // reply
461 *(u32
*) (p
+ 4) = htonl(session
[s
].magic
); // our magic number
462 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
464 log(3, session
[s
].ip
, s
, t
, " failed to send EchoReply.\n");
467 log(5, session
[s
].ip
, s
, t
, "LCP: Received EchoReq. Sending EchoReply\n");
468 tunnelsend(b
, l
+ (q
- b
), t
); // send it
470 else if (*p
== EchoReply
)
472 // Ignore it, last_packet time is set earlier than this.
474 else if (*p
== IdentRequest
)
479 log(1, 0, s
, t
, "Truncated Ident Packet (length=%d) to 1400 bytes\n", l
);
482 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
485 log(3, session
[s
].ip
, s
, t
, "Failed to create IdentRej.\n");
488 log_hex(5, "LCPIdentRej", q
, l
+ 4);
489 tunnelsend(b
, 12 + 4 + l
, t
);
493 log(1, session
[s
].ip
, s
, t
, "Unexpected LCP code %d\n", *p
);
494 STAT(tunnel_rx_errors
);
499 // Process IPCP messages
500 void processipcp(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
503 CSTAT(call_processipcp
);
505 log_hex(5, "IPCP", p
, l
);
508 log(1, 0, s
, t
, "Short IPCP %d bytes\n", l
);
509 STAT(tunnel_rx_errors
);
514 // happy with our IPCP
515 u16 r
= session
[s
].radius
;
516 if ((!r
|| radius
[r
].state
== RADIUSIPCP
) && !session
[s
].walled_garden
)
521 radiussend(r
, RADIUSSTART
); // send radius start, having got IPCP at last
523 session
[s
].flags
|= SF_IPCP_ACKED
;
525 log(3, session
[s
].ip
, s
, t
, "IPCP Acked, session is now active\n");
530 log(1, 0, s
, t
, "Unexpected IPCP code %d\n", *p
);
531 STAT(tunnel_rx_errors
);
534 log(4, session
[s
].ip
, s
, t
, "IPCP ConfigReq received\n");
535 if (ntohs(*(u16
*) (p
+ 2)) > l
)
537 log(1, 0, s
, t
, "Length mismatch IPCP %d/%d\n", ntohs(*(u16
*) (p
+ 2)), l
);
538 STAT(tunnel_rx_errors
);
543 log(3, 0, s
, t
, "Waiting on radius reply\n");
544 return; // have to wait on RADIUS reply
546 // form a config reply quoting the IP in the session
552 l
= ntohs(*(u16
*) (p
+ 2)); // We must use length from IPCP len field
555 while (q
< i
&& q
[1])
557 if (*q
!= 0x81 && *q
!= 0x83 && *q
!= 3)
566 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPIPCP
)))
568 log(2, 0, s
, t
, "Failed to send IPCP ConfigRej\n");
573 while (p
< i
&& p
[1])
575 if (*p
!= 0x81 && *p
!= 0x83 && *p
!= 3)
577 log(2, 0, s
, t
, "IPCP reject %d\n", *p
);
578 memcpy(q
+ n
, p
, p
[1]);
583 *(u16
*) (q
+ 2) = htons(n
);
584 log(4, session
[s
].ip
, s
, t
, "Sending ConfigRej\n");
585 tunnelsend(b
, n
+ (q
- b
), t
); // send it
589 log(4, session
[s
].ip
, s
, t
, "Sending ConfigAck\n");
591 if ((i
= findppp(p
, 0x81))) // Primary DNS address
593 if (*(u32
*) (i
+ 2) != htonl(session
[s
].dns1
))
595 *(u32
*) (i
+ 2) = htonl(session
[s
].dns1
);
597 log(5, session
[s
].ip
, s
, t
, " DNS1 = %s\n", inet_toa(session
[s
].dns1
));
600 if ((i
= findppp(p
, 0x83))) // Secondary DNS address (TBA, is it)
602 if (*(u32
*) (i
+ 2) != htonl(session
[s
].dns2
))
604 *(u32
*) (i
+ 2) = htonl(session
[s
].dns2
);
606 log(5, session
[s
].ip
, s
, t
, " DNS2 = %s\n", inet_toa(session
[s
].dns1
));
609 i
= findppp(p
, 3); // IP address
612 log(1, 0, s
, t
, "No IP in IPCP request\n");
613 STAT(tunnel_rx_errors
);
616 if (*(u32
*) (i
+ 2) != htonl(session
[s
].ip
))
618 *(u32
*) (i
+ 2) = htonl(session
[s
].ip
);
620 log(4, session
[s
].ip
, s
, t
, " No, a ConfigNak, client is requesting IP - sending %s\n",
621 inet_toa(htonl(session
[s
].ip
)));
623 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPIPCP
)))
625 log(2, 0, s
, t
, " Failed to send IPCP packet.\n");
628 tunnelsend(b
, l
+ (q
- b
), t
); // send it
633 // process IP packet received
635 // This MUST be called with at least 4 byte behind 'p'.
636 // (i.e. this routine writes to p[-4]).
637 void processipin(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
641 CSTAT(call_processipin
);
643 log_hex(5, "IP", p
, l
);
645 ip
= ntohl(*(u32
*)(p
+ 12));
649 log(1, ip
, s
, t
, "IP packet too long %d\n", l
);
650 STAT(tunnel_rx_errors
);
654 // no spoof (do sessionbyip to handled statically routed subnets)
655 if (ip
!= session
[s
].ip
&& sessionbyip(htonl(ip
)) != s
)
657 log(5, ip
, s
, t
, "Dropping packet with spoofed IP %s\n", inet_toa(htonl(ip
)));
661 // Add on the tun header
663 *(u32
*)p
= htonl(0x00000800);
666 if (session
[s
].tbf_in
&& !config
->cluster_iam_master
) { // Are we throttled and a slave?
667 master_throttle_packet(session
[s
].tbf_in
, p
, l
); // Pass it to the master for handling.
671 session
[s
].cin
+= l
- 4;
672 session
[s
].total_cin
+= l
- 4;
673 sess_count
[s
].cin
+= l
- 4;
678 if (session
[s
].snoop_ip
&& session
[s
].snoop_port
)
680 // Snooping this session
681 snoop_send_packet(p
, l
, session
[s
].snoop_ip
, session
[s
].snoop_port
);
683 STAT(tun_tx_packets
);
684 INC_STAT(tun_tx_bytes
, l
);
686 if (session
[s
].tbf_in
&& config
->cluster_iam_master
) { // Are we throttled and a master?? actually handle the throttled packets.
687 tbf_queue_packet(session
[s
].tbf_in
, p
, l
);
692 if (tun_write(p
, l
) < 0)
695 log(0, 0, s
, t
, "Error writing %d bytes to TUN device: %s (tunfd=%d, p=%p)\n",
696 l
, strerror(errno
), tunfd
, p
);
702 // Helper routine for the TBF filters.
703 // Used to send queued data in from the user.
705 void send_ipin(sessionidt s
, u8
*buf
, int len
)
707 log_hex(5, "IP in throttled", buf
, len
);
708 if (write(tunfd
, buf
, len
) < 0)
711 log(0, 0, 0, 0, "Error writing %d bytes to TUN device: %s (tunfd=%d, p=%p)\n",
712 len
, strerror(errno
), tunfd
, buf
);
715 // Increment packet counters
716 session
[s
].cin
+= len
- 4;
717 session
[s
].total_cin
+= len
- 4;
718 sess_count
[s
].cin
+= len
- 4;
725 // Process LCP messages
726 void processccp(tunnelidt t
, sessionidt s
, u8
* p
, u16 l
)
729 CSTAT(call_processccp
);
731 log_hex(5, "CCP", p
, l
);
732 if (l
< 2 || (*p
!= ConfigReq
&& *p
!= TerminateReq
))
734 log(1, 0, s
, t
, "Unexpected CCP request code %d\n", *p
);
735 STAT(tunnel_rx_errors
);
746 *p
= ConfigAck
; // accept no compression
750 *p
= ConfigRej
; // reject
755 *p
= TerminateAck
; // close
756 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPCCP
)))
758 log(1,0,0,0, "Failed to send CCP packet.\n");
761 tunnelsend(b
, l
+ (q
- b
), t
); // send it
765 // send a CHAP PP packet
766 void sendchap(tunnelidt t
, sessionidt s
)
769 u16 r
= session
[s
].radius
;
772 CSTAT(call_sendchap
);
776 log(1, 0, s
, t
, "No RADIUS to send challenge\n");
777 STAT(tunnel_tx_errors
);
780 log(1, 0, s
, t
, "Send CHAP challenge\n");
784 for (n
= 0; n
< 15; n
++)
785 radius
[r
].auth
[n
] = rand();
787 radius
[r
].chap
= 1; // CHAP not PAP
789 if (radius
[r
].state
!= RADIUSCHAP
)
791 radius
[r
].state
= RADIUSCHAP
;
792 radius
[r
].retry
= backoff(radius
[r
].try++);
793 if (radius
[r
].try > 5)
795 sessionshutdown(s
, "Timeout CHAP");
796 STAT(tunnel_tx_errors
);
799 q
= makeppp(b
, sizeof(b
), 0, 0, t
, s
, PPPCHAP
);
801 log(1, 0, s
, t
, "failed to send CHAP challenge.\n");
805 q
[1] = radius
[r
].id
; // ID
807 memcpy(q
+ 5, radius
[r
].auth
, 16); // challenge
808 strcpy(q
+ 21, hostname
); // our name
809 *(u16
*) (q
+ 2) = htons(strlen(hostname
) + 21); // length
810 tunnelsend(b
, strlen(hostname
) + 21 + (q
- b
), t
); // send it
813 // fill in a L2TP message with a PPP frame,
814 // copies existing PPP message and changes magic number if seen
815 // returns start of PPP frame
816 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
== PPPLCP
|| !(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
);