blob: 44eedaba9dc9655031d52fa5ef9525c1135e9d4e [file] [log] [blame]
Rich Lanea06d0c32013-03-25 08:52:03 -07001Introduction
2============
3
4LOCI is the C language module of LOXI, the Logical OpenFlow Extensible
5Interface. It provides a framework for managing OpenFlow objects in
6an object oriented fashion.
7
8All files in LOCI, even this README, are generated by LOXI. Please make
9modifications to LOXI instead of to these files directly.
10
11Compilation
12===========
13
14It's expected that users of LOCI will want to integrate it into their own build
15system. As an example, here's a simple command line to create a shared library
16on Linux:
17
18 gcc -fPIC -shared -I inc src/*.c -o loci.so
19
20LOCI has no dependencies beyond the C standard library.
21
22Documentation
23=============
24
25A Doxygen configuration file is provided. Just run `doxygen` to generate HTML
26documentation pages. Each OpenFlow object is linked to under the "Modules"
27tab.
28
29Usage
30=====
31
32Currently the best example code for using LOCI is the switchlight-core
33repository.
34
35Here's example code that creates a flow mod:
36
37 /* Create the match */
38 of_match_t match;
39 memset(&match, 0, sizeof(match));
40 match.fields.in_port = 1;
41 OF_MATCH_MASK_IN_PORT_EXACT_SET(&match);
42 match.fields.eth_type = 0x8000;
43 OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
44
45 /* Create a flow mod */
46 of_flow_add_t *flow_add = of_flow_add_new(OF_VERSION_1_0);
47 of_flow_add_idle_timeout_set(flow_add, 5);
48 of_flow_add_cookie_set(flow_add, 42);
49 of_flow_add_priority_set(flow_add, 10000);
50 of_flow_add_buffer_id_set(flow_add, -1);
51 if (of_flow_add_match_set(flow_add, &match)) {
52 fprintf(stderr, "Failed to set the match field\n");
53 abort();
54 }
55
56 /* Populate the action list */
57 of_list_action_t actions;
58 of_flow_add_actions_bind(flow_add, &actions);
59 int i;
60 for (i = 1; i <= 4; i++) {
61 of_action_output_t action;
62 of_action_output_init(&action, flow_add->version, -1, 1);
Rich Lane7fdaa5c2014-10-27 18:14:59 -070063 of_list_action_append_bind(&actions, &action);
Rich Lanea06d0c32013-03-25 08:52:03 -070064 of_action_output_port_set(&action, i);
65 }
66
67 /* Use the underlying buffer */
68 void *buf = WBUF_BUF(OF_OBJECT_TO_WBUF(flow_add));
69 uint16_t len = flow_add->length;
70 /* ... */
71
72 /* Free the flow mod */
73 of_flow_add_delete(flow_add);