diff options
author | Sander Vrijders <[email protected]> | 2016-11-01 14:32:47 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-11-01 14:32:47 +0100 |
commit | c69f318e8cbdb8124e40e6a47b1bbffe35914a44 (patch) | |
tree | 10c4029e0778dd80d6f1ed822e9dcd2f450feb8a /include | |
parent | 0a9f1f2936381dfe350c1846b3bafc306590a88f (diff) | |
download | ouroboros-c69f318e8cbdb8124e40e6a47b1bbffe35914a44.tar.gz ouroboros-c69f318e8cbdb8124e40e6a47b1bbffe35914a44.zip |
lib: Simplify CDAP API
This will simplify the CDAP API. Now the opcode has to be given when
sending a CDAP request. Before a separate operation was provided since
some of the function parameters are unused for certain commands.
Diffstat (limited to 'include')
-rw-r--r-- | include/ouroboros/cdap.h | 72 |
1 files changed, 23 insertions, 49 deletions
diff --git a/include/ouroboros/cdap.h b/include/ouroboros/cdap.h index bd8aa551..7312fb6f 100644 --- a/include/ouroboros/cdap.h +++ b/include/ouroboros/cdap.h @@ -30,43 +30,32 @@ #define F_SYNC 0x0001 +enum cdap_opcode { + CDAP_READ = 0, + CDAP_WRITE, + CDAP_START, + CDAP_STOP, + CDAP_CREATE, + CDAP_DELETE +}; + struct cdap; /* Callback functions that work on the application's RIB */ struct cdap_ops { + int (* cdap_request)(struct cdap * instance, + int invoke_id, + enum cdap_opcode opcode, + char * name, + uint8_t * data, + size_t len, + uint32_t flags); + int (* cdap_reply)(struct cdap * instance, int invoke_id, int result, uint8_t * data, size_t len); - - int (* cdap_read)(struct cdap * instance, - int invoke_id, - char * name); - int (* cdap_write)(struct cdap * instance, - int invoke_id, - char * name, - uint8_t * data, - size_t len, - uint32_t flags); - - int (* cdap_create)(struct cdap * instance, - int invoke_id, - char * name, - uint8_t * data, - size_t len); - int (* cdap_delete)(struct cdap * instance, - int invoke_id, - char * name, - uint8_t * data, - size_t len); - - int (* cdap_start)(struct cdap * instance, - int invoke_id, - char * name); - int (* cdap_stop)(struct cdap * instance, - int invoke_id, - char * name); }; /* Assumes flow is blocking */ @@ -75,27 +64,12 @@ struct cdap * cdap_create(struct cdap_ops * ops, int cdap_destroy(struct cdap * instance); /* Returns a positive invoke-id on success to be used in the callback */ -int cdap_send_read(struct cdap * instance, - char * name); -int cdap_send_write(struct cdap * instance, - char * name, - uint8_t * data, - size_t len, - uint32_t flags); - -int cdap_send_create(struct cdap * instance, - char * name, - uint8_t * data, - size_t len); -int cdap_send_delete(struct cdap * instance, - char * name, - uint8_t * data, - size_t len); - -int cdap_send_start(struct cdap * instance, - char * name); -int cdap_send_stop(struct cdap * instance, - char * name); +int cdap_send_request(struct cdap * instance, + enum cdap_opcode code, + char * name, + uint8_t * data, + size_t len, + uint32_t flags); /* Can only be called following a callback function */ int cdap_send_reply(struct cdap * instance, |