+ 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
+ {
+ static const wxChar *ifconfigLocations[] =
+ {
+ _T("/sbin"), // Linux, FreeBSD
+ _T("/usr/sbin"), // SunOS, Solaris, AIX, HP-UX
+ _T("/usr/etc"), // IRIX
+ };
+
+ for ( size_t n = 0; n < WXSIZEOF(ifconfigLocations); n++ )
+ {
+ wxString path(ifconfigLocations[n]);
+ path << _T("/ifconfig");
+
+ if ( wxFileExists(path) )
+ {
+ m_IfconfigPath = path;
+ break;
+ }
+ }