hlswmaster-ng/multisock.h

54 lines
898 B
C++

#ifndef _MULTISOCK_H_
#define _MULTISOCK_H_
#include <net/if.h>
#include <netinet/in.h>
#include "list.h"
#include "config.h"
class MultiSock {
public:
MultiSock(Config& conf);
~MultiSock();
int send(struct in_addr *dstip, int dport, char* data, int size);
int getRecvSocket();
protected:
MultiSock(const MultiSock& x);
MultiSock& operator=(const MultiSock& x);
private:
class Socket {
public:
static Socket* createSocket(const char* name, int port);
int show(char* buf, int size);
int getFD() { return fd; }
~Socket();
protected:
Socket(const Socket& s);
Socket& operator=(const Socket& s);
private:
Socket();
bool bindToDevice(const char* name);
bool bindToPort(int port);
int fd;
char devname[IFNAMSIZ];
struct sockaddr_in addr;
};
void addIface(const char* name, int port);
List<Socket> ifaceList;
fd_set fdsel;
};
#endif // _MULTISOCK_H_