This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
PPP and CHAT patch
- From: Matt Jerdonek <maj1224 at yahoo dot com>
- To: Patches eCos <ecos-patches at sources dot redhat dot com>
- Date: Tue, 29 Jun 2004 15:00:29 -0700 (PDT)
- Subject: PPP and CHAT patch
Attached is a patch that fixes various issues in the
chat and ppp area.
Please run the patch from the /ecos directory.
Thanks,
-- Matt
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
Index: packages/net/ppp/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/ChangeLog,v
retrieving revision 1.5
diff -u -b -r1.5 ChangeLog
--- packages/net/ppp/current/ChangeLog 6 May 2004 14:46:32 -0000 1.5
+++ packages/net/ppp/current/ChangeLog 29 Jun 2004 21:50:15 -0000
@@ -1,3 +1,25 @@
+2004-06-29 Matt Jerdonek <maj1224@yahoo.com>
+
+ * cdl/ppp.cdl:
+ * src/ipcp.c:
+ Add option to disallow negotiation of old-style VJ compression
+ * include/ppp.h:
+ Add structure to track ppp failure reasons
+ Add prototypes for cyg_ppp_get_local_addr and cyg_ppp_get_peer_addr
+ * include/pppd.h:
+ Fix compiler warning
+ * src/auth.c:
+ * src/lcp.c:
+ * src/pppd.c:
+ Add code to track ppp failure reasons
+ * src/chat.c:
+ Fixes to clear out buffer space to allow chat script to run
+ multiple times. Note: function is still not thread-safe
+ * src/sys-ecos.c:
+ Reset carrier detected bit when carrier lost
+ Reset ppp_tty control block when PPP started
+ Add functions cyg_ppp_get_local_addr and cyg_ppp_get_peer_addr
+
2004-05-06 Mark Retallack <mark.retallack@siemens.com>
* src/ppp_io.c:
Index: packages/net/ppp/current/cdl/ppp.cdl
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/cdl/ppp.cdl,v
retrieving revision 1.2
diff -u -b -r1.2 ppp.cdl
--- packages/net/ppp/current/cdl/ppp.cdl 17 Apr 2004 03:13:05 -0000 1.2
+++ packages/net/ppp/current/cdl/ppp.cdl 29 Jun 2004 21:50:15 -0000
@@ -162,8 +162,8 @@
default_value 0
description "This component provides control over
PPP compression features. WARNING: at
- present there are problems with this, and
- the compression code needs to allocate large
+ present there are problems with BSD and ZLIB,
+ and the compression code needs to allocate large
amounts of memory. Hence this is all currently
disabled."
@@ -183,6 +183,16 @@
compression into the PPP protocol."
}
+ cdl_option PPP_INHIBIT_OLD_VJ_COMPRESSION {
+ display "Inhibit older-style VJ compression"
+ flavor bool
+ default_value 0
+ description "This option prevents the IPCP state machine
+ from negotiating the pre-RFC1332 Van Jacobson
+ compression. Checking this option could
+ improve IPCP negotiation time at the expense
+ of compatibility."
+ }
}
cdl_component CYGPKG_PPP_CHAT {
Index: packages/net/ppp/current/include/ppp.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/include/ppp.h,v
retrieving revision 1.2
diff -u -b -r1.2 ppp.h
--- packages/net/ppp/current/include/ppp.h 17 Apr 2004 03:13:06 -0000 1.2
+++ packages/net/ppp/current/include/ppp.h 29 Jun 2004 21:50:15 -0000
@@ -71,6 +71,17 @@
typedef CYG_ADDRWORD cyg_ppp_handle_t;
// -------------------------------------------------------------------------
+/* PPP failure statistics */
+typedef struct {
+ int auth_failures; /* PAP or CHAP failures */
+ int no_proto; /* No network protocol running */
+ int idle_timeout; /* Idle timer expired */
+ int connect_time_expired; /* Max connect time expired */
+ int loopback; /* Loopback detected */
+ int no_response; /* Peer not responding */
+} cyg_ppp_stats_t;
+extern cyg_ppp_stats_t cyg_ppp_stats; /* PPP statistics */
+// -------------------------------------------------------------------------
typedef struct
{
@@ -134,5 +145,7 @@
// -------------------------------------------------------------------------
+externC u_int32_t cyg_ppp_get_local_addr(void);
+externC u_int32_t cyg_ppp_get_peer_addr(void);
#endif // CYGONCE_PPP_PPP_H multiple inclusion protection
// EOF ppp.h
Index: packages/net/ppp/current/include/pppd.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/include/pppd.h,v
retrieving revision 1.2
diff -u -b -r1.2 pppd.h
--- packages/net/ppp/current/include/pppd.h 17 Apr 2004 03:13:06 -0000 1.2
+++ packages/net/ppp/current/include/pppd.h 29 Jun 2004 21:50:15 -0000
@@ -85,6 +85,7 @@
#include <sys/types.h> /* for u_int32_t, if defined */
#include <sys/time.h> /* for struct timeval */
#include <cyg/ppp/net/ppp_defs.h>
+#include <cyg/ppp/ppp.h>
#if __STDC__
#include <stdarg.h>
@@ -376,6 +377,7 @@
void option_error __P((char *fmt, ...));
/* Print an error message about an option */
int setipaddr __P((char *)); /* set IP addresses */
+int gettimeofday __P((struct timeval *tv, struct timezone *tz));
/*
Index: packages/net/ppp/current/src/auth.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/auth.c,v
retrieving revision 1.3
diff -u -b -r1.3 auth.c
--- packages/net/ppp/current/src/auth.c 6 May 2004 13:54:57 -0000 1.3
+++ packages/net/ppp/current/src/auth.c 29 Jun 2004 21:50:15 -0000
@@ -283,6 +283,7 @@
if (!wo->neg_upap || !null_login(unit)) {
syslog(LOG_WARNING, "peer refused to authenticate");
lcp_close(unit, "peer refused to authenticate");
+ cyg_ppp_stats.auth_failures++;
return;
}
}
@@ -344,9 +345,11 @@
++num_np_open;
}
- if (num_np_open == 0)
+ if (num_np_open == 0) {
/* nothing to do */
lcp_close(0, "No network protocols running");
+ cyg_ppp_stats.no_proto++;
+ }
}
/*
@@ -360,6 +363,7 @@
* Authentication failure: take the link down
*/
lcp_close(unit, "Authentication failed");
+ cyg_ppp_stats.auth_failures++;
}
/*
@@ -422,6 +426,7 @@
* He'll probably take the link down, and there's not much
* we can do except wait for that.
*/
+ cyg_ppp_stats.auth_failures++;
}
/*
@@ -512,6 +517,7 @@
if (--num_np_open <= 0) {
/* no further use for the link: shut up shop. */
lcp_close(0, "No network protocols running");
+ cyg_ppp_stats.no_proto++;
}
}
@@ -533,6 +539,7 @@
/* link is idle: shut it down. */
syslog(LOG_INFO, "Terminating connection due to lack of activity.");
lcp_close(0, "Link inactive");
+ cyg_ppp_stats.idle_timeout++;
} else {
TIMEOUT(check_idle, NULL, idle_time_limit - itime);
}
@@ -547,6 +554,7 @@
{
syslog(LOG_INFO, "Connect time expired");
lcp_close(0, "Connect time expired"); /* Close connection */
+ cyg_ppp_stats.connect_time_expired++;
}
/*
Index: packages/net/ppp/current/src/chat.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/chat.c,v
retrieving revision 1.3
diff -u -b -r1.3 chat.c
--- packages/net/ppp/current/src/chat.c 17 Apr 2004 03:13:06 -0000 1.3
+++ packages/net/ppp/current/src/chat.c 29 Jun 2004 21:50:16 -0000
@@ -111,7 +111,7 @@
static cyg_io_handle_t cyg_ppp_chat_handle;
// String buffers
-static char cyg_ppp_chat_buffer[CHAT_STRING_LENGTH];
+char cyg_ppp_chat_buffer[CHAT_STRING_LENGTH];
static char cyg_ppp_chat_expect_buffer[CHAT_STRING_LENGTH];
//=====================================================================
@@ -365,16 +365,26 @@
const char *s;
Cyg_ErrNo err;
cyg_int32 result = 1;
+ cyg_uint32 zero = 0;
+ cyg_uint32 len = sizeof(zero);
cyg_ppp_chat_thread = cyg_thread_self();
cyg_ppp_chat_abort_count = 0;
cyg_ppp_chat_timeout = 45;
+ // Clear the result area
+ memset(cyg_ppp_chat_buffer, 0, CHAT_STRING_LENGTH);
+
while ((err = cyg_io_lookup(devname, &cyg_ppp_chat_handle)) < 0) {
if (err != 0)
syslog(LOG_ERR, "Failed to open %s: %d", devname,err);
}
+ // Flush the serial input before starting
+ cyg_io_get_config( cyg_ppp_chat_handle,
+ CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH,
+ &zero, &len);
+
// Set up timeout alarm.
cyg_alarm_create( cyg_real_time_clock(),
chat_alarm,
@@ -433,16 +443,10 @@
}
// Finally, wait for the serial device to drain
- {
- cyg_uint32 zero = 0;
- cyg_uint32 len = sizeof(zero);
-
cyg_io_get_config( cyg_ppp_chat_handle,
CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN,
&zero, &len);
- }
-
return result;
}
Index: packages/net/ppp/current/src/ipcp.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/ipcp.c,v
retrieving revision 1.2
diff -u -b -r1.2 ipcp.c
--- packages/net/ppp/current/src/ipcp.c 17 Apr 2004 03:13:06 -0000 1.2
+++ packages/net/ppp/current/src/ipcp.c 29 Jun 2004 21:50:16 -0000
@@ -83,6 +83,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
+#include <pkgconf/ppp.h>
#include "cyg/ppp/pppd.h"
#include "cyg/ppp/fsm.h"
#include "cyg/ppp/ipcp.h"
@@ -363,8 +364,10 @@
if (wo->neg_vj && !go->neg_vj && !go->old_vj) {
/* try an older style of VJ negotiation */
if (cis_received[f->unit] == 0) {
+#ifndef PPP_INHIBIT_OLD_VJ_COMPRESSION
/* keep trying the new style until we see some CI from the peer */
go->neg_vj = 1;
+#endif
} else {
/* use the old style only if the peer did */
if (ho->neg_vj && ho->old_vj) {
Index: packages/net/ppp/current/src/lcp.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/lcp.c,v
retrieving revision 1.2
diff -u -b -r1.2 lcp.c
--- packages/net/ppp/current/src/lcp.c 17 Apr 2004 03:13:06 -0000 1.2
+++ packages/net/ppp/current/src/lcp.c 29 Jun 2004 21:50:16 -0000
@@ -1018,6 +1018,7 @@
if (++try.numloops >= lcp_loopbackfail) {
syslog(LOG_NOTICE, "Serial line is looped back.");
lcp_close(f->unit, "Loopback detected");
+ cyg_ppp_stats.loopback++;
}
} else
try.numloops = 0;
@@ -1778,6 +1779,7 @@
syslog(LOG_INFO, "No response to %d echo-requests", lcp_echos_pending);
syslog(LOG_NOTICE, "Serial link appears to be disconnected.");
lcp_close(f->unit, "Peer not responding");
+ cyg_ppp_stats.no_response++;
}
}
Index: packages/net/ppp/current/src/pppd.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/pppd.c,v
retrieving revision 1.3
diff -u -b -r1.3 pppd.c
--- packages/net/ppp/current/src/pppd.c 6 May 2004 13:54:57 -0000 1.3
+++ packages/net/ppp/current/src/pppd.c 29 Jun 2004 21:50:17 -0000
@@ -193,6 +193,7 @@
u_char inpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for incoming packet */
char *no_ppp_msg = "Sorry - this system lacks PPP kernel support\n";
+cyg_ppp_stats_t cyg_ppp_stats;
/* Prototypes for procedures local to this file. */
Index: packages/net/ppp/current/src/sys-ecos.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/sys-ecos.c,v
retrieving revision 1.4
diff -u -b -r1.4 sys-ecos.c
--- packages/net/ppp/current/src/sys-ecos.c 6 May 2004 14:46:35 -0000 1.4
+++ packages/net/ppp/current/src/sys-ecos.c 29 Jun 2004 21:50:17 -0000
@@ -538,6 +538,7 @@
if( s->value == 0 )
{
// CD lost
+ ppp_tty.carrier_detected = 0;
kill_link = 1;
cyg_thread_release( ppp_tty.pppd_thread );
ppp_tty.pppd_wakeup = 1;
@@ -1692,6 +1693,9 @@
if( options == NULL || phase != PHASE_DEAD )
return 0;
+ // Initialize control block
+ memset(&ppp_tty, 0, sizeof(struct tty));
+
strncpy( devnam, devnam_arg, PATH_MAX );
ppp_tty.options = options;
@@ -1804,6 +1808,26 @@
cyg_thread_delete( ppp_tty.pppd_thread );
}
+// -------------------------------------------------------------------------
+
+externC u_int32_t cyg_ppp_get_local_addr(void)
+{
+ if (phase == PHASE_NETWORK && ifaddrs[0] != 0)
+ return(ipcp_gotoptions[0].ouraddr);
+ else
+ return(0);
+}
+
+// -------------------------------------------------------------------------
+
+externC u_int32_t cyg_ppp_get_peer_addr(void)
+{
+ if (phase == PHASE_NETWORK && ifaddrs[0] != 0)
+ return(ipcp_hisoptions[0].hisaddr);
+ else
+ return(0);
+}
+
//=====================================================================
// eCos extras