summaryrefslogtreecommitdiffstats
path: root/c/src/libnetworking/pppd
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2002-01-31 21:42:11 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2002-01-31 21:42:11 +0000
commit0286b9f6145f9664f6b0e196e24daee8be46b538 (patch)
tree5cdf87997238653f4083fe1c1326213040183044 /c/src/libnetworking/pppd
parentd8a78f4fb5fd9032522ef043e1584f31a7c17dfb (diff)
downloadrtems-0286b9f6145f9664f6b0e196e24daee8be46b538.tar.bz2
2001-01-31 Mike Siers <mikes@poliac.com>
* Nice Update of PPPD support which eliminates the requiremetn that drivers be in the termios TASK_DRIVEN mode. Mike did significant testing and reports that it seems to be more stable and handle larger packets better. This patch replaces the termios tasks with more general pppd network driver tasks. The functions pppinput() and pppstart() get called from the interrupt service routine. * Makefile.am, configure.ac, net/Makefile.am, net/bpf.h, net/ethernet.h, net/if.c, net/if.h, net/if_arp.h, net/if_dl.h, net/if_ethersubr.c, net/if_llc.h, net/if_loop.c, net/if_ppp.h, net/if_pppvar.h, net/if_types.h, net/netisr.h, net/ppp-comp.h, net/ppp_defs.h, net/pppcompress.h, net/radix.c, net/radix.h, net/raw_cb.c, net/raw_cb.h, net/raw_usrreq.c, net/route.c, net/route.h, net/rtsock.c, pppd/Makefile.am, pppd/README, pppd/STATUS, pppd/auth.c, pppd/cbcp.c, pppd/ccp.c, pppd/ccp.h, pppd/chap.c, pppd/chap.h, pppd/chap_ms.c, pppd/chap_ms.h, pppd/chat.c, pppd/demand.c, pppd/fsm.c, pppd/fsm.h, pppd/ipcp.c, pppd/ipcp.h, pppd/ipxcp.c, pppd/ipxcp.h, pppd/lcp.c, pppd/lcp.h, pppd/magic.c, pppd/magic.h, pppd/options.c, pppd/patchlevel.h, pppd/pathnames.h, pppd/pppd.8, pppd/pppd.h, pppd/rtemsmain.c, pppd/rtemspppd.c, pppd/rtemspppd.h, pppd/sys-rtems.c, pppd/upap.c, pppd/upap.h, pppd/utils.c, pppd/example/README, pppd/example/netconfig.h, wrapup/Makefile.am: Modified. * net/bsd-comp.c, net/if_ppp.c, net/ppp-deflate.c, net/ppp.h, net/ppp_tty.c, net/pppcompress.c, net/zlib.c, net/zlib.h: New file. * modem/, modem/.cvsignore, modem/Makefile.am, modem/ppp.c, modem/ppp.h, modem/ppp_tty.c, modem/pppcompress.c: Subdirectory removed.
Diffstat (limited to 'c/src/libnetworking/pppd')
-rw-r--r--c/src/libnetworking/pppd/Makefile.am10
-rw-r--r--c/src/libnetworking/pppd/README5
-rw-r--r--c/src/libnetworking/pppd/STATUS10
-rw-r--r--c/src/libnetworking/pppd/chap.h2
-rw-r--r--c/src/libnetworking/pppd/chat.c20
-rw-r--r--c/src/libnetworking/pppd/example/netconfig.h17
-rw-r--r--c/src/libnetworking/pppd/fsm.c6
-rw-r--r--c/src/libnetworking/pppd/fsm.h2
-rw-r--r--c/src/libnetworking/pppd/ipcp.c38
-rw-r--r--c/src/libnetworking/pppd/options.c4
-rw-r--r--c/src/libnetworking/pppd/pppd.h11
-rw-r--r--c/src/libnetworking/pppd/rtemsmain.c56
-rw-r--r--c/src/libnetworking/pppd/rtemspppd.c55
-rw-r--r--c/src/libnetworking/pppd/rtemspppd.h17
-rw-r--r--c/src/libnetworking/pppd/sys-rtems.c37
-rw-r--r--c/src/libnetworking/pppd/upap.h2
16 files changed, 171 insertions, 121 deletions
diff --git a/c/src/libnetworking/pppd/Makefile.am b/c/src/libnetworking/pppd/Makefile.am
index b9521d7dbe..67bc112b7f 100644
--- a/c/src/libnetworking/pppd/Makefile.am
+++ b/c/src/libnetworking/pppd/Makefile.am
@@ -10,7 +10,9 @@ AUTOMAKE_OPTIONS = foreign 1.4
LIBNAME = lib.a
LIB = $(ARCH)/$(LIBNAME)
-C_FILES = auth.c ccp.c chap.c chap_ms.c chat.c demand.c fsm.c ipcp.c lcp.c magic.c options.c upap.c md4.c md5.c utils.c sys-rtems.c rtemsmain.c rtemspppd.c
+C_FILES = auth.c ccp.c chap.c chap_ms.c chat.c demand.c fsm.c ipcp.c lcp.c \
+ magic.c options.c upap.c md4.c md5.c utils.c sys-rtems.c rtemsmain.c \
+ rtemspppd.c
C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
OBJS = $(C_O_FILES)
@@ -33,10 +35,10 @@ all-local: $(PREINSTALL_FILES) $(ARCH) $(OBJS) $(LIB)
EXTRA_DIST = auth.c ccp.c ccp.h chap.c chap.h chap_ms.c chap_ms.h \
chat.c demand.c fsm.c fsm.h ipcp.c ipcp.h ipxcp.c ipxcp.h \
lcp.c lcp.h magic.c magic.h md4.c md4.h md5.c md5.h options.c \
-patchlevel.h pathnames.h pppd.h rtemsmain.c rtemspppd.c rtemspppd.h \
-sys-rtems.c upap.c upap.h utils.c
+patchlevel.h pathnames.h pppd.h rtemsdialer.h rtemsmain.c rtemspppd.c \
+rtemspppd.h sys-rtems.c upap.c upap.h utils.c
-include_HEADERS = rtemspppd.h
+include_HEADERS = rtemspppd.h rtemsdialer.h
PREINSTALL_FILES = $(PROJECT_INCLUDE) $(include_HEADERS:%=$(PROJECT_INCLUDE)/%)
diff --git a/c/src/libnetworking/pppd/README b/c/src/libnetworking/pppd/README
index 7481988d83..28c9f7ef5d 100644
--- a/c/src/libnetworking/pppd/README
+++ b/c/src/libnetworking/pppd/README
@@ -20,5 +20,10 @@ 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.
+
+Update code to use RTEMS pppd network drivers. Now the pppd
+software is not dependent on using task driven mode. This
+change improved stablity and performance. This was updated
+by Mike Siers <mikes@poliac.com>.
=================================================================
diff --git a/c/src/libnetworking/pppd/STATUS b/c/src/libnetworking/pppd/STATUS
index ddb70c4b58..4c0d35d423 100644
--- a/c/src/libnetworking/pppd/STATUS
+++ b/c/src/libnetworking/pppd/STATUS
@@ -16,12 +16,10 @@ 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)
+The pppd code had now been updated to use it's own RTEMS network
+drivers. This removes the requirement for the task driven termios
+support. This update has fixed the large packet ping problem.
+Currently, I do not know of any problems with the port.
If you find any other problems or fix some problems, please post your
changes to the RTEMS mailing list.
diff --git a/c/src/libnetworking/pppd/chap.h b/c/src/libnetworking/pppd/chap.h
index 945d051d06..9f0361b1ae 100644
--- a/c/src/libnetworking/pppd/chap.h
+++ b/c/src/libnetworking/pppd/chap.h
@@ -110,7 +110,7 @@ typedef struct chap_state {
/*
* Timeouts.
*/
-#define CHAP_DEFTIMEOUT 3 /* Timeout time in seconds */
+#define CHAP_DEFTIMEOUT 5 /* Timeout time in seconds */
#define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */
extern chap_state chap[];
diff --git a/c/src/libnetworking/pppd/chat.c b/c/src/libnetworking/pppd/chat.c
index 150081d4e5..6d8a7f24c7 100644
--- a/c/src/libnetworking/pppd/chat.c
+++ b/c/src/libnetworking/pppd/chat.c
@@ -156,6 +156,7 @@ char *report_file = (char *) 0;
char *chat_file = (char *) 0;
char *phone_num = (char *) 0;
char *phone_num2 = (char *) 0;
+static int ttyfd;
static int timeout = DEFAULT_CHAT_TIMEOUT;
#ifdef TERMIOS
@@ -192,7 +193,7 @@ char *character __P((int c));
void chat_expect __P((register char *s));
char *clean __P((register char *s, int sending));
char *expect_strtok __P((char *, char *));
-int chatmain __P((char *));
+int chatmain __P((int, int, char *));
void *dup_mem(b, c)
@@ -224,39 +225,36 @@ char *getnextcommand(char **string)
return buf;
}
-int chatmain(argv)
-char *argv;
+int chatmain(int fd, int mode, char *pScript)
{
char *arg;
/* initialize exit code */
exit_code = 0;
+ ttyfd = fd;
if ( debug ) {
- dbglog("chat_main: %s\n", argv);
+ dbglog("chat_main: %s\n", pScript);
}
/* get first expect string */
- arg = getnextcommand(&argv);
+ arg = getnextcommand(&pScript);
while (( arg != NULL ) && ( exit_code == 0 )) {
/* process the expect string */
chat_expect(arg);
if ( exit_code == 0 ) {
/* get the next send string */
- arg = getnextcommand(&argv);
+ arg = getnextcommand(&pScript);
if ( arg != NULL ) {
/* process the send string */
chat_send(arg);
/* get the next expect string */
- arg = getnextcommand(&argv);
+ arg = getnextcommand(&pScript);
}
}
}
-
- if ( exit_code ) {
- exit_code = -exit_code;
- }
+ ttyfd = (int)-1;
return ( exit_code );
}
diff --git a/c/src/libnetworking/pppd/example/netconfig.h b/c/src/libnetworking/pppd/example/netconfig.h
index 6a95cce189..3428288cd2 100644
--- a/c/src/libnetworking/pppd/example/netconfig.h
+++ b/c/src/libnetworking/pppd/example/netconfig.h
@@ -5,16 +5,15 @@
#include <bsp.h>
/* external function prototypes */
-extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config,
- int attaching);
+extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching);
/* Default network interface */
static struct rtems_bsdnet_ifconfig netdriver_config = {
"ppp0", /* name */
rtems_ppp_driver_attach, /* attach function */
NULL, /* No more interfaces */
- "192.168.2.123", /* IP address */
- "255.255.255.0", /* IP net mask */
+ NULL, /* IP address */
+ NULL, /* IP net mask */
NULL, /* Driver supplies hardware address */
0 /* Use default driver parameters */
};
@@ -23,11 +22,11 @@ static struct rtems_bsdnet_ifconfig netdriver_config = {
struct rtems_bsdnet_config rtems_bsdnet_config = {
&netdriver_config,
NULL,
- 0, /* Default network task priority */
- 0, /* Default mbuf capacity */
- 0, /* Default mbuf cluster capacity */
- "rtems", /* Host name */
- "xxxyyy.com", /* Domain name */
+ 30, /* Default network task priority */
+ (256*1024), /* Default mbuf capacity */
+ (512*1024), /* Default mbuf cluster capacity */
+ 0, /* Host name */
+ 0, /* Domain name */
0, /* Gateway */
0, /* Log host */
{ 0 }, /* Name server(s) */
diff --git a/c/src/libnetworking/pppd/fsm.c b/c/src/libnetworking/pppd/fsm.c
index 07a8c11f1d..ba7ddfe715 100644
--- a/c/src/libnetworking/pppd/fsm.c
+++ b/c/src/libnetworking/pppd/fsm.c
@@ -59,7 +59,7 @@ fsm_init(f)
{
f->state = INITIAL;
f->flags = 0;
- f->id = 0; /* XXX Start with random id? */
+ f->id = 100; /* XXX Start with random id? */
f->timeouttime = DEFTIMEOUT;
f->maxconfreqtransmits = DEFMAXCONFREQS;
f->maxtermtransmits = DEFMAXTERMREQS;
@@ -413,8 +413,10 @@ fsm_rconfreq(f, id, inp, len)
f->state = OPENED;
if (f->callbacks->up)
(*f->callbacks->up)(f); /* Inform upper layers */
- } else
+ } else {
f->state = ACKSENT;
+ ppp_delay();
+ }
f->nakloops = 0;
} else {
diff --git a/c/src/libnetworking/pppd/fsm.h b/c/src/libnetworking/pppd/fsm.h
index c94a68e6ce..6f230d9ddf 100644
--- a/c/src/libnetworking/pppd/fsm.h
+++ b/c/src/libnetworking/pppd/fsm.h
@@ -119,7 +119,7 @@ typedef struct fsm_callbacks {
/*
* Timeouts.
*/
-#define DEFTIMEOUT 3 /* Timeout time in seconds */
+#define DEFTIMEOUT 5 /* Timeout time in seconds */
#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
diff --git a/c/src/libnetworking/pppd/ipcp.c b/c/src/libnetworking/pppd/ipcp.c
index 57245721fa..680409c5c8 100644
--- a/c/src/libnetworking/pppd/ipcp.c
+++ b/c/src/libnetworking/pppd/ipcp.c
@@ -1570,24 +1570,26 @@ static void
create_resolv(peerdns1, peerdns2)
u_int32_t peerdns1, peerdns2;
{
- FILE *f;
-
- f = fopen(_PATH_RESOLV, "w");
- if (f == NULL) {
- error("Failed to create %s: %m", _PATH_RESOLV);
- return;
- }
-
- if (peerdns1)
- fprintf(f, "nameserver %s\n", ip_ntoa(peerdns1));
-
- if (peerdns2)
- fprintf(f, "nameserver %s\n", ip_ntoa(peerdns2));
-
- if (ferror(f))
- error("Write failed to %s: %m", _PATH_RESOLV);
-
- fclose(f);
+ extern int rtems_bsdnet_nameserver_count;
+ extern struct in_addr rtems_bsdnet_nameserver[];
+
+ /* initialize values */
+ rtems_bsdnet_nameserver_count = (int)0;
+
+ /* check to see if primary was specified */
+ if ( peerdns1 ) {
+ rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns1;
+ rtems_bsdnet_nameserver_count++;
+ }
+
+ /* check to see if secondary was specified */
+ if ( peerdns2 ) {
+ rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns2;
+ rtems_bsdnet_nameserver_count++;
+ }
+
+ /* initialize resolver */
+ __res_init();
}
/*
diff --git a/c/src/libnetworking/pppd/options.c b/c/src/libnetworking/pppd/options.c
index 3f56dbf892..00dcf591ba 100644
--- a/c/src/libnetworking/pppd/options.c
+++ b/c/src/libnetworking/pppd/options.c
@@ -715,6 +715,10 @@ process_option(opt, argv)
sv = strdup(*argv);
if (sv == NULL)
novm("option argument");
+ if ( *(char **)(opt->addr) != NULL ) {
+ free((void *)*(char **)(opt->addr));
+ *(char **)(opt->addr) = NULL;
+ }
*(char **)(opt->addr) = sv;
}
break;
diff --git a/c/src/libnetworking/pppd/pppd.h b/c/src/libnetworking/pppd/pppd.h
index 3e4f6c68ee..a210a9ac55 100644
--- a/c/src/libnetworking/pppd/pppd.h
+++ b/c/src/libnetworking/pppd/pppd.h
@@ -19,10 +19,6 @@
* $Id$
*/
-/*
- * TODO:
- */
-
#ifndef __PPPD_H__
#define __PPPD_H__
@@ -32,6 +28,7 @@
#include <sys/types.h> /* for u_int32_t, if defined */
#include <sys/time.h> /* for struct timeval */
#include <net/ppp_defs.h>
+#include "rtemsdialer.h"
#if defined(__STDC__)
#include <stdarg.h>
@@ -167,6 +164,7 @@ extern int devnam_fixed; /* can no longer change devnam */
extern int unsuccess; /* # unsuccessful connection attempts */
extern int do_callback; /* set if we want to do callback next */
extern int doing_callback; /* set if this is a callback */
+extern dialerfp pppd_dialer; /* script dialer function callback */
/* Values for do_callback and doing_callback */
#define CALLBACK_DIALIN 1 /* we are expecting the call back */
@@ -378,8 +376,9 @@ void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
void restore_tty __P((int)); /* Restore port's original parameters */
void setdtr __P((int, int)); /* Raise or lower port's DTR line */
void output __P((int, u_char *, int)); /* Output a PPP packet */
-void wait_input __P((struct timeval *));
- /* Wait for input, with timeout */
+void wait_input __P((struct timeval *)); /* Wait for input, with timeout */
+
+void ppp_delay __P((void)); /* delay task for a little while */
int read_packet __P((u_char *)); /* Read PPP packet */
int get_loop_output __P((void)); /* Read pkts from loopback */
void ppp_send_config __P((int, int, u_int32_t, int, int));
diff --git a/c/src/libnetworking/pppd/rtemsmain.c b/c/src/libnetworking/pppd/rtemsmain.c
index 38383c6e06..17804db38f 100644
--- a/c/src/libnetworking/pppd/rtemsmain.c
+++ b/c/src/libnetworking/pppd/rtemsmain.c
@@ -41,9 +41,6 @@
#include <rtems.h>
#include <rtems/rtems_bsdnet.h>
-extern void rtems_bsdnet_semaphore_obtain(void);
-extern void rtems_bsdnet_semaphore_release(void);
-extern int chatmain(char *argv);
#include "pppd.h"
#include "magic.h"
@@ -58,6 +55,7 @@ extern int chatmain(char *argv);
#include "ccp.h"
#include "pathnames.h"
#include "patchlevel.h"
+#include "rtemsdialer.h"
#ifdef CBCP_SUPPORT
#include "cbcp.h"
@@ -94,6 +92,7 @@ int unsuccess; /* # unsuccessful connection attempts */
int do_callback; /* != 0 if we should do callback next */
int doing_callback; /* != 0 if we are doing callback */
char *callback_script; /* script for doing callback */
+dialerfp pppd_dialer;
int (*holdoff_hook) __P((void)) = NULL;
int (*new_phase_hook) __P((int)) = NULL;
@@ -129,7 +128,7 @@ static void get_input __P((void));
static void calltimeout __P((void));
static struct timeval *timeleft __P((struct timeval *));
static void holdoff_end __P((void *));
-static int device_script __P((char *, int, int, int));
+static int device_script __P((int, int, char *));
extern char *ttyname __P((int));
extern char *getlogin __P((void));
@@ -312,7 +311,7 @@ pppdmain(argc, argv)
}
if (initializer && initializer[0]) {
- if (device_script(initializer, ttyfd, ttyfd, 0) < 0) {
+ if (device_script(ttyfd, DIALER_INIT, initializer) < 0) {
error("Initializer script failed");
status = EXIT_INIT_FAILED;
goto fail;
@@ -324,7 +323,7 @@ pppdmain(argc, argv)
}
if (connector && connector[0]) {
- if (device_script(connector, ttyfd, ttyfd, 0) < 0) {
+ if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) {
error("Connect script failed");
status = EXIT_CONNECT_FAILED;
goto fail;
@@ -364,7 +363,7 @@ pppdmain(argc, argv)
/* run welcome script, if any */
if (welcomer && welcomer[0]) {
- if (device_script(welcomer, ttyfd, ttyfd, 0) < 0)
+ if (device_script(ttyfd, DIALER_WELCOME, welcomer) < 0)
warn("Welcome script failed");
}
@@ -387,10 +386,8 @@ pppdmain(argc, argv)
notice("Connect: %s <--> %s", ifname, ppp_devnam);
gettimeofday(&start_time, NULL);
- rtems_bsdnet_semaphore_obtain();
lcp_lowerup(0);
lcp_open(0); /* Start protocol */
- rtems_bsdnet_semaphore_release();
open_ccp_flag = 0;
status = EXIT_NEGOTIATION_FAILED;
@@ -398,7 +395,7 @@ pppdmain(argc, argv)
while (phase != PHASE_DEAD) {
wait_input(timeleft(&timo));
calltimeout();
- get_input();
+ get_input();
if (kill_link) {
lcp_close(0, "User request");
@@ -435,7 +432,7 @@ pppdmain(argc, argv)
new_phase(PHASE_DISCONNECT);
if (real_ttyfd >= 0)
set_up_tty(real_ttyfd, 1);
- if (device_script(disconnect_script, ttyfd, ttyfd, 0) < 0) {
+ if (device_script(ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
warn("disconnect script failed");
} else {
info("Serial link disconnected.");
@@ -477,7 +474,7 @@ pppdmain(argc, argv)
}
die(status);
- return 0;
+ return status;
}
/*
@@ -578,7 +575,7 @@ protocol_name(proto)
* get_input - called when incoming data is available.
*/
static void
-get_input()
+get_input(void)
{
int len, i;
u_char *p;
@@ -608,7 +605,6 @@ get_input()
return;
}
- rtems_bsdnet_semaphore_obtain();
p += 2; /* Skip address and control */
GETSHORT(protocol, p);
len -= PPP_HDRLEN;
@@ -618,7 +614,6 @@ get_input()
*/
if (protocol != PPP_LCP && lcp_fsm[0].state != OPENED) {
MAINDEBUG(("get_input: Received non-LCP packet when LCP not open."));
- rtems_bsdnet_semaphore_release();
return;
}
@@ -631,7 +626,6 @@ get_input()
|| protocol == PPP_PAP || protocol == PPP_CHAP)) {
MAINDEBUG(("get_input: discarding proto 0x%x in phase %d",
protocol, phase));
- rtems_bsdnet_semaphore_release();
return;
}
@@ -641,13 +635,11 @@ get_input()
for (i = 0; (protp = protocols[i]) != NULL; ++i) {
if (protp->protocol == protocol && protp->enabled_flag) {
(*protp->input)(0, p, len);
- rtems_bsdnet_semaphore_release();
return;
}
if (protocol == (protp->protocol & ~0x8000) && protp->enabled_flag
&& protp->datainput != NULL) {
(*protp->datainput)(0, p, len);
- rtems_bsdnet_semaphore_release();
return;
}
}
@@ -660,7 +652,8 @@ get_input()
warn("Unsupported protocol 0x%x received", protocol);
}
lcp_sprotrej(0, p - PPP_HDRLEN, len + PPP_HDRLEN);
- rtems_bsdnet_semaphore_release();
+
+ return;
}
/*
@@ -872,16 +865,27 @@ timeleft(tvp)
* device_script - run a program to talk to the serial device
* (e.g. to run the connector or disconnector script).
*/
-static int
-device_script(program, in, out, dont_wait)
- char *program;
- int in, out;
- int dont_wait;
+static int device_script(int fd, int mode, char *program)
{
- char pScript[256];
+ int iReturn = -1;
+ char pScript[128];
+ /* copyt script into temporary location */
strcpy(pScript, program);
- return chatmain(pScript);
+
+ /* check to see if dialer was initialized */
+ if ( !pppd_dialer ) {
+ /* set default dialer to chatmain */
+ pppd_dialer = chatmain;
+ }
+
+ /* check to see if dialer is set */
+ if ( pppd_dialer ) {
+ /* call the dialer */
+ iReturn = (*pppd_dialer)(fd, mode, program);
+ }
+
+ return ( -iReturn );
}
/*
diff --git a/c/src/libnetworking/pppd/rtemspppd.c b/c/src/libnetworking/pppd/rtemspppd.c
index 5a821cdfaf..0089c01946 100644
--- a/c/src/libnetworking/pppd/rtemspppd.c
+++ b/c/src/libnetworking/pppd/rtemspppd.c
@@ -1,15 +1,18 @@
#include <rtems.h>
+#include <rtems/rtems_bsdnet.h>
#include "pppd.h"
#include "rtemspppd.h"
/* define pppd function prototypes */
extern void pppasyncattach(void);
-extern int pppdmain(int, char **);
+extern int pppdmain(int, char **);
/* define global variables */
-rtems_id rtems_pppd_taskid;
+rtems_id rtems_pppd_taskid;
+rtems_pppd_hookfunction rtems_pppd_errorfp;
+rtems_pppd_hookfunction rtems_pppd_exitfp;
static rtems_task pppTask(rtems_task_argument arg)
@@ -18,6 +21,7 @@ static rtems_task pppTask(rtems_task_argument arg)
rtems_option options;
rtems_event_set in;
rtems_event_set out;
+ int iStatus;
/* call function to setup ppp line discipline */
pppasyncattach();
@@ -38,27 +42,48 @@ static rtems_task pppTask(rtems_task_argument arg)
else if ( out & RTEMS_EVENT_30 ) {
/* connect request */
/* execute the pppd main code */
- pppdmain(0, NULL);
+ iStatus = pppdmain(0, NULL);
+ if ( iStatus == EXIT_OK ) {
+ /* check exit callback */
+ if ( rtems_pppd_exitfp ) {
+ (*rtems_pppd_exitfp)();
+ }
+ }
+ else {
+ /* check error callback */
+ if ( rtems_pppd_errorfp ) {
+ (*rtems_pppd_errorfp)();
+ }
+ }
}
}
}
/* terminate myself */
+ rtems_pppd_taskid = 0;
rtems_task_delete(RTEMS_SELF);
}
int rtems_pppd_initialize(void)
{
- int iReturn = (int)-1;
+ int iReturn = (int)-1;
+ rtems_unsigned32 priority = 100;
rtems_status_code status;
rtems_name taskName;
+ /* determine priority value */
+ if ( rtems_bsdnet_config.network_task_priority ) {
+ priority = rtems_bsdnet_config.network_task_priority;
+ }
+
+ /* initialize the exit hook */
+ rtems_pppd_exitfp = (rtems_pppd_hookfunction)0;
+
+ /* create the rtems task */
taskName = rtems_build_name( 'p', 'p', 'p', 'd' );
- status = rtems_task_create(taskName,
- RTEMS_PPPD_TASK_PRIORITY,
- RTEMS_PPPD_TASK_STACK_SIZE,
- RTEMS_PPPD_TASK_INITIAL_MODES,
- RTEMS_DEFAULT_ATTRIBUTES,
+ status = rtems_task_create(taskName, priority, 8192,
+ (RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0)),
+ RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
&rtems_pppd_taskid);
if ( status == RTEMS_SUCCESSFUL ) {
status = rtems_task_start(rtems_pppd_taskid, pppTask, 0);
@@ -114,6 +139,12 @@ int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp)
case RTEMS_PPPD_IPDOWN_HOOK:
ip_down_hook = hookfp;
break;
+ case RTEMS_PPPD_ERROR_HOOK:
+ rtems_pppd_errorfp = hookfp;
+ break;
+ case RTEMS_PPPD_EXIT_HOOK:
+ rtems_pppd_exitfp = hookfp;
+ break;
default:
iReturn = (int)-1;
break;
@@ -122,6 +153,12 @@ int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp)
return ( iReturn );
}
+int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp)
+{
+ pppd_dialer = dialerfp;
+ return ( (int)0 );
+}
+
int rtems_pppd_set_option(const char *pOption, const char *pValue)
{
int iReturn = (int)0;
diff --git a/c/src/libnetworking/pppd/rtemspppd.h b/c/src/libnetworking/pppd/rtemspppd.h
index 9d44e58594..f60916e2ee 100644
--- a/c/src/libnetworking/pppd/rtemspppd.h
+++ b/c/src/libnetworking/pppd/rtemspppd.h
@@ -2,28 +2,18 @@
#ifndef RTEMSPPPD_H
#define RTEMSPPPD_H
-/* check to see if pppd task values are set */
-#ifndef RTEMS_PPPD_TASK_PRIORITY
-#define RTEMS_PPPD_TASK_PRIORITY 120
-#endif
-#ifndef RTEMS_PPPD_TASK_STACK_SIZE
-#define RTEMS_PPPD_TASK_STACK_SIZE (10*1024)
-#endif
-#ifndef RTEMS_PPPD_TASK_INITIAL_MODES
-#define RTEMS_PPPD_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
- RTEMS_NO_TIMESLICE | \
- RTEMS_NO_ASR | \
- RTEMS_INTERRUPT_LEVEL(0))
-#endif
/* define hook function identifiers */
#define RTEMS_PPPD_LINKUP_HOOK 1
#define RTEMS_PPPD_LINKDOWN_HOOK 2
#define RTEMS_PPPD_IPUP_HOOK 3
#define RTEMS_PPPD_IPDOWN_HOOK 4
+#define RTEMS_PPPD_ERROR_HOOK 5
+#define RTEMS_PPPD_EXIT_HOOK 6
/* define hook function pointer prototype */
typedef void (*rtems_pppd_hookfunction)(void);
+typedef int (*rtems_pppd_dialerfunction)(int tty, int mode, char *pScript);
/* define pppd function prototyes */
@@ -31,6 +21,7 @@ int rtems_pppd_initialize(void);
int rtems_pppd_terminate(void);
int rtems_pppd_reset_options(void);
int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp);
+int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp);
int rtems_pppd_set_option(const char *pOption, const char *pValue);
int rtems_pppd_connect(void);
int rtems_pppd_disconnect(void);
diff --git a/c/src/libnetworking/pppd/sys-rtems.c b/c/src/libnetworking/pppd/sys-rtems.c
index 90e0538ff1..dc8fa76538 100644
--- a/c/src/libnetworking/pppd/sys-rtems.c
+++ b/c/src/libnetworking/pppd/sys-rtems.c
@@ -95,12 +95,6 @@ static int dodefaultroute __P((u_int32_t, int));
static int get_ether_addr __P((u_int32_t, struct sockaddr_dl *));
-void
-sys_serialcallback(struct termios *tty, void *arg)
-{
- rtems_event_send(rtems_pppd_taskid, RTEMS_EVENT_31);
-}
-
/*
* sys_init - System-dependent initialization.
*/
@@ -187,6 +181,7 @@ int
establish_ppp(fd)
int fd;
{
+ int taskid = (int)rtems_pppd_taskid;
int pppdisc = PPPDISC;
int x;
@@ -206,6 +201,9 @@ establish_ppp(fd)
if (ioctl(fd, TIOCSETD, &pppdisc) < 0)
fatal("ioctl(TIOCSETD): %m");
+ /* set pppd taskid into the driver */
+ ioctl(fd, PPPIOCSTASK, &taskid);
+
if (!demand) {
/*
* Find out which interface we were given.
@@ -286,6 +284,11 @@ void
disestablish_ppp(fd)
int fd;
{
+ int taskid = (int)0;
+
+ /* clear pppd taskid from the driver */
+ ioctl(fd, PPPIOCSTASK, &taskid);
+
/* Reset non-blocking mode on fd. */
if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0)
warn("Couldn't restore device fd flags: %m");
@@ -344,7 +347,6 @@ set_up_tty(fd, local)
int fd, local;
{
struct termios tios;
- struct ttywakeup wakeup;
if (tcgetattr(fd, &tios) < 0)
fatal("tcgetattr: %m");
@@ -403,11 +405,6 @@ set_up_tty(fd, local)
fatal("tcsetattr: %m");
}
- /* set up callback function */
- wakeup.sw_pfn = sys_serialcallback;
- wakeup.sw_arg = (void *)fd;
- ioctl(fd, RTEMS_IO_RCVWAKEUP, &wakeup);
-
restore_term = 1;
}
@@ -489,6 +486,7 @@ output(unit, p, len)
{
if (debug);
dbglog("sent %P", p, len);
+/* printf("sent packet [%d]\n", len); */
if (write(ttyfd, p, len) < 0) {
if (errno != EIO)
@@ -496,6 +494,15 @@ output(unit, p, len)
}
}
+void
+ppp_delay(void)
+{
+ rtems_interval ticks;
+
+ /* recommended delay to help negotiation */
+ ticks = 300000/rtems_bsdnet_microseconds_per_tick;
+ rtems_task_wake_after(ticks);
+}
/*
* wait_input - wait until there is data available,
@@ -525,10 +532,11 @@ read_packet(buf)
int len;
if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
- if (errno == EWOULDBLOCK || errno == EINTR)
- return -1;
+ if (errno == EWOULDBLOCK || errno == EINTR) len = -1;
/*fatal("read: %m"); */
}
+
+/* printf("read packet [%d]\n", len); */
return len;
}
@@ -947,6 +955,7 @@ dodefaultroute(g, cmd)
u_int32_t g;
int cmd;
{
+ int status;
struct sockaddr_in address;
struct sockaddr_in netmask;
struct sockaddr_in gateway;
diff --git a/c/src/libnetworking/pppd/upap.h b/c/src/libnetworking/pppd/upap.h
index 42d6f4f0f6..6d5bf64026 100644
--- a/c/src/libnetworking/pppd/upap.h
+++ b/c/src/libnetworking/pppd/upap.h
@@ -76,7 +76,7 @@ typedef struct upap_state {
/*
* Timeouts.
*/
-#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */
+#define UPAP_DEFTIMEOUT 5 /* Timeout (seconds) for retransmitting req */
#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */
extern upap_state upap[];