minput-hop
Tiny client library for Synergy KVM and derivatives.
Loading...
Searching...
No Matches
Macros | Functions
synproto.h File Reference

Tools for dealing with the Synergy protocol. More...

#include "minput.h"
Include dependency graph for synproto.h:

Go to the source code of this file.

Macros

#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])
 

Functions

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)
 

Detailed Description

Tools for dealing with the Synergy protocol.

Macro Definition Documentation

◆ 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
bufferBuffer to pull integer out of.
offsetOffset 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
bufferBuffer to pull integer out of.
offsetOffset of the buffer (in bytes) of the integer to pull.

Function Documentation

◆ 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_bufThe buffer in which the server transmission is stored.
pkt_buf_szThe 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
sockfdThe socket identifier/handle on which the Synergy server is connected.
force_szForce the preliminary size of the response packet to this number. If 0, the number is calculated automatically.
fmtFormat 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
bufBuffer to write the formatted response to.
buf_szSize of buf in bytes.
fmtFormat string using the tokens below.
vargsA 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.