mirror of
https://github.com/mfontanini/libtins
synced 2026-01-30 05:24:26 +01:00
Added recv mechanism on PacketSender.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <map>
|
||||
#include "pdu.h"
|
||||
|
||||
namespace Tins {
|
||||
@@ -38,6 +39,12 @@ namespace Tins {
|
||||
*/
|
||||
class PacketSender {
|
||||
public:
|
||||
enum SocketType {
|
||||
IP_SOCKET,
|
||||
ICMP_SOCKET,
|
||||
SOCKETS_END
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Constructor for PacketSender objects.
|
||||
*/
|
||||
@@ -46,23 +53,28 @@ namespace Tins {
|
||||
|
||||
bool open_l2_socket();
|
||||
|
||||
bool open_l3_socket();
|
||||
bool open_l3_socket(SocketType type);
|
||||
|
||||
bool close_socket(uint32_t flag);
|
||||
|
||||
bool send(PDU* pdu);
|
||||
|
||||
PDU *send_recv(PDU *pdu);
|
||||
|
||||
bool send_l2(PDU *pdu);
|
||||
|
||||
PDU *recv_l3(PDU *pdu, struct sockaddr *link_addr, uint32_t len_link_addr, SocketType type);
|
||||
|
||||
bool send_l3(PDU *pdu, const struct sockaddr* link_addr, uint32_t len_link_addr);
|
||||
bool send_l3(PDU *pdu, struct sockaddr *link_addr, uint32_t len_link_addr, SocketType type);
|
||||
private:
|
||||
enum SocketType {
|
||||
IP_SOCKET,
|
||||
SOCKETS_END
|
||||
};
|
||||
static const int INVALID_RAW_SOCKET;
|
||||
|
||||
typedef std::map<SocketType, int> SocketTypeMap;
|
||||
|
||||
int find_type(SocketType type);
|
||||
|
||||
std::vector<int> _sockets;
|
||||
SocketTypeMap _types;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user