Opened 12 years ago
Closed 11 years ago
#9701 closed enhancement (fixed)
libnetapi: missing api for getting routing table / gateways
Reported by: | jackburton | Owned by: | axeld |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Kits/Network Kit | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Libnetapi currently lacks methods to get the system routing table. Could be implemented in various places:
In the mailing list I proposed
int32 BNetworkInterface::CountRoutes()
and
status_t BNetworkInterface::GetRouteAt(int32 index, route_entry* entry)
but since the routing table isn't interface-specific, although a single route can of course be interface-specific, I think it could be implemented in BNetworkRoster as a single method
status_t BNetworkRoster::GetRoutingTable(const char* interfaceName, BObjectList<route_entry>*)
which would return a list of route_entry objects (or a more friendly class (BRoute?)), with the option of filtering by interface name, or even family.
Unfortunately I suspect we don't push the use of BObjectList in public api, so we'll need to use a BList here....
Other ideas ?
Change History (6)
comment:2 by , 12 years ago
Replying to phoudoin:
What about this:
status_t BNetworkRoster::GetRouteAt(const char* interfaceName, int32 index, route_entry* route);Or, instead of
route_entry*
, introduce aBNetworkRoute
object to wrap it.If interfaceName is NULL, this call could returns all current network routes.
Yeah.
An alternative to
GetRouteAt()
semantic could be an opaque cookie-basedGetNextRoute()
, but IIRC we don't use it for method, only for C functions, asget_next_*_info()
and the likes.
We actually use this semantic in BNetworkDevice::GetNextNetwork(uint32& cookie, wireless_network& network);.
follow-up: 4 comment:3 by , 12 years ago
Okay, then what about:
status_t BNetworkRoster::GetNextRoute(uint32& cookie, route_entry& route, const chat* interfaceName = NULL);
follow-up: 5 comment:4 by , 12 years ago
Replying to phoudoin:
Okay, then what about:
status_t BNetworkRoster::GetNextRoute(uint32& cookie, route_entry& route, const chat* interfaceName = NULL);
I'd be okay with that one. Anyone else objects ? Any other suggestion ? I can go with this one if it's okay.
comment:5 by , 12 years ago
Replying to jackburton:
Replying to phoudoin:
Okay, then what about:
status_t BNetworkRoster::GetNextRoute(uint32& cookie, route_entry& route, const chat* interfaceName = NULL);I'd be okay with that one. Anyone else objects ? Any other suggestion ? I can go with this one if it's okay.
Although, now that I think about it, might be not that efficient to implement it that way. The network stack currently can only return the complete routing table. The GetNextRoute() semantics would involve either caching the whole routing table in the BNetworkRoster class, or getting the whole routing table at every GetNextRoute invocation, which is less that nice.
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I Implemented BNetworkRoster::GetNextRoute() in hrev46372. The api isn't the greatest, but it's usable. I'm closing this ticket.
What about this:
Or, instead of
route_entry*
, introduce aBNetworkRoute
object to wrap it.If interfaceName is NULL, this call could returns all current network routes.
An alternative to
GetRouteAt()
semantic could be an opaque cookie-basedGetNextRoute()
, but IIRC we don't use it for method, only for C functions, asget_next_*_info()
and the likes.