#include <DNS.h>
Inheritance diagram for vpr::sim::DNS:


Public Methods | |
| DNS () | |
| vpr::Uint32 | lookupAddress (const std::string &addr) |
| Given an Internet name or dotted-decimal address, this returns the IP address in network byte order. More... | |
Protected Attributes | |
| std::map< std::string, vpr::Uint32 > | mDnsAddressLookup |
| vpr::Uint32 | mUniqueGenerator |
|
|
Definition at line 64 of file DNS.h.
00064 : mUniqueGenerator( 0 ) 00065 { 00066 mDnsAddressLookup["localhost"] = 0x7F000001; 00067 } |
|
|
Given an Internet name or dotted-decimal address, this returns the IP address in network byte order.
Definition at line 57 of file DNS.cpp. References mDnsAddressLookup, and mUniqueGenerator.
00058 {
00059 vpr::Uint32 found_addr;
00060
00061 // if name is found in lookup, return the address
00062 if ( mDnsAddressLookup.count(addr_str) > 0 )
00063 {
00064 found_addr = mDnsAddressLookup[addr_str];
00065 }
00066 // if not found, then make an entry for the new address.
00067 else
00068 {
00069 union
00070 {
00071 vpr::Uint8 bytes[4];
00072 vpr::Uint32 value;
00073 } addr;
00074 int retval;
00075
00076 vpr::Uint32 temp1, temp2, temp3, temp4;
00077 retval = sscanf(addr_str.c_str(), "%3u.%3u.%3u.%3u", &temp1, &temp2,
00078 &temp3, &temp4);
00079 addr.bytes[0] = (vpr::Uint8) temp1;
00080 addr.bytes[1] = (vpr::Uint8) temp2;
00081 addr.bytes[2] = (vpr::Uint8) temp3;
00082 addr.bytes[3] = (vpr::Uint8) temp4;
00083
00084 if ( retval == 4 )
00085 {
00086 found_addr = vpr::System::Ntohl(addr.value);
00087 }
00088 else
00089 {
00090 found_addr = mUniqueGenerator++;
00091 }
00092
00093 mDnsAddressLookup[addr_str] = found_addr;
00094 }
00095
00096 return found_addr;
00097 }
|
|
|
Definition at line 78 of file DNS.h. Referenced by lookupAddress. |
|
|
Definition at line 80 of file DNS.h. Referenced by lookupAddress. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002