1 --- ppp-2.4.2/chat/Makefile.linux.vns 2004-05-28 12:11:22 +0400
2 +++ ppp-2.4.2/chat/Makefile.linux 2004-05-28 12:11:22 +0400
4 # $Id: Makefile.linux,v 1.10 2004/01/13 03:57:55 paulus Exp $
6 -CDEF1= -DTERMIOS # Use the termios structure
7 +#CDEF1= -DTERMIOS # Use the termios structure
8 CDEF2= -DSIGTYPE=void # Standard definition
9 CDEF3= -UNO_SLEEP # Use the usleep function
10 CDEF4= -DFNDELAY=O_NDELAY # Old name value
11 --- ppp-2.4.2/chat/chat.c.vns 2003-03-30 12:23:48 +0400
12 +++ ppp-2.4.2/chat/chat.c 2004-05-28 12:11:22 +0400
15 #if defined(get_term_param)
18 - if (get_term_param (&t) < 0)
19 - fatal(2, "Can't get terminal parameters: %m");
23 + ctl = get_term_param (&t);
25 + syslog(LOG_NOTICE, "Could not get FD: %s", strerror(errno));
26 + fatal(2, "Can't get terminal parameters: %m");
28 saved_tty_parameters = t;
29 have_tty_parameters = 1;
31 --- ppp-2.4.2/etc.ppp/callback-client.vns 2004-05-28 12:11:22 +0400
32 +++ ppp-2.4.2/etc.ppp/callback-client 2004-05-28 12:11:22 +0400
35 +# Script callback-client
36 +# Script parameters: delay time in seconds
40 +/usr/sbin/chat -v -t 2 "" \d+++\d\c OK ATH0 OK
42 +/usr/sbin/chat -v "" ATZ OK "" RING ATA CONNECT
43 --- ppp-2.4.2/etc.ppp/callback-server.vns 2004-05-28 12:11:22 +0400
44 +++ ppp-2.4.2/etc.ppp/callback-server 2004-05-28 12:11:22 +0400
47 +# Script callback-server
48 +# Script parameters: delay time in seconds, callback number
53 +/usr/sbin/chat -v -t 2 "" \d+++\d\c OK ATH0 OK
55 +/usr/sbin/chat -v "" ATZ OK ATD$NUMBER CONNECT
56 --- ppp-2.4.2/etc.ppp/callback-users.vns 2004-05-28 12:11:22 +0400
57 +++ ppp-2.4.2/etc.ppp/callback-users 2004-05-28 12:11:22 +0400
59 +# User list for callback
61 +# option - no callback
62 +# option * or empty user definied
63 +# option other admin definied: this number
64 +# in username * and ? wildcars valid, callback uses the best fit
66 +# zotyo 67435 # user zotyo admin definied, number 67453
67 +# gates - # gates not called back
69 \ ÷ ËÏÎÃÅ ÆÁÊÌÁ ÎÅÔ ÎÏ×ÏÊ ÓÔÒÏËÉ
70 --- ppp-2.4.2/pppd/auth.c.vns 2003-06-12 03:56:26 +0400
71 +++ ppp-2.4.2/pppd/auth.c 2004-05-28 12:11:22 +0400
74 /* Prototypes for procedures local to this file. */
76 -static void network_phase __P((int));
77 static void check_idle __P((void *));
78 static void connect_time_expired __P((void *));
79 static int plogin __P((char *, char *, char **));
82 * Proceed to the network phase.
86 +void network_phase(unit)
89 lcp_options *go = &lcp_gotoptions[unit];
92 * If we negotiated callback, do it now.
95 + if (((go->neg_cbcp) || (lcp_hisoptions[unit].neg_cbcp))
96 + && (phase != PHASE_CALLBACK)) {
97 new_phase(PHASE_CALLBACK);
98 (*cbcp_protent.open)(unit);
100 --- ppp-2.4.2/pppd/cbcp.c.vns 2003-01-31 14:11:17 +0300
101 +++ ppp-2.4.2/pppd/cbcp.c 2004-05-28 12:11:22 +0400
103 * cbcp - Call Back Configuration Protocol.
105 * Copyright (c) 1995 Pedro Roque Marques. All rights reserved.
106 + * Copyright (c) 2001 Bolke de Bruin
108 * Redistribution and use in source and binary forms, with or without
109 * modification, are permitted provided that the following conditions
112 #include <sys/types.h>
113 #include <sys/time.h>
115 +#include <sys/stat.h>
122 +#include "pathnames.h"
124 static const char rcsid[] = RCSID;
129 -static int setcbcp __P((char **));
131 -static option_t cbcp_option_list[] = {
132 - { "callback", o_special, (void *)setcbcp,
133 - "Ask for callback", OPT_PRIO | OPT_A2STRVAL, &cbcp[0].us_number },
138 * Protocol entry points.
150 /* internal prototypes */
152 +static void cbcp_sendreq __P((void *arg));
153 static void cbcp_recvreq __P((cbcp_state *us, u_char *pckt, int len));
154 -static void cbcp_resp __P((cbcp_state *us));
155 -static void cbcp_up __P((cbcp_state *us));
156 +static void cbcp_sendresp __P((cbcp_state *us));
157 +static void cbcp_recvresp __P((cbcp_state *us, char *pckt, int len));
158 +static void cbcp_sendack __P((void *));
159 static void cbcp_recvack __P((cbcp_state *us, u_char *pckt, int len));
160 static void cbcp_send __P((cbcp_state *us, int code, u_char *buf, int len));
161 +static void cbcp_make_options __P((int unit));
162 +static int cbcp_check_user __P((char *user, char *mask));
163 +static void cbcp_start_callback __P((cbcp_state *us));
164 +static void cbcp_up __P((cbcp_state *us));
166 -/* option processing */
171 - lcp_wantoptions[0].neg_cbcp = 1;
172 - cbcp_protent.enabled_flag = 1;
173 - cbcp[0].us_number = strdup(*argv);
174 - if (cbcp[0].us_number == 0)
175 - novm("callback number");
176 - cbcp[0].us_type |= (1 << CB_CONF_USER);
177 - cbcp[0].us_type |= (1 << CB_CONF_ADMIN);
180 +cbcp_state *stop_iface = NULL;
182 +void (*cbcp_init_hook) __P((cbcp_state *)) = NULL;
188 memset(us, 0, sizeof(cbcp_state));
190 - us->us_type |= (1 << CB_CONF_NO);
193 /* lower layer is up */
194 @@ -135,18 +122,19 @@
196 cbcp_state *us = &cbcp[iface];
198 - dbglog("cbcp_lowerup");
199 - dbglog("want: %d", us->us_type);
201 - if (us->us_type == CB_CONF_USER)
202 - dbglog("phone no: %s", us->us_number);
203 + CBCPDEBUG((LOG_DEBUG, "cbcp_lowerup"));
204 + CBCPDEBUG((LOG_DEBUG, "want: %d", us->us_type));
207 +/* CBCP indulhat: kliens oldal eseten nincs feladat,
208 + szerver oldalon atkuldeni a valszthato opciokat */
213 - dbglog("cbcp_open");
214 + CBCPDEBUG((LOG_DEBUG, "cbcp_open"));
215 + if (lcp_hisoptions[unit].neg_cbcp)
216 + cbcp_make_options(unit);
219 /* process an incomming packet */
220 @@ -161,11 +149,13 @@
223 cbcp_state *us = &cbcp[unit];
224 + lcp_options *go = &lcp_gotoptions[unit];
225 + lcp_options *his = &lcp_hisoptions[unit];
229 if (pktlen < CBCP_MINLEN) {
230 - error("CBCP packet is too small");
231 + syslog(LOG_ERR, "CBCP packet is too small");
239 - error("CBCP packet: invalid length");
240 + syslog(LOG_ERR, "CBCP packet: invalid length");
244 @@ -184,17 +174,36 @@
248 + if ( !go->neg_cbcp )
250 + syslog(LOG_ERR, "CBCP received CBCP_REQ, but CBCP running in server mode!");
254 cbcp_recvreq(us, inp, len);
258 - dbglog("CBCP_RESP received");
259 + if ( !his->neg_cbcp )
261 + syslog(LOG_ERR, "CBCP received CBCP_RESP, but CBCP running in client mode!");
264 + if (id != us->us_id)
265 + syslog(LOG_DEBUG, "id doesn't match: expected %d recv %d",
268 + cbcp_recvresp(us, inp, len);
272 + if ( !go->neg_cbcp )
274 + syslog(LOG_ERR, "CBCP received CBCP_ACK, but CBCP running in server mode!");
278 - dbglog("id doesn't match: expected %d recv %d",
279 + syslog(LOG_DEBUG, "id doesn't match: expected %d recv %d",
282 cbcp_recvack(us, inp, len);
283 @@ -274,13 +283,14 @@
284 printer(arg, " delay = %d", delay);
293 memcpy(str, p, olen - 4);
296 printer(arg, " number = %s", str);
299 @@ -306,41 +316,40 @@
303 - u_char type, opt_len, delay, addr_type;
304 + u_char type, opt_len, addr_type;
311 - dbglog("length: %d", len);
314 GETCHAR(opt_len, pckt);
318 - GETCHAR(delay, pckt);
319 + GETCHAR(us->us_delay, pckt);
321 us->us_allowed |= (1 << type);
325 - dbglog("no callback allowed");
326 + CBCPDEBUG((LOG_DEBUG, "no callback allowed"));
330 - dbglog("user callback allowed");
331 + CBCPDEBUG((LOG_DEBUG, "user callback allowed"));
333 GETCHAR(addr_type, pckt);
334 memcpy(address, pckt, opt_len - 4);
335 address[opt_len - 4] = 0;
337 - dbglog("address: %s", address);
338 + CBCPDEBUG((LOG_DEBUG, "address: %s", address));
343 - dbglog("user admin defined allowed");
344 + CBCPDEBUG((LOG_DEBUG, "user admin defined allowed"));
348 @@ -349,59 +358,63 @@
367 - cb_type = us->us_allowed & us->us_type;
368 - dbglog("cbcp_resp cb_type=%d", cb_type);
369 + cb_allowed = us->us_allowed;
370 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendresp: available options: %d", cb_allowed));
375 lcp_down(us->us_unit);
378 - if (cb_type & ( 1 << CB_CONF_USER ) ) {
379 - dbglog("cbcp_resp CONF_USER");
380 + if (cb_allowed & ( 1 << CB_CONF_USER ) ) { /* The best metod :-) */
381 + us->us_type= ( 1 << CB_CONF_USER );
382 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendresp CONF_USER"));
383 PUTCHAR(CB_CONF_USER, bufp);
384 len = 3 + 1 + strlen(us->us_number) + 1;
385 - PUTCHAR(len , bufp);
386 - PUTCHAR(5, bufp); /* delay */
387 + PUTCHAR(len, bufp);
388 + PUTCHAR(us->us_delay, bufp);
390 BCOPY(us->us_number, bufp, strlen(us->us_number) + 1);
391 cbcp_send(us, CBCP_RESP, buf, len);
395 - if (cb_type & ( 1 << CB_CONF_ADMIN ) ) {
396 - dbglog("cbcp_resp CONF_ADMIN");
397 + if (cb_allowed & ( 1 << CB_CONF_ADMIN ) ) {
398 + us->us_type= ( 1 << CB_CONF_ADMIN );
399 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendresp CONF_ADMIN"));
400 PUTCHAR(CB_CONF_ADMIN, bufp);
403 - PUTCHAR(5, bufp); /* delay */
404 + PUTCHAR(us->us_delay, bufp);
405 cbcp_send(us, CBCP_RESP, buf, len);
409 - if (cb_type & ( 1 << CB_CONF_NO ) ) {
410 - dbglog("cbcp_resp CONF_NO");
411 + if (cb_allowed & ( 1 << CB_CONF_NO ) ) {
412 + us->us_type= ( 1 << CB_CONF_NO );
413 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendresp CONF_NO"));
414 PUTCHAR(CB_CONF_NO, bufp);
417 cbcp_send(us, CBCP_RESP, buf, len);
418 - start_networks(us->us_unit);
421 + syslog(LOG_WARNING, "cbcp_sendresp: no usable options available!");
424 +/* Send the packet */
426 cbcp_send(us, code, buf, len)
428 @@ -428,38 +441,339 @@
429 output(us->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
434 cbcp_recvack(us, pckt, len)
439 - u_char type, delay, addr_type;
440 + u_char type, addr_type;
448 GETCHAR(opt_len, pckt);
451 - GETCHAR(delay, pckt);
452 + GETCHAR(us->us_delay, pckt);
455 GETCHAR(addr_type, pckt);
456 memcpy(address, pckt, opt_len - 4);
457 address[opt_len - 4] = 0;
459 - dbglog("peer will call: %s", address);
460 + CBCPDEBUG((LOG_DEBUG, "peer will call: %s", address));
462 - if (type == CB_CONF_NO)
464 + if (type != CB_CONF_NO)
466 + callback_in_progress = us->us_unit + 1;
467 + callback_in_progress |= CBCP_CLIENT;
471 + network_phase(us->us_unit);
474 + syslog(LOG_DEBUG, "cbcp: received bad ack - packet too small");
480 + if auth req, options from callback-users file, else use CBCP_CONF_USER */
482 +cbcp_make_options (unit)
485 + cbcp_state *us = &cbcp[unit];
488 + int best_fit, got_fit, newline;
489 + char uname[ 256 ], option[ 256 ];
493 + us->us_delay = 5; /* Default delay 5 seconds */
494 + if ( *peer_authname ) { /* Username available */
495 + userfile = fopen( _PATH_CBCP_USERS, "r" );
496 + if ( userfile == NULL ){
497 + syslog( LOG_ERR, "Can't open callback user file: %s %m",
498 + _PATH_CBCP_USERS );
499 + syslog( LOG_WARNING, "Allow user definied callback." );
500 + us->us_allowed = ( 1 << CB_CONF_USER );
503 + if ( fstat(fileno(userfile), &sbuf) < 0) {
504 + syslog(LOG_WARNING, "Cannot stat userfile file %s: %m",
505 + _PATH_CBCP_USERS );
506 + } else if ((sbuf.st_mode & (S_IRWXG | S_IRWXO)) != 0) {
507 + syslog(LOG_WARNING, "Warning - user file %s has world and/or group access",
508 + _PATH_CBCP_USERS );
511 + us->us_allowed = ( 1 << CB_CONF_NO ); /* Assume, no callback allowed */
513 + if (getword(userfile, uname, &newline, _PATH_CBCP_USERS)){ /* file not empty */
519 + * Skip until we find a word at the start of a line.
521 + while (!newline && getword(userfile, uname,
522 + &newline, _PATH_CBCP_USERS))
525 + break; /* got to end of file */
528 + * Got a user - check if it's a match or a wildcard.
530 + got_fit = cbcp_check_user( peer_authname, uname );
531 + if ( got_fit <= best_fit ){
536 + /* Read the options */
537 + best_fit = got_fit;
538 + if (getword(userfile, option, &newline, _PATH_CBCP_USERS))
544 + if ( best_fit == 100 )
549 + switch ( *option ){
550 + case '-' : us->us_allowed = ( 1 << CB_CONF_NO ); break;
552 + case 0 : us->us_allowed = ( 1 << CB_CONF_USER ); break;
553 + default : us->us_allowed = ( 1 << CB_CONF_ADMIN );
554 + us->us_number = strdup( option ); break;
556 + fclose( userfile );
560 + us->us_allowed = ( 1 << CB_CONF_USER );
562 + if (cbcp_init_hook)
563 + cbcp_init_hook( us );
565 + cbcp_sendreq( us );
569 +/* make cbcp request packet & send it */
574 + cbcp_state *us=(cbcp_state *)arg;
575 + u_char cb_allow = us->us_allowed;
577 + u_char *bufp = buf;
581 + if (us->us_count<=CBCP_MAXRETRY)
582 + TIMEOUT( cbcp_sendreq, arg, CBCP_DEFTIMEOUT );
585 + lcp_close(0, "Sorry, CBCP not responding.");
588 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendreq cb_allowed=%d", cb_allow));
591 + if (cb_allow & ( 1 << CB_CONF_USER ) ) {
592 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendreq CONF_USER"));
593 + PUTCHAR(CB_CONF_USER, bufp);
596 + PUTCHAR(us->us_delay, bufp);
599 + if (cb_allow & ( 1 << CB_CONF_ADMIN ) ) {
600 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendreq CONF_ADMIN"));
601 + PUTCHAR(CB_CONF_ADMIN, bufp);
604 + PUTCHAR(us->us_delay, bufp);
607 + if (cb_allow & ( 1 << CB_CONF_NO ) ) {
608 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendreq CONF_NO"));
609 + PUTCHAR(CB_CONF_NO, bufp);
612 + PUTCHAR(us->us_delay, bufp);
616 + cbcp_send(us, CBCP_REQ, buf, len);
619 + syslog(LOG_WARNING, "cbcp: no available options to client!");
623 +/* Received CBCP response, make ACK */
625 +cbcp_recvresp (us, pckt, len)
630 + u_char type, addr_type;
635 + GETCHAR(type, pckt);
636 + GETCHAR(opt_len, pckt);
638 + if (!(( 1 << type )& us->us_allowed )) {
639 + CBCPDEBUG((LOG_DEBUG, "CBCP received options not allowed on server!"));
643 + if ((type!= CB_CONF_NO ) &&
644 + (type!= CB_CONF_USER ) &&
645 + (type!= CB_CONF_ADMIN )) {
646 + syslog(LOG_DEBUG, "CBCP received BAD Response: too more or unknown options %d",type);
650 + UNTIMEOUT( cbcp_sendreq, us );
655 + GETCHAR(us->us_delay, pckt)
656 + if ( us->us_delay < 5 )
660 + GETCHAR(addr_type, pckt); /* Address Type mezo elvesztve !!! */
661 + memcpy(address, pckt, opt_len - 4);
662 + address[opt_len - 4] = 0;
664 + syslog(LOG_DEBUG, "peer will callback the client on: %s", address);
665 + us->us_number=strdup( address );
668 + us->us_type = ( 1 << type );
669 + cbcp_sendack( us );
673 + syslog(LOG_DEBUG, "CBCP received BAD Response: size to small");
677 +/* Send the CBCP_ACK packet */
682 + cbcp_state *us= (cbcp_state *)arg;
685 + u_char *bufp = buf;
688 + stop_iface = (cbcp_state *)arg;
689 + cb_type = us->us_type;
691 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendack cb_type=%d", cb_type));
694 + if (us->us_count<=CBCP_MAXRETRY)
695 + TIMEOUT( cbcp_sendack, arg, CBCP_DEFTIMEOUT );
698 + lcp_close(0, "Sorry, CBCP not responding.");
704 + lcp_down(us->us_unit);
707 + if (cb_type == (1 << CB_CONF_USER )) {
708 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendack CONF_USER"));
709 + PUTCHAR(CB_CONF_USER, bufp);
710 + len = 3 + 1 + strlen(us->us_number) + 1;
711 + PUTCHAR(len , bufp);
712 + PUTCHAR(us->us_delay, bufp); /* delay */
713 + PUTCHAR(1, bufp); /* Elvesztett byte... */
714 + BCOPY(us->us_number, bufp, strlen(us->us_number) + 1);
715 + cbcp_send(us, CBCP_ACK, buf, len);
716 +/* lcp_close( 2, "Illegal, but required to server..." ); */
717 + callback_in_progress = us->us_unit + 1;
721 + if (cb_type == (1 << CB_CONF_ADMIN )) {
722 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendack CONF_ADMIN"));
723 + PUTCHAR(CB_CONF_ADMIN, bufp);
725 + PUTCHAR(len , bufp);
726 + PUTCHAR(us->us_delay, bufp); /* delay */
728 + cbcp_send(us, CBCP_ACK, buf, len);
729 +/* lcp_close( 2, "Illegal, but required to server..." ); */
730 + callback_in_progress = us->us_unit + 1;
734 + if (cb_type == (1 << CB_CONF_NO )) {
735 + CBCPDEBUG((LOG_DEBUG, "cbcp_sendack CONF_NO"));
736 + PUTCHAR(CB_CONF_NO, bufp);
738 + PUTCHAR(len , bufp);
740 + cbcp_send(us, CBCP_ACK, buf, len);
741 + if (us->us_count<=1)
742 + network_phase(us->us_unit);
746 + syslog(LOG_DEBUG, "CBCP - Bad options in Ack routine.");
751 -/* ok peer will do callback */
752 +/* CBCP coming succesful up */
755 + if ( stop_iface && lcp_allowoptions[stop_iface->us_unit].neg_cbcp )
757 + UNTIMEOUT( cbcp_sendack, stop_iface );
758 + cbcp_start_callback( stop_iface );
762 +/* The server side coming up & client 'ack-ed' */
763 +void cbcp_start_callback (us)
766 + lcp_allowoptions[us->us_unit].neg_cbcp=0;
768 + CBCPDEBUG((LOG_DEBUG, "cbcp_start_callback running"));
771 +/* The client side coming up: server allowed the callback */
777 lcp_close(0, "Call me back, please");
778 status = EXIT_CALLBACK;
779 + lcp_wantoptions[us->us_unit].neg_cbcp=0;
780 + CBCPDEBUG((LOG_DEBUG, "cbcp_up called"));
781 + lcp_close(us->us_unit, "Call me back, please");
784 +/* The main module gets the script with parameters to run */
785 +char *cbcp_get_script()
787 + cbcp_state *us = &cbcp[(callback_in_progress & CBCP_NCLIENT)-1];
788 + char script[ 256 ];
790 + if ( callback_in_progress & CBCP_CLIENT )
791 + sprintf( script, "%s %d", _PATH_CBCP_CLIENT, us->us_delay );
793 + sprintf( script, "%s %d %s", _PATH_CBCP_SERVER,
794 + us->us_delay, us->us_number );
796 + return strdup( script );
799 +/* give me the hit rate. wild cars '*?' valids */
800 +int cbcp_check_user ( user, mask )
804 + char *curr_user = user;
805 + char *curr_mask = mask;
806 + char *find, backp = 0;
807 + int count, len = 0;
809 + if ( !strcasecmp( user, mask ))
812 + if ( !strcmp( mask, "*" ))
820 + while(( find = strpbrk( curr_mask, "*?" )) != 0 ) {
821 + if ( find != curr_mask ){
822 + len = find - curr_mask;
823 + if ( strncmp( curr_user, curr_mask, len ))
827 + curr_mask += len + 1;
830 + if ( *curr_user == 0 )
833 + if ( *find == '?' ) {
835 + if ( *curr_user == 0 )
838 + if ( *curr_mask == 0 )
841 + if ( ( find = strpbrk( curr_mask, "*?" )) != 0 ){
845 + curr_user = strstr( curr_user, curr_mask );
851 + find = strpbrk( curr_mask, "*?" );
853 + len = find - curr_mask;
855 + len = strlen( curr_mask );
863 + if ( *curr_user && *curr_mask && !strcmp( curr_user, curr_mask ))
864 + count += strlen( curr_user );
866 + return ( count * 100 / strlen( user ) );
869 --- ppp-2.4.2/pppd/cbcp.h.vns 1998-11-07 09:55:38 +0300
870 +++ ppp-2.4.2/pppd/cbcp.h 2004-05-28 12:11:22 +0400
872 u_char us_id; /* Current id */
877 char *us_number; /* Telefone Number */
884 +#define CBCP_DEFTIMEOUT 5
885 +#define CBCP_MAXRETRY 50
886 +#define CBCP_CLIENT 0x8000
887 +#define CBCP_NCLIENT 0x7fff
889 +#define CBCPDEBUG(x) /*if (debug)*/ syslog x
892 #define CB_CONF_USER 2
893 #define CB_CONF_ADMIN 3
894 #define CB_CONF_LIST 4
896 +char *cbcp_get_script __P(());
897 +void cbcp_stop __P(());
900 --- ppp-2.4.2/pppd/ipcp.c.vns 2004-05-28 12:11:22 +0400
901 +++ ppp-2.4.2/pppd/ipcp.c 2004-05-28 12:11:22 +0400
904 #include "pathnames.h"
910 static const char rcsid[] = RCSID;
913 @@ -1320,6 +1324,9 @@
914 u_char maxslotindex, cflag;
921 * Reset all his options.
923 --- ppp-2.4.2/pppd/ipv6cp.c.vns 2004-01-13 06:59:37 +0300
924 +++ ppp-2.4.2/pppd/ipv6cp.c 2004-05-28 12:11:22 +0400
927 #include "pathnames.h"
933 static const char rcsid[] = RCSID;
937 u_char *ucp = inp; /* Pointer to current output char */
938 int l = *len; /* Length left */
945 * Reset all his options.
947 --- ppp-2.4.2/pppd/ipxcp.c.vns 2003-11-18 13:42:56 +0300
948 +++ ppp-2.4.2/pppd/ipxcp.c 2004-05-28 12:11:22 +0400
950 #include "pathnames.h"
957 static const char rcsid[] = RCSID;
960 @@ -998,6 +1002,10 @@
961 u_char *ucp = inp; /* Pointer to current output char */
962 int l = *len; /* Length left */
969 * Reset all his options.
971 --- ppp-2.4.2/pppd/lcp.c.vns 2003-11-18 13:42:56 +0300
972 +++ ppp-2.4.2/pppd/lcp.c 2004-05-28 12:11:22 +0400
974 ao->neg_magicnumber = 1;
975 ao->neg_pcompression = 1;
976 ao->neg_accompression = 1;
981 ao->neg_endpoint = 1;
984 @@ -1769,6 +1767,16 @@
985 ho->neg_accompression = 1;
989 + LCPDEBUG((LOG_INFO, "lcp_reqci: rcvd CALLBACK"));
990 + if (!ao->neg_cbcp ||
991 + cilen != CILEN_CHAR ) {
999 if (!ao->neg_mrru || !multilink ||
1000 cilen != CILEN_SHORT) {
1001 --- ppp-2.4.2/pppd/main.c.vns 2004-01-13 07:00:34 +0300
1002 +++ ppp-2.4.2/pppd/main.c 2004-05-28 12:11:22 +0400
1003 @@ -156,6 +156,10 @@
1004 char **script_env; /* Env. variable values for scripts */
1005 int s_env_nalloc; /* # words avail at script_env */
1007 +#ifdef CBCP_SUPPORT
1008 +int callback_in_progress; /* Callback running */
1011 u_char outpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for outgoing packet */
1012 u_char inpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for incoming packet */
1014 @@ -276,6 +280,10 @@
1018 +#ifdef CBCP_SUPPORT
1022 struct protent *protp;
1025 @@ -540,6 +548,10 @@
1028 lcp_open(0); /* Start protocol */
1029 +#ifdef CBCP_SUPPORT
1030 + for(callback_in_progress=1;callback_in_progress;){
1031 + callback_in_progress=0;
1033 status = EXIT_NEGOTIATION_FAILED;
1034 new_phase(PHASE_ESTABLISH);
1035 while (phase != PHASE_DEAD) {
1036 @@ -568,7 +580,75 @@
1037 warn("unable to delete pid file %s: %m", pidfilename);
1040 +#ifdef CBCP_SUPPORT
1041 + if (callback_in_progress){
1044 + remove_fd(fd_ppp);
1046 + the_channel->disestablish_ppp(devfd);
1053 + setup_serial(connector);
1057 + devfd = callback();
1059 + /* set up the serial device as a ppp interface */
1060 + tdb_writelock(pppdb);
1061 + fd_ppp = the_channel->establish_ppp(devfd);
1063 + tdb_writeunlock(pppdb);
1064 + status = EXIT_FATAL_ERROR;
1068 + if (!demand && ifunit >= 0)
1070 + tdb_writeunlock(pppdb);
1073 + * Start opening the connection and wait for
1074 + * incoming events (reply, timeout, etc.).
1076 + notice("Connect: %s <--> %s", ifname, ppp_devnam);
1077 + gettimeofday(&start_time, NULL);
1078 + link_stats_valid = 0;
1079 + script_unsetenv("CONNECT_TIME");
1080 + script_unsetenv("BYTES_SENT");
1081 + script_unsetenv("BYTES_RCVD");
1085 + * If we are initiating this connection, wait for a short
1086 + * time for something from the peer. This can avoid bouncing
1087 + * our packets off his tty before he has it set up.
1090 + if (listen_time != 0) {
1092 + t.tv_sec = listen_time / 1000;
1093 + t.tv_usec = listen_time % 1000;
1097 + /*if (connector != NULL || ptycommand != NULL) {
1104 + lcp_open(0); /* Start protocol */
1110 * If we may want to bring the link up again, transfer
1111 * the ppp unit back to the loopback. Set the
1112 --- ppp-2.4.2/pppd/options.c.vns 2004-01-13 07:02:07 +0300
1113 +++ ppp-2.4.2/pppd/options.c 2004-05-28 12:11:22 +0400
1115 char *strdup __P((char *));
1118 +#ifdef CBCP_SUPPORT
1124 static const char rcsid[] = RCSID;
1126 struct option_value {
1127 @@ -162,6 +168,10 @@
1128 static int n_arguments __P((option_t *));
1129 static int number_option __P((char *, u_int32_t *, int));
1131 +#ifdef CBCP_SUPPORT
1132 +static int setcbcp __P((char **));
1136 * Structure to store extra lists of options.
1138 @@ -309,6 +319,11 @@
1139 "Check for traffic limit every N seconds", OPT_PRIO | OPT_LLIMIT | 1 },
1142 +#ifdef CBCP_SUPPORT
1143 + { "callback", o_special, setcbcp,
1144 + "Callback request to server - OR - calling back the client" },
1150 @@ -1586,3 +1601,23 @@
1155 +#ifdef CBCP_SUPPORT
1160 + cbcp[0].us_number = strdup(*argv);
1161 + if (cbcp_protent.enabled_flag)
1162 + novm("Only one callback parameter supported!");
1163 + if (cbcp[0].us_number == 0)
1164 + novm("callback number");
1165 + if (!strcmp(cbcp[0].us_number,"server")){
1166 + lcp_allowoptions[0].neg_cbcp = 1;
1168 + lcp_wantoptions[0].neg_cbcp = 1;
1170 + cbcp_protent.enabled_flag = 1;
1174 --- ppp-2.4.2/pppd/pathnames.h.vns 2002-11-09 14:24:42 +0300
1175 +++ ppp-2.4.2/pppd/pathnames.h 2004-05-28 12:11:22 +0400
1177 #define _PATH_IPXDOWN _ROOT_PATH "/etc/ppp/ipx-down"
1178 #endif /* IPX_CHANGE */
1180 +#ifdef CBCP_SUPPORT
1181 +#define _PATH_CBCP_SERVER _ROOT_PATH "/etc/ppp/callback-server"
1182 +#define _PATH_CBCP_CLIENT _ROOT_PATH "/etc/ppp/callback-client"
1183 +#define _PATH_CBCP_USERS _ROOT_PATH "/etc/ppp/callback-users"
1184 +#define _PATH_CBCP _ROOT_PATH "/etc/ppp/callback"
1185 +#endif /* CBCP_SUPPORT */
1188 #define _PATH_PPPDB _ROOT_PATH _PATH_VARRUN "pppd.tdb"
1189 #else /* __STDC__ */
1190 --- ppp-2.4.2/pppd/pppd.8.vns 2004-01-15 08:09:00 +0300
1191 +++ ppp-2.4.2/pppd/pppd.8 2004-05-28 12:11:22 +0400
1193 or include .. as a pathname component. The format of the options file
1196 +.B callback \fIserver/number
1197 +When compiled with the CBCP extensions (-DCBCP_SUPPORT) the ppp daemon
1198 +can act as a client to servers which provide CBCP-protocol callback
1199 +negotiation or act as a \fIserver. It reads its options from
1200 +/etc/ppp/callback-users and invokes /etc/ppp/callback-server
1201 +when dialing out. Otherwise it will invoke /etc/ppp/callback-client
1202 +to wait for a call.
1204 .B connect \fIscript
1205 Usually there is something which needs to be done to prepare the link
1206 before the PPP protocol can be started; for instance, with a dial-up
1207 --- ppp-2.4.2/pppd/pppd.h.vns 2003-04-07 04:01:46 +0400
1208 +++ ppp-2.4.2/pppd/pppd.h 2004-05-28 12:11:22 +0400
1213 +/* for cbcp_init_hook */
1219 @@ -331,6 +334,10 @@
1220 extern struct bpf_program active_filter; /* Filter for link-active pkts */
1223 +#ifdef CBCP_SUPPORT
1224 +extern int callback_in_progress; /*Callback running*/
1228 extern bool ms_lanman; /* Use LanMan password instead of NT */
1229 /* Has meaning only with MS-CHAP challenges */
1232 /* Procedures exported from tty.c. */
1233 void tty_init __P((void));
1234 +void setup_serial __P((char *));
1235 +int callback __P ((void));
1237 /* Procedures exported from utils.c. */
1238 void log_packet __P((u_char *, int, char *, int));
1240 /* read a complete buffer */
1242 /* Procedures exported from auth.c */
1243 +void network_phase __P((int)); /* the dataexchanger CP-s goung up */
1244 void link_required __P((int)); /* we are starting to use the link */
1245 void link_terminated __P((int)); /* we are finished with the link */
1246 void link_down __P((int)); /* the LCP layer has left the Opened state */
1248 extern void (*ip_up_hook) __P((void));
1249 extern void (*ip_down_hook) __P((void));
1250 extern void (*ip_choose_hook) __P((u_int32_t *));
1251 +extern void (*cbcp_init_hook) __P((cbcp_state *));
1253 extern int (*chap_check_hook) __P((void));
1254 extern int (*chap_passwd_hook) __P((char *user, char *passwd));
1255 --- ppp-2.4.2/pppd/tty.c.vns 2004-01-13 07:17:59 +0300
1256 +++ ppp-2.4.2/pppd/tty.c 2004-05-28 12:15:32 +0400
1261 +#ifdef CBCP_SUPPORT
1263 +#endif /* CBCP_SUPPORT */
1265 void tty_process_extra_options __P((void));
1266 void tty_check_options __P((void));
1268 static int ttyfd; /* Serial port file descriptor */
1269 static char speed_str[16]; /* Serial port speed as string */
1271 +/*static void setup_serial __P();*/
1273 mode_t tty_mode = (mode_t)-1; /* Original access permissions to tty */
1274 int baud_rate; /* Actual bits/second for serial device */
1275 char *callback_script; /* script for doing callback */
1276 @@ -511,10 +516,10 @@
1281 - struct stat statbuf;
1284 + connector = doing_callback? callback_script: connect_script;
1287 * Get a pty master/slave pair if the pty, notty, socket,
1288 * or record options were specified.
1289 @@ -542,72 +547,7 @@
1294 - * Open the serial device and set it up to be the ppp interface.
1295 - * First we open it in non-blocking mode so we can set the
1296 - * various termios flags appropriately. If we aren't dialling
1297 - * out and we want to use the modem lines, we reopen it later
1298 - * in order to wait for the carrier detect signal from the modem.
1302 - connector = doing_callback? callback_script: connect_script;
1303 - if (devnam[0] != 0) {
1305 - /* If the user specified the device name, become the
1306 - user before opening it. */
1309 - prio = privopen? OPRIO_ROOT: tty_options[0].priority;
1310 - if (prio < OPRIO_ROOT)
1312 - ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
1314 - if (prio < OPRIO_ROOT)
1319 - if (err != EINTR) {
1320 - error("Failed to open %s: %m", devnam);
1321 - status = EXIT_OPEN_FAILED;
1323 - if (!persist || err != EINTR)
1326 - real_ttyfd = ttyfd;
1327 - if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
1328 - || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
1329 - warn("Couldn't reset non-blocking mode on device: %m");
1333 - * Linux 2.4 and above blocks normal writes to the tty
1334 - * when it is in PPP line discipline, so this isn't needed.
1337 - * Do the equivalent of `mesg n' to stop broadcast messages.
1339 - if (fstat(ttyfd, &statbuf) < 0
1340 - || fchmod(ttyfd, statbuf.st_mode & ~(S_IWGRP | S_IWOTH)) < 0) {
1341 - warn("Couldn't restrict write permissions to %s: %m", devnam);
1343 - tty_mode = statbuf.st_mode;
1344 -#endif /* __linux__ */
1347 - * Set line speed, flow control, etc.
1348 - * If we have a non-null connection or initializer script,
1349 - * on most systems we set CLOCAL for now so that we can talk
1350 - * to the modem before carrier comes up. But this has the
1351 - * side effect that we might miss it if CD drops before we
1352 - * get to clear CLOCAL below. On systems where we can talk
1353 - * successfully to the modem with CLOCAL clear and CD down,
1354 - * we could clear CLOCAL at this point.
1356 - set_up_tty(ttyfd, ((connector != NULL && connector[0] != 0)
1357 - || initializer != NULL));
1359 + setup_serial(connector);
1362 * If the pty, socket, notty and/or record option was specified,
1363 @@ -736,6 +676,113 @@
1367 +void setup_serial(char *connector)
1370 + struct stat statbuf;
1373 + * Open the serial device and set it up to be the ppp interface.
1374 + * First we open it in non-blocking mode so we can set the
1375 + * various termios flags appropriately. If we aren't dialling
1376 + * out and we want to use the modem lines, we reopen it later
1377 + * in order to wait for the carrier detect signal from the modem.
1381 + connector = doing_callback? callback_script: connect_script;
1382 + if (devnam[0] != 0) {
1384 + /* If the user specified the device name, become the
1385 + user before opening it. */
1388 + prio = privopen? OPRIO_ROOT: tty_options[0].priority;
1389 + if (prio < OPRIO_ROOT)
1391 + ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
1393 + if (prio < OPRIO_ROOT)
1398 + if (err != EINTR) {
1399 + error("Failed to open %s: %m", devnam);
1400 + status = EXIT_OPEN_FAILED;
1402 + if (!persist || err != EINTR)
1405 + real_ttyfd = ttyfd;
1406 + if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
1407 + || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
1408 + warn("Couldn't reset non-blocking mode on device: %m");
1411 + * Do the equivalent of `mesg n' to stop broadcast messages.
1413 + if (fstat(ttyfd, &statbuf) < 0
1414 + || fchmod(ttyfd, statbuf.st_mode & ~(S_IWGRP | S_IWOTH)) < 0) {
1415 + warn("Couldn't restrict write permissions to %s: %m", devnam);
1417 + tty_mode = statbuf.st_mode;
1420 + * Set line speed, flow control, etc.
1421 + * If we have a non-null connection or initializer script,
1422 + * on most systems we set CLOCAL for now so that we can talk
1423 + * to the modem before carrier comes up. But this has the
1424 + * side effect that we might miss it if CD drops before we
1425 + * get to clear CLOCAL below. On systems where we can talk
1426 + * successfully to the modem with CLOCAL clear and CD down,
1427 + * we could clear CLOCAL at this point.
1429 + set_up_tty(ttyfd, ((connector != NULL && connector[0] != 0)
1430 + || initializer != NULL));
1434 +#ifdef CBCP_SUPPORT
1440 + cbcp_protent.enabled_flag = 0; /* Already not need */
1441 + s = cbcp_get_script();
1442 + syslog(LOG_INFO, "Callback with <%s>",s );
1444 + set_up_tty( ttyfd, 1 );
1446 + if (real_ttyfd != -1) {
1447 + if (!default_device && modem) {
1448 + setdtr(real_ttyfd, 0); /* in case modem is off hook */
1450 + setdtr(real_ttyfd, 1);
1454 + /* syslog(LOG_INFO, "ttyfd is %d and hungup is %d",ttyfd,hungup ); */
1455 + if (device_script(s, ttyfd, ttyfd, 0) < 0) {
1456 + error("Callback script failed");
1457 + status = EXIT_INIT_FAILED;
1458 + setdtr(ttyfd, 0 );
1462 + info("Serial connection established." );
1464 + if (real_ttyfd != -1)
1465 + set_up_tty( real_ttyfd, 0 );
1467 + slprintf(numbuf, sizeof(numbuf), "%d", baud_rate);
1468 + script_setenv("SPEED", numbuf, 1);
1473 +#endif /* CBCP Support */
1475 void disconnect_tty()