1
0
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:
Matias Fontanini
2011-08-15 12:39:46 -03:00
parent c803e25db4
commit 5c412208f9
7 changed files with 201 additions and 26 deletions

View File

@@ -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;
};
};