Skip to content

Commit 5b1021f

Browse files
net: Removed enable_shared_from_this from packets
1 parent 745d685 commit 5b1021f

4 files changed

Lines changed: 22 additions & 25 deletions

File tree

api/net/ip4/packet_arp.hpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
88
// You may obtain a copy of the License at
9-
//
9+
//
1010
// http://www.apache.org/licenses/LICENSE-2.0
11-
//
11+
//
1212
// Unless required by applicable law or agreed to in writing, software
1313
// distributed under the License is distributed on an "AS IS" BASIS,
1414
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,62 +24,61 @@
2424

2525
namespace net
2626
{
27-
class PacketArp : public Packet,
28-
public std::enable_shared_from_this<PacketArp>
27+
class PacketArp : public Packet
2928
{
3029
public:
3130
Arp::header& header() const
3231
{
3332
return *(Arp::header*) buffer();
3433
}
35-
34+
3635
static const size_t headers_size = sizeof(Arp::header);
37-
36+
3837
/** initializes to a default, empty Arp packet, given
3938
a valid MTU-sized buffer */
4039
void init(Ethernet::addr local_mac, IP4::addr local_ip)
41-
{
40+
{
4241
auto& hdr = header();
4342
hdr.ethhdr.type = Ethernet::ETH_ARP;
4443
hdr.htype = Arp::H_htype_eth;
4544
hdr.ptype = Arp::H_ptype_ip4;
4645
hdr.hlen_plen = Arp::H_hlen_plen;
47-
46+
4847
hdr.dipaddr = next_hop();
4948
hdr.sipaddr = local_ip;
5049
hdr.shwaddr = local_mac;
5150
}
52-
51+
5352
void set_dest_mac(Ethernet::addr mac) {
5453
header().dhwaddr = mac;
55-
header().ethhdr.dest = mac;
56-
}
57-
54+
header().ethhdr.dest = mac;
55+
}
56+
5857
void set_opcode(Arp::Opcode op) {
5958
header().opcode = op;
6059
}
61-
60+
6261
void set_dest_ip(IP4::addr ip) {
6362
header().dipaddr = ip;
6463
}
65-
64+
6665
IP4::addr source_ip() const {
6766
return header().sipaddr;
6867
}
69-
68+
7069
IP4::addr dest_ip() const {
7170
return header().dipaddr;
7271
}
73-
72+
7473
Ethernet::addr source_mac() const {
7574
return header().ethhdr.src;
7675
};
77-
76+
7877
Ethernet::addr dest_mac() const {
7978
return header().ethhdr.dest;
8079
};
81-
82-
80+
81+
8382
};
8483
}
8584

api/net/ip4/packet_ip4.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626

2727
namespace net {
2828

29-
class PacketIP4 : public Packet, // might work as upcast:
30-
public std::enable_shared_from_this<PacketIP4>
29+
class PacketIP4 : public Packet
3130
{
3231
public:
3332
static constexpr size_t DEFAULT_TTL {64};

api/net/ip4/packet_udp.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323

2424
namespace net
2525
{
26-
class PacketUDP : public PacketIP4, // might work as upcast:
27-
public std::enable_shared_from_this<PacketUDP>
26+
class PacketUDP : public PacketIP4
2827
{
2928
public:
3029

api/net/packet.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace net
2828
class Packet;
2929
using Packet_ptr = std::unique_ptr<Packet>;
3030

31-
class Packet : public std::enable_shared_from_this<Packet>
31+
class Packet
3232
{
3333
public:
3434
/**
@@ -54,7 +54,7 @@ namespace net
5454
bufstore->release(this);
5555
else
5656
delete[] (uint8_t*) this;
57-
} // see: buffer_store.cpp
57+
}
5858

5959
/** Get the buffer */
6060
BufferStore::buffer_t buffer() const noexcept

0 commit comments

Comments
 (0)