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