summaryrefslogtreecommitdiffstats
path: root/cpukit/pppd
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2001-10-12 13:43:05 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2001-10-12 13:43:05 +0000
commitaee474b0cf18922c8b21ca56aae4067835c6a860 (patch)
tree47e06016a77cfa961e90b3255fbfcda9a8837f58 /cpukit/pppd
parent2001-10-11 Alexandra Kossovsky <sasha@oktet.ru> (diff)
downloadrtems-aee474b0cf18922c8b21ca56aae4067835c6a860.tar.bz2
2001-10-12 Mike Siers <mikes@poliac.com>
* Update to stable working state. Congratulations Mike! :) * modem_example: Directory removed. * modem_example/16550.h, modem_example/README, modem_example/modem.c, modem_example/modem.h, modem_example/ppp.c, modem_example/ppp.h, modem_example/pppcompress.c: Files removed. * pppd/example/pppd.options: New file. * pppd/README, pppd/STATUS, pppd/cbcp.c, pppd/cbcp.h, pppd/chat.c, pppd/pppd.h, pppd/rtemsmain.c: Updated.
Diffstat (limited to 'cpukit/pppd')
-rw-r--r--cpukit/pppd/README4
-rw-r--r--cpukit/pppd/STATUS61
-rw-r--r--cpukit/pppd/cbcp.c456
-rw-r--r--cpukit/pppd/cbcp.h26
-rw-r--r--cpukit/pppd/chat.c416
-rw-r--r--cpukit/pppd/example/README7
-rw-r--r--cpukit/pppd/example/pppd.options9
-rw-r--r--cpukit/pppd/pppd.h2
-rw-r--r--cpukit/pppd/rtemsmain.c10
9 files changed, 683 insertions, 308 deletions
diff --git a/cpukit/pppd/README b/cpukit/pppd/README
index 0615100344..7481988d83 100644
--- a/cpukit/pppd/README
+++ b/cpukit/pppd/README
@@ -16,5 +16,9 @@ provided the modem driver as well.
The port was updated to 2.3.11 by Mike Siers <mikes@poliac.com>
who added an example test.
+
+Updated the chat program to return the correct errors and support
+the ABORT commands. Removed some dead code and did a lot of
+testing on a new Coldfire BSP. Version seems to be very stable.
=================================================================
diff --git a/cpukit/pppd/STATUS b/cpukit/pppd/STATUS
index 72aa80d792..ddb70c4b58 100644
--- a/cpukit/pppd/STATUS
+++ b/cpukit/pppd/STATUS
@@ -2,39 +2,28 @@
# $Id$
#
-
-Notes from Mike Siers <mikes@poliac.com>
-========================================
-
-I know that several users have tried out this version of
-pppd under RTEMS. It has been successfully used as both
-a client and server. Below are the only issues that I
-know of.
-
-1) Large packet ping causes RTEMS box to lock up
- If you ping the RTEMS box over the ppp link with a packet
- size greater than 1500, the RTEMS box locks up. I think
- the problem is in the pppd ethernet driver.
-
-2) Upgrade the libnetworking/modem files
- This upgrade did not modify the ppp ethernet driver files
- in the libnetworking/modem directory. Would like to
- upgrade these files. Hopefully, it will fix the large
- packet ping problem.
-
-3) The files cbcp.c and cbcp.h provide a callback feature
- that I have not tried to compile or use. The files in
- this directory are identical to the 2.3.11 versions.
- for completeness.
-
-
-JOEL: Are the modifications to the original pppd such that the
- real maintainers will accept them?
-
-No. The pppd 2.3.11 branch is an old branch. The current
-version is 2.4.x and it contains alot of extra items that
-just did not make sense to have in an embedded environment.
-I could make the RTEMS changes compatible with the standard
-2.3.11 release by using compilation flags. I have not
-contacted the maintainers to see if they are interested.
-
+The pppd application seems to very stable. It has been tested using
+the example application with the i386/pc586 and m68k/sbc5206e BSPs.
+The tests were executed using a null modem serial cable to connect
+with a UNIX box running either the ppp or pppd application and with
+an external modem to dial up a local ISP.
+
+If you have problems getting your target to make consistent connections
+with an ISP, the problem is most likely with the ppp options. First
+try using the "novj" and "noaccomp" options. If you have questions
+about what other option values are available for the rtems_pppd_set_option
+function, please look at the pppd.8 man page file or the the source code.
+The majority of options that are documented in man page should work
+with this function call.
+
+The pppd application requires the BSP termios driver support task
+driven I/O. Below is a list of known issues that need to be resolved:
+
+ - pppd locks up when it receives large packet pings (> 1500 bytes)
+ - pppd occasionaly locks up with mbuf allocation error
+ (problem is rare and may be BSP related)
+
+If you find any other problems or fix some problems, please post your
+changes to the RTEMS mailing list.
+
+Good Luck
diff --git a/cpukit/pppd/cbcp.c b/cpukit/pppd/cbcp.c
index e69de29bb2..eb60a8e249 100644
--- a/cpukit/pppd/cbcp.c
+++ b/cpukit/pppd/cbcp.c
@@ -0,0 +1,456 @@
+/*
+ * cbcp - Call Back Configuration Protocol.
+ *
+ * Copyright (c) 1995 Pedro Roque Marques
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Pedro Roque Marques. The name of the author may not be used to
+ * endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#define RCSID "$Id$"
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include "pppd.h"
+#include "cbcp.h"
+#include "fsm.h"
+#include "lcp.h"
+
+static const char rcsid[] = RCSID;
+
+/*
+ * Options.
+ */
+static int setcbcp __P((char **));
+
+static option_t cbcp_option_list[] = {
+ { "callback", o_special, setcbcp,
+ "Ask for callback" },
+ { NULL }
+};
+
+/*
+ * Protocol entry points.
+ */
+static void cbcp_init __P((int unit));
+static void cbcp_open __P((int unit));
+static void cbcp_lowerup __P((int unit));
+static void cbcp_input __P((int unit, u_char *pkt, int len));
+static void cbcp_protrej __P((int unit));
+static int cbcp_printpkt __P((u_char *pkt, int len,
+ void (*printer) __P((void *, char *, ...)),
+ void *arg));
+
+struct protent cbcp_protent = {
+ PPP_CBCP,
+ cbcp_init,
+ cbcp_input,
+ cbcp_protrej,
+ cbcp_lowerup,
+ NULL,
+ cbcp_open,
+ NULL,
+ cbcp_printpkt,
+ NULL,
+ 0,
+ "CBCP",
+ NULL,
+ cbcp_option_list,
+ NULL,
+ NULL,
+ NULL
+};
+
+cbcp_state cbcp[NUM_PPP];
+
+/* internal prototypes */
+
+static void cbcp_recvreq __P((cbcp_state *us, char *pckt, int len));
+static void cbcp_resp __P((cbcp_state *us));
+static void cbcp_up __P((cbcp_state *us));
+static void cbcp_recvack __P((cbcp_state *us, char *pckt, int len));
+static void cbcp_send __P((cbcp_state *us, u_char code, u_char *buf, int len));
+
+/* option processing */
+static int
+setcbcp(argv)
+ char **argv;
+{
+ lcp_wantoptions[0].neg_cbcp = 1;
+ cbcp_protent.enabled_flag = 1;
+ cbcp[0].us_number = strdup(*argv);
+ if (cbcp[0].us_number == 0)
+ novm("callback number");
+ cbcp[0].us_type |= (1 << CB_CONF_USER);
+ cbcp[0].us_type |= (1 << CB_CONF_ADMIN);
+ return (1);
+}
+
+/* init state */
+static void
+cbcp_init(iface)
+ int iface;
+{
+ cbcp_state *us;
+
+ us = &cbcp[iface];
+ memset(us, 0, sizeof(cbcp_state));
+ us->us_unit = iface;
+ us->us_type |= (1 << CB_CONF_NO);
+}
+
+/* lower layer is up */
+static void
+cbcp_lowerup(iface)
+ int iface;
+{
+ cbcp_state *us = &cbcp[iface];
+
+ dbglog("cbcp_lowerup");
+ dbglog("want: %d", us->us_type);
+
+ if (us->us_type == CB_CONF_USER)
+ dbglog("phone no: %s", us->us_number);
+}
+
+static void
+cbcp_open(unit)
+ int unit;
+{
+ dbglog("cbcp_open");
+}
+
+/* process an incomming packet */
+static void
+cbcp_input(unit, inpacket, pktlen)
+ int unit;
+ u_char *inpacket;
+ int pktlen;
+{
+ u_char *inp;
+ u_char code, id;
+ u_short len;
+
+ cbcp_state *us = &cbcp[unit];
+
+ inp = inpacket;
+
+ if (pktlen < CBCP_MINLEN) {
+ error("CBCP packet is too small");
+ return;
+ }
+
+ GETCHAR(code, inp);
+ GETCHAR(id, inp);
+ GETSHORT(len, inp);
+
+#if 0
+ if (len > pktlen) {
+ error("CBCP packet: invalid length");
+ return;
+ }
+#endif
+
+ len -= CBCP_MINLEN;
+
+ switch(code) {
+ case CBCP_REQ:
+ us->us_id = id;
+ cbcp_recvreq(us, inp, len);
+ break;
+
+ case CBCP_RESP:
+ dbglog("CBCP_RESP received");
+ break;
+
+ case CBCP_ACK:
+ if (id != us->us_id)
+ dbglog("id doesn't match: expected %d recv %d",
+ us->us_id, id);
+
+ cbcp_recvack(us, inp, len);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* protocol was rejected by foe */
+void cbcp_protrej(int iface)
+{
+}
+
+char *cbcp_codenames[] = {
+ "Request", "Response", "Ack"
+};
+
+char *cbcp_optionnames[] = {
+ "NoCallback",
+ "UserDefined",
+ "AdminDefined",
+ "List"
+};
+
+/* pretty print a packet */
+static int
+cbcp_printpkt(p, plen, printer, arg)
+ u_char *p;
+ int plen;
+ void (*printer) __P((void *, char *, ...));
+ void *arg;
+{
+ int code, opt, id, len, olen, delay;
+ u_char *pstart;
+
+ if (plen < HEADERLEN)
+ return 0;
+ pstart = p;
+ GETCHAR(code, p);
+ GETCHAR(id, p);
+ GETSHORT(len, p);
+ if (len < HEADERLEN || len > plen)
+ return 0;
+
+ if (code >= 1 && code <= sizeof(cbcp_codenames) / sizeof(char *))
+ printer(arg, " %s", cbcp_codenames[code-1]);
+ else
+ printer(arg, " code=0x%x", code);
+
+ printer(arg, " id=0x%x", id);
+ len -= HEADERLEN;
+
+ switch (code) {
+ case CBCP_REQ:
+ case CBCP_RESP:
+ case CBCP_ACK:
+ while(len >= 2) {
+ GETCHAR(opt, p);
+ GETCHAR(olen, p);
+
+ if (olen < 2 || olen > len) {
+ break;
+ }
+
+ printer(arg, " <");
+ len -= olen;
+
+ if (opt >= 1 && opt <= sizeof(cbcp_optionnames) / sizeof(char *))
+ printer(arg, " %s", cbcp_optionnames[opt-1]);
+ else
+ printer(arg, " option=0x%x", opt);
+
+ if (olen > 2) {
+ GETCHAR(delay, p);
+ printer(arg, " delay = %d", delay);
+ }
+
+ if (olen > 3) {
+ int addrt;
+ char str[256];
+
+ GETCHAR(addrt, p);
+ memcpy(str, p, olen - 4);
+ str[olen - 4] = 0;
+ printer(arg, " number = %s", str);
+ }
+ printer(arg, ">");
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ for (; len > 0; --len) {
+ GETCHAR(code, p);
+ printer(arg, " %.2x", code);
+ }
+
+ return p - pstart;
+}
+
+/* received CBCP request */
+static void
+cbcp_recvreq(us, pckt, pcktlen)
+ cbcp_state *us;
+ char *pckt;
+ int pcktlen;
+{
+ u_char type, opt_len, delay, addr_type;
+ char address[256];
+ int len = pcktlen;
+
+ address[0] = 0;
+
+ while (len) {
+ dbglog("length: %d", len);
+
+ GETCHAR(type, pckt);
+ GETCHAR(opt_len, pckt);
+
+ if (opt_len > 2)
+ GETCHAR(delay, pckt);
+
+ us->us_allowed |= (1 << type);
+
+ switch(type) {
+ case CB_CONF_NO:
+ dbglog("no callback allowed");
+ break;
+
+ case CB_CONF_USER:
+ dbglog("user callback allowed");
+ if (opt_len > 4) {
+ GETCHAR(addr_type, pckt);
+ memcpy(address, pckt, opt_len - 4);
+ address[opt_len - 4] = 0;
+ if (address[0])
+ dbglog("address: %s", address);
+ }
+ break;
+
+ case CB_CONF_ADMIN:
+ dbglog("user admin defined allowed");
+ break;
+
+ case CB_CONF_LIST:
+ break;
+ }
+ len -= opt_len;
+ }
+
+ cbcp_resp(us);
+}
+
+static void
+cbcp_resp(us)
+ cbcp_state *us;
+{
+ u_char cb_type;
+ u_char buf[256];
+ u_char *bufp = buf;
+ int len = 0;
+
+ cb_type = us->us_allowed & us->us_type;
+ dbglog("cbcp_resp cb_type=%d", cb_type);
+
+#if 0
+ if (!cb_type)
+ lcp_down(us->us_unit);
+#endif
+
+ if (cb_type & ( 1 << CB_CONF_USER ) ) {
+ dbglog("cbcp_resp CONF_USER");
+ PUTCHAR(CB_CONF_USER, bufp);
+ len = 3 + 1 + strlen(us->us_number) + 1;
+ PUTCHAR(len , bufp);
+ PUTCHAR(5, bufp); /* delay */
+ PUTCHAR(1, bufp);
+ BCOPY(us->us_number, bufp, strlen(us->us_number) + 1);
+ cbcp_send(us, CBCP_RESP, buf, len);
+ return;
+ }
+
+ if (cb_type & ( 1 << CB_CONF_ADMIN ) ) {
+ dbglog("cbcp_resp CONF_ADMIN");
+ PUTCHAR(CB_CONF_ADMIN, bufp);
+ len = 3;
+ PUTCHAR(len, bufp);
+ PUTCHAR(5, bufp); /* delay */
+ cbcp_send(us, CBCP_RESP, buf, len);
+ return;
+ }
+
+ if (cb_type & ( 1 << CB_CONF_NO ) ) {
+ dbglog("cbcp_resp CONF_NO");
+ PUTCHAR(CB_CONF_NO, bufp);
+ len = 3;
+ PUTCHAR(len , bufp);
+ PUTCHAR(0, bufp);
+ cbcp_send(us, CBCP_RESP, buf, len);
+ start_networks();
+ return;
+ }
+}
+
+static void
+cbcp_send(us, code, buf, len)
+ cbcp_state *us;
+ u_char code;
+ u_char *buf;
+ int len;
+{
+ u_char *outp;
+ int outlen;
+
+ outp = outpacket_buf;
+
+ outlen = 4 + len;
+
+ MAKEHEADER(outp, PPP_CBCP);
+
+ PUTCHAR(code, outp);
+ PUTCHAR(us->us_id, outp);
+ PUTSHORT(outlen, outp);
+
+ if (len)
+ BCOPY(buf, outp, len);
+
+ output(us->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
+}
+
+static void
+cbcp_recvack(us, pckt, len)
+ cbcp_state *us;
+ char *pckt;
+ int len;
+{
+ u_char type, delay, addr_type;
+ int opt_len;
+ char address[256];
+
+ if (len) {
+ GETCHAR(type, pckt);
+ GETCHAR(opt_len, pckt);
+
+ if (opt_len > 2)
+ GETCHAR(delay, pckt);
+
+ if (opt_len > 4) {
+ GETCHAR(addr_type, pckt);
+ memcpy(address, pckt, opt_len - 4);
+ address[opt_len - 4] = 0;
+ if (address[0])
+ dbglog("peer will call: %s", address);
+ }
+ if (type == CB_CONF_NO)
+ return;
+ }
+
+ cbcp_up(us);
+}
+
+/* ok peer will do callback */
+static void
+cbcp_up(us)
+ cbcp_state *us;
+{
+ persist = 0;
+ lcp_close(0, "Call me back, please");
+ status = EXIT_CALLBACK;
+}
diff --git a/cpukit/pppd/cbcp.h b/cpukit/pppd/cbcp.h
index e69de29bb2..c2ab3f6899 100644
--- a/cpukit/pppd/cbcp.h
+++ b/cpukit/pppd/cbcp.h
@@ -0,0 +1,26 @@
+#ifndef CBCP_H
+#define CBCP_H
+
+typedef struct cbcp_state {
+ int us_unit; /* Interface unit number */
+ u_char us_id; /* Current id */
+ u_char us_allowed;
+ int us_type;
+ char *us_number; /* Telefone Number */
+} cbcp_state;
+
+extern cbcp_state cbcp[];
+
+extern struct protent cbcp_protent;
+
+#define CBCP_MINLEN 4
+
+#define CBCP_REQ 1
+#define CBCP_RESP 2
+#define CBCP_ACK 3
+
+#define CB_CONF_NO 1
+#define CB_CONF_USER 2
+#define CB_CONF_ADMIN 3
+#define CB_CONF_LIST 4
+#endif
diff --git a/cpukit/pppd/chat.c b/cpukit/pppd/chat.c
index 31273714b4..150081d4e5 100644
--- a/cpukit/pppd/chat.c
+++ b/cpukit/pppd/chat.c
@@ -14,6 +14,12 @@
* This software is in the public domain.
*
* -----------------
+ * 22-May-99 added environment substitutuion, enabled with -E switch.
+ * Andreas Arens <andras@cityweb.de>.
+ *
+ * 12-May-99 added a feature to read data to be sent from a file,
+ * if the send string starts with @. Idea from gpk <gpk@onramp.net>.
+ *
* added -T and -U option and \T and \U substitution to pass a phone
* number into chat script. Two are needed for some ISDN TA applications.
* Keith Dart <kdart@cisco.com>
@@ -74,18 +80,12 @@
* Columbus, OH 43221
* (614)451-1883
*
- *
*/
-#ifndef lint
-/* static char rcsid[] = ""; */
-#endif
-
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <fcntl.h>
-#include <signal.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
@@ -93,13 +93,13 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <syslog.h>
+#include <termios.h>
+#include "pppd.h"
#undef TERMIOS
#define TERMIOS
-#include <termios.h>
-
#define STR_LEN 1024
char temp2[STR_LEN];
@@ -142,39 +142,34 @@ static int _O = 0; /* Internal state */
char *program_name;
-#define MAX_ABORTS 5
-#define MAX_REPORTS 5
+#define MAX_ABORTS 16
+#define MAX_REPORTS 16
#define DEFAULT_CHAT_TIMEOUT 45
-#define fcntl(a, b,c ) 0
-#define MAX_TIMEOUTS 10
-
-int echo = 0;
-int verbose = 0;
-int to_log = 1;
-int to_stderr = 0;
-int Verbose = 0;
-int quiet = 0;
-int report = 0;
-int exit_code = 0;
-char *report_file = (char *) 0;
-char *chat_file = (char *) 0;
-char *phone_num = (char *) 0;
-char *phone_num2 = (char *) 0;
-int chat_timeout = DEFAULT_CHAT_TIMEOUT;
-static int timeout = DEFAULT_CHAT_TIMEOUT;
-int have_tty_parameters = 0;
+#define MAX_TIMEOUTS 10
+
+int echo = 0;
+int quiet = 0;
+int report = 0;
+int use_env = 0;
+int exit_code = 0;
+char *report_file = (char *) 0;
+char *chat_file = (char *) 0;
+char *phone_num = (char *) 0;
+char *phone_num2 = (char *) 0;
+static int timeout = DEFAULT_CHAT_TIMEOUT;
#ifdef TERMIOS
#define term_parms struct termios
-#define get_term_param(param) tcgetattr(ttyfd, param)
-#define set_term_param(param) tcsetattr(ttyfd, TCSANOW, param)
+#define get_term_param(param) tcgetattr(0, param)
+#define set_term_param(param) tcsetattr(0, TCSANOW, param)
struct termios saved_tty_parameters;
#endif
-char *abort_string[MAX_ABORTS]={"BUSY","NO DIALTONE","NO CARRIER","NO ASWER","RINGING\r\n\r\nRINGING"};
-char *fail_reason = (char *)0,
- fail_buffer[50];
-int n_aborts = MAX_ABORTS, abort_next = 0, timeout_next = 0, echo_next = 0;
+char *fail_reason = (char *)0;
+char fail_buffer[50];
+char *abort_string[MAX_ABORTS]={"BUSY","NO DIALTONE","NO CARRIER","NO ANSWER","RING\r\nRING"};
+int n_aborts = 5;
+int abort_next = 0, timeout_next = 0, echo_next = 0;
int clear_abort_next = 0;
char *report_string[MAX_REPORTS] ;
@@ -186,19 +181,7 @@ int say_next = 0, hup_next = 0;
void *dup_mem __P((void *b, size_t c));
void *copy_of __P((char *s));
-/*
-SIGTYPE sigalrm __P((int signo));
-SIGTYPE sigint __P((int signo));
-SIGTYPE sigterm __P((int signo));
-SIGTYPE sighup __P((int signo));
-*/
-void unalarm __P((void));
-void init __P((void));
-void set_tty_parameters __P((void));
-void echo_stderr __P((int));
void break_sequence __P((void));
-void terminate __P((int status));
-void do_file __P((char *chat_file));
int get_string __P((register char *string));
int put_string __P((register char *s));
int write_char __P((int c));
@@ -208,19 +191,9 @@ void chat_send __P((register char *s));
char *character __P((int c));
void chat_expect __P((register char *s));
char *clean __P((register char *s, int sending));
-void break_sequence __P((void));
-void terminate __P((int status));
-void pack_array __P((char **array, int end));
char *expect_strtok __P((char *, char *));
-int vfmtmsg __P((char *, int, const char *, va_list)); /* vsprintf++ */
-
-#if 0
-int usleep( long usec ); /* returns 0 if ok, else -1 */
-#endif
-
-extern int input_fd,output_fd;
+int chatmain __P((char *));
-int main __P((int, char *[]));
void *dup_mem(b, c)
void *b;
@@ -228,29 +201,22 @@ size_t c;
{
void *ans = malloc (c);
if (!ans)
- return NULL;
+ return NULL;
- memcpy (ans, b, c);
+ memcpy(ans, b, c);
return ans;
}
void *copy_of (s)
char *s;
{
- return dup_mem (s, strlen (s) + 1);
+ return dup_mem(s, strlen (s) + 1);
}
-/*
- * chat [ -v ] [-T number] [-U number] [ -t timeout ] [ -f chat-file ] \
- * [ -r report-file ] \
- * [...[[expect[-say[-expect...]] say expect[-say[-expect]] ...]]]
- *
- * Perform a UUCP-dialer-like chat script on stdin and stdout.
- */
char *getnextcommand(char **string)
{
char *buf=*string,*res;
- res=strchr(buf,'@');
+ res=strchr(buf,'|');
if (res==NULL)
return NULL;
*res='\0';
@@ -258,8 +224,6 @@ char *getnextcommand(char **string)
return buf;
}
-
-extern int ttyfd;
int chatmain(argv)
char *argv;
{
@@ -268,78 +232,40 @@ char *argv;
/* initialize exit code */
exit_code = 0;
-printf("chat_main: %s\n", argv);
+ if ( debug ) {
+ dbglog("chat_main: %s\n", argv);
+ }
/* get first expect string */
arg = getnextcommand(&argv);
- while ( arg != NULL ) {
+ while (( arg != NULL ) && ( exit_code == 0 )) {
/* process the expect string */
chat_expect(arg);
-
- /* get the next send string */
- arg = getnextcommand(&argv);
- if ( arg != NULL ) {
- /* process the send string */
- chat_send(arg);
-
- /* get the next expect string */
+ if ( exit_code == 0 ) {
+ /* get the next send string */
arg = getnextcommand(&argv);
+ if ( arg != NULL ) {
+ /* process the send string */
+ chat_send(arg);
+
+ /* get the next expect string */
+ arg = getnextcommand(&argv);
+ }
}
}
- return 0;
-}
-
-
-
-/*
- * Print an error message and terminate.
- */
-
-void init()
-{
- set_tty_parameters();
-}
-
-void set_tty_parameters()
-{
- term_parms t;
+ if ( exit_code ) {
+ exit_code = -exit_code;
+ }
- if (get_term_param (&t) < 0)
- syslog(LOG_NOTICE,"Can't get terminal parameters:")
- ;
-
- saved_tty_parameters = t;
- have_tty_parameters = 1;
- t.c_iflag |= IGNBRK | ISTRIP | IGNPAR;
- t.c_oflag = 0;
- t.c_lflag = 0;
- t.c_cc[VERASE] =
- t.c_cc[VKILL] = 0;
- t.c_cc[VMIN] = 0;
- t.c_cc[VTIME] = 1;
- if (set_term_param (&t) < 0)
- syslog(LOG_NOTICE,"Can't set terminal parameters:")
- ;
+ return ( exit_code );
}
void break_sequence()
{
-
-/* tcsendbreak (0, 0);*/
+ tcsendbreak(ttyfd, 0);
}
-/*void terminate(status)
-int status;
-{
- echo_stderr(-1);
-
- if (have_tty_parameters) {
- if (set_term_param (&saved_tty_parameters) < 0)
- fatal(2, "Can't restore terminal parameters: %m");
- }
-}
-*/
/*
* 'Clean up' this string.
*/
@@ -347,10 +273,14 @@ char *clean(s, sending)
register char *s;
int sending; /* set to 1 when sending (putting) this string. */
{
- char temp[STR_LEN], cur_chr;
+ char temp[STR_LEN], env_str[STR_LEN], cur_chr;
register char *s1, *phchar;
int add_return = sending;
-#define isoctal(chr) (((chr) >= '0') && ((chr) <= '7'))
+#define isoctal(chr) (((chr) >= '0') && ((chr) <= '7'))
+#define isalnumx(chr) ((((chr) >= '0') && ((chr) <= '9')) \
+ || (((chr) >= 'a') && ((chr) <= 'z')) \
+ || (((chr) >= 'A') && ((chr) <= 'Z')) \
+ || (chr) == '_')
s1 = temp;
while (*s) {
@@ -367,6 +297,18 @@ int sending; /* set to 1 when sending (putting) this string. */
}
continue;
}
+
+ if (use_env && cur_chr == '$') { /* ARI */
+ phchar = env_str;
+ while (isalnumx(*s))
+ *phchar++ = *s++;
+ *phchar = '\0';
+ phchar = getenv(env_str);
+ if (phchar)
+ while (*phchar)
+ *s1++ = *phchar++;
+ continue;
+ }
if (cur_chr != '\\') {
*s1++ = cur_chr;
@@ -400,13 +342,12 @@ int sending; /* set to 1 when sending (putting) this string. */
case 'd':
if (sending)
*s1++ = '\\';
-
*s1++ = cur_chr;
break;
case 'T':
if (sending && phone_num) {
- for ( phchar = phone_num; *phchar != '\0'; phchar++)
+ for (phchar = phone_num; *phchar != '\0'; phchar++)
*s1++ = *phchar;
}
else {
@@ -417,7 +358,7 @@ int sending; /* set to 1 when sending (putting) this string. */
case 'U':
if (sending && phone_num2) {
- for ( phchar = phone_num2; *phchar != '\0'; phchar++)
+ for (phchar = phone_num2; *phchar != '\0'; phchar++)
*s1++ = *phchar;
}
else {
@@ -455,6 +396,13 @@ int sending; /* set to 1 when sending (putting) this string. */
*s1++ = 'N';
break;
+ case '$': /* ARI */
+ if (use_env) {
+ *s1++ = cur_chr;
+ break;
+ }
+ /* FALL THROUGH */
+
default:
if (isoctal (cur_chr)) {
cur_chr &= 0x07;
@@ -493,7 +441,6 @@ int sending; /* set to 1 when sending (putting) this string. */
/*
* A modified version of 'strtok'. This version skips \ sequences.
*/
-
char *expect_strtok (s, term)
char *s, *term;
{
@@ -548,8 +495,7 @@ char *expect_strtok (s, term)
/*
* Process the expect string
*/
-
-void chat_expect (s)
+void chat_expect (s)
char *s;
{
char *expect;
@@ -557,42 +503,42 @@ char *s;
if (strcmp(s, "HANGUP") == 0) {
++hup_next;
- return ;
+ return;
}
if (strcmp(s, "ABORT") == 0) {
++abort_next;
- return ;
+ return;
}
if (strcmp(s, "CLR_ABORT") == 0) {
++clear_abort_next;
- return ;
+ return;
}
if (strcmp(s, "REPORT") == 0) {
++report_next;
- return ;
+ return;
}
if (strcmp(s, "CLR_REPORT") == 0) {
++clear_report_next;
- return ;
+ return;
}
if (strcmp(s, "TIMEOUT") == 0) {
++timeout_next;
- return ;
+ return;
}
if (strcmp(s, "ECHO") == 0) {
++echo_next;
- return ;
+ return;
}
if (strcmp(s, "SAY") == 0) {
++say_next;
- return ;
+ return;
}
/*
@@ -600,10 +546,10 @@ char *s;
*/
for (;;) {
expect = expect_strtok (s, "-");
- s = (char *)0 ;
+ s = (char *) 0;
if (expect == (char *) 0)
- return ;
+ return;
reply = expect_strtok (s, "-");
@@ -622,11 +568,30 @@ char *s;
chat_send (reply);
}
+}
/*
- * The expectation did not occur. This is terminal.
+ * Translate the input character to the appropriate string for printing
+ * the data.
*/
- return ;
+
+char *character(c)
+int c;
+{
+ static char string[10];
+ char *meta;
+
+ meta = (c & 0x80) ? "M-" : "";
+ c &= 0x7F;
+
+ if (c < 32)
+ sprintf(string, "%s^%c", meta, (int)c + '@');
+ else if (c == 127)
+ sprintf(string, "%s^?", meta);
+ else
+ sprintf(string, "%s%c", meta, c);
+
+ return (string);
}
/*
@@ -635,16 +600,19 @@ char *s;
void chat_send (s)
register char *s;
{
+ char file_data[STR_LEN];
+
if (say_next) {
say_next = 0;
- s = clean(s,0);
- write(ttyfd, s, strlen(s));
+ s = clean(s, 1);
+ write(2, s, strlen(s));
free(s);
return;
}
if (hup_next) {
hup_next = 0;
+ return;
}
if (echo_next) {
@@ -654,36 +622,53 @@ register char *s;
}
if (abort_next) {
- /* char *s1; */
-
-
- ;
+ char *s1;
+ abort_next = 0;
+ if ( n_aborts < MAX_ABORTS ) {
+ s1 = clean(s, 0);
+ if (( strlen(s1) <= strlen(s) ) &&
+ ( strlen(s1) < sizeof(fail_buffer))) {
+
+ abort_string[n_aborts++] = s1;
+ }
+ }
+ return;
+ }
+ if (clear_abort_next) {
+ clear_abort_next = 0;
+ return;
+ }
+
+ if (report_next) {
+ report_next = 0;
+ return;
+ }
+
+ if (clear_report_next) {
+ clear_report_next = 0;
return;
}
if (timeout_next) {
- timeout=atoi(s);
timeout_next = 0;
- chat_timeout = atoi(s);
+ timeout = atoi(s);
- if (chat_timeout <= 0)
- chat_timeout = DEFAULT_CHAT_TIMEOUT;
-
+ if (timeout <= 0)
+ timeout = DEFAULT_CHAT_TIMEOUT;
return;
}
+
if (strcmp(s, "EOT") == 0)
s = "^D\\c";
else if (strcmp(s, "BREAK") == 0)
s = "\\K\\c";
- if (!put_string(s))
- {
- exit_code=1;
- return;
- }
+ if (!put_string(s)) {
+ exit_code = 2;
+ }
}
int get_char()
@@ -708,21 +693,10 @@ int get_char()
int put_char(c)
int c;
{
- int status;
- char ch = c;
-
- /* inter-character typing delay (?) */
+ char ch = c;
- status = write(ttyfd, &ch, 1);
+ write(ttyfd, &ch, 1);
- switch (status) {
- case 1:
- return (0);
-
- default:
-
-
- }
return 0;
}
@@ -774,44 +748,12 @@ register char *s;
}
}
- /* alarm(0);*/
return (1);
}
/*
- * Echo a character to stderr.
- * When called with -1, a '\n' character is generated when
- * the cursor is not at the beginning of a line.
- */
-void echo_stderr(n)
-int n;
-{
-/* static int need_lf;
- char *s;
-
- switch (n) {
- case '\r':
- break;
- case -1:
- if (need_lf == 0)
- break;
-
- case '\n':
- write(2, "\n", 1);
- need_lf = 0;
- break;
- default:
- s = character(n);
- write(2, s, strlen(s));
- need_lf = 1;
- break;
- }*/
-}
-
-/*
* 'Wait for' this string to appear on this file descriptor.
*/
-
int get_string(string)
register char *string;
{
@@ -820,6 +762,8 @@ register char *string;
char *logged = temp2;
struct termios tios;
+ memset(temp2, 0, sizeof(temp2));
+
tcgetattr(ttyfd, &tios);
tios.c_cc[VMIN] = 0;
tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
@@ -838,13 +782,12 @@ register char *string;
return (1);
}
-
while ( (c = get_char()) >= 0) {
int n, abort_len;
*s++ = c;
*s=0;
-
+
if (s - temp2 >= len &&
c == string[len - 1] &&
strncmp(s - len, string, len) == 0) {
@@ -871,60 +814,7 @@ register char *string;
s = temp2 + minlen;
}
}
+
exit_code = 3;
return (0);
}
-
-/*
- * Gross kludge to handle Solaris versions >= 2.6 having usleep.
- */
-
-/*
- usleep -- support routine for 4.2BSD system call emulations
- last edit: 29-Oct-1984 D A Gwyn
- */
-
-
-#if 0
-int
-usleep( usec ) /* returns 0 if ok, else -1 */
- long usec; /* delay in microseconds */
-{
- rtems_status_code status;
- rtems_interval ticks_per_second;
- rtems_interval ticks;
- status = rtems_clock_get(
- RTEMS_CLOCK_GET_TICKS_PER_SECOND,
- &ticks_per_second);
- ticks = (usec * (ticks_per_second/1000))/1000;
- status = rtems_task_wake_after( ticks );
- return 0;
-}
-#endif
-
-void pack_array (array, end)
- char **array; /* The address of the array of string pointers */
- int end; /* The index of the next free entry before CLR_ */
-{
- int i, j;
-
- for (i = 0; i < end; i++) {
- if (array[i] == NULL) {
- for (j = i+1; j < end; ++j)
- if (array[j] != NULL)
- array[i++] = array[j];
- for (; i < end; ++i)
- array[i] = NULL;
- break;
- }
- }
-}
-
-/*
- * vfmtmsg - format a message into a buffer. Like vsprintf except we
- * also specify the length of the output buffer, and we handle the
- * %m (error message) format.
- * Doesn't do floating-point formats.
- * Returns the number of chars put into buf.
- */
-#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0)
diff --git a/cpukit/pppd/example/README b/cpukit/pppd/example/README
index 969745f3a2..677e00af33 100644
--- a/cpukit/pppd/example/README
+++ b/cpukit/pppd/example/README
@@ -6,3 +6,10 @@ This is an example user application using pppd. It is built using
the RTEMS application Makefiles. The file Makefile-user should
be renamed to Makefile or the -f option given to make. The file
is renamed to avoid bootstrap -c removing it.
+
+The files ppp.conf and pppd.options are sample configuration files
+that have successfully used to make ppp connections over a null
+modem serial cable to a UNIX box. Please review the man pages
+for either the ppp or pppd applications to ensure they are configured
+correctly.
+
diff --git a/cpukit/pppd/example/pppd.options b/cpukit/pppd/example/pppd.options
new file mode 100644
index 0000000000..c0706e6ec5
--- /dev/null
+++ b/cpukit/pppd/example/pppd.options
@@ -0,0 +1,9 @@
+/dev/tty00
+57600
+crtscts
+passive
+local
+noauth
+debug
+persist
+192.168.2.222:192.168.2.111
diff --git a/cpukit/pppd/pppd.h b/cpukit/pppd/pppd.h
index e30ddfe55e..3e4f6c68ee 100644
--- a/cpukit/pppd/pppd.h
+++ b/cpukit/pppd/pppd.h
@@ -589,6 +589,8 @@ extern void (*auth_linkdown_hook) __P((void));
#define DEBUGCHAP 1
#endif
#define DEBUGMAIN 1
+#define DEBUGUPAP 1
+#define DEBUGCHAP 1
#ifdef DEBUGMAIN
diff --git a/cpukit/pppd/rtemsmain.c b/cpukit/pppd/rtemsmain.c
index 5a266a9ff3..38383c6e06 100644
--- a/cpukit/pppd/rtemsmain.c
+++ b/cpukit/pppd/rtemsmain.c
@@ -107,8 +107,6 @@ int phase; /* where the link is at */
int kill_link;
int open_ccp_flag;
-static int waiting;
-
char **script_env; /* Env. variable values for scripts */
int s_env_nalloc; /* # words avail at script_env */
@@ -234,8 +232,6 @@ pppdmain(argc, argv)
setlogmask(LOG_UPTO(LOG_DEBUG));
*/
- waiting = 0;
-
do_callback = 0;
for (;;) {
@@ -400,12 +396,10 @@ pppdmain(argc, argv)
status = EXIT_NEGOTIATION_FAILED;
new_phase(PHASE_ESTABLISH);
while (phase != PHASE_DEAD) {
- waiting = 1;
wait_input(timeleft(&timo));
- waiting = 0;
-
calltimeout();
get_input();
+
if (kill_link) {
lcp_close(0, "User request");
kill_link = 0;
@@ -469,9 +463,7 @@ pppdmain(argc, argv)
new_phase(PHASE_HOLDOFF);
TIMEOUT(holdoff_end, NULL, t);
do {
- waiting = 1;
wait_input(timeleft(&timo));
- waiting = 0;
calltimeout();
if (kill_link) {