1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
/******************************************************************************
(c) 2002-2003 Christine Caulfield christine.caulfield@googlemail.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
******************************************************************************/
// interfaces-bpf.h
// BPF implementation of LATinterfaces
class BPFInterfaces : public LATinterfaces
{
public:
BPFInterfaces() { _latd_bpf_interface_name = NULL; };
~BPFInterfaces() {};
// Initialise
virtual int Start(int proto);
// Return a list of valid interface numbers and the count
virtual void get_all_interfaces(int *ifs, int &num);
// Print the name of an interface
virtual std::string ifname(int ifn);
// Find an interface number by name
virtual int find_interface(char *name);
// true if this class defines one FD for each active
// interface, false if one fd is used for all interfaces.
virtual bool one_fd_per_interface();
// Return the FD for this interface (will only be called once for
// select if above returns false)
virtual int get_fd(int ifn);
// Send a packet to a given macaddr
virtual int send_packet(int ifn, unsigned char macaddr[], unsigned char *data, int len);
// Receive a packet from a given interface
virtual int recv_packet(int sockfd, int &ifn, unsigned char macaddr[], unsigned char *data, int maxlen, bool &more);
// Open a connection on an interface
virtual int set_lat_multicast(int ifn);
// Close an interface.
virtual int remove_lat_multicast(int ifn);
// Bind a socket to an interface
virtual int bind_socket(int interface);
/* these are bad, but they get the job done for now. we only
support using a single interface: */
int _latd_bpf_fd;
char *_latd_bpf_interface_name;
unsigned char _latd_bpf_interface_addr[ETHER_ADDR_LEN];
unsigned int _latd_bpf_buffer_size;
unsigned char *_latd_bpf_buffer;
unsigned int _latd_bpf_buffer_end;
unsigned int _latd_bpf_buffer_offset;
private:
};
|