Changeset 2452 for source/ariba/communication
- Timestamp:
- Feb 18, 2009, 11:39:30 AM (16 years ago)
- Location:
- source/ariba/communication
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/communication/EndpointDescriptor.cpp
r2451 r2452 38 38 39 39 #include "EndpointDescriptor.h" 40 #include "ariba/utility/misc/StringFormat.h" 41 #include "ariba/utility/misc/Helper.h" 40 42 41 43 namespace ariba { … … 68 70 string EndpointDescriptor::toString() const { 69 71 if( locator == NULL ) return "<undefined locator>"; 70 else return locator->toString(); 72 std::ostringstream o; 73 o << "ip{" << locator->getIP() << "}"; 74 o << ","; 75 o << "tcp(ip,{" << locator->getPort() << "})"; 76 return o.str(); 71 77 } 72 78 73 79 EndpointDescriptor* EndpointDescriptor::fromString( string str ) { 74 EndpointDescriptor* ep = new EndpointDescriptor(); 75 ep->locator->fromString(str); 76 ep->isUnspec = false; 80 using namespace boost::xpressive; 81 using namespace ariba::utility::string_format; 82 using namespace ariba::utility::Helper; 83 using namespace std; 84 85 EndpointDescriptor* ep = NULL; 86 smatch match; 87 if (regex_search(str, match, robjects)) { 88 regex_nav nav = match; 89 for (int i=0; i<nav.size(); i++) { 90 string type = nav[i][robject_id].str(); 91 if (type=="ip") { 92 string ip = nav[i][robject_data].str(); 93 ip = ip.substr(1,ip.size()-2); 94 cout << "ep-ip = " <<ip << endl; 95 ep = new EndpointDescriptor(); 96 ep->locator = new IPv4Locator(); 97 ep->locator->setIP(ip); 98 ep->isUnspec = false; 99 } else 100 if (type=="tcp") { 101 string port = nav[i][robject_data][rfields][1].str(); 102 port = port.substr(1,port.size()-2); 103 cout << "ep-tcp-port = " << port << endl; 104 ep->locator->setPort(stoi(port)); 105 } 106 } 107 } 77 108 return ep; 78 109 } -
source/ariba/communication/modules/network/ip/IPv4Locator.h
r2451 r2452 77 77 virtual string toString() const; 78 78 79 void setIP( string ip ) { 80 ipv4Address = boost::asio::ip::address_v4::from_string( ip ); 81 } 82 79 83 string getIP() const { 80 84 return ipv4Address.to_string(); … … 91 95 boost::asio::ip::address_v4 ipv4Address; 92 96 uint16_t port; 93 94 97 }; 95 98
Note:
See TracChangeset
for help on using the changeset viewer.