inet.cc (6712:b95abe00dd9d) | inet.cc (7777:369f90d32e2e) |
---|---|
1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 103 unchanged lines hidden (view full) --- 112ostream & 113operator<<(ostream &stream, const EthAddr &ea) 114{ 115 const uint8_t *a = ea.addr(); 116 ccprintf(stream, "%x:%x:%x:%x:%x:%x", a[0], a[1], a[2], a[3], a[4], a[5]); 117 return stream; 118} 119 | 1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 103 unchanged lines hidden (view full) --- 112ostream & 113operator<<(ostream &stream, const EthAddr &ea) 114{ 115 const uint8_t *a = ea.addr(); 116 ccprintf(stream, "%x:%x:%x:%x:%x:%x", a[0], a[1], a[2], a[3], a[4], a[5]); 117 return stream; 118} 119 |
120string 121IpAddress::string() const 122{ 123 stringstream stream; 124 stream << *this; 125 return stream.str(); 126} 127 128bool 129operator==(const IpAddress &left, const IpAddress &right) 130{ 131 return left.ip() == right.ip(); 132} 133 134ostream & 135operator<<(ostream &stream, const IpAddress &ia) 136{ 137 uint32_t ip = ia.ip(); 138 ccprintf(stream, "%x.%x.%x.%x", 139 (uint8_t)(ip >> 0), (uint8_t)(ip >> 8), 140 (uint8_t)(ip >> 16), (uint8_t)(ip >> 24)); 141 return stream; 142} 143 144string 145IpNetmask::string() const 146{ 147 stringstream stream; 148 stream << *this; 149 return stream.str(); 150} 151 152bool 153operator==(const IpNetmask &left, const IpNetmask &right) 154{ 155 return (left.ip() == right.ip()) && 156 (left.netmask() == right.netmask()); 157} 158 159ostream & 160operator<<(ostream &stream, const IpNetmask &in) 161{ 162 ccprintf(stream, "%s/%d", (const IpAddress &)in, in.netmask()); 163 return stream; 164} 165 166string 167IpWithPort::string() const 168{ 169 stringstream stream; 170 stream << *this; 171 return stream.str(); 172} 173 174bool 175operator==(const IpWithPort &left, const IpWithPort &right) 176{ 177 return (left.ip() == right.ip()) && (left.port() == right.port()); 178} 179 180ostream & 181operator<<(ostream &stream, const IpWithPort &iwp) 182{ 183 ccprintf(stream, "%s:%d", (const IpAddress &)iwp, iwp.port()); 184 return stream; 185} 186 |
|
120uint16_t 121cksum(const IpPtr &ptr) 122{ 123 int sum = ip_cksum_add(ptr->bytes(), ptr->hlen(), 0); 124 return ip_cksum_carry(sum); 125} 126 127uint16_t --- 104 unchanged lines hidden --- | 187uint16_t 188cksum(const IpPtr &ptr) 189{ 190 int sum = ip_cksum_add(ptr->bytes(), ptr->hlen(), 0); 191 return ip_cksum_carry(sum); 192} 193 194uint16_t --- 104 unchanged lines hidden --- |