Fix FreeBSD build.
[haiku.git] / headers / os / net / NetworkRoute.h
blobe30730ed7c12627b726a1af6e55ed99c293e1ffc
1 /*
2 * Copyright 2015, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _NETWORK_ROUTE_H
6 #define _NETWORK_ROUTE_H
8 #include <net/route.h>
10 #include <ObjectList.h>
13 class BNetworkRoute {
14 public:
15 BNetworkRoute();
16 ~BNetworkRoute();
18 status_t SetTo(const BNetworkRoute& other);
19 status_t SetTo(const route_entry& routeEntry);
21 void Adopt(BNetworkRoute& other);
23 const route_entry& RouteEntry() const;
25 const sockaddr* Destination() const;
26 status_t SetDestination(const sockaddr& destination);
27 void UnsetDestination();
29 const sockaddr* Mask() const;
30 status_t SetMask(const sockaddr& mask);
31 void UnsetMask();
33 const sockaddr* Gateway() const;
34 status_t SetGateway(const sockaddr& gateway);
35 void UnsetGateway();
37 const sockaddr* Source() const;
38 status_t SetSource(const sockaddr& source);
39 void UnsetSource();
41 uint32 Flags() const;
42 void SetFlags(uint32 flags);
44 uint32 MTU() const;
45 void SetMTU(uint32 mtu);
47 int AddressFamily() const;
49 static status_t GetDefaultRoute(int family,
50 const char* interfaceName,
51 BNetworkRoute& route);
52 static status_t GetDefaultGateway(int family,
53 const char* interfaceName,
54 sockaddr& gateway);
56 static status_t GetRoutes(int family,
57 BObjectList<BNetworkRoute>& routes);
58 static status_t GetRoutes(int family, const char* interfaceName,
59 BObjectList<BNetworkRoute>& routes);
60 static status_t GetRoutes(int family, const char* interfaceName,
61 uint32 filterFlags,
62 BObjectList<BNetworkRoute>& routes);
64 private:
65 BNetworkRoute(const BNetworkRoute& other);
66 // unimplemented to disallow copying
68 status_t _AllocateAndSetAddress(const sockaddr& from,
69 sockaddr*& to);
70 void _FreeAndUnsetAddress(sockaddr*& address);
72 route_entry fRouteEntry;
75 #endif // _NETWORK_ROUTE_H