mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-09 23:53:28 -04:00
hwstub: allow minor version mismatch in net layer
Change-Id: I81a75bd7b9f3fd1a56e5bea521966c1847adfec7
This commit is contained in:
parent
966c1d7650
commit
eb39277d4a
2 changed files with 27 additions and 8 deletions
|
|
@ -112,6 +112,7 @@ protected:
|
|||
virtual void destroy_device_list(void *ptr);
|
||||
virtual error create_device(ctx_dev_t dev, std::shared_ptr<hwstub::device>& hwdev);
|
||||
virtual bool match_device(ctx_dev_t dev, std::shared_ptr<hwstub::device> hwdev);
|
||||
static inline int hwstub_ver(int major, int minor) { return major * 100 + minor; }
|
||||
|
||||
enum class state
|
||||
{
|
||||
|
|
@ -122,6 +123,7 @@ protected:
|
|||
|
||||
state m_state; /* client state */
|
||||
error m_error; /* error state for DEAD */
|
||||
int m_ver; /* Server revision (uses hwstub_ver()) */
|
||||
};
|
||||
|
||||
/** Socket based net context
|
||||
|
|
|
|||
|
|
@ -437,14 +437,25 @@ void context::delayed_init()
|
|||
return;
|
||||
}
|
||||
/* check the server is running the same version */
|
||||
debug() << "[net::ctx] <-- HELLO " << ((args[0] & 0xff00) >> 8) << "." << (args[0] & 0xff) << "";
|
||||
if(args[0] != (HWSTUB_VERSION_MAJOR << 8 | HWSTUB_VERSION_MINOR))
|
||||
int serv_maj = (args[0] >> 8) & 0xff;
|
||||
int serv_min = args[0] & 0xff;
|
||||
debug() << "[net::ctx] <-- HELLO " << serv_maj << "." << serv_min << "";
|
||||
|
||||
m_ver = hwstub_ver(serv_maj, serv_min);
|
||||
/* Major mismatch -> error */
|
||||
if(serv_maj != HWSTUB_VERSION_MAJOR)
|
||||
{
|
||||
debug() << " (mismatch)\n";
|
||||
debug() << " (major version mismatch)\n";
|
||||
m_state = state::DEAD;
|
||||
m_error = error::SERVER_MISMATCH;
|
||||
}
|
||||
debug() << " (good)\n";
|
||||
else
|
||||
debug() << " (good)\n";
|
||||
/* Minor mismatch -> warning */
|
||||
if(serv_min < HWSTUB_VERSION_MINOR)
|
||||
debug() << "[net::ctx] Some operations might not be supported by the server.\n";
|
||||
else if(serv_min > HWSTUB_VERSION_MINOR)
|
||||
debug() << "[net::ctx] Some operations might not be supported by this client.\n";
|
||||
/* good, we can now send commands */
|
||||
m_state = state::IDLE;
|
||||
}
|
||||
|
|
@ -994,16 +1005,22 @@ error server::handle_cmd(client_state *state, uint32_t cmd, uint32_t args[HWSTUB
|
|||
/* HELLO */
|
||||
if(cmd == HWSERVER_HELLO)
|
||||
{
|
||||
debug() << "[net::srv::cmd] --> HELLO " << ((args[0] & 0xff00) >> 8)
|
||||
<< "." << (args[0] & 0xff);
|
||||
if(args[0] != (HWSTUB_VERSION_MAJOR << 8 | HWSTUB_VERSION_MINOR))
|
||||
int cli_maj = (args[0] >> 8) & 0xff;
|
||||
int cli_min = args[0] & 0xff;
|
||||
debug() << "[net::srv::cmd] --> HELLO " << cli_maj << "." << cli_min;
|
||||
if(cli_maj != HWSTUB_VERSION_MAJOR)
|
||||
{
|
||||
debug() << " (mismatch)\n";
|
||||
debug() << " (major version mismatch)\n";
|
||||
return error::ERROR;
|
||||
}
|
||||
debug() << " (good)\n";
|
||||
debug() << "[net::srv::cmd] <-- HELLO " << HWSTUB_VERSION_MAJOR << "."
|
||||
<< HWSTUB_VERSION_MINOR << "\n";
|
||||
/* Minor mismatch -> warning */
|
||||
if(cli_min < HWSTUB_VERSION_MINOR)
|
||||
debug() << "[net::ctx] Some operations might not be supported by the client.\n";
|
||||
else if(cli_min > HWSTUB_VERSION_MINOR)
|
||||
debug() << "[net::ctx] Some operations might not be supported by this server.\n";
|
||||
/* send HELLO with our version */
|
||||
args[0] = HWSTUB_VERSION_MAJOR << 8 | HWSTUB_VERSION_MINOR;
|
||||
return error::SUCCESS;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue