Skip to content

Commit ca755d7

Browse files
committed
iface: rename IpPacket to Packet
1 parent c647a32 commit ca755d7

File tree

12 files changed

+126
-155
lines changed

12 files changed

+126
-155
lines changed

src/iface/interface/ieee802154.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ impl InterfaceInner {
1010
meta: PacketMeta,
1111
sixlowpan_payload: &'payload [u8],
1212
_fragments: &'output mut FragmentsBuffer,
13-
) -> Option<IpPacket<'output>> {
13+
) -> Option<Packet<'output>> {
1414
let ieee802154_frame = check!(Ieee802154Frame::new_checked(sixlowpan_payload));
1515
let ieee802154_repr = check!(Ieee802154Repr::parse(&ieee802154_frame));
1616

@@ -45,7 +45,7 @@ impl InterfaceInner {
4545
ll_dst_a: Ieee802154Address,
4646
tx_token: Tx,
4747
meta: PacketMeta,
48-
packet: IpPacket,
48+
packet: Packet,
4949
frag: &mut Fragmenter,
5050
) {
5151
let ll_src_a = self.hardware_addr.ieee802154_or_panic();

src/iface/interface/igmp.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use super::{check, IgmpReportState, Interface, InterfaceInner, IpPacket};
1+
use super::*;
2+
23
use crate::phy::{Device, PacketMeta};
34
use crate::time::{Duration, Instant};
45
use crate::wire::*;
@@ -231,7 +232,7 @@ impl InterfaceInner {
231232
&mut self,
232233
ipv4_repr: Ipv4Repr,
233234
ip_payload: &'frame [u8],
234-
) -> Option<IpPacket<'frame>> {
235+
) -> Option<Packet<'frame>> {
235236
let igmp_packet = check!(IgmpPacket::new_checked(ip_payload));
236237
let igmp_repr = check!(IgmpRepr::parse(&igmp_packet));
237238

src/iface/interface/ipv4.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ use crate::socket::AnySocket;
88

99
use crate::phy::{Medium, TxToken};
1010
use crate::time::Instant;
11-
use crate::wire::{Ipv4Packet as Ipv4PacketWire, *};
11+
use crate::wire::*;
1212

1313
impl InterfaceInner {
1414
pub(super) fn process_ipv4<'a>(
1515
&mut self,
1616
sockets: &mut SocketSet,
1717
meta: PacketMeta,
18-
ipv4_packet: &Ipv4PacketWire<&'a [u8]>,
18+
ipv4_packet: &Ipv4Packet<&'a [u8]>,
1919
frag: &'a mut FragmentsBuffer,
20-
) -> Option<IpPacket<'a>> {
20+
) -> Option<Packet<'a>> {
2121
let ipv4_repr = check!(Ipv4Repr::parse(ipv4_packet, &self.caps.checksum));
2222
if !self.is_unicast_v4(ipv4_repr.src_addr) && !ipv4_repr.src_addr.is_unspecified() {
2323
// Discard packets with non-unicast source addresses but allow unspecified
@@ -238,7 +238,7 @@ impl InterfaceInner {
238238
_sockets: &mut SocketSet,
239239
ip_repr: IpRepr,
240240
ip_payload: &'frame [u8],
241-
) -> Option<IpPacket<'frame>> {
241+
) -> Option<Packet<'frame>> {
242242
let icmp_packet = check!(Icmpv4Packet::new_checked(ip_payload));
243243
let icmp_repr = check!(Icmpv4Repr::parse(&icmp_packet, &self.caps.checksum));
244244

@@ -293,7 +293,7 @@ impl InterfaceInner {
293293
&self,
294294
ipv4_repr: Ipv4Repr,
295295
icmp_repr: Icmpv4Repr<'icmp>,
296-
) -> Option<IpPacket<'frame>> {
296+
) -> Option<Packet<'frame>> {
297297
if !self.is_unicast_v4(ipv4_repr.src_addr) {
298298
// Do not send ICMP replies to non-unicast sources
299299
None
@@ -306,7 +306,7 @@ impl InterfaceInner {
306306
payload_len: icmp_repr.buffer_len(),
307307
hop_limit: 64,
308308
};
309-
Some(IpPacket::new_ipv4(
309+
Some(Packet::new_ipv4(
310310
ipv4_reply_repr,
311311
IpPayload::Icmpv4(icmp_repr),
312312
))
@@ -322,7 +322,7 @@ impl InterfaceInner {
322322
payload_len: icmp_repr.buffer_len(),
323323
hop_limit: 64,
324324
};
325-
Some(IpPacket::new_ipv4(
325+
Some(Packet::new_ipv4(
326326
ipv4_reply_repr,
327327
IpPayload::Icmpv4(icmp_repr),
328328
))
@@ -379,7 +379,7 @@ impl InterfaceInner {
379379
}
380380

381381
let mut packet =
382-
Ipv4PacketWire::new_unchecked(&mut tx_buffer[..frag.ipv4.repr.buffer_len()]);
382+
Ipv4Packet::new_unchecked(&mut tx_buffer[..frag.ipv4.repr.buffer_len()]);
383383
frag.ipv4.repr.emit(&mut packet, &caps.checksum);
384384
packet.set_ident(frag.ipv4.ident);
385385
packet.set_more_frags(more_frags);
@@ -405,13 +405,13 @@ impl InterfaceInner {
405405
&self,
406406
version: IgmpVersion,
407407
group_addr: Ipv4Address,
408-
) -> Option<IpPacket<'any>> {
408+
) -> Option<Packet<'any>> {
409409
let iface_addr = self.ipv4_addr()?;
410410
let igmp_repr = IgmpRepr::MembershipReport {
411411
group_addr,
412412
version,
413413
};
414-
let pkt = IpPacket::new_ipv4(
414+
let pkt = Packet::new_ipv4(
415415
Ipv4Repr {
416416
src_addr: iface_addr,
417417
// Send to the group being reported
@@ -427,13 +427,10 @@ impl InterfaceInner {
427427
}
428428

429429
#[cfg(feature = "proto-igmp")]
430-
pub(super) fn igmp_leave_packet<'any>(
431-
&self,
432-
group_addr: Ipv4Address,
433-
) -> Option<IpPacket<'any>> {
430+
pub(super) fn igmp_leave_packet<'any>(&self, group_addr: Ipv4Address) -> Option<Packet<'any>> {
434431
self.ipv4_addr().map(|iface_addr| {
435432
let igmp_repr = IgmpRepr::LeaveGroup { group_addr };
436-
IpPacket::new_ipv4(
433+
Packet::new_ipv4(
437434
Ipv4Repr {
438435
src_addr: iface_addr,
439436
dst_addr: Ipv4Address::MULTICAST_ALL_ROUTERS,

src/iface/interface/ipv6.rs

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
use super::check;
2-
use super::icmp_reply_payload_len;
3-
use super::InterfaceInner;
4-
use super::SocketSet;
5-
use super::{IpPacket, IpPayload};
1+
use super::*;
62

73
#[cfg(feature = "socket-icmp")]
84
use crate::socket::icmp;
@@ -17,7 +13,7 @@ impl InterfaceInner {
1713
sockets: &mut SocketSet,
1814
meta: PacketMeta,
1915
ipv6_packet: &Ipv6Packet<&'frame [u8]>,
20-
) -> Option<IpPacket<'frame>> {
16+
) -> Option<Packet<'frame>> {
2117
let ipv6_repr = check!(Ipv6Repr::parse(ipv6_packet));
2218

2319
if !ipv6_repr.src_addr.is_unicast() {
@@ -53,7 +49,7 @@ impl InterfaceInner {
5349
nxt_hdr: IpProtocol,
5450
handled_by_raw_socket: bool,
5551
ip_payload: &'frame [u8],
56-
) -> Option<IpPacket<'frame>> {
52+
) -> Option<Packet<'frame>> {
5753
match nxt_hdr {
5854
IpProtocol::Icmpv6 => self.process_icmpv6(sockets, ipv6_repr.into(), ip_payload),
5955

@@ -109,7 +105,7 @@ impl InterfaceInner {
109105
_sockets: &mut SocketSet,
110106
ip_repr: IpRepr,
111107
ip_payload: &'frame [u8],
112-
) -> Option<IpPacket<'frame>> {
108+
) -> Option<Packet<'frame>> {
113109
let icmp_packet = check!(Icmpv6Packet::new_checked(ip_payload));
114110
let icmp_repr = check!(Icmpv6Repr::parse(
115111
&ip_repr.src_addr(),
@@ -157,18 +153,14 @@ impl InterfaceInner {
157153
// Forward any NDISC packets to the ndisc packet handler
158154
#[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))]
159155
Icmpv6Repr::Ndisc(repr) if ip_repr.hop_limit() == 0xff => match ip_repr {
160-
IpRepr::Ipv6(ipv6_repr) => {
161-
use crate::phy::Medium;
162-
163-
match self.caps.medium {
164-
#[cfg(feature = "medium-ethernet")]
165-
Medium::Ethernet => self.process_ndisc(ipv6_repr, repr),
166-
#[cfg(feature = "medium-ieee802154")]
167-
Medium::Ieee802154 => self.process_ndisc(ipv6_repr, repr),
168-
#[cfg(feature = "medium-ip")]
169-
Medium::Ip => None,
170-
}
171-
}
156+
IpRepr::Ipv6(ipv6_repr) => match self.caps.medium {
157+
#[cfg(feature = "medium-ethernet")]
158+
Medium::Ethernet => self.process_ndisc(ipv6_repr, repr),
159+
#[cfg(feature = "medium-ieee802154")]
160+
Medium::Ieee802154 => self.process_ndisc(ipv6_repr, repr),
161+
#[cfg(feature = "medium-ip")]
162+
Medium::Ip => None,
163+
},
172164
#[allow(unreachable_patterns)]
173165
_ => unreachable!(),
174166
},
@@ -188,7 +180,7 @@ impl InterfaceInner {
188180
&mut self,
189181
ip_repr: Ipv6Repr,
190182
repr: NdiscRepr<'frame>,
191-
) -> Option<IpPacket<'frame>> {
183+
) -> Option<Packet<'frame>> {
192184
match repr {
193185
NdiscRepr::NeighborAdvert {
194186
lladdr,
@@ -237,7 +229,7 @@ impl InterfaceInner {
237229
hop_limit: 0xff,
238230
payload_len: advert.buffer_len(),
239231
};
240-
Some(IpPacket::new_ipv6(ip_repr, IpPayload::Icmpv6(advert)))
232+
Some(Packet::new_ipv6(ip_repr, IpPayload::Icmpv6(advert)))
241233
} else {
242234
None
243235
}
@@ -253,7 +245,7 @@ impl InterfaceInner {
253245
ipv6_repr: Ipv6Repr,
254246
handled_by_raw_socket: bool,
255247
ip_payload: &'frame [u8],
256-
) -> Option<IpPacket<'frame>> {
248+
) -> Option<Packet<'frame>> {
257249
let ext_hdr = check!(Ipv6ExtHeader::new_checked(ip_payload));
258250
let ext_repr = check!(Ipv6ExtHeaderRepr::parse(&ext_hdr));
259251
let hbh_hdr = check!(Ipv6HopByHopHeader::new_checked(ext_repr.data));
@@ -294,7 +286,7 @@ impl InterfaceInner {
294286
&self,
295287
ipv6_repr: Ipv6Repr,
296288
icmp_repr: Icmpv6Repr<'icmp>,
297-
) -> Option<IpPacket<'frame>> {
289+
) -> Option<Packet<'frame>> {
298290
if ipv6_repr.dst_addr.is_unicast() {
299291
let ipv6_reply_repr = Ipv6Repr {
300292
src_addr: ipv6_repr.dst_addr,
@@ -303,7 +295,7 @@ impl InterfaceInner {
303295
payload_len: icmp_repr.buffer_len(),
304296
hop_limit: 64,
305297
};
306-
Some(IpPacket::new_ipv6(
298+
Some(Packet::new_ipv6(
307299
ipv6_reply_repr,
308300
IpPayload::Icmpv6(icmp_repr),
309301
))

0 commit comments

Comments
 (0)