2018-02-24 00:30:44 +01:00
|
|
|
#ifndef __MESSAGE_SET_H
|
|
|
|
#define __MESSAGE_SET_H
|
|
|
|
|
2018-03-03 17:42:28 +01:00
|
|
|
#include "mlist.h"
|
2018-03-06 03:08:14 +01:00
|
|
|
#include "sock.h"
|
|
|
|
#include "mavl.h"
|
|
|
|
#include "conn.h"
|
2018-02-24 00:30:44 +01:00
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
struct cw_MsgSet {
|
2018-03-11 00:56:41 +01:00
|
|
|
mavl_t msgdata;
|
2018-03-03 17:42:28 +01:00
|
|
|
mavl_t handlers_by_id;
|
|
|
|
mavl_t handlers_by_key;
|
2018-03-03 08:15:19 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cw_ElemDef{
|
2018-03-03 17:42:28 +01:00
|
|
|
int proto;
|
|
|
|
int vendor;
|
2018-03-03 08:15:19 +01:00
|
|
|
int id;
|
|
|
|
int mand;
|
|
|
|
int op;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cw_ElemData{
|
2018-03-03 17:42:28 +01:00
|
|
|
int proto;
|
|
|
|
int vendor;
|
|
|
|
int id;
|
2018-03-03 08:15:19 +01:00
|
|
|
int mand;
|
|
|
|
};
|
|
|
|
|
2018-03-09 07:44:17 +01:00
|
|
|
struct cw_ElemHandlerParams {
|
|
|
|
struct conn * conn;
|
|
|
|
struct cw_MsgData * msgdata;
|
|
|
|
struct sockaddr *from;
|
2018-03-11 10:34:20 +01:00
|
|
|
mavl_t mand_found;
|
2018-03-09 07:44:17 +01:00
|
|
|
};
|
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
struct cw_ElemHandler {
|
|
|
|
const char * name;
|
|
|
|
int id;
|
|
|
|
int vendor;
|
|
|
|
int proto;
|
|
|
|
int min_len;
|
|
|
|
int max_len;
|
2018-03-05 21:42:11 +01:00
|
|
|
const struct cw_Type * type;
|
2018-03-03 08:15:19 +01:00
|
|
|
const char * key;
|
2018-03-09 07:44:17 +01:00
|
|
|
int (*get)(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
|
|
|
uint8_t*data, int len);
|
2018-03-06 03:08:14 +01:00
|
|
|
/*
|
|
|
|
int (*end_in)(struct conn *conn,struct cw_action_in *a,uint8_t*elem,int len,struct sockaddr *from);
|
2018-03-03 08:15:19 +01:00
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cw_MsgDef{
|
|
|
|
const char * name;
|
|
|
|
int type; /**< Message type */
|
|
|
|
int receiver; /**< Who can receive this message */
|
|
|
|
int * states; /**< states in wich the message is allowed */
|
|
|
|
|
|
|
|
|
|
|
|
struct cw_ElemDef * elements;
|
|
|
|
|
|
|
|
};
|
2018-02-26 20:18:53 +01:00
|
|
|
|
|
|
|
|
2018-03-02 08:49:37 +01:00
|
|
|
struct cw_MsgData{
|
2018-02-26 20:18:53 +01:00
|
|
|
int type;
|
|
|
|
const char * name;
|
|
|
|
int * states;
|
2018-02-28 07:38:02 +01:00
|
|
|
int receiver;
|
2018-02-26 20:18:53 +01:00
|
|
|
mavl_t elements_tree;
|
|
|
|
mlist_t elements_list;
|
|
|
|
};
|
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
|
2018-03-09 07:44:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
extern struct cw_MsgSet * cw_msgset_create();
|
|
|
|
|
|
|
|
extern void cw_msgset_destroy(struct cw_MsgSet * set);
|
|
|
|
extern int cw_msgset_add(struct cw_MsgSet * set,
|
2018-03-03 17:42:28 +01:00
|
|
|
struct cw_MsgDef messages[], struct cw_ElemHandler handlers[]);
|
2018-03-03 08:15:19 +01:00
|
|
|
mlist_t cw_msgset_get_msg(struct cw_MsgSet * set, int type);
|
2018-03-04 16:59:20 +01:00
|
|
|
struct cw_MsgData * cw_msgset_get_msgdata(struct cw_MsgSet *set,int type);
|
2018-03-05 20:39:15 +01:00
|
|
|
struct cw_ElemHandler * cw_msgset_get_elemhandler(struct cw_MsgSet * set,
|
|
|
|
int proto, int vendor, int id);
|
2018-02-26 20:18:53 +01:00
|
|
|
|
|
|
|
|
2018-03-03 08:15:19 +01:00
|
|
|
#endif
|