* Internal backend socket protocol changed: uint32_t session-id added, see clixon_proto.h

* * Changed session-id handing. Instead of using pid of peer process, a proper session id generated by the server is used, following RFC6241.
This commit is contained in:
Olof hagsand 2019-10-19 19:52:09 +02:00
parent a387c599e2
commit b624e911b8
23 changed files with 230 additions and 155 deletions

View file

@ -51,8 +51,8 @@
*/
/* Struct per database in hash */
typedef struct {
int de_pid;
cxobj *de_xml; /* cache */
uint32_t de_id; /* session id */
cxobj *de_xml; /* cache */
} db_elmnt;
/*
@ -98,4 +98,7 @@ int clicon_xml_changelog_set(clicon_handle h, cxobj *xchlog);
int clicon_argv_get(clicon_handle h, int *argc, char ***argv);
int clicon_argv_set(clicon_handle h, char *argv0, int argc, char **argv);
int clicon_session_id_set(clicon_handle h, uint32_t id);
uint32_t clicon_session_id_get(clicon_handle h);
#endif /* _CLIXON_DATA_H_ */

View file

@ -57,10 +57,10 @@ int xmldb_get0_clear(clicon_handle h, cxobj *x);
int xmldb_get0_free(clicon_handle h, cxobj **xp);
int xmldb_put(clicon_handle h, const char *db, enum operation_type op, cxobj *xt, char *username, cbuf *cbret); /* in clixon_datastore_write.[ch] */
int xmldb_copy(clicon_handle h, const char *from, const char *to);
int xmldb_lock(clicon_handle h, const char *db, int pid);
int xmldb_lock(clicon_handle h, const char *db, uint32_t id);
int xmldb_unlock(clicon_handle h, const char *db);
int xmldb_unlock_all(clicon_handle h, int pid);
int xmldb_islocked(clicon_handle h, const char *db);
int xmldb_unlock_all(clicon_handle h, uint32_t id);
uint32_t xmldb_islocked(clicon_handle h, const char *db);
int xmldb_exists(clicon_handle h, const char *db);
int xmldb_delete(clicon_handle h, const char *db);
int xmldb_create(clicon_handle h, const char *db);

View file

@ -51,8 +51,9 @@ enum format_enum{
/* Protocol message header */
struct clicon_msg {
uint32_t op_len; /* length of message. network byte order. */
char op_body[0]; /* rest of message, actual data */
uint32_t op_len; /* length of message. network byte order. */
uint32_t op_id; /* session-id. network byte order. */
char op_body[0]; /* rest of message, actual data */
};
/*
@ -62,11 +63,11 @@ char *format_int2str(enum format_enum showas);
enum format_enum format_str2int(char *str);
#if defined(__GNUC__) && __GNUC__ >= 3
struct clicon_msg *clicon_msg_encode(char *format, ...) __attribute__ ((format (printf, 1, 2)));
struct clicon_msg *clicon_msg_encode(uint32_t id, char *format, ...) __attribute__ ((format (printf, 2, 3)));
#else
struct clicon_msg *clicon_msg_encode(char *format, ...);
struct clicon_msg *clicon_msg_encode(uint32_t id, char *format, ...);
#endif
int clicon_msg_decode(struct clicon_msg *msg, yang_stmt *yspec, cxobj **xml);
int clicon_msg_decode(struct clicon_msg *msg, yang_stmt *yspec, uint32_t *id, cxobj **xml);
int clicon_connect_unix(char *sockpath);
@ -87,7 +88,7 @@ int clicon_msg_send(int s, struct clicon_msg *msg);
int clicon_msg_rcv(int s, struct clicon_msg **msg, int *eof);
int send_msg_notify_xml(int s, cxobj *xev);
int send_msg_notify_xml(clicon_handle h, int s, cxobj *xev);
int send_msg_reply(int s, char *data, uint32_t datalen);

View file

@ -54,7 +54,7 @@ int clicon_rpc_lock(clicon_handle h, char *db);
int clicon_rpc_unlock(clicon_handle h, char *db);
int clicon_rpc_get(clicon_handle h, char *xpath, cvec *nsc, netconf_content content, int32_t depth, cxobj **xret);
int clicon_rpc_close_session(clicon_handle h);
int clicon_rpc_kill_session(clicon_handle h, int session_id);
int clicon_rpc_kill_session(clicon_handle h, uint32_t session_id);
int clicon_rpc_validate(clicon_handle h, char *db);
int clicon_rpc_commit(clicon_handle h);
int clicon_rpc_discard_changes(clicon_handle h);