1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-30 13:34:27 +01:00

Added PacketSender class.

This commit is contained in:
Matias F
2011-08-10 15:10:14 -03:00
parent bb859c6ed2
commit 072ac15754
6 changed files with 116 additions and 5 deletions

View File

@@ -38,7 +38,7 @@ namespace Tins {
void dest_address(uint32_t ip);
/* Virtual methods */
uint32_t header_size();
uint32_t header_size() const;
void write_serialization(uint8_t *buffer, uint32_t total_sz);
private:
struct iphdr {

29
include/packetsender.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef __PACKET_SENDER_H
#define __PACKET_SENDER_H
#include <map>
#include <stdint.h>
#include "pdu.h"
namespace Tins {
class PacketSender {
public:
/* Opens a socket, using flag as protocol family.
* Return true if it was possible to open it(or it was already open),
* false otherwise. */
bool open_socket(uint32_t flag);
bool close_socket(uint32_t flag);
bool send(PDU *pdu);
private:
typedef std::map<uint32_t, int> SocketMap;
bool write(int sock, uint8_t *buffer, uint32_t size);
SocketMap _sockets;
};
};
#endif

View File

@@ -27,7 +27,7 @@ namespace Tins {
void inner_pdu(PDU *next_pdu);
/* Serializes the whole chain of PDU's, including this one. */
uint8_t *serialize();
uint8_t *serialize(uint32_t &sz);
/* Serialize this PDU storing the result in buffer. */
void serialize(uint8_t *buffer, uint32_t total_sz);