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