mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
2005-01-31 Sergei Organov <osv@topconrd.ru>
PR 771/pppd * libnetworking/pppd/chat.c, libnetworking/pppd/rtemsmain.c: The fix committed to fix PR736 breaks pppd. chat.c should have its own static ttyfd for pppd to work correctly. The symptom is that second invokation of chat (for connect script) fails due to pppd_ttyfd set to -1 by previous chat invokation (for init script). In addition, this patch fixes leaving of dangling pointer in the abort_stbring[] by chat_send().
This commit is contained in:
@@ -1,3 +1,14 @@
|
|||||||
|
2005-01-31 Sergei Organov <osv@topconrd.ru>
|
||||||
|
|
||||||
|
PR 771/pppd
|
||||||
|
* libnetworking/pppd/chat.c, libnetworking/pppd/rtemsmain.c: The fix
|
||||||
|
committed to fix PR736 breaks pppd. chat.c should have its own static
|
||||||
|
ttyfd for pppd to work correctly. The symptom is that second
|
||||||
|
invokation of chat (for connect script) fails due to pppd_ttyfd set
|
||||||
|
to -1 by previous chat invokation (for init script). In addition,
|
||||||
|
this patch fixes leaving of dangling pointer in the abort_stbring[]
|
||||||
|
by chat_send().
|
||||||
|
|
||||||
2005-01-24 Ralf Corsepius <ralf.corsepius@rtems.org>
|
2005-01-24 Ralf Corsepius <ralf.corsepius@rtems.org>
|
||||||
|
|
||||||
* configure.ac: Remove CFLAGS_DEBUG_V.
|
* configure.ac: Remove CFLAGS_DEBUG_V.
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ static int use_env = 0;
|
|||||||
static int exit_code = 0;
|
static int exit_code = 0;
|
||||||
static char *phone_num = (char *) 0;
|
static char *phone_num = (char *) 0;
|
||||||
static char *phone_num2 = (char *) 0;
|
static char *phone_num2 = (char *) 0;
|
||||||
/* static */ int pppd_ttyfd;
|
static int ttyfd;
|
||||||
static int timeout = DEFAULT_CHAT_TIMEOUT;
|
static int timeout = DEFAULT_CHAT_TIMEOUT;
|
||||||
|
|
||||||
#ifdef TERMIOS
|
#ifdef TERMIOS
|
||||||
@@ -246,7 +246,7 @@ int chatmain(int fd, int mode, char *pScript)
|
|||||||
|
|
||||||
/* initialize exit code */
|
/* initialize exit code */
|
||||||
exit_code = 0;
|
exit_code = 0;
|
||||||
pppd_ttyfd = fd;
|
ttyfd = fd;
|
||||||
|
|
||||||
script=pScript;
|
script=pScript;
|
||||||
|
|
||||||
@@ -271,14 +271,14 @@ int chatmain(int fd, int mode, char *pScript)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pppd_ttyfd = (int)-1;
|
ttyfd = (int)-1;
|
||||||
|
|
||||||
return ( exit_code );
|
return ( exit_code );
|
||||||
}
|
}
|
||||||
|
|
||||||
void break_sequence()
|
void break_sequence()
|
||||||
{
|
{
|
||||||
tcsendbreak(pppd_ttyfd, 0);
|
tcsendbreak(ttyfd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -639,16 +639,15 @@ register char *s;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (abort_next) {
|
if (abort_next) {
|
||||||
char *s1;
|
|
||||||
|
|
||||||
abort_next = 0;
|
abort_next = 0;
|
||||||
if ( n_aborts < MAX_ABORTS ) {
|
if ( n_aborts < MAX_ABORTS ) {
|
||||||
|
char *s1;
|
||||||
s1 = clean(s, 0);
|
s1 = clean(s, 0);
|
||||||
if (( strlen(s1) <= strlen(s) ) && ( strlen(s1) < sizeof(fail_buffer))) {
|
if (( strlen(s1) <= strlen(s) ) && ( strlen(s1) < sizeof(fail_buffer)))
|
||||||
abort_string[n_aborts++] = s1;
|
abort_string[n_aborts++] = s1;
|
||||||
|
else
|
||||||
|
free(s1);
|
||||||
}
|
}
|
||||||
free(s1);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +698,7 @@ static int get_char()
|
|||||||
|
|
||||||
while(tries)
|
while(tries)
|
||||||
{
|
{
|
||||||
status = read(pppd_ttyfd, &c, 1);
|
status = read(ttyfd, &c, 1);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 1:
|
case 1:
|
||||||
return ((int)c & 0x7F);
|
return ((int)c & 0x7F);
|
||||||
@@ -715,7 +714,7 @@ int c;
|
|||||||
{
|
{
|
||||||
char ch = c;
|
char ch = c;
|
||||||
|
|
||||||
return(write(pppd_ttyfd, &ch, 1));
|
return(write(ttyfd, &ch, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_char (c)
|
static int write_char (c)
|
||||||
@@ -791,10 +790,10 @@ register char *in_string;
|
|||||||
|
|
||||||
memset(temp2, 0, sizeof(temp2));
|
memset(temp2, 0, sizeof(temp2));
|
||||||
|
|
||||||
tcgetattr(pppd_ttyfd, &tios);
|
tcgetattr(ttyfd, &tios);
|
||||||
tios.c_cc[VMIN] = 0;
|
tios.c_cc[VMIN] = 0;
|
||||||
tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
|
tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
|
||||||
tcsetattr(pppd_ttyfd, TCSANOW, &tios);
|
tcsetattr(ttyfd, TCSANOW, &tios);
|
||||||
|
|
||||||
string = clean(in_string, 0);
|
string = clean(in_string, 0);
|
||||||
len = strlen(string);
|
len = strlen(string);
|
||||||
@@ -807,7 +806,8 @@ register char *in_string;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return (1);
|
free(string);
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( (c = get_char()) >= 0) {
|
while ( (c = get_char()) >= 0) {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ int pppifunit; /* Interface unit number */
|
|||||||
char hostname[MAXNAMELEN]; /* Our hostname */
|
char hostname[MAXNAMELEN]; /* Our hostname */
|
||||||
static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
|
static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
|
||||||
|
|
||||||
/* int pppd_ttyfd; * Serial port file descriptor */
|
int pppd_ttyfd; /* Serial port file descriptor */
|
||||||
int baud_rate; /* Actual bits/second for serial device */
|
int baud_rate; /* Actual bits/second for serial device */
|
||||||
int hungup; /* terminal has been hung up */
|
int hungup; /* terminal has been hung up */
|
||||||
int privileged; /* we're running as real uid root */
|
int privileged; /* we're running as real uid root */
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ static int use_env = 0;
|
|||||||
static int exit_code = 0;
|
static int exit_code = 0;
|
||||||
static char *phone_num = (char *) 0;
|
static char *phone_num = (char *) 0;
|
||||||
static char *phone_num2 = (char *) 0;
|
static char *phone_num2 = (char *) 0;
|
||||||
/* static */ int pppd_ttyfd;
|
static int ttyfd;
|
||||||
static int timeout = DEFAULT_CHAT_TIMEOUT;
|
static int timeout = DEFAULT_CHAT_TIMEOUT;
|
||||||
|
|
||||||
#ifdef TERMIOS
|
#ifdef TERMIOS
|
||||||
@@ -246,7 +246,7 @@ int chatmain(int fd, int mode, char *pScript)
|
|||||||
|
|
||||||
/* initialize exit code */
|
/* initialize exit code */
|
||||||
exit_code = 0;
|
exit_code = 0;
|
||||||
pppd_ttyfd = fd;
|
ttyfd = fd;
|
||||||
|
|
||||||
script=pScript;
|
script=pScript;
|
||||||
|
|
||||||
@@ -271,14 +271,14 @@ int chatmain(int fd, int mode, char *pScript)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pppd_ttyfd = (int)-1;
|
ttyfd = (int)-1;
|
||||||
|
|
||||||
return ( exit_code );
|
return ( exit_code );
|
||||||
}
|
}
|
||||||
|
|
||||||
void break_sequence()
|
void break_sequence()
|
||||||
{
|
{
|
||||||
tcsendbreak(pppd_ttyfd, 0);
|
tcsendbreak(ttyfd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -639,16 +639,15 @@ register char *s;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (abort_next) {
|
if (abort_next) {
|
||||||
char *s1;
|
|
||||||
|
|
||||||
abort_next = 0;
|
abort_next = 0;
|
||||||
if ( n_aborts < MAX_ABORTS ) {
|
if ( n_aborts < MAX_ABORTS ) {
|
||||||
|
char *s1;
|
||||||
s1 = clean(s, 0);
|
s1 = clean(s, 0);
|
||||||
if (( strlen(s1) <= strlen(s) ) && ( strlen(s1) < sizeof(fail_buffer))) {
|
if (( strlen(s1) <= strlen(s) ) && ( strlen(s1) < sizeof(fail_buffer)))
|
||||||
abort_string[n_aborts++] = s1;
|
abort_string[n_aborts++] = s1;
|
||||||
|
else
|
||||||
|
free(s1);
|
||||||
}
|
}
|
||||||
free(s1);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +698,7 @@ static int get_char()
|
|||||||
|
|
||||||
while(tries)
|
while(tries)
|
||||||
{
|
{
|
||||||
status = read(pppd_ttyfd, &c, 1);
|
status = read(ttyfd, &c, 1);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 1:
|
case 1:
|
||||||
return ((int)c & 0x7F);
|
return ((int)c & 0x7F);
|
||||||
@@ -715,7 +714,7 @@ int c;
|
|||||||
{
|
{
|
||||||
char ch = c;
|
char ch = c;
|
||||||
|
|
||||||
return(write(pppd_ttyfd, &ch, 1));
|
return(write(ttyfd, &ch, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_char (c)
|
static int write_char (c)
|
||||||
@@ -791,10 +790,10 @@ register char *in_string;
|
|||||||
|
|
||||||
memset(temp2, 0, sizeof(temp2));
|
memset(temp2, 0, sizeof(temp2));
|
||||||
|
|
||||||
tcgetattr(pppd_ttyfd, &tios);
|
tcgetattr(ttyfd, &tios);
|
||||||
tios.c_cc[VMIN] = 0;
|
tios.c_cc[VMIN] = 0;
|
||||||
tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
|
tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
|
||||||
tcsetattr(pppd_ttyfd, TCSANOW, &tios);
|
tcsetattr(ttyfd, TCSANOW, &tios);
|
||||||
|
|
||||||
string = clean(in_string, 0);
|
string = clean(in_string, 0);
|
||||||
len = strlen(string);
|
len = strlen(string);
|
||||||
@@ -807,7 +806,8 @@ register char *in_string;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return (1);
|
free(string);
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( (c = get_char()) >= 0) {
|
while ( (c = get_char()) >= 0) {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ int pppifunit; /* Interface unit number */
|
|||||||
char hostname[MAXNAMELEN]; /* Our hostname */
|
char hostname[MAXNAMELEN]; /* Our hostname */
|
||||||
static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
|
static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
|
||||||
|
|
||||||
/* int pppd_ttyfd; * Serial port file descriptor */
|
int pppd_ttyfd; /* Serial port file descriptor */
|
||||||
int baud_rate; /* Actual bits/second for serial device */
|
int baud_rate; /* Actual bits/second for serial device */
|
||||||
int hungup; /* terminal has been hung up */
|
int hungup; /* terminal has been hung up */
|
||||||
int privileged; /* we're running as real uid root */
|
int privileged; /* we're running as real uid root */
|
||||||
|
|||||||
Reference in New Issue
Block a user