9671118b0f34a9aac95dd0a43fe89610a025a9e4
3 char const *cvs_id_ppp
= "$Id: ppp.c,v 1.19 2004-11-04 23:33:13 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
);
45 if ((hl
= ntohs(*(u16
*) (p
+ 2))) > l
)
47 log(1, 0, s
, t
, "Length mismatch PAP %u/%u\n", hl
, l
);
48 STAT(tunnel_rx_errors
);
55 log(1, 0, s
, t
, "Unexpected PAP code %d\n", *p
);
56 STAT(tunnel_rx_errors
);
63 if (*b
&& *b
< sizeof(user
))
64 memcpy(user
, b
+ 1, *b
);
67 if (*b
&& *b
< sizeof(pass
))
68 memcpy(pass
, b
+ 1, *b
);
70 log(3, 0, s
, t
, "PAP login %s/%s\n", user
, pass
);
72 if (session
[s
].ip
|| !session
[s
].radius
)
74 // respond now, either no RADIUS available or already authenticated
77 u8
*p
= makeppp(b
, sizeof(b
), 0, 0, t
, s
, PPPPAP
);
78 if (!p
) { // Failed to make ppp header!
79 log(1,0,0,0, "Failed to make PPP header in process pap!\n");
85 *p
= 3; // cant authorise
87 *(u16
*) (p
+ 2) = htons(5); // length
88 p
[4] = 0; // no message
91 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
);
92 session
[s
].flags
&= ~SF_IPCP_ACKED
;
96 log(1, 0, s
, t
, "No radius session available to authenticate session...\n");
98 log(3, 0, s
, t
, "Fallback response to PAP (%s)\n", (session
[s
].ip
) ? "ACK" : "NAK");
99 tunnelsend(b
, 5 + (p
- b
), t
); // send it
103 // set up RADIUS request
104 u16 r
= session
[s
].radius
;
106 // Run PRE_AUTH plugins
107 struct param_pre_auth packet
= { &tunnel
[t
], &session
[s
], strdup(user
), strdup(pass
), PPPPAP
, 1 };
108 run_plugins(PLUGIN_PRE_AUTH
, &packet
);
109 if (!packet
.continue_auth
)
111 log(3, 0, s
, t
, "A plugin rejected PRE_AUTH\n");
112 if (packet
.username
) free(packet
.username
);
113 if (packet
.password
) free(packet
.password
);
117 strncpy(session
[s
].user
, packet
.username
, sizeof(session
[s
].user
) - 1);
118 strncpy(radius
[r
].pass
, packet
.password
, sizeof(radius
[r
].pass
) - 1);
120 free(packet
.username
);
121 free(packet
.password
);
124 log(3, 0, s
, t
, "Sending login for %s/%s to radius\n", user
, pass
);
125 radiussend(r
, RADIUSAUTH
);
129 // Process CHAP messages
130 void processchap(tunnelidt t
, sessionidt s
, u8
*p
, u16 l
)
135 CSTAT(call_processchap
);
137 log_hex(5, "CHAP", p
, l
);
138 r
= session
[s
].radius
;
141 log(1, 0, s
, t
, "Unexpected CHAP message\n");
143 // FIXME: Need to drop the session here.
145 STAT(tunnel_rx_errors
);
151 log(1, 0, s
, t
, "Short CHAP %u bytes\n", l
);
152 STAT(tunnel_rx_errors
);
156 if ((hl
= ntohs(*(u16
*) (p
+ 2))) > l
)
158 log(1, 0, s
, t
, "Length mismatch CHAP %u/%u\n", hl
, l
);
159 STAT(tunnel_rx_errors
);
166 log(1, 0, s
, t
, "Unexpected CHAP response code %d\n", *p
);
167 STAT(tunnel_rx_errors
);
170 if (p
[1] != radius
[r
].id
)
172 log(1, 0, s
, t
, "Wrong CHAP response ID %d (should be %d) (%d)\n", p
[1], radius
[r
].id
, r
);
173 STAT(tunnel_rx_errors
);
177 if (l
< 5 || p
[4] != 16)
179 log(1, 0, s
, t
, "Bad CHAP response length %d\n", l
< 5 ? -1 : p
[4]);
180 STAT(tunnel_rx_errors
);
186 if (l
< 16 || l
- 16 >= sizeof(session
[s
].user
))
188 log(1, 0, s
, t
, "CHAP user too long %d\n", l
- 16);
189 STAT(tunnel_rx_errors
);
193 // Run PRE_AUTH plugins
195 struct param_pre_auth packet
= { &tunnel
[t
], &session
[s
], NULL
, NULL
, PPPCHAP
, 1 };
197 packet
.username
= calloc(l
- 16 + 1, 1);
198 packet
.password
= calloc(16, 1);
199 memcpy(packet
.username
, p
+ 16, l
- 16);
200 memcpy(packet
.password
, p
, 16);
202 run_plugins(PLUGIN_PRE_AUTH
, &packet
);
203 if (!packet
.continue_auth
)
205 log(3, 0, s
, t
, "A plugin rejected PRE_AUTH\n");
206 if (packet
.username
) free(packet
.username
);
207 if (packet
.password
) free(packet
.password
);
211 strncpy(session
[s
].user
, packet
.username
, sizeof(session
[s
].user
) - 1);
212 memcpy(radius
[r
].pass
, packet
.password
, 16);
214 free(packet
.username
);
215 free(packet
.password
);
219 log(3, 0, s
, t
, "CHAP login %s\n", session
[s
].user
);
220 radiussend(r
, RADIUSAUTH
);
223 char *ppp_lcp_types
[] = {
239 void dumplcp(u8
*p
, int l
)
244 log_hex(5, "PPP LCP Packet", p
, l
);
245 log(4, 0, 0, 0, "PPP LCP Packet type %d (%s len %d)\n", *p
, ppp_lcp_types
[(int)*p
], ntohs( ((u16
*) p
)[1]) );
246 log(4, 0, 0, 0, "Length: %d\n", l
);
247 if (*p
!= ConfigReq
&& *p
!= ConfigRej
&& *p
!= ConfigAck
)
256 log(4, 0, 0, 0, " Option length is %d...\n", length
);
261 log(4, 0, 0, 0, " Option type is 0...\n");
268 case 1: // Maximum-Receive-Unit
270 log(4, 0, 0, 0, " %s %d\n", lcp_types
[type
], ntohs(*(u16
*)(o
+ 2)));
272 log(4, 0, 0, 0, " %s odd length %d\n", lcp_types
[type
], length
);
274 case 3: // Authentication-Protocol
278 int proto
= ntohs(*(u16
*)(o
+ 2));
279 log(4, 0, 0, 0, " %s 0x%x (%s)\n", lcp_types
[type
], proto
,
280 proto
== 0xC223 ? "CHAP" :
281 proto
== 0xC023 ? "PAP" : "UNKNOWN");
284 log(4, 0, 0, 0, " %s odd length %d\n", lcp_types
[type
], length
);
287 case 4: // Quality-Protocol
289 u32 qp
= ntohl(*(u32
*)(o
+ 2));
290 log(4, 0, 0, 0, " %s %x\n", lcp_types
[type
], qp
);
293 case 5: // Magic-Number
297 u32 magicno
= ntohl(*(u32
*)(o
+ 2));
298 log(4, 0, 0, 0, " %s %x\n", lcp_types
[type
], magicno
);
301 log(4, 0, 0, 0, " %s odd length %d\n", lcp_types
[type
], length
);
304 case 7: // Protocol-Field-Compression
306 log(4, 0, 0, 0, " %s\n", lcp_types
[type
]);
309 case 8: // Address-And-Control-Field-Compression
311 log(4, 0, 0, 0, " %s\n", lcp_types
[type
]);
315 log(2, 0, 0, 0, " Unknown PPP LCP Option type %d\n", type
);
323 // Process LCP messages
324 void processlcp(tunnelidt t
, sessionidt s
, u8
*p
, u16 l
)
331 CSTAT(call_processlcp
);
333 log_hex(5, "LCP", p
, l
);
336 log(1, session
[s
].ip
, s
, t
, "Short LCP %d bytes\n", l
);
337 STAT(tunnel_rx_errors
);
341 if ((hl
= ntohs(*(u16
*) (p
+ 2))) > l
)
343 log(1, 0, s
, t
, "Length mismatch LCP %u/%u\n", hl
, l
);
344 STAT(tunnel_rx_errors
);
351 log(3, session
[s
].ip
, s
, t
, "LCP: Discarding ConfigAck\n");
352 session
[s
].flags
|= SESSIONLCPACK
;
354 else if (*p
== ConfigReq
)
359 log(3, session
[s
].ip
, s
, t
, "LCP: ConfigReq (%d bytes)...\n", l
);
360 if (config
->debug
> 3) dumplcp(p
, l
);
366 if (length
== 0 || type
== 0) break;
369 case 1: // Maximum-Receive-Unit
370 session
[s
].mru
= ntohs(*(u16
*)(o
+ 2));
373 log_hex(2, "PPP LCP Packet", p
, l
);
374 log(2, 0, 0, 0, "PPP LCP Packet type %d (%s len %d)\n", *p
, ppp_lcp_types
[(int)*p
], ntohs( ((u16
*) p
)[1]) );
376 case 3: // Authentication-Protocol
378 int proto
= ntohs(*(u16
*)(o
+ 2));
381 log(2, session
[s
].ip
, s
, t
, " Remote end is trying to do CHAP. Rejecting it.\n");
385 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
387 log(2, session
[s
].ip
, s
, t
, " Failed to send packet.\n");
392 memcpy(q
, o
, length
);
393 *(u16
*)(q
+= 2) = htons(0xC023); // NAK -> Use PAP instead
398 case 5: // Magic-Number
400 magicno
= ntohl(*(u32
*)(o
+ 2));
403 case 4: // Quality-Protocol
404 case 7: // Protocol-Field-Compression
405 case 8: // Address-And-Control-Field-Compression
407 case 13: // CallBack option for LCP extention of win2000/routers L2TP client
411 // Reject LCP CallBack
412 log(2, session
[s
].ip
, s
, t
, " PPP LCP Option type %d, len=%d\n", type
, length
);
413 memcpy(p
+ 4, o
, length
);
414 *(u16
*)(p
+ 2) = htons(length
+ 4);
416 q
= makeppp(b
,sizeof(b
), p
, length
+ 4, t
, s
, PPPLCP
);
417 tunnelsend(b
, 12 + length
+ 4, t
);
422 // Reject Unknown LCP Option to stop to send it again
423 log(2, session
[s
].ip
, s
, t
, " Unknown PPP LCP Option type %d\n", type
);
424 memcpy(p
+ 4, o
, length
);
425 *(u16
*)(p
+ 2) = htons(length
+ 4);
427 q
= makeppp(b
,sizeof(b
), p
, length
+ 4, t
, s
, PPPLCP
);
428 tunnelsend(b
, 12 + length
+ 4, t
);
437 // Send back a ConfigAck
438 log(3, session
[s
].ip
, s
, t
, "ConfigReq accepted, sending as Ack\n");
439 // for win2k L2TP clients and LCP renegotiation of alive session
440 if (magicno
|| l
== 4 || (session
[s
].mru
&& l
== 8)) initlcp(t
, s
);
441 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
444 log(3, session
[s
].ip
, s
, t
, " failed to create packet.\n");
448 tunnelsend(b
, l
+ (q
- b
), t
);
452 // Already built a ConfigNak... send it
453 log(3, session
[s
].ip
, s
, t
, "Sending ConfigNak\n");
454 tunnelsend(b
, l
+ (q
- b
), t
);
457 if (!(session
[s
].flags
& SESSIONLCPACK
))
460 else if (*p
== ConfigNak
)
462 log(1, session
[s
].ip
, s
, t
, "Remote end sent a ConfigNak. Ignoring\n");
463 if (config
->debug
> 3) dumplcp(p
, l
);
466 else if (*p
== TerminateReq
)
468 *p
= TerminateAck
; // close
469 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
471 log(3, session
[s
].ip
, s
, t
, "Failed to create PPP packet in processlcp.\n");
474 log(3, session
[s
].ip
, s
, t
, "LCP: Received TerminateReq. Sending TerminateAck\n");
475 sessionshutdown(s
, "Remote end closed connection.");
476 tunnelsend(b
, l
+ (q
- b
), t
); // send it
478 else if (*p
== TerminateAck
)
480 sessionshutdown(s
, "Connection closed.");
482 else if (*p
== EchoReq
)
484 *p
= EchoReply
; // reply
485 *(u32
*) (p
+ 4) = htonl(session
[s
].magic
); // our magic number
486 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
488 log(3, session
[s
].ip
, s
, t
, " failed to send EchoReply.\n");
491 log(5, session
[s
].ip
, s
, t
, "LCP: Received EchoReq. Sending EchoReply\n");
492 tunnelsend(b
, l
+ (q
- b
), t
); // send it
494 else if (*p
== EchoReply
)
496 // Ignore it, last_packet time is set earlier than this.
498 else if (*p
== IdentRequest
)
503 log(1, 0, s
, t
, "Truncated Ident Packet (length=%d) to 1400 bytes\n", l
);
506 q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPLCP
);
509 log(3, session
[s
].ip
, s
, t
, "Failed to create IdentRej.\n");
512 log_hex(5, "LCPIdentRej", q
, l
+ 4);
513 tunnelsend(b
, 12 + 4 + l
, t
);
517 log(1, session
[s
].ip
, s
, t
, "Unexpected LCP code %d\n", *p
);
518 STAT(tunnel_rx_errors
);
523 // Process IPCP messages
524 void processipcp(tunnelidt t
, sessionidt s
, u8
*p
, u16 l
)
528 CSTAT(call_processipcp
);
530 log_hex(5, "IPCP", p
, l
);
533 log(1, 0, s
, t
, "Short IPCP %d bytes\n", l
);
534 STAT(tunnel_rx_errors
);
538 if ((hl
= ntohs(*(u16
*) (p
+ 2))) > l
)
540 log(1, 0, s
, t
, "Length mismatch IPCP %u/%u\n", hl
, l
);
541 STAT(tunnel_rx_errors
);
548 // happy with our IPCP
549 u16 r
= session
[s
].radius
;
550 if ((!r
|| radius
[r
].state
== RADIUSIPCP
) && !session
[s
].walled_garden
)
555 radiussend(r
, RADIUSSTART
); // send radius start, having got IPCP at last
557 session
[s
].flags
|= SF_IPCP_ACKED
;
559 log(3, session
[s
].ip
, s
, t
, "IPCP Acked, session is now active\n");
564 log(1, 0, s
, t
, "Unexpected IPCP code %d\n", *p
);
565 STAT(tunnel_rx_errors
);
568 log(4, session
[s
].ip
, s
, t
, "IPCP ConfigReq received\n");
572 log(3, 0, s
, t
, "Waiting on radius reply\n");
573 return; // have to wait on RADIUS reply
575 // form a config reply quoting the IP in the session
583 while (q
< i
&& q
[1])
585 if (*q
!= 0x81 && *q
!= 0x83 && *q
!= 3)
594 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPIPCP
)))
596 log(2, 0, s
, t
, "Failed to send IPCP ConfigRej\n");
601 while (p
< i
&& p
[1])
603 if (*p
!= 0x81 && *p
!= 0x83 && *p
!= 3)
605 log(2, 0, s
, t
, "IPCP reject %d\n", *p
);
606 memcpy(q
+ n
, p
, p
[1]);
611 *(u16
*) (q
+ 2) = htons(n
);
612 log(4, session
[s
].ip
, s
, t
, "Sending ConfigRej\n");
613 tunnelsend(b
, n
+ (q
- b
), t
); // send it
617 log(4, session
[s
].ip
, s
, t
, "Sending ConfigAck\n");
619 if ((i
= findppp(p
, 0x81))) // Primary DNS address
621 if (*(u32
*) (i
+ 2) != htonl(session
[s
].dns1
))
623 *(u32
*) (i
+ 2) = htonl(session
[s
].dns1
);
625 log(5, session
[s
].ip
, s
, t
, " DNS1 = %s\n", inet_toa(session
[s
].dns1
));
628 if ((i
= findppp(p
, 0x83))) // Secondary DNS address (TBA, is it)
630 if (*(u32
*) (i
+ 2) != htonl(session
[s
].dns2
))
632 *(u32
*) (i
+ 2) = htonl(session
[s
].dns2
);
634 log(5, session
[s
].ip
, s
, t
, " DNS2 = %s\n", inet_toa(session
[s
].dns1
));
637 i
= findppp(p
, 3); // IP address
640 log(1, 0, s
, t
, "No IP in IPCP request\n");
641 STAT(tunnel_rx_errors
);
644 if (*(u32
*) (i
+ 2) != htonl(session
[s
].ip
))
646 *(u32
*) (i
+ 2) = htonl(session
[s
].ip
);
648 log(4, session
[s
].ip
, s
, t
, " No, a ConfigNak, client is requesting IP - sending %s\n",
649 inet_toa(htonl(session
[s
].ip
)));
651 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPIPCP
)))
653 log(2, 0, s
, t
, " Failed to send IPCP packet.\n");
656 tunnelsend(b
, l
+ (q
- b
), t
); // send it
661 // process IP packet received
663 // This MUST be called with at least 4 byte behind 'p'.
664 // (i.e. this routine writes to p[-4]).
665 void processipin(tunnelidt t
, sessionidt s
, u8
*p
, u16 l
)
669 CSTAT(call_processipin
);
671 log_hex(5, "IP", p
, l
);
673 ip
= ntohl(*(u32
*)(p
+ 12));
677 log(1, ip
, s
, t
, "IP packet too long %d\n", l
);
678 STAT(tunnel_rx_errors
);
682 // no spoof (do sessionbyip to handled statically routed subnets)
683 if (ip
!= session
[s
].ip
&& sessionbyip(htonl(ip
)) != s
)
685 log(5, ip
, s
, t
, "Dropping packet with spoofed IP %s\n", inet_toa(htonl(ip
)));
689 if (session
[s
].snoop_ip
&& session
[s
].snoop_port
)
691 // Snooping this session
692 snoop_send_packet(p
, l
, session
[s
].snoop_ip
, session
[s
].snoop_port
);
695 // Add on the tun header
697 *(u32
*)p
= htonl(0x00000800);
700 if (session
[s
].tbf_in
&& !config
->cluster_iam_master
) { // Are we throttled and a slave?
701 master_throttle_packet(session
[s
].tbf_in
, p
, l
); // Pass it to the master for handling.
705 session
[s
].cin
+= l
- 4;
706 session
[s
].total_cin
+= l
- 4;
707 sess_count
[s
].cin
+= l
- 4;
712 STAT(tun_tx_packets
);
713 INC_STAT(tun_tx_bytes
, l
);
715 if (session
[s
].tbf_in
&& config
->cluster_iam_master
) { // Are we throttled and a master?? actually handle the throttled packets.
716 tbf_queue_packet(session
[s
].tbf_in
, p
, l
);
721 if (tun_write(p
, l
) < 0)
724 log(0, 0, s
, t
, "Error writing %d bytes to TUN device: %s (tunfd=%d, p=%p)\n",
725 l
, strerror(errno
), tunfd
, p
);
731 // Helper routine for the TBF filters.
732 // Used to send queued data in from the user.
734 void send_ipin(sessionidt s
, u8
*buf
, int len
)
736 log_hex(5, "IP in throttled", buf
, len
);
737 if (write(tunfd
, buf
, len
) < 0)
740 log(0, 0, 0, 0, "Error writing %d bytes to TUN device: %s (tunfd=%d, p=%p)\n",
741 len
, strerror(errno
), tunfd
, buf
);
744 // Increment packet counters
745 session
[s
].cin
+= len
- 4;
746 session
[s
].total_cin
+= len
- 4;
747 sess_count
[s
].cin
+= len
- 4;
754 // Process LCP messages
755 void processccp(tunnelidt t
, sessionidt s
, u8
*p
, u16 l
)
758 CSTAT(call_processccp
);
760 log_hex(5, "CCP", p
, l
);
761 if (l
< 2 || (*p
!= ConfigReq
&& *p
!= TerminateReq
))
763 log(1, 0, s
, t
, "Unexpected CCP request code %d\n", *p
);
764 STAT(tunnel_rx_errors
);
775 *p
= ConfigAck
; // accept no compression
779 *p
= ConfigRej
; // reject
784 *p
= TerminateAck
; // close
785 if (!(q
= makeppp(b
, sizeof(b
), p
, l
, t
, s
, PPPCCP
)))
787 log(1,0,0,0, "Failed to send CCP packet.\n");
790 tunnelsend(b
, l
+ (q
- b
), t
); // send it
794 // send a CHAP PP packet
795 void sendchap(tunnelidt t
, sessionidt s
)
798 u16 r
= session
[s
].radius
;
801 CSTAT(call_sendchap
);
805 log(1, 0, s
, t
, "No RADIUS to send challenge\n");
806 STAT(tunnel_tx_errors
);
809 log(1, 0, s
, t
, "Send CHAP challenge\n");
813 for (n
= 0; n
< 15; n
++)
814 radius
[r
].auth
[n
] = rand();
816 radius
[r
].chap
= 1; // CHAP not PAP
818 if (radius
[r
].state
!= RADIUSCHAP
)
820 radius
[r
].state
= RADIUSCHAP
;
821 radius
[r
].retry
= backoff(radius
[r
].try++);
822 if (radius
[r
].try > 5)
824 sessionshutdown(s
, "Timeout CHAP");
825 STAT(tunnel_tx_errors
);
828 q
= makeppp(b
, sizeof(b
), 0, 0, t
, s
, PPPCHAP
);
830 log(1, 0, s
, t
, "failed to send CHAP challenge.\n");
834 q
[1] = radius
[r
].id
; // ID
836 memcpy(q
+ 5, radius
[r
].auth
, 16); // challenge
837 strcpy(q
+ 21, hostname
); // our name
838 *(u16
*) (q
+ 2) = htons(strlen(hostname
) + 21); // length
839 tunnelsend(b
, strlen(hostname
) + 21 + (q
- b
), t
); // send it
842 // fill in a L2TP message with a PPP frame,
843 // copies existing PPP message and changes magic number if seen
844 // returns start of PPP frame
845 u8
*makeppp(u8
*b
, int size
, u8
*p
, int l
, tunnelidt t
, sessionidt s
, u16 mtype
)
848 return NULL
; // Need more space than this!!
850 *(u16
*) (b
+ 0) = htons(0x0002); // L2TP with no options
851 *(u16
*) (b
+ 2) = htons(tunnel
[t
].far
); // tunnel
852 *(u16
*) (b
+ 4) = htons(session
[s
].far
); // session
854 if (mtype
== PPPLCP
|| !(session
[s
].l2tp_flags
& SESSIONACFC
))
856 *(u16
*) b
= htons(0xFF03); // HDLC header
859 if (mtype
< 0x100 && session
[s
].l2tp_flags
& SESSIONPFC
)
863 *(u16
*) b
= htons(mtype
);
868 log(3,0,0,0, "Would have overflowed the buffer in makeppp: size %d, len %d.\n", size
, l
);
869 return NULL
; // Run out of room to hold the packet!
876 // find a PPP option, returns point to option, or 0 if not found
877 u8
*findppp(u8
*b
, u8 mtype
)
879 u16 l
= ntohs(*(u16
*) (b
+ 2));
886 if (l
< b
[1] || !b
[1])
896 // Send initial LCP ConfigReq
897 void initlcp(tunnelidt t
, sessionidt s
)
899 char b
[500] = {0}, *q
;
901 q
= makeppp(b
, sizeof(b
), NULL
, 0, t
, s
, PPPLCP
);
903 log(1, 0, s
, t
, "Failed to send LCP ConfigReq.\n");
906 log(4, 0, s
, t
, "Sending LCP ConfigReq for PAP\n");
908 *(u8
*)(q
+ 1) = (time_now
% 255) + 1; // ID
909 *(u16
*)(q
+ 2) = htons(14); // Length
912 *(u32
*)(q
+ 6) = htonl(session
[s
].magic
);
915 *(u16
*)(q
+ 12) = htons(0xC023); // PAP
916 tunnelsend(b
, 12 + 14, t
);
920 void sendccp(tunnelidt t
, sessionidt s
)
922 char *q
, b
[500] = {0};
924 q
= makeppp(b
, sizeof(b
), NULL
, 0, t
, s
, PPPCCP
);
926 *(u8
*)(q
+ 1) = (time_now
% 255) + 1; // ID
927 *(u16
*)(q
+ 2) = htons(4); // Length
928 log_hex(5, "PPPCCP", q
, 4);
929 tunnelsend(b
, (q
- b
) + 4 , t
);