OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 University of Washington | 3 * Copyright (c) 2009 University of Washington |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 UanAddress | 91 UanAddress |
92 UanAddress::GetBroadcast () | 92 UanAddress::GetBroadcast () |
93 { | 93 { |
94 return UanAddress (255); | 94 return UanAddress (255); |
95 } | 95 } |
96 UanAddress | 96 UanAddress |
97 UanAddress::Allocate () | 97 UanAddress::Allocate () |
98 { | 98 { |
99 static uint8_t nextAllocated = 0; | 99 static uint8_t nextAllocated = 0; |
100 | 100 |
101 uint32_t address = nextAllocated++; | 101 uint8_t address = nextAllocated++; |
102 if (nextAllocated == 255) | 102 if (nextAllocated == 255) |
103 { | 103 { |
104 nextAllocated = 0; | 104 nextAllocated = 0; |
105 } | 105 } |
106 | 106 |
107 return UanAddress (address); | 107 return UanAddress (address); |
108 } | 108 } |
109 | 109 |
110 bool | 110 bool |
111 operator < (const UanAddress &a, const UanAddress &b) | 111 operator < (const UanAddress &a, const UanAddress &b) |
(...skipping 15 matching lines...) Expand all Loading... |
127 | 127 |
128 std::ostream& | 128 std::ostream& |
129 operator<< (std::ostream& os, const UanAddress & address) | 129 operator<< (std::ostream& os, const UanAddress & address) |
130 { | 130 { |
131 os << (int) address.m_address; | 131 os << (int) address.m_address; |
132 return os; | 132 return os; |
133 } | 133 } |
134 std::istream& | 134 std::istream& |
135 operator>> (std::istream& is, UanAddress & address) | 135 operator>> (std::istream& is, UanAddress & address) |
136 { | 136 { |
137 int x; | 137 uint8_t x; |
138 is >> x; | 138 is >> x; |
139 NS_ASSERT (0 <= x); | 139 NS_ASSERT (0 <= x); |
140 NS_ASSERT (x <= 255); | 140 NS_ASSERT (x <= 255); |
141 address.m_address = x; | 141 address.m_address = x; |
142 return is; | 142 return is; |
143 } | 143 } |
144 | 144 |
145 } // namespace ns3 | 145 } // namespace ns3 |
OLD | NEW |