Skip to content

Commit

Permalink
Removed the PDU* parameter in several PDU's constructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfontanini committed Apr 23, 2013
1 parent 7e85058 commit bf60433
Show file tree
Hide file tree
Showing 24 changed files with 83 additions and 143 deletions.
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ subdir = .
DIST_COMMON = README $(am__configure_deps) $(libtins_include_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/libtins.pc.in $(top_srcdir)/configure \
$(top_srcdir)/include/config.h.in AUTHORS INSTALL THANKS \
$(top_srcdir)/include/config.h.in AUTHORS THANKS TODO \
config.guess config.sub depcomp install-sh ltmain.sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
Expand Down
48 changes: 12 additions & 36 deletions include/dot11.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,8 @@ namespace Tins {
* destination's and source's MAC.
*
* \param dst_hw_addr The destination hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11(const address_type &dst_hw_addr = address_type(),
PDU* child = 0);
Dot11(const address_type &dst_hw_addr = address_type());

/**
* \brief Constructs 802.11 PDU from a buffer and adds all
Expand Down Expand Up @@ -2656,11 +2654,9 @@ namespace Tins {
*
* \param dst_hw_addr The destination hardware address.
* \param src_hw_addr The source hardware address.
* \param child The inner PDU.
*/
Dot11Data(const address_type &dst_hw_addr = address_type(),
const address_type &src_hw_addr = address_type(),
PDU* child = 0);
const address_type &src_hw_addr = address_type());

/**
* \brief Constructs a Dot11Data object from a buffer and adds
Expand Down Expand Up @@ -2828,11 +2824,9 @@ namespace Tins {
*
* \param dst_hw_addr The destination hardware address.
* \param src_hw_addr The source hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11QoSData(const address_type &dst_hw_addr = address_type(),
const address_type &src_hw_addr = address_type(),
PDU* child = 0);
const address_type &src_hw_addr = address_type());

/**
* \brief Constructors Dot11QoSData object from a buffer and adds
Expand Down Expand Up @@ -2919,10 +2913,8 @@ namespace Tins {
* source hardware addresses.
*
* \param dst_addr The destination hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11Control(const address_type &dst_addr = address_type(),
PDU* child = 0);
Dot11Control(const address_type &dst_addr = address_type());

/**
* \brief Constructs a Dot11Control object from a buffer and
Expand Down Expand Up @@ -2981,11 +2973,9 @@ namespace Tins {
*
* \param dst_addr The destination hardware address.
* \param target_addr The source hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11ControlTA(const address_type &dst_addr = address_type(),
const address_type &target_addr = address_type(),
PDU* child = 0);
const address_type &target_addr = address_type());

/**
* \brief Constructs a Dot11ControlTA object from a buffer and
Expand Down Expand Up @@ -3037,11 +3027,9 @@ namespace Tins {
*
* \param dst_addr The destination hardware address.
* \param target_addr The source hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11RTS(const address_type &dst_addr = address_type(),
const address_type &target_addr = address_type(),
PDU* child = 0);
const address_type &target_addr = address_type());

/**
* \brief Constructs a Dot11RTS object from a buffer and adds all
Expand Down Expand Up @@ -3098,11 +3086,9 @@ namespace Tins {
*
* \param dst_addr The destination hardware address.
* \param target_addr The source hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11PSPoll(const address_type &dst_addr = address_type(),
const address_type &target_addr = address_type(),
PDU* child = 0);
const address_type &target_addr = address_type());

/**
* \brief Constructs a Dot11PSPoll object from a buffer and
Expand Down Expand Up @@ -3160,11 +3146,9 @@ namespace Tins {
*
* \param dst_addr The destination hardware address.
* \param target_addr The source hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11CFEnd(const address_type &dst_addr = address_type(),
const address_type &target_addr = address_type(),
PDU* child = 0);
const address_type &target_addr = address_type());

/**
* \brief Constructs a Dot11CFEnd object from a buffer and adds
Expand Down Expand Up @@ -3222,11 +3206,9 @@ namespace Tins {
*
* \param dst_addr The destination hardware address.
* \param target_addr The source hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11EndCFAck(const address_type &dst_addr = address_type(),
const address_type &target_addr = address_type(),
PDU* child = 0);
const address_type &target_addr = address_type());

/**
* \brief Constructs a Dot11EndCFAck frame object from a buffer
Expand Down Expand Up @@ -3283,10 +3265,8 @@ namespace Tins {
* hardware addresses.
*
* \param dst_addr The destination hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11Ack(const address_type &dst_addr = address_type(),
PDU* child = 0);
Dot11Ack(const address_type &dst_addr = address_type());

/**
* \brief Constructs a Dot11Ack frame object from a buffer and
Expand Down Expand Up @@ -3347,11 +3327,9 @@ namespace Tins {
*
* \param dst_addr The destination hardware address.
* \param target_addr The source hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11BlockAckRequest(const address_type &dst_addr = address_type(),
const address_type &target_addr = address_type(),
PDU* child = 0);
const address_type &target_addr = address_type());

/**
* \brief Constructs a Dot11BlockAckRequest object from a buffer
Expand Down Expand Up @@ -3490,11 +3468,9 @@ namespace Tins {
*
* \param dst_addr The destination hardware address.
* \param target_addr The source hardware address.
* \param child PDU* with the PDU contained by the 802.11 PDU (optional).
*/
Dot11BlockAck(const address_type &dst_addr = address_type(),
const address_type &target_addr = address_type(),
PDU* child = 0);
const address_type &target_addr = address_type());

/**
* \brief Constructs a Dot11BlockAck frame object from a buffer
Expand Down
3 changes: 1 addition & 2 deletions include/dot3.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ namespace Tins {
* \param child The PDU which will be set as the inner PDU.
*/
Dot3(const address_type &dst_hw_addr = address_type(),
const address_type &src_hw_addr = address_type(),
PDU* child = 0);
const address_type &src_hw_addr = address_type());

/**
* \brief Constructs a Dot3 object from a buffer and adds a
Expand Down
8 changes: 3 additions & 5 deletions include/ethernetII.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ namespace Tins {
/**
* \brief Constructs an ethernet II PDU.
*
* \param dst_hw_addr address_type containing the destination's MAC(optional).
* \param src_hw_addr address_type containing the source's MAC(optional).
* \param child PDU* with the PDU contained by the ethernet PDU (optional).
* \param dst_hw_addr address_type containing the destination's MAC.
* \param src_hw_addr address_type containing the source's MAC.
*/
EthernetII(const address_type &dst_hw_addr = address_type(),
const address_type &src_hw_addr = address_type(),
PDU* child = 0);
const address_type &src_hw_addr = address_type());

/**
* \brief Constructs a EthernetII object from a buffer and adds
Expand Down
5 changes: 1 addition & 4 deletions include/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,9 @@ namespace Tins {
*
* \param ip_dst The destination ip address(optional).
* \param ip_src The source ip address(optional).
* \param child pointer to a PDU which will be set as the inner_pdu
* for the packet being constructed(optional).
*/
IP(address_type ip_dst = address_type(),
address_type ip_src = address_type(),
PDU *child = 0);
address_type ip_src = address_type());

/**
* \brief Constructs an IP object from a buffer and adds all
Expand Down
15 changes: 7 additions & 8 deletions include/llc.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,17 @@ namespace Tins {
};

/**
* \brief Creates an instance of LLC
* \param child The child PDU.(optional)
* \brief Default constructor.
*/
LLC(PDU *child = 0);
LLC();

/**
* \brief Creates an instance of LLC, setting the dsap and ssap.
* The control field is set all to 0.
* @param dsap The dsap value to be set.
* @param ssap The ssap value to be set.
* \brief Constructs an instance of LLC, setting the dsap and ssap.
* The control field is set to 0.
* \param dsap The dsap value to be set.
* \param ssap The ssap value to be set.
*/
LLC(uint8_t dsap, uint8_t ssap, PDU* child = 0);
LLC(uint8_t dsap, uint8_t ssap);

/**
* \brief Constructs a LLC object from a buffer and adds all
Expand Down
10 changes: 0 additions & 10 deletions include/loopback.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ class Loopback : public PDU {
* The family identifier is left as zero.
*/
Loopback();

/**
* \brief Construct a Loopback object.
*
* The NetworkInterface object will only be used in *BSD, where
* Null/Loopback PDUs can actually be sent.
*
* \param inner_pdu The inner pdu to be set.
*/
Loopback(PDU *inner_pdu = 0);

/**
* \brief Construct a Loopback object from a buffer and adds
Expand Down
8 changes: 2 additions & 6 deletions include/pdu.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,9 @@ namespace Tins {
};

/**
* \brief PDU constructor
*
* Must be called by subclasses in their constructors.
* \param flag The flag identifier for the subclass' PDU.
* \param next_pdu The child PDU. Can be obviated.
* \brief Default constructor.
*/
PDU(PDU *next_pdu = 0);
PDU();

#if TINS_IS_CXX11
/**
Expand Down
5 changes: 2 additions & 3 deletions include/radiotap.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ namespace Tins {
};

/**
* \brief Creates an instance of RadioTap.
* \param child The child PDU.
* \brief Default constructor.
*/
RadioTap(PDU *child = 0);
RadioTap();

/**
* \brief Constructs a RadioTap object from a buffer and adds all
Expand Down
3 changes: 1 addition & 2 deletions include/snap.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ namespace Tins {
* \brief Creates an instance of SNAP
* This constructor sets the dsap and ssap fields to 0xaa, and
* the id field to 3.
* \param child The child PDU.(optional)
*/
SNAP(PDU *child = 0);
SNAP();

/**
* \brief Constructs a SNAP object from a buffer and adds all
Expand Down
6 changes: 3 additions & 3 deletions include/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ namespace Tins {
*
* Creates an instance of UDP. Destination and source port can
* be provided, otherwise both will be 0.
*
* \param dport Destination port.
* \param sport Source port.
* \param child The child PDU(optional).
* */
UDP(uint16_t dport = 0, uint16_t sport = 0, PDU *child = 0);
UDP(uint16_t dport = 0, uint16_t sport = 0);

/**
* \brief Constructs an UDP object from a buffer.
Expand Down Expand Up @@ -145,7 +145,7 @@ namespace Tins {
/**
* \sa PDU::clone
*/
PDU *clone() const {
UDP *clone() const {
return new UDP(*this);
}
private:
Expand Down
18 changes: 9 additions & 9 deletions src/arp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,24 @@ EthernetII ARP::make_arp_request(ipaddress_type target, ipaddress_type sender,
const hwaddress_type &hw_snd)
{
/* Create ARP packet and set its attributes */
ARP* arp = new ARP();
arp->target_ip_addr(target);
arp->sender_ip_addr(sender);
arp->sender_hw_addr(hw_snd);
arp->opcode(REQUEST);
ARP arp;
arp.target_ip_addr(target);
arp.sender_ip_addr(sender);
arp.sender_hw_addr(hw_snd);
arp.opcode(REQUEST);

/* Create the EthernetII PDU with the ARP PDU as its inner PDU */
return EthernetII(EthernetII::BROADCAST, hw_snd, arp);
return EthernetII(EthernetII::BROADCAST, hw_snd) / arp;
}

EthernetII ARP::make_arp_reply(ipaddress_type target, ipaddress_type sender,
const hwaddress_type &hw_tgt, const hwaddress_type &hw_snd)
{
/* Create ARP packet and set its attributes */
ARP* arp = new ARP(target, sender, hw_tgt, hw_snd);
arp->opcode(REPLY);
ARP arp(target, sender, hw_tgt, hw_snd);
arp.opcode(REPLY);

/* Create the EthernetII PDU with the ARP PDU as its inner PDU */
return EthernetII(hw_tgt, hw_snd, arp);
return EthernetII(hw_tgt, hw_snd) / arp;
}
}
Loading

0 comments on commit bf60433

Please sign in to comment.