Changeset 4890 for source/ariba
- Timestamp:
- Jul 14, 2009, 9:17:10 AM (15 years ago)
- Location:
- source/ariba
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/communication/modules/transport/protlib/address.cpp
r4889 r4890 6 6 /// $HeadURL: https://svn.ipv6.tm.uka.de/nsis/protlib/trunk/src/address.cpp $ 7 7 // =========================================================== 8 // 8 // 9 9 // Copyright (C) 2005-2007, all rights reserved by 10 10 // - Institute of Telematics, Universitaet Karlsruhe (TH) … … 12 12 // More information and contact: 13 13 // https://projekte.tm.uka.de/trac/NSIS 14 // 14 // 15 15 // This program is free software; you can redistribute it and/or modify 16 16 // it under the terms of the GNU General Public License as published by … … 54 54 55 55 /** Set subtype. */ 56 address::address(subtype_t st) 57 : subtype(st) 58 { 59 //Log(DEBUG_LOG,LOG_NORMAL,"address","address constructor called for " << (void *) this); 56 address::address(subtype_t st) 57 : subtype(st) 58 { 59 //Log(DEBUG_LOG,LOG_NORMAL,"address","address constructor called for " << (void *) this); 60 60 } 61 61 … … 83 83 catch_bad_alloc(ha = new hostaddress(*this)); 84 84 return ha; 85 } // end copy 85 } // end copy 86 86 87 87 bool hostaddress::operator==(const address& ie) const { … … 102 102 103 103 /** Initialize hostaddress from string if possible. */ 104 hostaddress::hostaddress(const char *str, bool *res) 104 hostaddress::hostaddress(const char *str, bool *res) 105 105 : address(IPv6HostAddress), 106 ipv4flag(false), 106 ipv4flag(false), 107 107 outstring(NULL) 108 108 { … … 118 118 * @return true on success. 119 119 */ 120 bool 120 bool 121 121 hostaddress::set_ipv4(const char *str) { 122 122 struct in_addr in; … … 127 127 } // end set_ipv4 128 128 129 /** Set IPv4 address from struct in_addr. 130 * This changes object type to IPv4. 129 /** Set IPv4 address from struct in_addr. 130 * This changes object type to IPv4. 131 131 */ 132 132 void hostaddress::set_ip(const struct in_addr &in) { 133 133 clear_ip(); 134 ipv4addr = in; 134 ipv4addr = in; 135 135 // set subtype to IPv4 136 136 set_subtype(true); … … 148 148 return true; 149 149 } else return false; 150 } // end set_ipv6 151 152 /** Set IPv6 address from struct in6_addr. 153 * This changes object type to IPv6. 154 */ 155 void 150 } // end set_ipv6 151 152 /** Set IPv6 address from struct in6_addr. 153 * This changes object type to IPv6. 154 */ 155 void 156 156 hostaddress::set_ip(const struct in6_addr &in) { 157 157 clear_ip(); 158 ipv6addr = in; 158 ipv6addr = in; 159 159 // set subtype to IPv6 160 160 set_subtype(false); … … 185 185 * hostaddress object and should be copied if used for a longer time. 186 186 */ 187 const char* hostaddress::get_ip_str() const 187 const char* hostaddress::get_ip_str() const 188 188 { 189 189 // If outstring exists then it is valid. 190 if (outstring) 190 if (outstring) 191 191 return outstring; 192 192 else 193 outstring= (ipv4flag ? new(nothrow) char[INET_ADDRSTRLEN] : 193 outstring= (ipv4flag ? new(nothrow) char[INET_ADDRSTRLEN] : 194 194 new(nothrow) char[INET6_ADDRSTRLEN]); 195 195 196 if (hostaddress::get_ip_str(outstring)) 196 if (hostaddress::get_ip_str(outstring)) 197 197 return outstring; 198 else 198 else 199 199 { 200 200 // error 201 if (outstring) 201 if (outstring) 202 202 delete[] outstring; 203 203 … … 209 209 * @param str string buffer 210 210 */ 211 const char* hostaddress::get_ip_str(char *str) const 211 const char* hostaddress::get_ip_str(char *str) const 212 212 { 213 213 if (!str) return NULL; 214 214 memset(str,0, ipv4flag ? INET_ADDRSTRLEN : INET6_ADDRSTRLEN); 215 return ipv4flag ? inet_ntop(AF_INET,(void*)&ipv4addr,str,INET_ADDRSTRLEN) 215 return ipv4flag ? inet_ntop(AF_INET,(void*)&ipv4addr,str,INET_ADDRSTRLEN) 216 216 : inet_ntop(AF_INET6,(void*)&ipv6addr,str,INET6_ADDRSTRLEN); 217 217 } // end get_ip_str(char*) … … 247 247 /// returns false if address is not allowed to be used 248 248 /// as source address: loopback, multicast, broadcast, unspecified 249 bool 249 bool 250 250 hostaddress::is_bogus_source() const 251 251 { 252 252 if (ipv4flag) 253 253 { // IPv4 254 if ( IN_MULTICAST(ipv4addr.s_addr) || 254 if ( IN_MULTICAST(ipv4addr.s_addr) || 255 255 ipv4addr.s_addr == INADDR_LOOPBACK || 256 256 ipv4addr.s_addr == INADDR_ANY || … … 323 323 324 324 /** Set subtype and IPv4 flag. This does NOT clear the outstring buffer. 325 * Use clear_ip(). 325 * Use clear_ip(). 326 326 */ 327 327 void hostaddress::set_subtype(bool ipv4) { 328 ipv4flag = ipv4; 328 ipv4flag = ipv4; 329 329 subtype = ipv4flag ? IPv4HostAddress : IPv6HostAddress; 330 330 } // end set_subtype … … 422 422 catch_bad_alloc(aa = new appladdress(*this)); 423 423 return aa; 424 } // end copy 424 } // end copy 425 425 426 426 bool appladdress::operator==(const address& ie) const { … … 454 454 catch_bad_alloc(na = new netaddress(*this)); 455 455 return na; 456 } // end copy 456 } // end copy 457 457 458 458 bool netaddress::operator==(const address& ie) const { … … 485 485 486 486 /** Set subtype and IPv4 flag. This does NOT clear the outstring buffer. 487 * Use clear_ip(). 487 * Use clear_ip(). 488 488 * In addition the prefix length is checked and set to reasonable values. 489 489 */ 490 490 void netaddress::set_subtype(bool ipv4) { 491 ipv4flag = ipv4; 491 ipv4flag = ipv4; 492 492 if (ipv4) { 493 subtype = IPv4NetAddress; 493 subtype = IPv4NetAddress; 494 494 if (prefix_length>32) prefix_length = 32; 495 495 } else { … … 502 502 503 503 /** Constructor sets address type and clears prefix length. */ 504 netaddress::netaddress() : 504 netaddress::netaddress() : 505 505 hostaddress(), 506 506 prefix_length(0) … … 514 514 } // end copy constructor 515 515 516 /** Initialize with the given host address and prefix length. 516 /** Initialize with the given host address and prefix length. 517 517 * Prefix length is optional and set to 0 if missing. 518 518 */ … … 530 530 long int len = 0; 531 531 uint32 iplen; 532 c har* i = NULL;532 const char* i = NULL; 533 533 char* errptr = NULL; 534 534 char ipstr[INET6_ADDRSTRLEN] = {0}; … … 785 785 catch_bad_alloc(ha = new udsaddress(*this)); 786 786 return ha; 787 } // end copy 787 } // end copy 788 788 789 789 bool udsaddress::operator==(const address& ie) const { … … 876 876 } 877 877 props->insert(pair<AddrProperty *, bool>(p, propagate)); 878 878 879 879 } else { 880 880 props = new propmap_t(); … … 1525 1525 if (head->right->index > head->index) 1526 1526 collect(head->right, p, list); 1527 1527 1528 1528 } 1529 1529 -
source/ariba/utility/misc/Helper.h
r4063 r4890 45 45 #include <ctime> 46 46 #include <ostream> 47 #include <cstdio> 47 48 #include <iomanip> 48 49 #include <cassert> -
source/ariba/utility/serialization/Serialization.hpp
r3690 r4890 200 200 #include <typeinfo> 201 201 #include <iostream> 202 #include <cstdio> 202 203 203 204 //---------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.