Add update_table API: accepts sscanf style strings and populates a map
authorBrenden Blanco <bblanco@plumgrid.com>
Sun, 9 Aug 2015 04:00:59 +0000 (21:00 -0700)
committerBrenden Blanco <bblanco@plumgrid.com>
Sun, 9 Aug 2015 04:00:59 +0000 (21:00 -0700)
commit985adf61590397f35e318c8e9944b9e9c69e6a34
treedc9ff007c82b6e9256b5131afe179f2e51264a47
parent8ac3ea7ea29a180de05d4d20f4275e451f379d97
Add update_table API: accepts sscanf style strings and populates a map

This is the culmination of the previous patches. It adds an api that can
input map data in a string format, but validating the numbers and
locations of data fields. The use case is for fuse file input/output. A
printf api may follow.

Take the table with key/leaf of:
  struct Key { int a; int b; };
  struct Leaf { int a; int b; int c; struct SubLeaf { int x; int y; } s; };

One would input to this table using:
  update_table(table_name, "{1 2}", "{1 2 -3 {9 0xa}}");

The implementation uses a JITed function for each unique type, that is
invoked to run sscanf on behalf of the caller. The input must have the
exact right number of arguments. Bit fields are supported, but the
caller must be aware of the collapse of those bitfields into an aligned
field, as well as endianness.

Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
src/cc/bpf_common.cc
src/cc/bpf_common.h
src/cc/bpf_module.cc
src/cc/bpf_module.h
src/cc/table_desc.h
src/python/bpf/__init__.py
tests/cc/test_clang.py