+ int testResult;
+
+ testResult = CheckProcNet();
+ if(testResult == -1)
+ testResult = CheckIfconfig();
+ if(testResult == -1)
+ testResult = CheckConnect();
+ if(testResult == -1)
+ testResult = CheckPing();
+ m_IsOnline = testResult;
+}
+
+int
+wxDialUpManagerImpl::CheckConnect(void)
+{
+ // second method: try to connect to a well known host:
+ // This can be used under Win 9x, too!
+ struct hostent *hp;
+ struct sockaddr_in serv_addr;
+
+ if((hp = gethostbyname(m_BeaconHost.mb_str())) == NULL)
+ return 0; // no DNS no net
+
+ serv_addr.sin_family = hp->h_addrtype;
+ memcpy(&serv_addr.sin_addr,hp->h_addr, hp->h_length);
+ serv_addr.sin_port = htons(m_BeaconPort);
+
+ int sockfd;
+ if( ( sockfd = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0)
+ {
+ return -1; // no info
+ }
+
+ if( connect(sockfd, (struct sockaddr *) &serv_addr,
+ sizeof(serv_addr)) >= 0)
+ {
+ close(sockfd);
+ return 1; // we cant connect, so we have a network!
+ }
+ //connected!
+ close(sockfd);
+ if(errno == ENETUNREACH)
+ return 0; // network is unreachable
+ // connect failed, but don't know why
+ return -1;
+}
+
+
+int
+wxDialUpManagerImpl::CheckProcNet(void)
+{
+ int rc = -1;
+
+#ifdef __LINUX__
+ if (wxFileExists(_T("/proc/net/route")))
+ {
+ // NOTE: cannot use wxFile::Length because file doesn't support
+ // seeking
+ FILE *f = fopen("/proc/net/route", "rt");
+ if (f != NULL)
+ {
+ char output[256];
+
+ while (fgets(output, 256, f) != NULL)
+ {
+ if (strstr(output,"ppp") // ppp
+ || strstr(output,"sl") // slip
+ || strstr(output,"pl")) // plip
+ rc = 1;
+ }
+ if (rc == -1) rc = 0;
+ fclose(f);
+ }
+ }
+#endif
+
+ return rc;
+}
+
+
+int
+wxDialUpManagerImpl::CheckIfconfig(void)
+{
+ int rc = -1;
+
+ // First time check for ifconfig location. We only use the variant which
+ // does not take arguments, a la GNU.
+ if ( m_CanUseIfconfig == -1 ) // unknown