X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fdpif.h;h=3c376ec1f380bfa7186362a5de66abb0c672e9fd;hb=bc4a05c639ee3789d009bb6143345cf121b2d4d4;hp=3e72539c1652512af8254b0984c18f39aaa0f5e7;hpb=856081f683d3e7d5b5fa07af4233d285eb205c47;p=sliver-openvswitch.git diff --git a/lib/dpif.h b/lib/dpif.h index 3e72539c1..3c376ec1f 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,13 +63,46 @@ int dpif_set_drop_frags(struct dpif *, bool drop_frags); int dpif_port_add(struct dpif *, struct netdev *, uint16_t *port_nop); int dpif_port_del(struct dpif *, uint16_t port_no); + +/* A port within a datapath. + * + * 'name' and 'type' are suitable for passing to netdev_open(). */ +struct dpif_port { + char *name; /* Network device name, e.g. "eth0". */ + char *type; /* Network device type, e.g. "system". */ + uint32_t port_no; /* Port number within datapath. */ +}; +void dpif_port_clone(struct dpif_port *, const struct dpif_port *); +void dpif_port_destroy(struct dpif_port *); int dpif_port_query_by_number(const struct dpif *, uint16_t port_no, - struct odp_port *); + struct dpif_port *); int dpif_port_query_by_name(const struct dpif *, const char *devname, - struct odp_port *); + struct dpif_port *); int dpif_port_get_name(struct dpif *, uint16_t port_no, char *name, size_t name_size); -int dpif_port_list(const struct dpif *, struct odp_port **, size_t *n_ports); +int dpif_get_max_ports(const struct dpif *); + +struct dpif_port_dump { + const struct dpif *dpif; + int error; + void *state; +}; +void dpif_port_dump_start(struct dpif_port_dump *, const struct dpif *); +bool dpif_port_dump_next(struct dpif_port_dump *, struct dpif_port *); +int dpif_port_dump_done(struct dpif_port_dump *); + +/* Iterates through each DPIF_PORT in DPIF, using DUMP as state. + * + * Arguments all have pointer type. + * + * If you break out of the loop, then you need to free the dump structure by + * hand using dpif_port_dump_done(). */ +#define DPIF_PORT_FOR_EACH(DPIF_PORT, DUMP, DPIF) \ + for (dpif_port_dump_start(DUMP, DPIF); \ + (dpif_port_dump_next(DUMP, DPIF_PORT) \ + ? true \ + : (dpif_port_dump_done(DUMP), false)); \ + ) int dpif_port_poll(const struct dpif *, char **devnamep); void dpif_port_poll_wait(const struct dpif *); @@ -78,7 +111,6 @@ int dpif_flow_flush(struct dpif *); int dpif_flow_put(struct dpif *, struct odp_flow_put *); int dpif_flow_del(struct dpif *, struct odp_flow *); int dpif_flow_get(const struct dpif *, struct odp_flow *); -int dpif_flow_get_multiple(const struct dpif *, struct odp_flow[], size_t n); struct dpif_flow_dump { const struct dpif *dpif; @@ -121,7 +153,7 @@ int dpif_recv_set_mask(struct dpif *, int listen_mask); int dpif_get_sflow_probability(const struct dpif *, uint32_t *probability); int dpif_set_sflow_probability(struct dpif *, uint32_t probability); int dpif_recv(struct dpif *, struct dpif_upcall *); -int dpif_recv_purge(struct dpif *); +void dpif_recv_purge(struct dpif *); void dpif_recv_wait(struct dpif *); void dpif_get_netflow_ids(const struct dpif *,