Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

void NetTest::Main (  ) [virtual]

User override function for the main execution routine of the thread. A descendent class must provide the code that will be executed in the thread within this function.

Note that the correct way for a thread to terminate is to return from this function.

Implements PThread.

Definition at line 61 of file netif.cxx.

References PIPSocket::InterfaceEntry::GetAddress(), PIPSocket::RouteEntry::GetDestination(), PIPSocket::GetGatewayAddress(), PIPSocket::GetGatewayInterface(), PIPSocket::RouteEntry::GetInterface(), PIPSocket::GetInterfaceTable(), PIPSocket::InterfaceEntry::GetMACAddress(), PIPSocket::RouteEntry::GetMetric(), PIPSocket::InterfaceEntry::GetName(), PIPSocket::RouteEntry::GetNetMask(), PIPSocket::InterfaceEntry::GetNetMask(), PIPSocket::RouteEntry::GetNetwork(), PIPSocket::GetRouteTable(), and PString::IsEmpty().

{

  cout << "Net Test Utility" << endl;
  cout << endl;

  // Read the interface table
  PIPSocket::InterfaceTable if_table;

  // Read the Interface Table
  if ( !PIPSocket::GetInterfaceTable( if_table ) ) {
        cout << "GetInterfaceTable() failed. No interface table" << endl;
        exit(0);
  }

  // Display the interface table
  cout << "The interface table has " << if_table.GetSize()
       <<" entries" << endl;

  for (PINDEX i=0; i < if_table.GetSize(); i++) {
    PIPSocket::InterfaceEntry if_entry = if_table[i];
    cout << i << " " << if_entry.GetName() << " "
                     << if_entry.GetAddress() << " "
                     << if_entry.GetNetMask() << " "
                     << if_entry.GetMACAddress() << "."
                     << endl;
  }
  cout << endl;

  // Read the Route Table
  PIPSocket::RouteTable rt_table;

  if ( !PIPSocket::GetRouteTable( rt_table ) ) {
        cout << "GetRouteTable() failed. No routing table" << endl;
        exit(0);
  }

  // Display the route table
  cout << "The route table has " << rt_table.GetSize()
       <<" entries" << endl;

  for (PINDEX i=0; i < rt_table.GetSize(); i++) {
    PIPSocket::RouteEntry rt_entry = rt_table[i];
    cout << i << " " << rt_entry.GetNetwork() << " "
                     << rt_entry.GetNetMask() << " "
                     << rt_entry.GetDestination() << " "
                     << rt_entry.GetInterface() << " "
                     << rt_entry.GetMetric() << "."
                     << endl;
  }
  cout << endl;

  // Get the Default Gateway
  PIPSocket::Address addr;
  PIPSocket::GetGatewayAddress(addr);
  cout << "Default gateway is " << addr << endl;
  cout << endl;

  // Get the interface for the Default Gateway
  PString gw_if = PIPSocket::GetGatewayInterface();
  if ( gw_if.IsEmpty() )
    cout << "No default gateway interface" << endl;
  else
    cout << "Gateway is on " << gw_if << endl;
  cout << endl;


}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index