author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Fri, 11 Jul 2008 18:39:19 +0100 | |
changeset 3416 | 926ccb845111 |
parent 3179 | 1763f7ac8e80 |
child 3852 | 9cf7ad0cac85 |
permissions | -rw-r--r-- |
242 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2006 INRIA |
|
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
19 |
*/ |
|
976
e82bac1816ce
ethernet Header and Trailer classes
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
524
diff
changeset
|
20 |
#include "address-utils.h" |
242 | 21 |
|
22 |
namespace ns3 { |
|
23 |
||
24 |
void WriteTo (Buffer::Iterator &i, Ipv4Address ad) |
|
25 |
{ |
|
3179
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
26 |
i.WriteHtonU32 (ad.Get ()); |
242 | 27 |
} |
1167 | 28 |
void WriteTo (Buffer::Iterator &i, const Address &ad) |
242 | 29 |
{ |
1167 | 30 |
uint8_t mac[Address::MAX_SIZE]; |
31 |
ad.CopyTo (mac); |
|
247
fb7375bb43d7
make the sample code compile and link.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
32 |
i.Write (mac, ad.GetLength ()); |
242 | 33 |
} |
1494
c2985e1cd091
rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
34 |
void WriteTo (Buffer::Iterator &i, Mac48Address ad) |
1167 | 35 |
{ |
36 |
uint8_t mac[6]; |
|
37 |
ad.CopyTo (mac); |
|
38 |
i.Write (mac, 6); |
|
39 |
} |
|
242 | 40 |
|
41 |
void ReadFrom (Buffer::Iterator &i, Ipv4Address &ad) |
|
42 |
{ |
|
3179
1763f7ac8e80
bug 146: s/HostOrder//
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
43 |
ad.Set (i.ReadNtohU32 ()); |
242 | 44 |
} |
1167 | 45 |
void ReadFrom (Buffer::Iterator &i, Address &ad, uint32_t len) |
242 | 46 |
{ |
1167 | 47 |
uint8_t mac[Address::MAX_SIZE]; |
242 | 48 |
i.Read (mac, len); |
1167 | 49 |
ad.CopyFrom (mac, len); |
50 |
} |
|
1494
c2985e1cd091
rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
51 |
void ReadFrom (Buffer::Iterator &i, Mac48Address &ad) |
1167 | 52 |
{ |
53 |
uint8_t mac[6]; |
|
54 |
i.Read (mac, 6); |
|
55 |
ad.CopyFrom (mac); |
|
242 | 56 |
} |
57 |
||
1167 | 58 |
} // namespace ns3 |