Modules | |
Request | |
Allocation/Freeing | |
| |
struct flnl_result * | flnl_result_alloc (void) |
void | flnl_result_put (struct flnl_result *res) |
Cache Management | |
| |
struct nl_cache * | flnl_result_alloc_cache (void) |
Allocate lookup result cache. | |
Lookup | |
| |
struct nl_msg * | flnl_lookup_build_request (struct flnl_request *req, int flags) |
Builds a netlink request message to do a lookup. | |
int | flnl_lookup (struct nl_handle *handle, struct flnl_request *req, struct nl_cache *cache) |
Perform FIB Lookup. | |
Attribute Access | |
| |
int | flnl_result_get_table_id (struct flnl_result *res) |
int | flnl_result_get_prefixlen (struct flnl_result *res) |
int | flnl_result_get_nexthop_sel (struct flnl_result *res) |
int | flnl_result_get_type (struct flnl_result *res) |
int | flnl_result_get_scope (struct flnl_result *res) |
int | flnl_result_get_error (struct flnl_result *res) |
struct nl_cache* flnl_result_alloc_cache | ( | void | ) | [read] |
Allocates a new lookup result cache and initializes it properly.
Definition at line 183 of file lookup.c.
References nl_cache_alloc().
00184 { 00185 return nl_cache_alloc(&fib_lookup_ops); 00186 }
struct nl_msg* flnl_lookup_build_request | ( | struct flnl_request * | req, | |
int | flags | |||
) | [read] |
req | Requested match. | |
flags | additional netlink message flags |
Builds a new netlink message requesting a change of link attributes. The netlink message header isn't fully equipped with all relevant fields and must be sent out via nl_send_auto_complete() or supplemented as needed. old must point to a link currently configured in the kernel and tmpl must contain the attributes to be changed set via rtnl_link_set_*
functions.
Definition at line 212 of file lookup.c.
References nl_addr_get_binary_addr(), nlmsg_alloc_simple(), nlmsg_append(), and nlmsg_free().
Referenced by flnl_lookup().
00213 { 00214 struct nl_msg *msg; 00215 struct nl_addr *addr; 00216 uint64_t fwmark; 00217 int tos, scope, table; 00218 struct fib_result_nl fr = {0}; 00219 00220 fwmark = flnl_request_get_fwmark(req); 00221 tos = flnl_request_get_tos(req); 00222 scope = flnl_request_get_scope(req); 00223 table = flnl_request_get_table(req); 00224 00225 fr.fl_fwmark = fwmark != UINT_LEAST64_MAX ? fwmark : 0; 00226 fr.fl_tos = tos >= 0 ? tos : 0; 00227 fr.fl_scope = scope >= 0 ? scope : RT_SCOPE_UNIVERSE; 00228 fr.tb_id_in = table >= 0 ? table : RT_TABLE_UNSPEC; 00229 00230 addr = flnl_request_get_addr(req); 00231 if (!addr) { 00232 nl_error(EINVAL, "Request must specify the address"); 00233 return NULL; 00234 } 00235 00236 fr.fl_addr = *(uint32_t *) nl_addr_get_binary_addr(addr); 00237 00238 msg = nlmsg_alloc_simple(0, flags); 00239 if (!msg) 00240 goto errout; 00241 00242 if (nlmsg_append(msg, &fr, sizeof(fr), NLMSG_ALIGNTO) < 0) 00243 goto errout; 00244 00245 return msg; 00246 00247 errout: 00248 nlmsg_free(msg); 00249 return NULL; 00250 }
int flnl_lookup | ( | struct nl_handle * | handle, | |
struct flnl_request * | req, | |||
struct nl_cache * | cache | |||
) |
handle | Netlink handle. | |
req | Lookup request object. | |
cache | Cache for result. |
Builds a netlink message to request a FIB lookup, waits for the reply and adds the result to the specified cache.
Definition at line 263 of file lookup.c.
References flnl_lookup_build_request(), nl_cache_pickup(), nl_send_auto_complete(), and nlmsg_free().
00265 { 00266 struct nl_msg *msg; 00267 int err; 00268 00269 msg = flnl_lookup_build_request(req, 0); 00270 if (!msg) 00271 return nl_errno(ENOMEM); 00272 00273 err = nl_send_auto_complete(handle, msg); 00274 nlmsg_free(msg); 00275 if (err < 0) 00276 return err; 00277 00278 return nl_cache_pickup(handle, cache); 00279 }