author | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
commit | 16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (unidiff) | |
tree | 0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/settings/networksettings/ppp/modem.cpp | |
parent | 8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff) | |
download | opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2 |
convert to Opie Debugging Framework
Diffstat (limited to 'noncore/settings/networksettings/ppp/modem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/modem.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index 3dbc8c3..f3f2639 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -46,25 +46,25 @@ | |||
46 | #ifndef _PATH_RESCONF | 46 | #ifndef _PATH_RESCONF |
47 | #define _PATH_RESCONF "/etc/resolv.conf" | 47 | #define _PATH_RESCONF "/etc/resolv.conf" |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #define strlcpy strcpy | 50 | #define strlcpy strcpy |
51 | #include "auth.h" | 51 | #include "auth.h" |
52 | #include "modem.h" | 52 | #include "modem.h" |
53 | #include "pppdata.h" | 53 | #include "pppdata.h" |
54 | #define qError qDebug | 54 | #define qError qDebug |
55 | 55 | ||
56 | 56 | ||
57 | #define MY_ASSERT(x) if (!(x)) { \ | 57 | #define MY_ASSERT(x) if (!(x)) { \ |
58 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ | 58 | ofatal << "ASSERT: \"" << #x << "\" in " << __FILE__ << " (" << __LINE__ << ")\n" << oendl; \ |
59 | exit(1); } | 59 | exit(1); } |
60 | 60 | ||
61 | 61 | ||
62 | static sigjmp_buf jmp_buffer; | 62 | static sigjmp_buf jmp_buffer; |
63 | 63 | ||
64 | //Modem *Modem::modem = 0; | 64 | //Modem *Modem::modem = 0; |
65 | 65 | ||
66 | 66 | ||
67 | const char* pppdPath() { | 67 | const char* pppdPath() { |
68 | // wasting a few bytes | 68 | // wasting a few bytes |
69 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; | 69 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; |
70 | static char *pppdPath = 0L; | 70 | static char *pppdPath = 0L; |
@@ -156,25 +156,25 @@ speed_t Modem::modemspeed() { | |||
156 | return B38400; | 156 | return B38400; |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | bool Modem::opentty() { | 161 | bool Modem::opentty() { |
162 | // int flags; | 162 | // int flags; |
163 | 163 | ||
164 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 164 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
165 | close(modemfd); | 165 | close(modemfd); |
166 | device = _pppdata->modemDevice(); | 166 | device = _pppdata->modemDevice(); |
167 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 167 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
168 | qDebug("error opening modem device !"); | 168 | odebug << "error opening modem device !" << oendl; |
169 | errmsg = QObject::tr("Unable to open modem."); | 169 | errmsg = QObject::tr("Unable to open modem."); |
170 | return false; | 170 | return false; |
171 | } | 171 | } |
172 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 172 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
173 | //} | 173 | //} |
174 | 174 | ||
175 | #if 0 | 175 | #if 0 |
176 | if(_pppdata->UseCDLine()) { | 176 | if(_pppdata->UseCDLine()) { |
177 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 177 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
178 | errmsg = QObject::tr("Unable to detect state of CD line."); | 178 | errmsg = QObject::tr("Unable to detect state of CD line."); |
179 | ::close(modemfd); | 179 | ::close(modemfd); |
180 | modemfd = -1; | 180 | modemfd = -1; |
@@ -297,56 +297,56 @@ void Modem::notify(const QObject *receiver, const char *member) { | |||
297 | 297 | ||
298 | void Modem::stop() { | 298 | void Modem::stop() { |
299 | disconnect(SIGNAL(charWaiting(unsigned char))); | 299 | disconnect(SIGNAL(charWaiting(unsigned char))); |
300 | stopNotifier(); | 300 | stopNotifier(); |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | void Modem::startNotifier() { | 304 | void Modem::startNotifier() { |
305 | if(modemfd >= 0) { | 305 | if(modemfd >= 0) { |
306 | if(sn == 0) { | 306 | if(sn == 0) { |
307 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); | 307 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); |
308 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); | 308 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); |
309 | qDebug("QSocketNotifier started!"); | 309 | odebug << "QSocketNotifier started!" << oendl; |
310 | } else { | 310 | } else { |
311 | qDebug("QSocketNotifier re-enabled!"); | 311 | odebug << "QSocketNotifier re-enabled!" << oendl; |
312 | sn->setEnabled(true); | 312 | sn->setEnabled(true); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void Modem::stopNotifier() { | 318 | void Modem::stopNotifier() { |
319 | if(sn != 0) { | 319 | if(sn != 0) { |
320 | sn->setEnabled(false); | 320 | sn->setEnabled(false); |
321 | disconnect(sn); | 321 | disconnect(sn); |
322 | delete sn; | 322 | delete sn; |
323 | sn = 0; | 323 | sn = 0; |
324 | qDebug( "QSocketNotifier stopped!" ); | 324 | odebug << "QSocketNotifier stopped!" << oendl; |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | void Modem::flush() { | 329 | void Modem::flush() { |
330 | char c; | 330 | char c; |
331 | while(read(modemfd, &c, 1) == 1); | 331 | while(read(modemfd, &c, 1) == 1); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | bool Modem::writeChar(unsigned char c) { | 335 | bool Modem::writeChar(unsigned char c) { |
336 | int s; | 336 | int s; |
337 | do { | 337 | do { |
338 | s = write(modemfd, &c, 1); | 338 | s = write(modemfd, &c, 1); |
339 | if (s < 0) { | 339 | if (s < 0) { |
340 | qError( "write() in Modem::writeChar failed" ); | 340 | oerr << "write() in Modem::writeChar failed" << oendl; |
341 | return false; | 341 | return false; |
342 | } | 342 | } |
343 | } while(s == 0); | 343 | } while(s == 0); |
344 | 344 | ||
345 | return true; | 345 | return true; |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | bool Modem::writeLine(const char *buf) { | 349 | bool Modem::writeLine(const char *buf) { |
350 | int len = strlen(buf); | 350 | int len = strlen(buf); |
351 | char *b = new char[len+2]; | 351 | char *b = new char[len+2]; |
352 | memcpy(b, buf, len); | 352 | memcpy(b, buf, len); |
@@ -356,25 +356,25 @@ bool Modem::writeLine(const char *buf) { | |||
356 | b[len++]='\n'; | 356 | b[len++]='\n'; |
357 | else if(term == "CR") | 357 | else if(term == "CR") |
358 | b[len++]='\r'; | 358 | b[len++]='\r'; |
359 | else if(term == "CR/LF") { | 359 | else if(term == "CR/LF") { |
360 | b[len++]='\r'; | 360 | b[len++]='\r'; |
361 | b[len++]='\n'; | 361 | b[len++]='\n'; |
362 | } | 362 | } |
363 | int l = len; | 363 | int l = len; |
364 | while(l) { | 364 | while(l) { |
365 | int wr = write(modemfd, &b[len-l], l); | 365 | int wr = write(modemfd, &b[len-l], l); |
366 | if(wr < 0) { | 366 | if(wr < 0) { |
367 | // TODO do something meaningful with the error code (or ignore it | 367 | // TODO do something meaningful with the error code (or ignore it |
368 | qError( "write() in Modem::writeLine failed" ); | 368 | oerr << "write() in Modem::writeLine failed" << oendl; |
369 | delete[] b; | 369 | delete[] b; |
370 | return false; | 370 | return false; |
371 | } | 371 | } |
372 | l -= wr; | 372 | l -= wr; |
373 | } | 373 | } |
374 | delete[] b; | 374 | delete[] b; |
375 | return true; | 375 | return true; |
376 | } | 376 | } |
377 | 377 | ||
378 | 378 | ||
379 | bool Modem::hangup() { | 379 | bool Modem::hangup() { |
380 | // this should really get the modem to hang up and go into command mode | 380 | // this should really get the modem to hang up and go into command mode |
@@ -465,25 +465,25 @@ void Modem::escape_to_command_mode() { | |||
465 | const QString Modem::modemMessage() { | 465 | const QString Modem::modemMessage() { |
466 | return errmsg; | 466 | return errmsg; |
467 | } | 467 | } |
468 | 468 | ||
469 | 469 | ||
470 | QString Modem::parseModemSpeed(const QString &s) { | 470 | QString Modem::parseModemSpeed(const QString &s) { |
471 | // this is a small (and bad) parser for modem speeds | 471 | // this is a small (and bad) parser for modem speeds |
472 | int rx = -1; | 472 | int rx = -1; |
473 | int tx = -1; | 473 | int tx = -1; |
474 | int i; | 474 | int i; |
475 | QString result; | 475 | QString result; |
476 | 476 | ||
477 | qDebug( "Modem reported result string: %s", s.latin1()); | 477 | odebug << "Modem reported result string: " << s.latin1() << "" << oendl; |
478 | 478 | ||
479 | const int RXMAX = 7; | 479 | const int RXMAX = 7; |
480 | const int TXMAX = 2; | 480 | const int TXMAX = 2; |
481 | QRegExp rrx[RXMAX] = { | 481 | QRegExp rrx[RXMAX] = { |
482 | QRegExp("[0-9]+[:/ ]RX", false), | 482 | QRegExp("[0-9]+[:/ ]RX", false), |
483 | QRegExp("[0-9]+RX", false), | 483 | QRegExp("[0-9]+RX", false), |
484 | QRegExp("[/: -][0-9]+[/: ]", false), | 484 | QRegExp("[/: -][0-9]+[/: ]", false), |
485 | QRegExp("[/: -][0-9]+$", false), | 485 | QRegExp("[/: -][0-9]+$", false), |
486 | QRegExp("CARRIER [^0-9]*[0-9]+", false), | 486 | QRegExp("CARRIER [^0-9]*[0-9]+", false), |
487 | QRegExp("CONNECT [^0-9]*[0-9]+", false), | 487 | QRegExp("CONNECT [^0-9]*[0-9]+", false), |
488 | QRegExp("[0-9]+") // panic mode | 488 | QRegExp("[0-9]+") // panic mode |
489 | }; | 489 | }; |
@@ -551,131 +551,131 @@ QString Modem::parseModemSpeed(const QString &s) { | |||
551 | } | 551 | } |
552 | } | 552 | } |
553 | 553 | ||
554 | if(rx == -1 && tx == -1) | 554 | if(rx == -1 && tx == -1) |
555 | result = QObject::tr("Unknown speed"); | 555 | result = QObject::tr("Unknown speed"); |
556 | else if(tx == -1) | 556 | else if(tx == -1) |
557 | result.setNum(rx); | 557 | result.setNum(rx); |
558 | else if(rx == -1) // should not happen | 558 | else if(rx == -1) // should not happen |
559 | result.setNum(tx); | 559 | result.setNum(tx); |
560 | else | 560 | else |
561 | result.sprintf("%d/%d", rx, tx); | 561 | result.sprintf("%d/%d", rx, tx); |
562 | 562 | ||
563 | qDebug( "The parsed result is: %s", result.latin1()); | 563 | odebug << "The parsed result is: " << result.latin1() << "" << oendl; |
564 | 564 | ||
565 | return result; | 565 | return result; |
566 | } | 566 | } |
567 | 567 | ||
568 | 568 | ||
569 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if | 569 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if |
570 | // a lock file can't be created ( permission problem ) | 570 | // a lock file can't be created ( permission problem ) |
571 | int Modem::lockdevice() { | 571 | int Modem::lockdevice() { |
572 | int fd; | 572 | int fd; |
573 | char newlock[80]=""; // safe | 573 | char newlock[80]=""; // safe |
574 | 574 | ||
575 | if(!_pppdata->modemLockFile()) { | 575 | if(!_pppdata->modemLockFile()) { |
576 | qDebug("The user doesn't want a lockfile."); | 576 | odebug << "The user doesn't want a lockfile." << oendl; |
577 | return 0; | 577 | return 0; |
578 | } | 578 | } |
579 | 579 | ||
580 | if (modem_is_locked) | 580 | if (modem_is_locked) |
581 | return 1; | 581 | return 1; |
582 | 582 | ||
583 | QString lockfile = LOCK_DIR"/LCK.."; | 583 | QString lockfile = LOCK_DIR"/LCK.."; |
584 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ | 584 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ |
585 | 585 | ||
586 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { | 586 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { |
587 | // if ((fd = Requester::rq-> | 587 | // if ((fd = Requester::rq-> |
588 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | 588 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { |
589 | // Mario: it's not necessary to read more than lets say 32 bytes. If | 589 | // Mario: it's not necessary to read more than lets say 32 bytes. If |
590 | // file has more than 32 bytes, skip the rest | 590 | // file has more than 32 bytes, skip the rest |
591 | char oldlock[33]; // safe | 591 | char oldlock[33]; // safe |
592 | int sz = read(fd, &oldlock, 32); | 592 | int sz = read(fd, &oldlock, 32); |
593 | close (fd); | 593 | close (fd); |
594 | if (sz <= 0) | 594 | if (sz <= 0) |
595 | return 1; | 595 | return 1; |
596 | oldlock[sz] = '\0'; | 596 | oldlock[sz] = '\0'; |
597 | 597 | ||
598 | qDebug( "Device is locked by: %s", oldlock); | 598 | odebug << "Device is locked by: " << oldlock << "" << oendl; |
599 | 599 | ||
600 | int oldpid; | 600 | int oldpid; |
601 | int match = sscanf(oldlock, "%d", &oldpid); | 601 | int match = sscanf(oldlock, "%d", &oldpid); |
602 | 602 | ||
603 | // found a pid in lockfile ? | 603 | // found a pid in lockfile ? |
604 | if (match < 1 || oldpid <= 0) | 604 | if (match < 1 || oldpid <= 0) |
605 | return 1; | 605 | return 1; |
606 | 606 | ||
607 | // check if process exists | 607 | // check if process exists |
608 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) | 608 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) |
609 | return 1; | 609 | return 1; |
610 | 610 | ||
611 | qDebug( "lockfile is stale" ); | 611 | odebug << "lockfile is stale" << oendl; |
612 | } | 612 | } |
613 | } | 613 | } |
614 | 614 | ||
615 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); | 615 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); |
616 | if(fd >= 0) { | 616 | if(fd >= 0) { |
617 | sprintf(newlock,"%010d\n", getpid()); | 617 | sprintf(newlock,"%010d\n", getpid()); |
618 | qDebug("Locking Device: %s", newlock); | 618 | odebug << "Locking Device: " << newlock << "" << oendl; |
619 | 619 | ||
620 | write(fd, newlock, strlen(newlock)); | 620 | write(fd, newlock, strlen(newlock)); |
621 | close(fd); | 621 | close(fd); |
622 | modem_is_locked=true; | 622 | modem_is_locked=true; |
623 | 623 | ||
624 | return 0; | 624 | return 0; |
625 | } | 625 | } |
626 | 626 | ||
627 | return -1; | 627 | return -1; |
628 | 628 | ||
629 | } | 629 | } |
630 | 630 | ||
631 | 631 | ||
632 | // UnLock modem device | 632 | // UnLock modem device |
633 | void Modem::unlockdevice() { | 633 | void Modem::unlockdevice() { |
634 | if (modem_is_locked) { | 634 | if (modem_is_locked) { |
635 | qDebug( "UnLocking Modem Device" ); | 635 | odebug << "UnLocking Modem Device" << oendl; |
636 | close(modemfd); | 636 | close(modemfd); |
637 | modemfd = -1; | 637 | modemfd = -1; |
638 | unlink(lockfile); | 638 | unlink(lockfile); |
639 | lockfile[0] = '\0'; | 639 | lockfile[0] = '\0'; |
640 | modem_is_locked=false; | 640 | modem_is_locked=false; |
641 | } | 641 | } |
642 | } | 642 | } |
643 | 643 | ||
644 | int Modem::openLockfile( QString lockfile, int flags) | 644 | int Modem::openLockfile( QString lockfile, int flags) |
645 | { | 645 | { |
646 | int fd; | 646 | int fd; |
647 | int mode; | 647 | int mode; |
648 | flags = O_RDONLY; | 648 | flags = O_RDONLY; |
649 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) | 649 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) |
650 | mode = 0644; | 650 | mode = 0644; |
651 | else | 651 | else |
652 | mode = 0; | 652 | mode = 0; |
653 | 653 | ||
654 | lockfile = LOCK_DIR; | 654 | lockfile = LOCK_DIR; |
655 | lockfile += "/LCK.."; | 655 | lockfile += "/LCK.."; |
656 | lockfile += device.right( device.length() - device.findRev("/") -1 ); | 656 | lockfile += device.right( device.length() - device.findRev("/") -1 ); |
657 | qDebug("lockfile >%s<",lockfile.latin1()); | 657 | odebug << "lockfile >" << lockfile.latin1() << "<" << oendl; |
658 | // TODO: | 658 | // TODO: |
659 | // struct stat st; | 659 | // struct stat st; |
660 | // if(stat(lockfile.data(), &st) == -1) { | 660 | // if(stat(lockfile.data(), &st) == -1) { |
661 | // if(errno == EBADF) | 661 | // if(errno == EBADF) |
662 | // return -1; | 662 | // return -1; |
663 | // } else { | 663 | // } else { |
664 | // // make sure that this is a regular file | 664 | // // make sure that this is a regular file |
665 | // if(!S_ISREG(st.st_mode)) | 665 | // if(!S_ISREG(st.st_mode)) |
666 | // return -1; | 666 | // return -1; |
667 | // } | 667 | // } |
668 | if ((fd = open(lockfile, flags, mode)) == -1) { | 668 | if ((fd = open(lockfile, flags, mode)) == -1) { |
669 | qDebug("error opening lockfile!"); | 669 | odebug << "error opening lockfile!" << oendl; |
670 | lockfile = QString::null; | 670 | lockfile = QString::null; |
671 | fd = open(DEVNULL, O_RDONLY); | 671 | fd = open(DEVNULL, O_RDONLY); |
672 | } else | 672 | } else |
673 | fchown(fd, 0, 0); | 673 | fchown(fd, 0, 0); |
674 | return fd; | 674 | return fd; |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | 678 | ||
679 | void alarm_handler(int) { | 679 | void alarm_handler(int) { |
680 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); | 680 | // fprintf(stderr, "alarm_handler(): Received SIGALRM\n"); |
681 | 681 | ||
@@ -918,60 +918,60 @@ bool Modem::execpppd(const char *arguments) { | |||
918 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); | 918 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); |
919 | break; | 919 | break; |
920 | case 0: | 920 | case 0: |
921 | fprintf(stderr, "Kernel supports ppp alright.\n"); | 921 | fprintf(stderr, "Kernel supports ppp alright.\n"); |
922 | break; | 922 | break; |
923 | } | 923 | } |
924 | 924 | ||
925 | execve(pppdPath(), args, 0L); | 925 | execve(pppdPath(), args, 0L); |
926 | _exit(0); | 926 | _exit(0); |
927 | break; | 927 | break; |
928 | 928 | ||
929 | default: | 929 | default: |
930 | qDebug("In parent: pppd pid %d\n",pppdPid); | 930 | odebug << "In parent: pppd pid " << pppdPid << "\n" << oendl; |
931 | close(modemfd); | 931 | close(modemfd); |
932 | 932 | ||
933 | ::close( m_pppdLOG[1] ); | 933 | ::close( m_pppdLOG[1] ); |
934 | // set it to nonblocking io | 934 | // set it to nonblocking io |
935 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); | 935 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); |
936 | 936 | ||
937 | if ( !(flag & O_NONBLOCK) ) { | 937 | if ( !(flag & O_NONBLOCK) ) { |
938 | qDebug("Setting nonblocking io"); | 938 | odebug << "Setting nonblocking io" << oendl; |
939 | flag |= O_NONBLOCK; | 939 | flag |= O_NONBLOCK; |
940 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); | 940 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); |
941 | } | 941 | } |
942 | 942 | ||
943 | delete m_modemDebug; | 943 | delete m_modemDebug; |
944 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); | 944 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); |
945 | connect(m_modemDebug, SIGNAL(activated(int) ), | 945 | connect(m_modemDebug, SIGNAL(activated(int) ), |
946 | this, SLOT(slotModemDebug(int) ) ); | 946 | this, SLOT(slotModemDebug(int) ) ); |
947 | 947 | ||
948 | modemfd = -1; | 948 | modemfd = -1; |
949 | m_pppdDev = QString::fromLatin1("ppp0"); | 949 | m_pppdDev = QString::fromLatin1("ppp0"); |
950 | return true; | 950 | return true; |
951 | break; | 951 | break; |
952 | } | 952 | } |
953 | } | 953 | } |
954 | 954 | ||
955 | 955 | ||
956 | bool Modem::killpppd() { | 956 | bool Modem::killpppd() { |
957 | qDebug("In killpppd and pid is %d", pppdPid ); | 957 | odebug << "In killpppd and pid is " << pppdPid << "" << oendl; |
958 | if(pppdPid > 0) { | 958 | if(pppdPid > 0) { |
959 | delete m_modemDebug; | 959 | delete m_modemDebug; |
960 | m_modemDebug = 0; | 960 | m_modemDebug = 0; |
961 | qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); | 961 | odebug << "In killpppd(): Sending SIGTERM to " << pppdPid << "\n" << oendl; |
962 | if(kill(pppdPid, SIGTERM) < 0) { | 962 | if(kill(pppdPid, SIGTERM) < 0) { |
963 | qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); | 963 | odebug << "Error terminating " << pppdPid << ". Sending SIGKILL\n" << oendl; |
964 | if(kill(pppdPid, SIGKILL) < 0) { | 964 | if(kill(pppdPid, SIGKILL) < 0) { |
965 | qDebug("Error killing %d\n", pppdPid); | 965 | odebug << "Error killing " << pppdPid << "\n" << oendl; |
966 | return false; | 966 | return false; |
967 | } | 967 | } |
968 | } | 968 | } |
969 | } | 969 | } |
970 | return true; | 970 | return true; |
971 | } | 971 | } |
972 | 972 | ||
973 | 973 | ||
974 | void Modem::parseargs(char* buf, char** args) { | 974 | void Modem::parseargs(char* buf, char** args) { |
975 | int nargs = 0; | 975 | int nargs = 0; |
976 | int quotes; | 976 | int quotes; |
977 | 977 | ||
@@ -1026,46 +1026,46 @@ void Modem::killPPPDaemon() | |||
1026 | killpppd(); | 1026 | killpppd(); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | int Modem::pppdExitStatus() | 1029 | int Modem::pppdExitStatus() |
1030 | { | 1030 | { |
1031 | return _pppdExitStatus; | 1031 | return _pppdExitStatus; |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | int Modem::openResolv(int flags) | 1034 | int Modem::openResolv(int flags) |
1035 | { | 1035 | { |
1036 | int fd; | 1036 | int fd; |
1037 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { | 1037 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { |
1038 | qDebug("error opening resolv.conf!"); | 1038 | odebug << "error opening resolv.conf!" << oendl; |
1039 | fd = open(DEVNULL, O_RDONLY); | 1039 | fd = open(DEVNULL, O_RDONLY); |
1040 | } | 1040 | } |
1041 | return fd; | 1041 | return fd; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | bool Modem::setHostname(const QString & name) | 1044 | bool Modem::setHostname(const QString & name) |
1045 | { | 1045 | { |
1046 | return sethostname(name, name.length()) == 0; | 1046 | return sethostname(name, name.length()) == 0; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | QString Modem::pppDevice()const { | 1049 | QString Modem::pppDevice()const { |
1050 | return m_pppdDev; | 1050 | return m_pppdDev; |
1051 | } | 1051 | } |
1052 | void Modem::setPPPDevice( const QString& dev ) { | 1052 | void Modem::setPPPDevice( const QString& dev ) { |
1053 | m_pppdDev = dev; | 1053 | m_pppdDev = dev; |
1054 | } | 1054 | } |
1055 | pid_t Modem::pppPID()const { | 1055 | pid_t Modem::pppPID()const { |
1056 | return pppdPid; | 1056 | return pppdPid; |
1057 | } | 1057 | } |
1058 | void Modem::setPPPDPid( pid_t pid ) { | 1058 | void Modem::setPPPDPid( pid_t pid ) { |
1059 | qDebug("Modem setting pid"); | 1059 | odebug << "Modem setting pid" << oendl; |
1060 | _pppdExitStatus = -1; | 1060 | _pppdExitStatus = -1; |
1061 | pppdPid = pid; | 1061 | pppdPid = pid; |
1062 | modemfd = -1; | 1062 | modemfd = -1; |
1063 | } | 1063 | } |
1064 | void Modem::slotModemDebug(int fd) { | 1064 | void Modem::slotModemDebug(int fd) { |
1065 | char buf[2049]; | 1065 | char buf[2049]; |
1066 | int len; | 1066 | int len; |
1067 | 1067 | ||
1068 | // read in pppd data look for Using interface | 1068 | // read in pppd data look for Using interface |
1069 | // then read the interface | 1069 | // then read the interface |
1070 | // we limit to 10 device now 0-9 | 1070 | // we limit to 10 device now 0-9 |
1071 | if((len = ::read(fd, buf, 2048)) > 0) { | 1071 | if((len = ::read(fd, buf, 2048)) > 0) { |