6 #include "device_protos.h"
9 #define CONTROL_SEARCH_BEGIN 1
10 #define CONTROL_SKIP_HEADER1 2
11 #define CONTROL_SKIP_HEADER2 3
12 #define CONTROL_READ_DATA 4
23 #define TERMINATE_REQUEST 5
24 #define TERMINATE_ACK 6
25 #define PROTOCOL_REJECT 8
26 #define ECHO_REQUEST 9
28 #define DISCARD_REQUEST 11
36 void init_ppp(LIBBASETYPEPTR LIBBASE
);
37 void Set_phase(UBYTE ph
);
39 void ProcessPacket(struct packet
* p
);
40 void SendPPP_Packet(struct packet
*);
41 void EscapePacket(struct packet
*);
43 void AddChkSum(struct packet
* );
45 void AddBytes(struct packet
*p
,const BYTE
*data
,const ULONG len
);
46 void AddByte(struct packet
*p
,const BYTE b
);
48 void LCP_packet(struct packet
*);
50 void SendEchoReply(struct packet
*);
51 void SendTerminateReq();
52 void SendEchoRequest();
54 void IPCP_Packet(struct packet
* );
57 void PAP_Packet(struct packet
* );
60 unsigned char LocalIP
[4]={0,0,0,0};
61 unsigned char RemoteIP
[4]={0,0,0,0};
62 unsigned char PrimaryDNS
[4]={0,0,0,0};
63 unsigned char SecondaryDNS
[4]={0,0,0,0};
68 UBYTE
*username
,*password
;
80 struct PPPBase
*ppp_libbase
;
83 struct packet recdpacket
;
85 unsigned long threadid
, bytesrecd
,byteswritten
;
88 unsigned char writestr
[200],ctemp
;
91 static unsigned short fcstab
[256] = {
92 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
93 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
94 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
95 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
96 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
97 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
98 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
99 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
100 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
101 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
102 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
103 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
104 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
105 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
106 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
107 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
108 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
109 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
110 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
111 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
112 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
113 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
114 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
115 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
116 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
117 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
118 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
119 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
120 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
121 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
122 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
123 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
126 #define PPPINITFCS16 0xffff
127 #define PPPGOODFCS16 0xf0b8
128 #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
130 void AddChkSum(struct packet
*p
){
137 fcs
= PPP_FCS(fcs
, 0xff); // header simulation...
138 fcs
= PPP_FCS(fcs
, 0x03);
141 for( i
=0 ;i
< p
->packetsize
; i
++ ){
142 fcs
= PPP_FCS(fcs
, *cp
);
147 AddByte( p
, (fcs
& 0x00ff) );
148 AddByte( p
,((fcs
>> 8 ) & 0x00ff));
153 void ppp_timer(int dt
){
155 // No timeouts in network & dead phases.
156 if( (phase
== PPP_PHASE_NETWORK
) || (phase
== PPP_PHASE_DEAD
)) return;
160 if(phase
== PPP_PHASE_PROTOCOL_CONF
){ // sometimes IPCP takes a looong time...
162 bug("PPP Giveup :-(\n");
163 Set_phase( PPP_PHASE_DEAD
);
168 if( timer
< TIMEOUT
) return;
171 if( ++trycounter
> MAX_TRY
){
172 bug("PPP Giveup :-(\n");
173 Set_phase( PPP_PHASE_DEAD
);
176 bug("PPP Retrying...\n");
177 Set_phase( phase
); // Retry
182 BYTE
Phase(){ return phase
;}
184 void Set_phase(UBYTE ph
){
185 bug("\nPPP PHASE: ");
188 if( phase
!= ph
)trycounter
= 0; // first try
192 case PPP_PHASE_CONFIGURATION
:
193 bug("CONFIGURATION\n");
196 async_map
= 0xffffffff;
199 device_conf_ok
= FALSE
;
204 case PPP_PHASE_AUTHENTICATION
:
205 bug("AUTHENTICATION\n");
208 if( authentication
){
211 bug("no authentication configured -> next phase\n");
212 Set_phase( PPP_PHASE_PROTOCOL_CONF
);
216 case PPP_PHASE_PROTOCOL_CONF
:
217 bug("PROTOCOL_CONF\n");
221 device_conf_ok
= FALSE
;
246 case PPP_PHASE_NETWORK
:
250 if( (RemoteIP
[0] | RemoteIP
[1] | RemoteIP
[2] | RemoteIP
[3]) == 0 ){
251 bug("\nCould not determine remote IP address !! defaulting to 10.64.64.64\n");
257 memcpy( ppp_libbase
->LocalIP
, LocalIP
, 4 );
258 memcpy( ppp_libbase
->RemoteIP
, RemoteIP
, 4 );
259 memcpy( ppp_libbase
->PrimaryDNS
, PrimaryDNS
, 4 );
260 memcpy( ppp_libbase
->SecondaryDNS
, SecondaryDNS
, 4 );
266 case PPP_PHASE_TERMINATE
:
272 case PPP_PHASE_DEAD
:
278 bug("ERROR unknown phase:%d\n",ph
);
285 void init_ppp(LIBBASETYPEPTR LIBBASE
){
288 Control
=CONTROL_SEARCH_BEGIN
;
290 recdpacket
.packetsize
= 0;
292 ppp_libbase
= LIBBASE
;
294 username
= LIBBASE
->username
;
295 password
= LIBBASE
->password
;
297 Set_phase( PPP_PHASE_DEAD
);
301 void printpacket(struct packet
* p
){
303 for( i
=0 ;i
< p
->packetsize
; i
++ ) bug("%x,",p
->data
[i
]);
307 void AddBytes(struct packet
*p
,const BYTE
*data
,const ULONG len
){
309 if( p
->packetsize
+ len
>= MAXPSIZE
){
310 bug("\nPPP ERROR:AddBytes MAXPSIZE\n");
314 memcpy( &p
->data
[ p
->packetsize
] , data
, len
);
315 p
->packetsize
+= len
;
319 void AddByte(struct packet
*p
,const BYTE b
){
321 if( p
->packetsize
>= MAXPSIZE
){
322 bug("\nPPP ERROR:AddByte MAXPSIZE\n");
325 p
->data
[p
->packetsize
] = b
;
329 void bytes_received( UBYTE
*bytes
,ULONG len
){
336 // bug("Control=%d c=%d,%c,%x \n",Control,c,c,c);
338 if( c
== 0x7e ){ // start/end mark
340 if( Control
== CONTROL_READ_DATA
){
342 Control
= CONTROL_SEARCH_BEGIN
;
343 ProcessPacket(&recdpacket
);
344 recdpacket
.packetsize
= 0;
346 }else if( Control
== CONTROL_SEARCH_BEGIN
){
348 recdpacket
.packetsize
=0;
349 Control
= CONTROL_SKIP_HEADER1
;
352 bug("PPP control sync error, unexpected start/end mark!\n");
354 }else if( c
== 0x7d ){ // next byte is escaped
364 if( Control
== CONTROL_READ_DATA
){
365 AddByte(&recdpacket
,c
);
369 else if( Control
== CONTROL_SKIP_HEADER1
){
371 Control
= CONTROL_SKIP_HEADER2
;
374 bug("PPP control sync error, byte=0x%x, should be 0xff\n",c
);
375 Control
= CONTROL_SEARCH_BEGIN
;
379 else if( Control
== CONTROL_SKIP_HEADER2
){
381 Control
= CONTROL_READ_DATA
;
383 bug("PPP control sync error, byte=0x%x, should be 0x03\n",c
);
384 Control
= CONTROL_SEARCH_BEGIN
;
392 void ProcessPacket(struct packet
* p
){
396 if( p
->packetsize
< 8 ){
397 bug("Too short PPP packet received\n");
401 p
->packetsize
-=2; // -checksum
403 // bug("ProcessPacket size=%d\n",p->packetsize);
406 type
= ( p
->data
[0] << 8 ) | p
->data
[1];
422 // bug("IP packet received,size %d\n",p->packetsize);
423 if( ( p
->packetsize
- 2 ) <= 1500 ){
424 Incoming_IP_Packet( ppp_libbase
, p
->data
+ 2 , p
->packetsize
- 2 );
426 bug("OVERSIZE Incoming IP packet !!!!!!!!!!!!!!!!! %d bytes\n",p
->packetsize
- 2 );
432 bug("Link Quality Report protocol not supported :-(\n");
436 bug("Compression Control Protocol not supported :-(\n");
441 bug("Received unknown packet: type=%x\n",type
);
448 void PAP_Packet(struct packet
* f
){
449 bug("\nPAP packet size=%d\n",f
->packetsize
);
452 switch ( f
->data
[2] ){
455 bug("PAP Req Received\n");
459 bug("PAP Ack Received: PAP authentication succeeded\n");
461 if( phase
== PPP_PHASE_AUTHENTICATION
){
462 Set_phase( PPP_PHASE_PROTOCOL_CONF
);
468 bug("PAP Nak received\n");
472 bug("PAP Reject received\n");
473 Set_phase( PPP_PHASE_DEAD
);
477 bug("PAP unknown type received\n");
488 bug("\nSend PAP req \"%s\",\"%s\"\n",username
,password
);
490 AddByte( &p
, 0xc0 );//PAP
491 AddByte( &p
, 0x23 );
492 AddByte( &p
, REQUEST
); // req.
493 AddByte( &p
, ++number
); // number
494 AddByte( &p
, 0x00 ); // size
495 AddByte( &p
, 0x00 ); // size <- p.data[5]
497 AddByte( &p
, strlen( username
) );
498 for( i
=0 ; i
< strlen( username
) ; i
++ ) AddByte( &p
, username
[i
] );
500 AddByte( &p
, strlen( password
) );
501 for( i
=0 ; i
< strlen( password
) ; i
++ ) AddByte( &p
, password
[i
] );
503 p
.data
[5] = p
.packetsize
- 2; // size
511 void Send_response( UWORD type
,UBYTE code
,UBYTE
*ptr
,ULONG len
,BYTE num
){
516 if(type
==IPCP
){ bug("IPCP "); }else
517 if(type
==LCP
){ bug("LCP "); }else
518 bug("unknown type 0x%x\n",type
);
520 if(code
==NAK
){ bug("Nak\n"); }else
521 if(code
==REJECT
){ bug("Reject\n"); }else
522 bug("unknown code 0x%x\n",code
);
525 AddByte( &p
, type
>> 8 );
526 AddByte( &p
, type
& 0x00ff );
528 AddByte( &p
, num
); // number
529 AddByte( &p
, 0x00 ); // size
530 AddByte( &p
, 0x00 ); // <- data[5]
532 for( i
=0 ; i
<len
;i
++ ) AddByte( &p
, ptr
[i
] );
534 p
.data
[5] = p
.packetsize
- 2; // size
540 void Send_Ack(struct packet
*p
){
548 void IPCP_Packet(struct packet
* p
){
549 bug("\nIPCP_Packet size=%d\n",p
->packetsize
);
553 UBYTE
*ptr
= p
->data
+ 6 ;
556 switch ( p
->data
[2] ){
560 bug("ipcp Req Received\n");
563 while( (IPTR
)ptr
< (IPTR
)( p
->data
+ p
->packetsize
) ){
566 bug(" Type %d,len %d: ",type
,len
);
567 for( i
=0 ; i
< len
; i
++ ) bug("%x,",ptr
[i
]);bug("\n");
569 if( type
== 3 ){ // remote IP address
574 bug("remote IP address is %d.%d.%d.%d\n",RemoteIP
[0],RemoteIP
[1],
575 RemoteIP
[2],RemoteIP
[3]);
579 bug(" Unknown type %d ,send reject response...\n",type
);
580 Send_response( IPCP
, REJECT
, ptr
, len
, p
->data
[3] );
592 device_conf_ok
= TRUE
;
593 if( ( phase
== PPP_PHASE_PROTOCOL_CONF
) && my_conf_ok
){
594 Set_phase( PPP_PHASE_NETWORK
);
602 bug("IPCP Ack Received\n");
603 if( (LocalIP
[0] | LocalIP
[1] | LocalIP
[2] | LocalIP
[3]) == 0 ){
604 bug(" LocalIP still 0.0.0.0 -> Resend IPCP_req\n");
608 if( phase
== PPP_PHASE_PROTOCOL_CONF
&& device_conf_ok
){
609 Set_phase( PPP_PHASE_NETWORK
);
617 bug("ipcp Nak received\n");
620 while( (IPTR
)ptr
< (IPTR
)( p
->data
+ p
->packetsize
) ){
623 bug(" Type %d,len %d: ",type
,len
);
624 for( i
=0 ; i
< len
; i
++ ) bug("%x,",ptr
[i
]);bug("\n");
626 if( type
== 3 ){ // local IP address
631 bug("Local IP address is %d.%d.%d.%d\n",LocalIP
[0],LocalIP
[1],
632 LocalIP
[2],LocalIP
[3]);
634 }else if( type
== 129 ){ // PrimaryDNS address
635 PrimaryDNS
[0]=ptr
[2];
636 PrimaryDNS
[1]=ptr
[3];
637 PrimaryDNS
[2]=ptr
[4];
638 PrimaryDNS
[3]=ptr
[5];
639 bug("PrimaryDNS address is %d.%d.%d.%d\n",PrimaryDNS
[0],PrimaryDNS
[1],
640 PrimaryDNS
[2],PrimaryDNS
[3]);
641 }else if( type
== 131 ){ // SecondaryDNS address
642 SecondaryDNS
[0]=ptr
[2];
643 SecondaryDNS
[1]=ptr
[3];
644 SecondaryDNS
[2]=ptr
[4];
645 SecondaryDNS
[3]=ptr
[5];
646 bug("SecondaryDNS address is %d.%d.%d.%d\n",SecondaryDNS
[0],SecondaryDNS
[1],
647 SecondaryDNS
[2],SecondaryDNS
[3]);
650 bug(" Unknown type %d\n",type
);
661 bug("IPCP Reject received\n");
665 bug("unknow IPCP Received:%d\n",p
->data
[2]);
671 void Send_IPCP_req(){
673 bug("\nsend IPCP req\n");
680 AddByte( &p
, REQUEST
);
681 AddByte( &p
, ++number
);
683 AddByte( &p
, 0x00 ); //size
687 AddByte( &p
,LocalIP
[0] );
688 AddByte( &p
,LocalIP
[1] );
689 AddByte( &p
,LocalIP
[2] );
690 AddByte( &p
,LocalIP
[3] );
692 //if( ppp_libbase->enable_dns ){ // ask DNS addresses too...
695 AddByte( &p
, PrimaryDNS
[0] );
696 AddByte( &p
, PrimaryDNS
[1] );
697 AddByte( &p
, PrimaryDNS
[2] );
698 AddByte( &p
, PrimaryDNS
[3] );
702 AddByte( &p
, SecondaryDNS
[0] );
703 AddByte( &p
, SecondaryDNS
[1] );
704 AddByte( &p
, SecondaryDNS
[2] );
705 AddByte( &p
, SecondaryDNS
[3] );
707 p
.data
[5] = p
.packetsize
- 2; // size
715 void LCP_packet(struct packet
*p
){
717 bug("\nLCP packet size=%d\n",p
->packetsize
);
724 switch ( p
->data
[2] ){
727 bug("LCP Request Received\n");
732 while( (IPTR
)ptr
< (IPTR
)( p
->data
+ p
->packetsize
) ){
736 bug(" Type %d,len %d: ",type
,len
);
737 for( i
=0 ; i
< len
; i
++ ) bug("%x,",ptr
[i
]);bug("\n");
739 if( type
== 2 ){ // async control character map
740 async_map
= ( ptr
[2] << 24) | ( ptr
[3] << 16) | ( ptr
[4] << 8) | (ptr
[5] );
741 bug(" Async_map = %x\n",async_map
);
742 }else if( type
== 1 ){ // maximum receive unit
743 mru
= ( ptr
[2] << 8) | (ptr
[3] );
744 bug(" MRU = %d\n",mru
);
745 // if( mru !=1500 ){ // unlikely
748 // SendConfNak( ptr , len , p->data[3] );
754 else if( type
== 3 ){ // authentication
755 if( ptr
[2] == 0xc0 && ptr
[3] == 0x23 ){
756 bug(" Authentication = PAP\n");
757 authentication
= 0xc0;
759 ptr
[2] = 0xc0; // PAP
761 Send_response( LCP
, NAK
, ptr
, len
, p
->data
[3] );
766 ptr[2] = 0xc2; // CHAP md5
769 SendConfNak( ptr , 5 , p->data[3] );
777 bug(" Unknown type %d ,send reject response...\n",type
);
778 Send_response( LCP
, REJECT
, ptr
, len
, p
->data
[3] );
788 device_conf_ok
= TRUE
;
794 bug("LCP Ack Received !\n");
799 bug("LCP Nak Received HELP !\n");
803 bug("LCP Reject Received HELP !\n");
807 bug("LCP ECHO_REQUEST Received\n");
812 bug("LCP ECHO_REPLY Received\n");
815 case PROTOCOL_REJECT
:
816 bug("LCP Protocol-Reject ( %d bytes ) Received WTF!???????\n" , p
->packetsize
);
819 case TERMINATE_REQUEST
:
820 bug("LCP Terminate request Received :-(\n");
821 Set_phase( PPP_PHASE_DEAD
);
825 bug("LCP Terminate Act Received\n");
826 Set_phase( PPP_PHASE_DEAD
);
829 case DISCARD_REQUEST
:
830 bug("LCP Discard-Request Received ????\n");
834 bug("LCP Link-Quality Report Received ????\n");
838 bug("unknow lcp Received:%d\n",p
->data
[2]);
842 if( phase
== PPP_PHASE_CONFIGURATION
&&
843 my_conf_ok
&& device_conf_ok
845 Set_phase( PPP_PHASE_AUTHENTICATION
);
850 void SendEchoRequest(){
852 bug("\nsend ECHO_REQUEST\n");
854 AddByte( &p
, 0xc0 );//LPC
855 AddByte( &p
, 0x21 );
856 AddByte( &p
, ECHO_REQUEST
);
857 AddByte( &p
, ++number
); // number
858 AddByte( &p
, 0x00 ); // size
859 AddByte( &p
, 0x00 );
860 p
.data
[5] = p
.packetsize
- 2; // size
866 void SendEchoReply(struct packet
*p
){
867 bug("\nLCP Send Echo Reply \n");
868 p
->data
[2] = ECHO_REPLY
;
877 bug("\nsend LCP Req\n");
880 AddByte( &p
, 0xc0 );//LPC
881 AddByte( &p
, 0x21 );
883 AddByte( &p
, REQUEST
); // conf req
885 AddByte( &p
, ++number
); // number
887 AddByte( &p
, 0x00 ); // size
888 AddByte( &p
, 0x00 ); // <- data[5]
890 AddByte( &p , 0x01 ); // max receive unit 1500 (default)
891 AddByte( &p , 0x04 );
892 AddByte( &p , 0x05 );
893 AddByte( &p , 0xdc );
895 AddByte( &p
, 0x02 ); // async control char map 0000
896 AddByte( &p
, 0x06 );
897 AddByte( &p
, 0x00 );
898 AddByte( &p
, 0x00 );
899 AddByte( &p
, 0x00 );
900 AddByte( &p
, 0x00 );
902 p
.data
[5] = p
.packetsize
- 2; // size
910 void SendTerminateReq(){
913 bug("\nsend LCP Terminate request \n");
915 AddByte( &p
, 0xc0 );//LPC
916 AddByte( &p
, 0x21 );
918 AddByte( &p
, TERMINATE_REQUEST
); // terminate req
920 AddByte( &p
, ++number
); // number
922 AddByte( &p
, 0x00 ); // size
923 AddByte( &p
, 0x00 ); // <- data[5]
925 p
.data
[5] = p
.packetsize
- 2; // size
935 void send_IP_packet( BYTE
*data
,ULONG len
){
938 // bug( "Send IP packet:%d bytes\n" , len );
942 p
.header
[0] = 0x7e; // escaped header
947 AddByte( &p
, 0x00 ); // IP
948 AddByte( &p
, 0x21 );
950 AddBytes( &p
, data
, len
);
954 AddByte( &p
, 0x7e );
955 SendBYTES( ppp_libbase
->ser
, p
.header
, p
.packetsize
+ 4 );
960 void EscapePacket(struct packet
* p
){
964 for(i
=0;i
<p
->packetsize
;i
++){
965 dummy
.data
[i
]=p
->data
[i
];
967 dummy
.packetsize
=p
->packetsize
;
969 for(j
=0,i
=0;i
<dummy
.packetsize
;i
++,j
++){
971 if( j
>= MAXPSIZE
-1 ){
972 bug( "PPP ERROR: EscapePacket MAXPSIZE\n" );
977 if( dummy
.data
[i
] < 32 ){
978 if( async_map
& ( 1L << dummy
.data
[i
] ) ){
981 p
->data
[j
]=dummy
.data
[i
]^0x20;
983 p
->data
[j
]=dummy
.data
[i
];
988 if( dummy
.data
[i
] == 0x7e || dummy
.data
[i
]== 0x7d ){
991 p
->data
[j
]=dummy
.data
[i
]^0x20;
995 p
->data
[j
]=dummy
.data
[i
];
1001 void SendPPP_Packet(struct packet
* p
){
1003 // bug("SendPPP_Packet size=%d\n",p->packetsize);
1006 p
->header
[0] = 0x7e; // escaped header
1007 p
->header
[1] = 0xff;
1008 p
->header
[2] = 0x7d;
1009 p
->header
[3] = 0x23;
1012 AddByte( p
, 0x7e );// end mark
1014 DoBYTES( ppp_libbase
->ser
, p
->header
, p
->packetsize
+ 4 ); // 4 = header size