a2c61551f2abc5bcea9140a2239a70d635ed3cd5
[olsrd.git] / lib / pud / src / networkInterfaces.h
1 #ifndef _PUD_NETWORKINTERFACES_H
2 #define _PUD_NETWORKINTERFACES_H
3
4 /* Plugin includes */
5
6 /* OLSR includes */
7 #include "olsr_types.h"
8 #include "interfaces.h"
9 #include "scheduler.h"
10
11 /* System includes */
12 #include <stdbool.h>
13 #include <net/if.h>
14
15 /** A list of TRxTxNetworkInterface objects, used for non-OLSR interfaces */
16 typedef struct _TRxTxNetworkInterface {
17                 /** The socket file descriptor for the non-OLSR interface*/
18                 int socketFd;
19
20                 /** The name of the interface */
21                 unsigned char name[IFNAMSIZ + 1];
22
23                 /** The IP address of the interface */
24                 union olsr_sockaddr ipAddress;
25
26                 /** the socket handler function */
27                 socket_handler_func handler;
28
29                 /** The next TRxTxNetworkInterface in the list */
30                 struct _TRxTxNetworkInterface * next;
31 } TRxTxNetworkInterface;
32
33 /** A list of TOLSRNetworkInterface objects, used for OLSR interfaces */
34 typedef struct _TOLSRNetworkInterface {
35                 /** A pointer to the OLSR interface */
36                 struct interface * olsrIntf;
37
38                 /** The next TOLSRNetworkInterface in the list */
39                 struct _TOLSRNetworkInterface * next;
40 } TOLSRNetworkInterface;
41
42 bool createNetworkInterfaces(socket_handler_func rxSocketHandlerFunction);
43 void closeNetworkInterfaces(void);
44
45 unsigned char * getMainIpMacAddress(void);
46 TRxTxNetworkInterface * getRxNetworkInterfaces(void);
47 TRxTxNetworkInterface * getTxNetworkInterfaces(void);
48 int getUplinkSocketFd(void);
49 TOLSRNetworkInterface * getOlsrNetworkInterface(struct interface * olsrIntf);
50
51 #endif /* _PUD_NETWORKINTERFACES_H */