Opened 7 years ago

Closed 6 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:
Has a Patch: no 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:1 by phoudoin, 7 years ago

What about this:

status_t BNetworkRoster::GetRouteAt(const char* interfaceName, 
    int32 index, route_entry* route);

Or, instead of route_entry*, introduce a BNetworkRoute 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-based GetNextRoute(), but IIRC we don't use it for method, only for C functions, as get_next_*_info() and the likes.

Last edited 7 years ago by phoudoin (previous) (diff)

in reply to:  1 comment:2 by jackburton, 7 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 a BNetworkRoute 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-based GetNextRoute(), but IIRC we don't use it for method, only for C functions, as get_next_*_info() and the likes.

We actually use this semantic in BNetworkDevice::GetNextNetwork(uint32& cookie, wireless_network& network);.

comment:3 by phoudoin, 7 years ago

Okay, then what about:

status_t BNetworkRoster::GetNextRoute(uint32& cookie, route_entry& route, 
    const chat* interfaceName = NULL);

in reply to:  3 ; comment:4 by jackburton, 6 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.

in reply to:  4 comment:5 by jackburton, 6 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 jackburton, 6 years ago

Resolution: fixed
Status: newclosed

I Implemented BNetworkRoster::GetNextRoute() in hrev46372. The api isn't the greatest, but it's usable. I'm closing this ticket.

Note: See TracTickets for help on using tickets.