Deleted Added
sdiff udiff text old ( 9200:16de812c5f53 ) new ( 9955:5d8722ab804b )
full compact
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * Copyright (c) 2010 Advanced Micro Devices, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;

--- 13 unchanged lines hidden (view full) ---

23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Authors: Nathan Binkert
30 * Gabe Black
31 */
32
33#include <cstddef>
34#include <cstdio>
35#include <sstream>
36#include <string>
37
38#include "base/cprintf.hh"

--- 161 unchanged lines hidden (view full) ---

200 int tcplen = ip->len() - ip->hlen();
201 int sum = ip_cksum_add(ip->payload(), tcplen, 0);
202 sum = ip_cksum_add(&ip->ip_src, 8, sum); // source and destination
203 sum += htons(ip->ip_p + tcplen);
204 return ip_cksum_carry(sum);
205}
206
207uint16_t
208cksum(const TcpPtr &tcp)
209{ return __tu_cksum(IpPtr(tcp.packet())); }
210
211uint16_t
212cksum(const UdpPtr &udp)
213{ return __tu_cksum(IpPtr(udp.packet())); }
214
215bool
216IpHdr::options(vector<const IpOpt *> &vec) const
217{
218 vec.clear();
219
220 const uint8_t *data = bytes() + sizeof(struct ip_hdr);
221 int all = hlen() - sizeof(struct ip_hdr);

--- 6 unchanged lines hidden (view full) ---

228 vec.push_back(opt);
229 all -= len;
230 data += len;
231 }
232
233 return true;
234}
235
236bool
237TcpHdr::options(vector<const TcpOpt *> &vec) const
238{
239 vec.clear();
240
241 const uint8_t *data = bytes() + sizeof(struct tcp_hdr);
242 int all = off() - sizeof(struct tcp_hdr);
243 while (all > 0) {

--- 11 unchanged lines hidden (view full) ---

255}
256
257int
258hsplit(const EthPacketPtr &ptr)
259{
260 int split_point = 0;
261
262 IpPtr ip(ptr);
263 if (ip) {
264 split_point = ip.pstart();
265
266 TcpPtr tcp(ip);
267 if (tcp)
268 split_point = tcp.pstart();
269
270 UdpPtr udp(ip);
271 if (udp)
272 split_point = udp.pstart();
273 }
274 return split_point;
275}
276
277
278} // namespace Net