4 * general serializing and deserializing should be in separate library
8 void fwp_msg_header_deflate(unsigned char *data, unsigned int type,
9 fwp_participant_id_t participant_id)
11 struct fwp_msg_header* msg_header;
13 msg_header = (struct fwp_msg_header*) data;
14 /*header = (struct fwp_msg_header*)
15 fwp_msgb_put(msgb, sizeof(struct fwp_msg_header));*/
17 msg_header->type = htons(type);
18 msg_header->node_id = htonl(participant_id.node_id);
19 msg_header->app_id = htonl(participant_id.app_id);
22 void fwp_msg_header_inflate(unsigned char *data, unsigned int *type,
23 fwp_participant_id_t *participant_id)
25 struct fwp_msg_header *msg_header;
27 msg_header = (struct fwp_msg_header*) data;
28 /*fwp_msgb_pull(msgb,sizeof(struct fwp_msg_header));*/
29 *type = ntohs(msg_header->type);
30 participant_id->node_id = ntohl(msg_header->node_id);
31 participant_id->app_id = ntohl(msg_header->app_id);
34 void fwp_msg_contract_deflate(unsigned char *data, struct fwp_contract *cont)
36 struct fwp_msg_contract* msg_contract;
38 msg_contract = (struct fwp_msg_contract*) data;
39 /*msgcnt = (struct fwp_msg_contract*)
40 fwp_msgb_put(msgb,sizeof(struct fwp_msg_contract));*/
41 msg_contract->budget = htons(cont->budget);
42 msg_contract->period_usec = htonl(cont->period_usec);
45 void fwp_msg_contract_inflate(unsigned char *data, struct fwp_contract *cont)
47 struct fwp_msg_contract* msg_contract;
49 msg_contract = (struct fwp_msg_contract*) data;
50 /*fwp_msgb_pull(msgb,sizeof(struct fwp_msg_contract));*/
51 cont->budget = ntohs(msg_contract->budget);
52 cont->period_usec = ntohl(msg_contract->period_usec);
55 void fwp_msg_vres_params_deflate(unsigned char *data, unsigned int status,
56 fwp_vres_params_t *vparams)
58 struct fwp_msg_vres_params* msg_vparams;
60 msg_vparams = (struct fwp_msg_vres_params*) data;
61 /*msgcnt = (struct fwp_msg_contract*)
62 fwp_msgb_put(msgb,sizeof(struct fwp_msg_contract));*/
64 msg_vparams->id = htons(vparams->id);
65 msg_vparams->ac_id = vparams->ac_id;
66 msg_vparams->status = status;
68 msg_vparams->budget = htons(vparams->budget);
69 msg_vparams->period_usec = htonl(vparams->period_usec);
72 void fwp_msg_vres_params_inflate(unsigned char *data, unsigned int *status,
73 fwp_vres_params_t *vparams)
75 struct fwp_msg_vres_params* msg_vparams;
77 msg_vparams = (struct fwp_msg_vres_params*) data;
78 /*fwp_msgb_pull(msgb,sizeof(struct fwp_msg_contract));*/
80 vparams->id = ntohs(msg_vparams->id);
81 vparams->ac_id = msg_vparams->ac_id;
82 *status = msg_vparams->status;
84 vparams->budget = ntohs(msg_vparams->budget);
85 vparams->period_usec = ntohl(msg_vparams->period_usec);
88 void fwp_msg_hello_deflate(unsigned char *data,
89 fwp_participant_info_t *participant_info)
91 struct fwp_msg_hello* msg_hello;
93 msg_hello = (struct fwp_msg_hello*) data;
94 /*header = (struct fwp_msg_header*)
95 fwp_msgb_put(msgb, sizeof(struct fwp_msg_header));*/
97 msg_hello->node_id = htonl(participant_info->id.node_id);
98 msg_hello->app_id = htonl(participant_info->id.app_id);
99 msg_hello->stream_id= htons(participant_info->stream_id);
102 void fwp_msg_hello_inflate(unsigned char *data,
103 fwp_participant_info_t *participant_info)
105 struct fwp_msg_hello *msg_hello;
107 msg_hello = (struct fwp_msg_hello*) data;
108 /*fwp_msgb_pull(msgb,sizeof(struct fwp_msg_header));*/
109 participant_info->id.node_id = ntohl(msg_hello->node_id);
110 participant_info->id.app_id = ntohl(msg_hello->app_id);
111 participant_info->stream_id = ntohs(msg_hello->stream_id);