author | tille <tille> | 2003-06-06 13:24:19 (UTC) |
---|---|---|
committer | tille <tille> | 2003-06-06 13:24:19 (UTC) |
commit | d3e9154252841f3adcfbd9868e263475fc698ebb (patch) (unidiff) | |
tree | b40d6fad6e96d78ed963e3df50faba67bfc2cda7 | |
parent | 78a5ebf10450a99211a5e86be1abc0397b749db3 (diff) | |
download | opie-d3e9154252841f3adcfbd9868e263475fc698ebb.zip opie-d3e9154252841f3adcfbd9868e263475fc698ebb.tar.gz opie-d3e9154252841f3adcfbd9868e263475fc698ebb.tar.bz2 |
includes for arm
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index 002c8e7..2da9b14 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -1,224 +1,226 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd Front End for the KDE project | 2 | * kPPP: A pppd Front End for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * This file was added by Harri Porten <porten@tu-harburg.de> | 9 | * This file was added by Harri Porten <porten@tu-harburg.de> |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | #include <fcntl.h> | 30 | #include <fcntl.h> |
31 | #include <signal.h> | 31 | #include <signal.h> |
32 | #include <sys/ioctl.h> | 32 | #include <sys/ioctl.h> |
33 | #include <sys/types.h> | ||
34 | #include <sys/stat.h> | ||
33 | #include <setjmp.h> | 35 | #include <setjmp.h> |
34 | #include <regex.h> | 36 | #include <regex.h> |
35 | #include <qregexp.h> | 37 | #include <qregexp.h> |
36 | #include <assert.h> | 38 | #include <assert.h> |
37 | #include <string.h> | 39 | #include <string.h> |
38 | 40 | ||
39 | #ifdef HAVE_RESOLV_H | 41 | #ifdef HAVE_RESOLV_H |
40 | # include <arpa/nameser.h> | 42 | # include <arpa/nameser.h> |
41 | # include <resolv.h> | 43 | # include <resolv.h> |
42 | #endif | 44 | #endif |
43 | 45 | ||
44 | #ifndef _PATH_RESCONF | 46 | #ifndef _PATH_RESCONF |
45 | #define _PATH_RESCONF "/etc/resolv.conf" | 47 | #define _PATH_RESCONF "/etc/resolv.conf" |
46 | #endif | 48 | #endif |
47 | 49 | ||
48 | #define strlcpy strcpy | 50 | #define strlcpy strcpy |
49 | #include "auth.h" | 51 | #include "auth.h" |
50 | #include "modem.h" | 52 | #include "modem.h" |
51 | #include "pppdata.h" | 53 | #include "pppdata.h" |
52 | //#include <klocale.h> | 54 | //#include <klocale.h> |
53 | #define i18n QObject::tr | 55 | #define i18n QObject::tr |
54 | #define qError qDebug | 56 | #define qError qDebug |
55 | //#include <kdebug.h> | 57 | //#include <kdebug.h> |
56 | //#include <config.h> | 58 | //#include <config.h> |
57 | 59 | ||
58 | #define MY_ASSERT(x) if (!(x)) { \ | 60 | #define MY_ASSERT(x) if (!(x)) { \ |
59 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ | 61 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ |
60 | exit(1); } | 62 | exit(1); } |
61 | 63 | ||
62 | 64 | ||
63 | static sigjmp_buf jmp_buffer; | 65 | static sigjmp_buf jmp_buffer; |
64 | 66 | ||
65 | //Modem *Modem::modem = 0; | 67 | //Modem *Modem::modem = 0; |
66 | 68 | ||
67 | 69 | ||
68 | const char* pppdPath() { | 70 | const char* pppdPath() { |
69 | // wasting a few bytes | 71 | // wasting a few bytes |
70 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; | 72 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; |
71 | static char *pppdPath = 0L; | 73 | static char *pppdPath = 0L; |
72 | char *p; | 74 | char *p; |
73 | 75 | ||
74 | if(pppdPath == 0L) { | 76 | if(pppdPath == 0L) { |
75 | const char *c = PPPDSEARCHPATH; | 77 | const char *c = PPPDSEARCHPATH; |
76 | while(*c != '\0') { | 78 | while(*c != '\0') { |
77 | while(*c == ':') | 79 | while(*c == ':') |
78 | c++; | 80 | c++; |
79 | p = buffer; | 81 | p = buffer; |
80 | while(*c != '\0' && *c != ':') | 82 | while(*c != '\0' && *c != ':') |
81 | *p++ = *c++; | 83 | *p++ = *c++; |
82 | *p = '\0'; | 84 | *p = '\0'; |
83 | strcat(p, "/"); | 85 | strcat(p, "/"); |
84 | strcat(p, PPPDNAME); | 86 | strcat(p, PPPDNAME); |
85 | if(access(buffer, F_OK) == 0) | 87 | if(access(buffer, F_OK) == 0) |
86 | return (pppdPath = buffer); | 88 | return (pppdPath = buffer); |
87 | } | 89 | } |
88 | } | 90 | } |
89 | 91 | ||
90 | return pppdPath; | 92 | return pppdPath; |
91 | } | 93 | } |
92 | 94 | ||
93 | 95 | ||
94 | Modem::Modem( PPPData* pd ) | 96 | Modem::Modem( PPPData* pd ) |
95 | { | 97 | { |
96 | _pppdata = pd; | 98 | _pppdata = pd; |
97 | modemfd = -1; | 99 | modemfd = -1; |
98 | _pppdExitStatus = -1; | 100 | _pppdExitStatus = -1; |
99 | pppdPid = -1; | 101 | pppdPid = -1; |
100 | sn = 0L; | 102 | sn = 0L; |
101 | data_mode = false; | 103 | data_mode = false; |
102 | modem_is_locked = false; | 104 | modem_is_locked = false; |
103 | lockfile[0] = '\0'; | 105 | lockfile[0] = '\0'; |
104 | device = "/dev/modem"; | 106 | device = "/dev/modem"; |
105 | } | 107 | } |
106 | 108 | ||
107 | 109 | ||
108 | Modem::~Modem() | 110 | Modem::~Modem() |
109 | { | 111 | { |
110 | } | 112 | } |
111 | 113 | ||
112 | 114 | ||
113 | speed_t Modem::modemspeed() { | 115 | speed_t Modem::modemspeed() { |
114 | // convert the string modem speed int the gpppdata object to a t_speed type | 116 | // convert the string modem speed int the gpppdata object to a t_speed type |
115 | // to set the modem. The constants here should all be ifdef'd because | 117 | // to set the modem. The constants here should all be ifdef'd because |
116 | // other systems may not have them | 118 | // other systems may not have them |
117 | int i = _pppdata->speed().toInt()/100; | 119 | int i = _pppdata->speed().toInt()/100; |
118 | 120 | ||
119 | switch(i) { | 121 | switch(i) { |
120 | case 24: | 122 | case 24: |
121 | return B2400; | 123 | return B2400; |
122 | break; | 124 | break; |
123 | case 96: | 125 | case 96: |
124 | return B9600; | 126 | return B9600; |
125 | break; | 127 | break; |
126 | case 192: | 128 | case 192: |
127 | return B19200; | 129 | return B19200; |
128 | break; | 130 | break; |
129 | case 384: | 131 | case 384: |
130 | return B38400; | 132 | return B38400; |
131 | break; | 133 | break; |
132 | #ifdef B57600 | 134 | #ifdef B57600 |
133 | case 576: | 135 | case 576: |
134 | return B57600; | 136 | return B57600; |
135 | break; | 137 | break; |
136 | #endif | 138 | #endif |
137 | 139 | ||
138 | #ifdef B115200 | 140 | #ifdef B115200 |
139 | case 1152: | 141 | case 1152: |
140 | return B115200; | 142 | return B115200; |
141 | break; | 143 | break; |
142 | #endif | 144 | #endif |
143 | 145 | ||
144 | #ifdef B230400 | 146 | #ifdef B230400 |
145 | case 2304: | 147 | case 2304: |
146 | return B230400; | 148 | return B230400; |
147 | break; | 149 | break; |
148 | #endif | 150 | #endif |
149 | 151 | ||
150 | #ifdef B460800 | 152 | #ifdef B460800 |
151 | case 4608: | 153 | case 4608: |
152 | return B460800; | 154 | return B460800; |
153 | break; | 155 | break; |
154 | #endif | 156 | #endif |
155 | 157 | ||
156 | default: | 158 | default: |
157 | return B38400; | 159 | return B38400; |
158 | break; | 160 | break; |
159 | } | 161 | } |
160 | } | 162 | } |
161 | 163 | ||
162 | bool Modem::opentty() { | 164 | bool Modem::opentty() { |
163 | // int flags; | 165 | // int flags; |
164 | 166 | ||
165 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 167 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
166 | close(modemfd); | 168 | close(modemfd); |
167 | device = _pppdata->modemDevice(); | 169 | device = _pppdata->modemDevice(); |
168 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 170 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
169 | qDebug("error opening modem device !"); | 171 | qDebug("error opening modem device !"); |
170 | errmsg = i18n("Unable to open modem."); | 172 | errmsg = i18n("Unable to open modem."); |
171 | return false; | 173 | return false; |
172 | } | 174 | } |
173 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 175 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
174 | //} | 176 | //} |
175 | 177 | ||
176 | #if 0 | 178 | #if 0 |
177 | if(_pppdata->UseCDLine()) { | 179 | if(_pppdata->UseCDLine()) { |
178 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 180 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
179 | errmsg = i18n("Unable to detect state of CD line."); | 181 | errmsg = i18n("Unable to detect state of CD line."); |
180 | ::close(modemfd); | 182 | ::close(modemfd); |
181 | modemfd = -1; | 183 | modemfd = -1; |
182 | return false; | 184 | return false; |
183 | } | 185 | } |
184 | if ((flags&TIOCM_CD) == 0) { | 186 | if ((flags&TIOCM_CD) == 0) { |
185 | errmsg = i18n("The modem is not ready."); | 187 | errmsg = i18n("The modem is not ready."); |
186 | ::close(modemfd); | 188 | ::close(modemfd); |
187 | modemfd = -1; | 189 | modemfd = -1; |
188 | return false; | 190 | return false; |
189 | } | 191 | } |
190 | } | 192 | } |
191 | #endif | 193 | #endif |
192 | 194 | ||
193 | tcdrain (modemfd); | 195 | tcdrain (modemfd); |
194 | tcflush (modemfd, TCIOFLUSH); | 196 | tcflush (modemfd, TCIOFLUSH); |
195 | 197 | ||
196 | if(tcgetattr(modemfd, &tty) < 0){ | 198 | if(tcgetattr(modemfd, &tty) < 0){ |
197 | // this helps in some cases | 199 | // this helps in some cases |
198 | tcsendbreak(modemfd, 0); | 200 | tcsendbreak(modemfd, 0); |
199 | sleep(1); | 201 | sleep(1); |
200 | if(tcgetattr(modemfd, &tty) < 0){ | 202 | if(tcgetattr(modemfd, &tty) < 0){ |
201 | errmsg = i18n("The modem is busy."); | 203 | errmsg = i18n("The modem is busy."); |
202 | ::close(modemfd); | 204 | ::close(modemfd); |
203 | modemfd = -1; | 205 | modemfd = -1; |
204 | return false; | 206 | return false; |
205 | } | 207 | } |
206 | } | 208 | } |
207 | 209 | ||
208 | memset(&initial_tty,'\0',sizeof(initial_tty)); | 210 | memset(&initial_tty,'\0',sizeof(initial_tty)); |
209 | 211 | ||
210 | initial_tty = tty; | 212 | initial_tty = tty; |
211 | 213 | ||
212 | tty.c_cc[VMIN] = 0; // nonblocking | 214 | tty.c_cc[VMIN] = 0; // nonblocking |
213 | tty.c_cc[VTIME] = 0; | 215 | tty.c_cc[VTIME] = 0; |
214 | tty.c_oflag = 0; | 216 | tty.c_oflag = 0; |
215 | tty.c_lflag = 0; | 217 | tty.c_lflag = 0; |
216 | 218 | ||
217 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); | 219 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); |
218 | tty.c_cflag |= CS8 | CREAD; | 220 | tty.c_cflag |= CS8 | CREAD; |
219 | tty.c_cflag |= CLOCAL; // ignore modem status lines | 221 | tty.c_cflag |= CLOCAL; // ignore modem status lines |
220 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; | 222 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; |
221 | tty.c_lflag &= ~ICANON; // non-canonical mode | 223 | tty.c_lflag &= ~ICANON; // non-canonical mode |
222 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); | 224 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); |
223 | 225 | ||
224 | 226 | ||