00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _LAYER2_H_
00011 #define _LAYER2_H_
00012
00013 #include "config.h"
00014 #include "usi++/usi-structs.h"
00015 #include "RX.h"
00016 #include "TX.h"
00017
00018 #include <stdio.h>
00019
00020 namespace usipp {
00021
00025 class Layer2 {
00026 private:
00027 RX *d_rx;
00028 TX *d_tx;
00029 public:
00034 Layer2(RX *r = NULL, TX *t = NULL);
00035
00036
00037 virtual ~Layer2() {}
00038
00040 virtual int sniffpack(void *, size_t);
00041
00043 virtual int sendpack(void *buf, size_t len, struct sockaddr *);
00044
00046 virtual int init_device(char *dev, int promisc, size_t snaplen);
00047
00049 int setfilter(char *f);
00050
00052 int timeout(struct timeval);
00053
00055 bool timeout();
00056
00058 TX *register_tx(TX *t) { TX *r = d_tx; d_tx = t; return r; }
00059
00061 RX *register_rx(RX *r) { RX *ret = d_rx; d_rx = r; return ret; }
00062
00064 TX *tx() { return d_tx; }
00065
00067 RX *rx() { return d_rx; }
00068 };
00069
00070 }
00071 #endif