author | tille <tille> | 2003-06-06 13:24:19 (UTC) |
---|---|---|
committer | tille <tille> | 2003-06-06 13:24:19 (UTC) |
commit | d3e9154252841f3adcfbd9868e263475fc698ebb (patch) (side-by-side diff) | |
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,288 +1,290 @@ /* * kPPP: A pppd Front End for the KDE project * * $Id$ * * Copyright (C) 1997 Bernd Johannes Wuebben * wuebben@math.cornell.edu * * This file was added by Harri Porten <porten@tu-harburg.de> * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <signal.h> #include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> #include <setjmp.h> #include <regex.h> #include <qregexp.h> #include <assert.h> #include <string.h> #ifdef HAVE_RESOLV_H # include <arpa/nameser.h> # include <resolv.h> #endif #ifndef _PATH_RESCONF #define _PATH_RESCONF "/etc/resolv.conf" #endif #define strlcpy strcpy #include "auth.h" #include "modem.h" #include "pppdata.h" //#include <klocale.h> #define i18n QObject::tr #define qError qDebug //#include <kdebug.h> //#include <config.h> #define MY_ASSERT(x) if (!(x)) { \ qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ exit(1); } static sigjmp_buf jmp_buffer; //Modem *Modem::modem = 0; const char* pppdPath() { // wasting a few bytes static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; static char *pppdPath = 0L; char *p; if(pppdPath == 0L) { const char *c = PPPDSEARCHPATH; while(*c != '\0') { while(*c == ':') c++; p = buffer; while(*c != '\0' && *c != ':') *p++ = *c++; *p = '\0'; strcat(p, "/"); strcat(p, PPPDNAME); if(access(buffer, F_OK) == 0) return (pppdPath = buffer); } } return pppdPath; } Modem::Modem( PPPData* pd ) { _pppdata = pd; modemfd = -1; _pppdExitStatus = -1; pppdPid = -1; sn = 0L; data_mode = false; modem_is_locked = false; lockfile[0] = '\0'; device = "/dev/modem"; } Modem::~Modem() { } speed_t Modem::modemspeed() { // convert the string modem speed int the gpppdata object to a t_speed type // to set the modem. The constants here should all be ifdef'd because // other systems may not have them int i = _pppdata->speed().toInt()/100; switch(i) { case 24: return B2400; break; case 96: return B9600; break; case 192: return B19200; break; case 384: return B38400; break; #ifdef B57600 case 576: return B57600; break; #endif #ifdef B115200 case 1152: return B115200; break; #endif #ifdef B230400 case 2304: return B230400; break; #endif #ifdef B460800 case 4608: return B460800; break; #endif default: return B38400; break; } } bool Modem::opentty() { // int flags; //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { close(modemfd); device = _pppdata->modemDevice(); if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { qDebug("error opening modem device !"); errmsg = i18n("Unable to open modem."); return false; } //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { //} #if 0 if(_pppdata->UseCDLine()) { if(ioctl(modemfd, TIOCMGET, &flags) == -1) { errmsg = i18n("Unable to detect state of CD line."); ::close(modemfd); modemfd = -1; return false; } if ((flags&TIOCM_CD) == 0) { errmsg = i18n("The modem is not ready."); ::close(modemfd); modemfd = -1; return false; } } #endif tcdrain (modemfd); tcflush (modemfd, TCIOFLUSH); if(tcgetattr(modemfd, &tty) < 0){ // this helps in some cases tcsendbreak(modemfd, 0); sleep(1); if(tcgetattr(modemfd, &tty) < 0){ errmsg = i18n("The modem is busy."); ::close(modemfd); modemfd = -1; return false; } } memset(&initial_tty,'\0',sizeof(initial_tty)); initial_tty = tty; tty.c_cc[VMIN] = 0; // nonblocking tty.c_cc[VTIME] = 0; tty.c_oflag = 0; tty.c_lflag = 0; tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); tty.c_cflag |= CS8 | CREAD; tty.c_cflag |= CLOCAL; // ignore modem status lines tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; tty.c_lflag &= ~ICANON; // non-canonical mode tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); if(_pppdata->flowcontrol() != "None") { if(_pppdata->flowcontrol() == "CRTSCTS") { tty.c_cflag |= CRTSCTS; } else { tty.c_iflag |= IXON | IXOFF; tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ } } else { tty.c_cflag &= ~CRTSCTS; tty.c_iflag &= ~(IXON | IXOFF); } cfsetospeed(&tty, modemspeed()); cfsetispeed(&tty, modemspeed()); tcdrain(modemfd); if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ errmsg = i18n("The modem is busy."); ::close(modemfd); modemfd=-1; return false; } errmsg = i18n("Modem Ready."); return true; } bool Modem::closetty() { if(modemfd >=0 ) { stop(); /* discard data not read or transmitted */ tcflush(modemfd, TCIOFLUSH); if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ errmsg = i18n("Can't restore tty settings: tcsetattr()\n"); ::close(modemfd); modemfd = -1; return false; } ::close(modemfd); modemfd = -1; } return true; } void Modem::readtty(int) { char buffer[200]; unsigned char c; int len; // read data in chunks of up to 200 bytes if((len = ::read(modemfd, buffer, 200)) > 0) { // split buffer into single characters for further processing for(int i = 0; i < len; i++) { c = buffer[i] & 0x7F; emit charWaiting(c); } |