infra: allow mixed network protocol levels

This commit is contained in:
Thomas Schoebel-Theuer 2019-07-11 09:52:04 +02:00 committed by Thomas Schoebel-Theuer
parent 0c5b5daa38
commit 593ca2bb8f
3 changed files with 10 additions and 0 deletions

View File

@ -566,6 +566,8 @@ int receiver_thread(void *data)
}
switch (cmd.cmd_code & CMD_FLAG_MASK) {
case CMD_NOP:
break;
case CMD_NOTIFY:
mars_trigger();
break;

View File

@ -1181,6 +1181,7 @@ EXPORT_SYMBOL_GPL(_mars_recv_struct);
const struct meta mars_cmd_meta[] = {
META_INI_SUB(cmd_stamp, struct mars_cmd, mars_lamport_time_meta),
META_INI(cmd_proto, struct mars_cmd, FIELD_INT),
META_INI(cmd_code, struct mars_cmd, FIELD_INT),
META_INI(cmd_int1, struct mars_cmd, FIELD_INT),
META_INI(cmd_str1, struct mars_cmd, FIELD_STRING),
@ -1191,6 +1192,7 @@ int mars_send_cmd(struct mars_socket *msock, struct mars_cmd *cmd, bool cork)
{
int status;
cmd->cmd_proto = MARS_PROTO_LEVEL;
status = desc_send_struct(msock, cmd, mars_cmd_meta, cork);
return status;
}
@ -1200,6 +1202,8 @@ int _mars_recv_cmd(struct mars_socket *msock, struct mars_cmd *cmd, int line)
int status;
status = desc_recv_struct(msock, cmd, mars_cmd_meta, line);
if (status >= 0)
msock->s_remote_proto_level = cmd->cmd_proto;
return status;
}

View File

@ -33,6 +33,8 @@
extern int mars_net_default_port;
extern bool mars_net_is_alive;
#define MARS_PROTO_LEVEL 1
#define MAX_FIELD_LEN 32
#define MAX_DESC_CACHE 16
@ -63,6 +65,7 @@ struct mars_socket {
struct socket *s_socket;
void *s_buffer;
atomic_t s_count;
int s_remote_proto_level; /* corresponds to MARS_PROTO_LEVEL of remote site */
int s_pos;
int s_debug_nr;
int s_send_abort;
@ -110,6 +113,7 @@ enum {
struct mars_cmd {
struct lamport_time cmd_stamp; // for automatic lamport clock
int cmd_proto;
int cmd_code;
int cmd_int1;
//int cmd_int2;