Fix FreeBSD build.
[haiku.git] / headers / os / net / NetworkInterface.h
blobd966c34c0ba98ad4beba7bfda97105e9d5df4a99
1 /*
2 * Copyright 2010, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _NETWORK_INTERFACE_H
6 #define _NETWORK_INTERFACE_H
9 #include <net/if.h>
10 #include <net/if_types.h>
12 #include <ObjectList.h>
13 #include <NetworkAddress.h>
16 class BNetworkInterface;
17 class BNetworkRoute;
20 class BNetworkInterfaceAddress {
21 public:
22 BNetworkInterfaceAddress();
23 ~BNetworkInterfaceAddress();
25 status_t SetTo(const BNetworkInterface& interface,
26 int32 index);
28 void SetAddress(const BNetworkAddress& address);
29 void SetMask(const BNetworkAddress& mask);
30 void SetBroadcast(const BNetworkAddress& broadcast);
31 void SetDestination(
32 const BNetworkAddress& destination);
34 BNetworkAddress& Address() { return fAddress; }
35 BNetworkAddress& Mask() { return fMask; }
36 BNetworkAddress& Broadcast() { return fBroadcast; }
37 BNetworkAddress& Destination() { return fBroadcast; }
39 const BNetworkAddress& Address() const { return fAddress; }
40 const BNetworkAddress& Mask() const { return fMask; }
41 const BNetworkAddress& Broadcast() const { return fBroadcast; }
42 const BNetworkAddress& Destination() const { return fBroadcast; }
44 void SetFlags(uint32 flags);
45 uint32 Flags() const { return fFlags; }
47 int32 Index() const { return fIndex; }
49 private:
50 int32 fIndex;
51 BNetworkAddress fAddress;
52 BNetworkAddress fMask;
53 BNetworkAddress fBroadcast;
54 uint32 fFlags;
58 class BNetworkInterface {
59 public:
60 BNetworkInterface();
61 BNetworkInterface(const char* name);
62 BNetworkInterface(uint32 index);
63 ~BNetworkInterface();
65 void Unset();
66 void SetTo(const char* name);
67 status_t SetTo(uint32 index);
69 bool Exists() const;
71 const char* Name() const;
72 uint32 Index() const;
73 uint32 Flags() const;
74 uint32 MTU() const;
75 int32 Media() const;
76 uint32 Metric() const;
77 uint32 Type() const;
78 status_t GetStats(ifreq_stats& stats);
79 bool HasLink() const;
81 status_t SetFlags(uint32 flags);
82 status_t SetMTU(uint32 mtu);
83 status_t SetMedia(int32 media);
84 status_t SetMetric(uint32 metric);
86 int32 CountAddresses() const;
87 status_t GetAddressAt(int32 index,
88 BNetworkInterfaceAddress& address);
89 int32 FindAddress(const BNetworkAddress& address);
90 int32 FindFirstAddress(int family);
92 status_t AddAddress(
93 const BNetworkInterfaceAddress& address);
94 status_t AddAddress(const BNetworkAddress& address);
95 status_t SetAddress(
96 const BNetworkInterfaceAddress& address);
97 status_t RemoveAddress(
98 const BNetworkInterfaceAddress& address);
99 status_t RemoveAddress(const BNetworkAddress& address);
100 status_t RemoveAddressAt(int32 index);
102 status_t GetHardwareAddress(BNetworkAddress& address);
104 status_t AddRoute(const BNetworkRoute& route);
105 status_t AddDefaultRoute(const BNetworkAddress& gateway);
106 status_t RemoveRoute(const BNetworkRoute& route);
107 status_t RemoveRoute(int family,
108 const BNetworkRoute& route);
109 status_t RemoveDefaultRoute(int family);
110 status_t GetRoutes(int family,
111 BObjectList<BNetworkRoute>& routes) const;
112 status_t GetDefaultRoute(int family,
113 BNetworkRoute& route) const;
114 status_t GetDefaultGateway(int family,
115 BNetworkAddress& gateway) const;
117 status_t AutoConfigure(int family);
119 private:
120 char fName[IF_NAMESIZE];
121 BList fAddresses;
125 #endif // _NETWORK_INTERFACE_H