|
XSocket API
2.0
XIA Socket Library
|
Build DAGs for use as addresses in XIA. More...
#include <dagaddr.hpp>
Public Member Functions | |
| Graph () | |
| Create an empty graph. More... | |
| Graph (const Node &n) | |
| Create a graph from a node. More... | |
| Graph (const Graph &r) | |
| Create a copy of a graph. More... | |
| Graph (std::string dag_string) | |
| Create a graph from a DAG string. More... | |
| Graph (const sockaddr_x *s) | |
| Create a graph from a sockaddr_x. More... | |
| Graph & | operator= (const Graph &r) |
| Graph & | operator*= (const Graph &r) |
| Graph | operator* (const Graph &r) const |
| Append a graph to this one. More... | |
| Graph & | operator+= (const Graph &r) |
| Graph | operator+ (const Graph &r) const |
| Merge a graph with this one. More... | |
| Graph | operator* (const Node &r) const |
| Append a node. More... | |
| Graph | operator+ (const Node &r) const |
| Merge with a node. More... | |
| bool | operator== (const Graph &r) const |
| Compare two graphs logically. More... | |
| void | append_node_str (std::string node_str) |
| void | print_graph () const |
| Print the graph. More... | |
| std::string | http_url_string () const |
| std::string | dag_string () const |
| Return the graph in string form. More... | |
| const Node & | intent_AD () const |
| const Node & | intent_HID () const |
| const Node & | intent_SID () const |
| std::string | intent_AD_str () const |
| Return the AD for the Graph's intent node. More... | |
| std::string | intent_HID_str () const |
| std::string | intent_SID_str () const |
| bool | is_valid () const |
| Check if this is a valid graph. More... | |
| bool | is_final_intent (const Node &n) |
| Test if a node is the final intent. More... | |
| bool | is_final_intent (const std::string xid_string) |
| Test if a node is the final intent. More... | |
| Graph | next_hop (const Node &n) |
| Get the next "intent unit" in the DAG starting at the supplied node. More... | |
| Graph | next_hop (const std::string xid_string) |
| Get the next "intent unit" in the DAG starting at the supplied XID. More... | |
| Graph | first_hop () |
| Get the first "intent unit" in the DAG. More... | |
| uint8_t | num_nodes () const |
| Get the number of nodes in the DAG. More... | |
| Node | get_node (int i) const |
| Get a node from the DAG. More... | |
| size_t | fill_wire_buffer (node_t *buf) const |
| Fill a wire buffer with this DAG. More... | |
| void | fill_sockaddr (sockaddr_x *s) const |
| Fill a sockaddr_x with this DAG. More... | |
| void | from_wire_format (uint8_t num_nodes, const node_t *buf) |
| void | from_sockaddr (const sockaddr_x *s) |
| Fills an empty graph from a sockaddr_x. More... | |
| void | replace_final_intent (const Node &new_intent) |
| Replace the DAG's final intent with the supplied Node. More... | |
| Node | get_final_intent () const |
| Return the final intent of the DAG. More... | |
| bool | replace_intent_HID (std::string new_hid_str) |
| bool | replace_intent_AD (std::string new_ad_str) |
| size_t | unparse_node_size () const |
| Number of nodes in this graph. More... | |
| bool | flatten () |
| Flatten the direct edge from source to intent, if it exists. More... | |
| bool | first_hop_is_sid () const |
| Is the first hop from source node an SID? More... | |
| bool | remove_intent_sid_node () |
| bool | remove_intent_node () |
| std::vector< const Node * > | get_nodes_of_type (unsigned int type) const |
| Get a list of nodes of the specified type. More... | |
| std::string | xid_str_from_index (std::size_t node) const |
| Return XID as a string for node at specified index. More... | |
| std::size_t | final_intent_index () const |
| Get the index of the final intent node. More... | |
| int | compare_except_intent_AD (Graph other) const |
| Compare two graphs while ignoring intent AD. More... | |
Static Public Attributes | |
| static const std::size_t | MAX_XIDS_IN_ALL_PATHS = 30 |
| static const std::size_t | INVALID_GRAPH_INDEX = 255 |
This class provides the user a simple set of operators to build a DAG for use as address within XIA.
Create Node(s) first and then build Graph from them Node objects are compared by reference. So even if two Nodes have the same XID, they are considered separate. This allows us to build Graphs with the same XID appearing more than once.
| Graph::Graph | ( | ) |
Create an empty graph.
| Graph::Graph | ( | const Node & | n | ) |
Create a graph containing a single node.
| n | The node the new graph should contain. |
| Graph::Graph | ( | const Graph & | r | ) |
Create a new graph that is a copy of the supplied graph.
| r | The graph to be copied. |
| Graph::Graph | ( | std::string | dag_string | ) |
Create a new graph from a DAG string. It is generally recommended not to write DAG strings from scratch, but to obtain them by creating Graphs with other constructors and calling Graph::dag_string(). This constructor is also useful for creating a DAG from a DAG string obtained from the XSocket API (from the XrecvFrom() call, for example).
| dag_string | The DAG in the string format used by the XSocket API. Example 1: DAG 2 0 - AD:4349445f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f 2 1 - HID:4849445f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f 2 - SID:534944305f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f RE ( AD:1000000000000000000000000000000000000000 HID:0000000000000000000000000000000000000000 ) SID:1110000000000000000000000000000000001113 |
| Graph::Graph | ( | const sockaddr_x * | s | ) |
Create a new graph from a sockaddr_x. This constructor is useful for creating a DAG from from a sockaddr_x obtained from the XSocket API (from the XrecvFrom() call, for example).
| s | The sockaddr_x |
| void Graph::append_node_str | ( | std::string | node_str | ) |
| int Graph::compare_except_intent_AD | ( | Graph | other | ) | const |
| std::string Graph::dag_string | ( | ) | const |
Get the DAG string representation of the graph. This string is suitable for use with the XSocket API.
| void Graph::fill_sockaddr | ( | sockaddr_x * | s | ) | const |
Fill the provided sockaddr_x with this DAG
| s | The sockaddr_x struct to be filled in (allocated by caller) |
| size_t Graph::fill_wire_buffer | ( | node_t * | buf | ) | const |
Fill the provided buffer with this DAG
| s | The wire buffer struct to be filled in (allocated by caller) |
| std::size_t Graph::final_intent_index | ( | ) | const |
Get the index of the final intent node. This method returns the index of the first sink node it finds.
| Graph Graph::first_hop | ( | ) |
Get the first "intent unit" in the DAG. Calling this method is equivalent to calling g.next_hope(Node()).
| bool Graph::first_hop_is_sid | ( | ) | const |
| bool Graph::flatten | ( | ) |
Try to flatten a graph with a direct edge between the source and intent by removing that edge.
| void Graph::from_sockaddr | ( | const sockaddr_x * | s | ) |
Fills an empty graph from a sockaddr_x. Behavior is undefined if the graph contains nodes or edges prior to this call.
| s | The sockaddr_x. |
| void Graph::from_wire_format | ( | uint8_t | num_nodes, |
| const node_t * | buf | ||
| ) |
@ Fills an empty graph from our binary wire format
Fills an empty graph from a memory buffer containing the graph in serialized wire form.
| num_nodes | The number of nodes in the graph |
| buf | The memory buffer containing graph in serialized wire format |
| Node Graph::get_final_intent | ( | ) | const |
Returns the DAG's final intent (as a Node).
| Node Graph::get_node | ( | int | i | ) | const |
Get a Node from the graph at the specified index. The sink node will always be returned last (that is, it has index num_nodes()-1).
| i | The index of the node to return |
| std::vector< const Node * > Graph::get_nodes_of_type | ( | unsigned int | type | ) | const |
Return a list of the nodes in the DAG of the specified XID type. The vector returned contains pointers to the node objects in the DAG, not copies.
| xid_type | The XID type of interest. Must be one of: Node::XID_TYPE_AD (Administrative Domain) Node::XID_TYPE_HID (Host) Node::XID_TYPE_CID (Content) Node::XID_TYPE_SID (Service) Node::XID_TYPE_FID (Flood) Node::XID_TYPE_IP (IPv4 / 4ID) |
| std::string Graph::http_url_string | ( | ) | const |
| const Node & Graph::intent_AD | ( | ) | const |
| std::string Graph::intent_AD_str | ( | ) | const |
Get the AD string on first path to intent node Note: This function is essentially identical to intent_HID_str()
| const Node & Graph::intent_HID | ( | ) | const |
| std::string Graph::intent_HID_str | ( | ) | const |
| const Node & Graph::intent_SID | ( | ) | const |
| std::string Graph::intent_SID_str | ( | ) | const |
| bool Graph::is_final_intent | ( | const Node & | n | ) |
Check whether or not the supplied Node is the final intent of the DAG
| n | The node to check |
| bool Graph::is_final_intent | ( | const std::string | xid_string | ) |
Check whether or not the supplied XID is the final intent of the DAG
| xid_string | The XID to check |
| bool Graph::is_valid | ( | ) | const |
Make sure this Graph represents a valid XIA DAG. For now we just do a bunch of simple checks like making sure there's at least one node and that the intent node has a valid XID type.
Get the next "intent unit" in the DAG starting at the supplied node. An intent node is a node that can be reached by following the highest priority out edge of each node beginning with the source. An intent unit is an intent node along with its fallbacks. In the new DAG, the previous intent unit becomes the source node.
| n | The node from which to find the next intent unit. n must be an intent node. |
| Graph Graph::next_hop | ( | const std::string | xid_string | ) |
This method is the same as Graph::next_hop(const Node& n) except it takes an XID string instead of a Node object.
| xid_string | The XID of the intent node from which to find the next intent unit. |
| uint8_t Graph::num_nodes | ( | ) | const |
Get the number of nodes in the DAG.
Append the supplied graph to the end of this one and return the resulting graph.
| r | The graph to be appended |
Append a node to the end of this graph and return the result.
| r | The node to append |
Merge the supplied graph with this one and return the resulting graph. If both graphs share the same source and sink, one graph will become a fallback path.
| r | The graph to be merged with this one |
Merge the supplied node with this graph. If the node is already present in this graph, the resulting graph will be the same. If the node is different, the new node will be added to the graph but will not be connected by any edges.
| r | The node with which to merge |
| bool Graph::operator== | ( | const Graph & | g | ) | const |
Two graphs can be represented differently in memory or as a string We compare them logically by walking all possible paths from source to sink and comparing the order of nodes on each path with those in the other graph.
| g | The other graph to compare against |
| void Graph::print_graph | ( | ) | const |
Print the graph. Useful for debugging.
| bool Graph::remove_intent_node | ( | ) |
| bool Graph::remove_intent_sid_node | ( | ) |
| void Graph::replace_final_intent | ( | const Node & | new_intent | ) |
Replace the DAG's final intent with the supplied node.
| new_intent | The Node to become the DAG's new final intent. |
| bool Graph::replace_intent_AD | ( | std::string | new_ad_str | ) |
| bool Graph::replace_intent_HID | ( | std::string | new_hid_str | ) |
| size_t Graph::unparse_node_size | ( | ) | const |
Get the number of nodes in this graph or 0 if there are no nodes Note: we may return 0 on failure
| std::string Graph::xid_str_from_index | ( | std::size_t | node | ) | const |
Get the XID in string format from nodes_ at specified index.
|
static |
|
static |
1.8.11