Logo Search packages:      
Sourcecode: paris-traceroute version File versions  Download package

char * Util::getRoute ( const char *  dest  )  [static]

Return the source address (in network endianess) to use to contact the destination addr.

Parameters:
addr The destination address
Returns:
The source address

Definition at line 25 of file Util.cc.

                                {
  FILE * fd;
  char buff[20];

  // Ouvre un tube nommé


#ifdef __APPLE__
  fd = popen(" a=`/usr/sbin/netstat -rn | grep default`; /sbin/ifconfig `echo $a | cut -d ' ' -f 6` | grep \"inet \" | cut -d ' ' -f 2", "r");
#endif

#ifdef __FreeBSD__
      fd = popen(" a=`netstat -rn | grep default`; /sbin/ifconfig `echo $a | cut -d ' ' -f 6` | grep \"inet \" | cut -d ' ' -f 2", "r");

#endif

#ifdef __NetBSD__
  
  fd = popen(" a=`/usr/bin/netstat -rn | grep default`; /sbin/ifconfig `echo $a | cut -d ' ' -f 7` | grep \"inet \" | cut -d ' ' -f 2", "r");
#endif
      
#ifdef __linux__
  fd = popen(" a=`/sbin/route -n | grep default`; /sbin/ifconfig `echo $a | cut -d ' ' -f 8` | grep \"inet \" | cut -d ':' -f 2 | cut -d ' ' -f 1", "r");
#endif

  fscanf(fd, "%s", buff);
  pclose(fd);

  log(INFO, "Source address = %s\n", buff);

  return strdup(buff);
}


Generated by  Doxygen 1.6.0   Back to index