Tools for dealing with the Synergy protocol.
More...
#include "minput.h"
Go to the source code of this file.
|
|
#define | SYNPROTO_TIMEOUT_MS 5000 |
| | Timeout to wait between keepalives before disconnecting.
|
| |
|
#define | swap_32(num) ((((num)>>24)&0xff) | (((num)<<8)&0xff0000) | (((num)>>8)&0xff00) | (((num)<<24)&0xff000000)) |
| | Swap byte order in a 32-bit integer from network to native.
|
| |
|
#define | swap_16(num) (((num)>>8) | ((num)<<8)) |
| | Swap byte order in a 16-bit integer from network to native.
|
| |
| #define | synproto_exval_32(buffer, offset) (swap_32( *((uint32_t*)&(buffer[offset])) )) |
| | Perform endianness swap on a 32-bit integer from a buffer if needed.
|
| |
| #define | synproto_exval_16(buffer, offset) (swap_16( *((uint16_t*)&(buffer[offset])) )) |
| | Perform endianness swap on a 16-bit integer from a buffer if needed.
|
| |
|
#define | synproto_exval_8(buffer, offset) (buffer[offset]) |
| |
|
|
void | synproto_dump (const char *buf, size_t buf_sz) |
| | Given a buffer with a string from the Synergy server, dump it into a more human-readable form.
|
| |
| size_t | synproto_vprintf (char *buf, size_t buf_sz, const char *fmt, va_list vargs) |
| | Given a format string and tokens, write those tokens into a buffer using specific tokens listed here.
|
| |
| uint32_t | synproto_send (int sockfd, uint8_t force_sz, const char *fmt,...) |
| | Send a formatted string to the Synergy server with tokens as specified for synproto_vprintf().
|
| |
| int | synproto_parse_and_reply (struct NETIO_CFG *config, const char *pkt_buf, uint32_t pkt_buf_sz) |
| | Given a buffer with a string from the Synergy server, parse it and respond or simulate OS activity as directed.
|
| |
|
void | synproto_reset_calv_deadline (struct NETIO_CFG *config) |
| |
Tools for dealing with the Synergy protocol.
◆ synproto_exval_16
| #define synproto_exval_16 |
( |
| buffer, |
|
|
| offset ) (swap_16( *((uint16_t*)&(buffer[offset])) )) |
Perform endianness swap on a 16-bit integer from a buffer if needed.
- Parameters
-
| buffer | Buffer to pull integer out of. |
| offset | Offset of the buffer (in bytes) of the integer to pull. |
◆ synproto_exval_32
| #define synproto_exval_32 |
( |
| buffer, |
|
|
| offset ) (swap_32( *((uint32_t*)&(buffer[offset])) )) |
Perform endianness swap on a 32-bit integer from a buffer if needed.
- Parameters
-
| buffer | Buffer to pull integer out of. |
| offset | Offset of the buffer (in bytes) of the integer to pull. |
◆ synproto_parse_and_reply()
| int synproto_parse_and_reply |
( |
struct NETIO_CFG * | config, |
|
|
const char * | pkt_buf, |
|
|
uint32_t | pkt_buf_sz ) |
Given a buffer with a string from the Synergy server, parse it and respond or simulate OS activity as directed.
- Parameters
-
| pkt_buf | The buffer in which the server transmission is stored. |
| pkt_buf_sz | The size of pkt_buf. |
◆ synproto_send()
| uint32_t synproto_send |
( |
int | sockfd, |
|
|
uint8_t | force_sz, |
|
|
const char * | fmt, |
|
|
| ... ) |
Send a formatted string to the Synergy server with tokens as specified for synproto_vprintf().
- Parameters
-
| sockfd | The socket identifier/handle on which the Synergy server is connected. |
| force_sz | Force the preliminary size of the response packet to this number. If 0, the number is calculated automatically. |
| fmt | Format string using the tokens from synproto_vprintf(). |
◆ synproto_vprintf()
| size_t synproto_vprintf |
( |
char * | buf, |
|
|
size_t | buf_sz, |
|
|
const char * | fmt, |
|
|
va_list | vargs ) |
Given a format string and tokens, write those tokens into a buffer using specific tokens listed here.
- Parameters
-
| buf | Buffer to write the formatted response to. |
| buf_sz | Size of buf in bytes. |
| fmt | Format string using the tokens below. |
| vargs | A va_list of tokens already initialized with va_start(). |
- Returns
- The size of the string written to buf in bytes.
| Token | Specifies |
| %ni | Where n is a single-digit number, an integer n-bytes wide. |
| %s | A null-terminated string. |