|
|
| 86 |
|
86 |
|
| 87 |
// XXX todo: leave any multicast groups that have been joined |
87 |
// XXX todo: leave any multicast groups that have been joined |
| 88 |
m_node = 0; |
88 |
m_node = 0; |
|
|
89 |
/** |
| 90 |
* Note: actually this function is called AFTER |
| 91 |
* UdpSocketImpl::Destroy or UdpSocketImpl::Destroy6 |
| 92 |
* so the code below is unnecessary in normal operations |
| 93 |
*/ |
| 89 |
if (m_endPoint != 0) |
94 |
if (m_endPoint != 0) |
| 90 |
{ |
95 |
{ |
| 91 |
NS_ASSERT (m_udp != 0); |
96 |
NS_ASSERT (m_udp != 0); |
|
|
| 101 |
m_udp->DeAllocate (m_endPoint); |
106 |
m_udp->DeAllocate (m_endPoint); |
| 102 |
NS_ASSERT (m_endPoint == 0); |
107 |
NS_ASSERT (m_endPoint == 0); |
| 103 |
} |
108 |
} |
|
|
109 |
if (m_endPoint6 != 0) |
| 110 |
{ |
| 111 |
NS_ASSERT (m_udp != 0); |
| 112 |
/** |
| 113 |
* Note that this piece of code is a bit tricky: |
| 114 |
* when DeAllocate is called, it will call into |
| 115 |
* Ipv4EndPointDemux::Deallocate which triggers |
| 116 |
* a delete of the associated endPoint which triggers |
| 117 |
* in turn a call to the method UdpSocketImpl::Destroy below |
| 118 |
* will will zero the m_endPoint field. |
| 119 |
*/ |
| 120 |
NS_ASSERT (m_endPoint6 != 0); |
| 121 |
m_udp->DeAllocate (m_endPoint6); |
| 122 |
NS_ASSERT (m_endPoint6 == 0); |
| 123 |
} |
| 104 |
m_udp = 0; |
124 |
m_udp = 0; |
| 105 |
} |
125 |
} |
| 106 |
|
126 |
|
|
|
| 143 |
UdpSocketImpl::Destroy (void) |
163 |
UdpSocketImpl::Destroy (void) |
| 144 |
{ |
164 |
{ |
| 145 |
NS_LOG_FUNCTION_NOARGS (); |
165 |
NS_LOG_FUNCTION_NOARGS (); |
| 146 |
m_node = 0; |
|
|
| 147 |
m_endPoint = 0; |
166 |
m_endPoint = 0; |
| 148 |
m_udp = 0; |
167 |
} |
|
|
168 |
|
| 169 |
void |
| 170 |
UdpSocketImpl::Destroy6 (void) |
| 171 |
{ |
| 172 |
NS_LOG_FUNCTION_NOARGS (); |
| 173 |
m_endPoint6 = 0; |
| 149 |
} |
174 |
} |
| 150 |
|
175 |
|
| 151 |
int |
176 |
int |
| 152 |
UdpSocketImpl::FinishBind (void) |
177 |
UdpSocketImpl::FinishBind (void) |
| 153 |
{ |
178 |
{ |
| 154 |
NS_LOG_FUNCTION_NOARGS (); |
179 |
NS_LOG_FUNCTION_NOARGS (); |
|
|
180 |
bool done = false; |
| 155 |
if (m_endPoint != 0) |
181 |
if (m_endPoint != 0) |
| 156 |
{ |
182 |
{ |
| 157 |
m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this))); |
183 |
m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this))); |
| 158 |
m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this))); |
184 |
m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this))); |
| 159 |
m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this))); |
185 |
m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this))); |
| 160 |
return 0; |
186 |
done = true; |
| 161 |
} |
187 |
} |
| 162 |
else if (m_endPoint6 != 0) |
188 |
if (m_endPoint6 != 0) |
| 163 |
{ |
189 |
{ |
| 164 |
m_endPoint6->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp6, Ptr<UdpSocketImpl> (this))); |
190 |
m_endPoint6->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp6, Ptr<UdpSocketImpl> (this))); |
| 165 |
m_endPoint6->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp6, Ptr<UdpSocketImpl> (this))); |
191 |
m_endPoint6->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp6, Ptr<UdpSocketImpl> (this))); |
| 166 |
m_endPoint6->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this))); |
192 |
m_endPoint6->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy6, Ptr<UdpSocketImpl> (this))); |
|
|
193 |
done = true; |
| 194 |
} |
| 195 |
if (done) |
| 196 |
{ |
| 167 |
return 0; |
197 |
return 0; |
| 168 |
} |
198 |
} |
| 169 |
return -1; |
199 |
return -1; |