20 #ifndef LIBJAYLINK_LIBJAYLINK_INTERNAL_H    21 #define LIBJAYLINK_LIBJAYLINK_INTERNAL_H    27 #include <sys/types.h>    31 #include <sys/socket.h>    32 #include <arpa/inet.h>    52 #if defined(_WIN32) || defined(__MSYS__) || defined(__CYGWIN__)    55 #define JAYLINK_PRIV __attribute__ ((visibility ("hidden")))    59 #define MIN(a, b) (((a) < (b)) ? (a) : (b))    64     struct libusb_context *usb_ctx;
   102     struct libusb_device *usb_dev;
   114     char ipv4_address[INET_ADDRSTRLEN];
   185     struct libusb_device_handle *usb_devh;
   187     uint8_t interface_number;
   191     uint8_t endpoint_out;
   246         const char *format, ...);
   248         const char *format, ...);
   250         const char *format, ...);
   252         const char *format, ...);
   254         const char *format, ...);
   266         int flags, 
const struct sockaddr *address,
   267         size_t address_length);
   269         int flags, 
struct sockaddr *address, 
size_t *address_length);
   271         const void *value, 
size_t length);
   278         size_t write_length, 
size_t read_length, 
bool has_command);
   280         size_t length, 
bool has_command);
   294         size_t read_length, 
bool has_command);
   296         size_t length, 
bool has_command);
   310         size_t read_length, 
bool has_command);
   312         size_t length, 
bool has_command);
 jaylink_host_interface
Host interfaces. 
 
uint8_t * buffer
Buffer for write and read operations. 
 
JAYLINK_PRIV int transport_usb_open(struct jaylink_device_handle *devh)
 
jaylink_usb_address
USB addresses. 
 
JAYLINK_PRIV int transport_tcp_start_write(struct jaylink_device_handle *devh, size_t length, bool has_command)
 
JAYLINK_PRIV int log_vprintf(const struct jaylink_context *ctx, enum jaylink_log_level level, const char *format, va_list args, void *user_data)
 
JAYLINK_PRIV int transport_read(struct jaylink_device_handle *devh, uint8_t *buffer, size_t length)
Read data from a device. 
 
bool has_mac_address
Indicates whether the MAC address is available. 
 
JAYLINK_PRIV struct jaylink_device * device_allocate(struct jaylink_context *ctx)
 
JAYLINK_PRIV size_t list_length(struct list *list)
 
jaylink_log_level
libjaylink log levels. 
 
JAYLINK_PRIV uint32_t buffer_get_u32(const uint8_t *buffer, size_t offset)
Read a 32-bit unsigned integer value from a buffer. 
 
size_t buffer_size
Buffer size. 
 
struct list * discovered_devs
List of recently discovered devices. 
 
JAYLINK_PRIV void log_err(const struct jaylink_context *ctx, const char *format,...)
 
JAYLINK_PRIV int discovery_usb_scan(struct jaylink_context *ctx)
 
JAYLINK_PRIV int transport_tcp_open(struct jaylink_device_handle *devh)
 
size_t bytes_available
Number of bytes available in the buffer to be read. 
 
bool has_serial_number
Indicates whether the serial number is available. 
 
JAYLINK_PRIV int transport_usb_start_write_read(struct jaylink_device_handle *devh, size_t write_length, size_t read_length, bool has_command)
 
void * log_callback_data
User data to be passed to the log callback function. 
 
#define JAYLINK_NICKNAME_MAX_LENGTH
Maximum length of a device's nickname including trailing null-terminator in bytes. 
 
JAYLINK_PRIV int transport_usb_read(struct jaylink_device_handle *devh, uint8_t *buffer, size_t length)
 
bool(* list_compare_callback)(const void *data, const void *user_data)
 
Opaque structure representing a device. 
 
struct list * devs
List of allocated device instances. 
 
JAYLINK_PRIV void log_dbgio(const struct jaylink_context *ctx, const char *format,...)
 
JAYLINK_PRIV struct list * list_find_custom(struct list *list, list_compare_callback callback, const void *user_data)
 
JAYLINK_PRIV int transport_open(struct jaylink_device_handle *devh)
Open a device. 
 
JAYLINK_PRIV uint16_t buffer_get_u16(const uint8_t *buffer, size_t offset)
Read a 16-bit unsigned integer value from a buffer. 
 
Opaque structure representing a libjaylink context. 
 
#define JAYLINK_PRIV
Macro to mark private libjaylink symbol. 
 
#define JAYLINK_MAC_ADDRESS_LENGTH
Media Access Control (MAC) address length in bytes. 
 
JAYLINK_PRIV int transport_tcp_read(struct jaylink_device_handle *devh, uint8_t *buffer, size_t length)
 
JAYLINK_PRIV int transport_tcp_start_read(struct jaylink_device_handle *devh, size_t length)
 
JAYLINK_PRIV int transport_tcp_start_write_read(struct jaylink_device_handle *devh, size_t write_length, size_t read_length, bool has_command)
 
size_t ref_count
Number of references held on this device instance. 
 
size_t read_length
Number of bytes left for the read operation. 
 
JAYLINK_PRIV void log_dbg(const struct jaylink_context *ctx, const char *format,...)
 
bool has_nickname
Indicates whether the nickname is available. 
 
struct jaylink_context * ctx
libjaylink context. 
 
size_t write_pos
Current write position in the buffer. 
 
jaylink_log_callback log_callback
Log callback function. 
 
enum jaylink_log_level log_level
Current log level. 
 
static const char * product_name(const struct flash_bank *bank)
 
JAYLINK_PRIV int transport_usb_start_read(struct jaylink_device_handle *devh, size_t length)
 
static enum jaylink_target_interface iface
 
static enum jaylink_usb_address usb_address
 
JAYLINK_PRIV int transport_tcp_write(struct jaylink_device_handle *devh, const uint8_t *buffer, size_t length)
 
JAYLINK_PRIV bool socket_recv(int sock, void *buffer, size_t *length, int flags)
Receive a message from a socket. 
 
JAYLINK_PRIV bool socket_sendto(int sock, const void *buffer, size_t *length, int flags, const struct sockaddr *address, size_t address_length)
Send a message on a socket. 
 
JAYLINK_PRIV int transport_usb_start_write(struct jaylink_device_handle *devh, size_t length, bool has_command)
 
JAYLINK_PRIV void buffer_set_u16(uint8_t *buffer, uint16_t value, size_t offset)
Write a 16-bit unsigned integer value to a buffer. 
 
JAYLINK_PRIV int transport_start_read(struct jaylink_device_handle *devh, size_t length)
Start a read operation for a device. 
 
JAYLINK_PRIV bool socket_send(int sock, const void *buffer, size_t *length, int flags)
Send a message on a socket. 
 
int(* jaylink_log_callback)(const struct jaylink_context *ctx, enum jaylink_log_level level, const char *format, va_list args, void *user_data)
Log callback function type. 
 
JAYLINK_PRIV void list_free(struct list *list)
 
Opaque structure representing a handle of a device. 
 
JAYLINK_PRIV int transport_close(struct jaylink_device_handle *devh)
Close a device. 
 
int sock
Socket descriptor. 
 
JAYLINK_PRIV int transport_start_write(struct jaylink_device_handle *devh, size_t length, bool has_command)
Start a write operation for a device. 
 
#define JAYLINK_PRODUCT_NAME_MAX_LENGTH
Maximum length of a device's product name including trailing null-terminator in bytes. 
 
JAYLINK_PRIV int discovery_tcp_scan(struct jaylink_context *ctx)
 
char log_domain[JAYLINK_LOG_DOMAIN_MAX_LENGTH+1]
Log domain. 
 
JAYLINK_PRIV void log_warn(const struct jaylink_context *ctx, const char *format,...)
 
Public libjaylink header file to be used by applications. 
 
JAYLINK_PRIV int transport_tcp_close(struct jaylink_device_handle *devh)
 
JAYLINK_PRIV int transport_usb_write(struct jaylink_device_handle *devh, const uint8_t *buffer, size_t length)
 
static struct jaylink_device_handle * devh
 
JAYLINK_PRIV int transport_usb_close(struct jaylink_device_handle *devh)
 
#define JAYLINK_LOG_DOMAIN_MAX_LENGTH
Maximum length of a libjaylink log domain in bytes. 
 
JAYLINK_PRIV bool socket_recvfrom(int sock, void *buffer, size_t *length, int flags, struct sockaddr *address, size_t *address_length)
Receive a message from a socket. 
 
JAYLINK_PRIV struct list * list_remove(struct list *list, const void *data)
 
JAYLINK_PRIV bool socket_bind(int sock, const struct sockaddr *address, size_t length)
Bind an address to a socket. 
 
size_t read_pos
Current read position in the buffer. 
 
struct jaylink_device * dev
Device instance. 
 
JAYLINK_PRIV int transport_start_write_read(struct jaylink_device_handle *devh, size_t write_length, size_t read_length, bool has_command)
Start a write and read operation for a device. 
 
JAYLINK_PRIV void log_info(const struct jaylink_context *ctx, const char *format,...)
 
size_t write_length
Number of bytes left to be written before the write operation will be performed. 
 
uint32_t serial_number
Serial number of the device. 
 
JAYLINK_PRIV int transport_write(struct jaylink_device_handle *devh, const uint8_t *buffer, size_t length)
Write data to a device. 
 
bool has_hw_version
Indicates whether the hardware version is available. 
 
JAYLINK_PRIV struct list * list_prepend(struct list *list, void *data)
 
bool has_product_name
Indicates whether the product name is available. 
 
JAYLINK_PRIV bool socket_close(int sock)
Close a socket. 
 
JAYLINK_PRIV void buffer_set_u32(uint8_t *buffer, uint32_t value, size_t offset)
Write a 32-bit unsigned integer value to a buffer. 
 
JAYLINK_PRIV bool socket_set_option(int sock, int level, int option, const void *value, size_t length)
Set an option on a socket.