#include "ydef.h"
#include "yapi.h"
#include "ytcp.h"
#include "yfifo.h"
#include "yhash.h"
#include "ykey.h"
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include "ymemory.h"
#include <unistd.h>
#include <stdio.h>
Go to the source code of this file.
Classes | |
struct | _HTTPNetHubSt |
struct | _HTTPReqSt |
struct | _HubSt |
struct | _pktItem |
struct | _RequestSt |
struct | _WSChanSt |
struct | _WSNetHubSt |
struct | _WSReqSt |
struct | _yGenericDeviceSt |
struct | _yInterfaceSt |
struct | _YIOHDL_internal |
struct | _yPrivDeviceSt |
struct | FUpdateContext |
struct | OS_USB_Packet |
struct | pktQueue |
struct | USB_HDL |
struct | yContextSt |
struct | yPerfMon |
Macros | |
#define | ALLOC_YDX_PER_HUB 256 |
#define | dbglog(args...) dbglogf(__FILE_ID__,__LINE__, ## args) |
#define | DEVGEN_LOG_ACTIVATED 1u |
#define | DEVGEN_LOG_PENDING 2u |
#define | DEVGEN_LOG_PULLING 4u |
#define | ENUMLOG(fmt, args...) |
#define | FIND_FROM_ANY (FIND_FROM_SERIAL|FIND_FROM_NAME) |
#define | FIND_FROM_NAME 2 |
#define | FIND_FROM_SERIAL 1 |
#define | HALENUMLOG(fmt, args...) |
#define | HALLOG(fmt, args...) |
#define | HTTP_RAW_BUFF_SIZE (8*1024) |
#define | MAX_YDX_PER_HUB 255 |
#define | MSC_VS2003 1310 |
#define | NB_LINUX_USB_TR 1 |
#define | NB_MAX_STARTUP_RETRY 5u |
#define | NBMAX_INTERFACE_PER_DEV 1 |
#define | NBMAX_NET_HUB 32 |
#define | NBMAX_USB_DEVICE_CONNECTED 256 |
#define | NET_HUB_NOT_CONNECTION_TIMEOUT (6*1024) |
#define | NETENUMLOG(fmt, args...) |
#define | NEXT_IFACE_NO(current, total) (current+1<total?current+1:0) |
#define | NEXT_YPKT_NO(current) ((current+1)& YPKTNOMSK) |
#define | REQLOG(fmt, args...) |
#define | SETUPED_IFACE_CACHE_SIZE 128 |
#define | STRINGIFY(x) #x |
#define | TCPLOG(fmt, args...) |
#define | TCPREQ_IN_USE 2 |
#define | TCPREQ_KEEPALIVE 1 |
#define | TOSTRING(x) STRINGIFY(x) |
#define | TRACEFILE_NAMELEN 512 |
#define | WIN_DEVICE_PATH_LEN 512 |
#define | WSLOG(fmt, args...) |
#define | yApproximateSleep(ms) usleep(ms*1000) |
#define | YASSERT(x) if(!(x)){dbglog("ASSERT FAILED:%s:%d\n",__FILE_ID__ , __LINE__);YDEBUG_BREAK} |
#define | YCTX_OSX_MULTIPLES_HID 1 |
#define | YDEBUG_BREAK {} |
#define | YERR(code) ySetErr(code,errmsg,NULL,__FILE_ID__,__LINE__) |
#define | YERRMSG(code, message) ySetErr(code,errmsg,message,__FILE_ID__,__LINE__) |
#define | YERRMSGSILENT(code, message) ySetErr(code, errmsg, message, NULL, 0) |
#define | YERRMSGTO(code, message, buffer) ySetErr(code,buffer,message,__FILE_ID__,__LINE__) |
#define | YERRTO(code, buffer) ySetErr(code,buffer,NULL,__FILE_ID__,__LINE__) |
#define | yFree(ptr) free(ptr) |
#define | YIO_REMOTE_CLOSE 1u |
#define | yMalloc(size) malloc(size) |
#define | yMemcpy(dst, src, size) memcpy(dst,src,size) |
#define | yMemmove(dst, src, size) memmove(dst,src,size) |
#define | yMemset(dst, val, size) memset(dst,val,size) |
#define | YPANIC {dbglog("YPANIC:%s:%d\n",__FILE_ID__ , __LINE__);YDEBUG_BREAK} |
#define | YPKT_VERSION_ORIGINAL_RELEASE 0x0202 |
#define | YPROPERR(call) {int tmpres=(call); if(YISERR(tmpres)) {return (YRETCODE)tmpres;}} |
#define | YREQLOG(fmt, args...) |
#define | YSPRINTF ysprintf_s |
#define | YSTRCAT(dst, dstsize, src) ystrcat_s(dst,dstsize,src) |
#define | YSTRCMP(A, B) strcmp(A,B) |
#define | YSTRCPY(dst, dstsize, src) ystrcpy_s(dst,dstsize,src) |
#define | YSTRDUP(src) ystrdup_s(src) |
#define | YSTRICMP(A, B) strcasecmp(A,B) |
#define | YSTRLEN(str) ((int)strlen(str)) |
#define | YSTRNCAT(dst, dstsize, src, len) ystrncat_s(dst,dstsize,src,len) |
#define | YSTRNCMP(A, B, len) strncmp(A,B,len) |
#define | YSTRNCPY(dst, dstsize, src, len) ystrncpy_s(dst,dstsize,src,len) |
#define | YSTRNICMP(A, B, len) strncasecmp(A,B,len) |
#define | yTracePtr(ptr) |
#define | YVSPRINTF yvsprintf_s |
#define | YWIN_EVENT_INTERRUPT 1 |
#define | YWIN_EVENT_READ 0 |
Typedefs | |
typedef struct _HTTPNetHubSt | HTTPNetHub |
typedef struct _HTTPReqSt | HTTPReqSt |
typedef struct _HubSt | HubSt |
typedef struct _pktItem | pktItem |
typedef void(* | RequestProgress) (void *context, u32 acked, u32 totalbytes) |
typedef struct _RequestSt | RequestSt |
typedef struct _WSChanSt | WSChanSt |
typedef struct _WSNetHubSt | WSNetHub |
typedef struct _WSReqSt | WSReqSt |
typedef void(* | yDevInfoCallback) (const yDeviceSt *infos) |
typedef struct _yGenericDeviceSt | yGenericDeviceSt |
typedef struct _yInterfaceSt | yInterfaceSt |
typedef struct _YIOHDL_internal | YIOHDL_internal |
typedef void(* | yNotificCallback) (const char *serial, const char *funcid, const char *funcname, const char *funcval) |
typedef struct _yPrivDeviceSt | yPrivDeviceSt |
Enumerations | |
enum | NET_HUB_STATE { NET_HUB_DISCONNECTED =0, NET_HUB_TRYING, NET_HUB_ESTABLISHED, NET_HUB_TOCLOSE, NET_HUB_CLOSED } |
enum | RequestState { REQ_CLOSED = 0, REQ_OPEN, REQ_CLOSED_BY_HUB, REQ_CLOSED_BY_API, REQ_ERROR } |
enum | USB_THREAD_STATE { USB_THREAD_NOT_STARTED, USB_THREAD_RUNNING, USB_THREAD_MUST_STOP, USB_THREAD_STOPED } |
enum | WS_BASE_STATE { WS_BASE_OFFLINE = 0, WS_BASE_HEADER_SENT, WS_BASE_SOCKET_UPGRADED, WS_BASE_AUTHENTICATING, WS_BASE_CONNECTED } |
enum | YDEV_STATUS { YDEV_UNPLUGGED =0, YDEV_WORKING, YDEV_NOTRESPONDING } |
enum | YENU_ACTION { YENU_NONE, YENU_START, YENU_STOP, YENU_RESTART } |
enum | YHTTP_STATUS { YHTTP_CLOSED, YHTTP_OPENED, YHTTP_INREQUEST, YHTTP_CLOSE_BY_DEV, YHTTP_CLOSE_BY_API } |
enum | YRUN_STATUS { YRUN_STOPED, YRUN_AVAIL, YRUN_REQUEST, YRUN_BUSY, YRUN_IDLE, YRUN_ERROR } |
Functions | |
int | dbglogf (const char *fileid, int line, const char *fmt,...) |
void | devHdlInfo (YUSBDEV hdl, yDeviceSt *infos) |
void | dumpYPerfEntry (yPerfMon *entry, const char *name) |
yPrivDeviceSt * | findDev (const char *str, u32 flags) |
yPrivDeviceSt * | findDevFromIOHdl (YIOHDL_internal *hdl) |
YUSBDEV | findDevHdlFromStr (const char *str) |
void | freeDevYdxInfos (int devYdx) |
int | FusionErrmsg (int code, char *errmsg, const char *generr, const char *detailerr) |
int | handleNetNotification (HubSt *hub) |
void | initDevYdxInfos (int devYdxy, yStrRef serial) |
int | vdbglogf (const char *fileid, int line, const char *fmt, va_list args) |
void | wpSafeRegister (HubSt *hub, u8 devYdx, yStrRef serialref, yStrRef lnameref, yStrRef productref, u16 deviceid, yUrlRef devUrl, s8 beacon) |
void | wpSafeUnregister (yStrRef serialref) |
void | wpSafeUpdate (HubSt *hub, u8 devYdx, yStrRef serialref, yStrRef lnameref, yUrlRef devUrl, s8 beacon) |
u32 | yapiGetCNonce (u32 nc) |
YRETCODE | yapiHTTPRequestSyncDone_internal (YIOHDL *iohdl, char *errmsg) |
YRETCODE | yapiHTTPRequestSyncStartEx_internal (YIOHDL *iohdl, int tcpchan, const char *device, const char *request, int requestsize, char **reply, int *replysize, yapiRequestProgressCallback progress_cb, void *progress_ctx, char *errmsg) |
int | yapiJsonGetPath_internal (const char *path, const char *json_data, int json_size, int withHTTPheader, const char **output, char *errmsg) |
YRETCODE | yapiPullDeviceLog (const char *serial) |
YRETCODE | yapiPullDeviceLogEx (int devydx) |
YRETCODE | yapiRequestOpen (YIOHDL_internal *iohdl, int tpchan, const char *device, const char *request, int reqlen, yapiRequestAsyncCallback callback, void *context, yapiRequestProgressCallback progress_cb, void *progress_ctx, char *errmsg) |
int | YFOPEN (FILE **f, const char *filename, const char *mode) |
void | yFunctionTimedUpdate (YAPI_FUNCTION fundescr, double deviceTime, const u8 *report, u32 len) |
void | yFunctionUpdate (YAPI_FUNCTION fundescr, const char *value) |
int | ymemfind (const u8 *haystack, u32 haystack_len, const u8 *needle, u32 needle_len) |
void | yPktQueueFree (pktQueue *q) |
void | yPktQueueInit (pktQueue *q) |
YRETCODE | yPktQueuePeekH2D (yInterfaceSt *iface, pktItem **pkt) |
YRETCODE | yPktQueuePopH2D (yInterfaceSt *iface, pktItem **pkt) |
YRETCODE | yPktQueuePushD2H (yInterfaceSt *iface, const USB_Packet *pkt, char *errmsg) |
YRETCODE | yPktQueuePushH2D (yInterfaceSt *iface, const USB_Packet *pkt, char *errmsg) |
void | yPktQueueSetError (pktQueue *q, YRETCODE code, const char *msg) |
YRETCODE | yPktQueueWaitAndPopD2H (yInterfaceSt *iface, pktItem **pkt, int ms, char *errmsg) |
void | ypUpdateHybrid (const char *serial, Notification_funydx funInfo, const char *funcval) |
void | ypUpdateUSB (const char *serial, const char *funcid, const char *funcname, int funclass, int funydx, const char *funcval) |
void | ypUpdateYdx (int devydx, Notification_funydx funInfo, const char *funcval) |
int | ySetErr (int code, char *outmsg, const char *erreur, const char *file, u32 line) |
int | ysprintf_s (char *dst, unsigned dstsize, const char *fmt,...) |
YRETCODE | ystrcat_s (char *dst, unsigned dstsize, const char *src) |
YRETCODE | ystrcpy_s (char *dst, unsigned dstsize, const char *src) |
char * | ystrdup_s (const char *src) |
YRETCODE | ystrncat_s (char *dst, unsigned dstsize, const char *src, unsigned len) |
YRETCODE | ystrncpy_s (char *dst, unsigned dstsize, const char *src, unsigned len) |
int | yUsbClose (YIOHDL_internal *ioghdl, char *errmsg) |
int | yUsbEOF (YIOHDL_internal *ioghdl, char *errmsg) |
int | yUsbFree (yContextSt *ctx, char *errmsg) |
int | yUSBGetBooloader (const char *serial, const char *name, yInterfaceSt *iface, char *errmsg) |
yGenericDeviceSt * | yUSBGetGenericInfo (yStrRef devdescr) |
int | yUsbIdle (void) |
int | yUsbInit (yContextSt *ctx, char *errmsg) |
int | yUsbOpen (YIOHDL_internal *ioghdl, const char *device, char *errmsg) |
int | yUsbOpenDevDescr (YIOHDL_internal *ioghdl, yStrRef devdescr, char *errmsg) |
int | yUsbReadBlock (YIOHDL_internal *ioghdl, char *buffer, int len, u64 blockUntil, char *errmsg) |
int | yUsbReadNonBlock (YIOHDL_internal *ioghdl, char *buffer, int len, char *errmsg) |
void | yUSBReleaseAllDevices (void) |
int | yUsbSetIOAsync (YIOHDL_internal *ioghdl, yapiRequestAsyncCallback callback, void *context, char *errmsg) |
int | yUsbTrafficPending (void) |
YRETCODE | yUSBUpdateDeviceList (char *errmsg) |
int | yUsbWrite (YIOHDL_internal *ioghdl, const char *buffer, int writelen, char *errmsg) |
int | yvsprintf_s (char *dst, unsigned dstsize, const char *fmt, va_list arg) |
int | yyyOShdlCompare (yPrivDeviceSt *dev, yInterfaceSt *newiface) |
void | yyyPacketShutdown (yInterfaceSt *iface) |
YRETCODE | yyySendPacket (yInterfaceSt *iface, const USB_Packet *pkt, char *errmsg) |
int | yyySetup (yInterfaceSt *iface, char *errmsg) |
int | yyySignalOutPkt (yInterfaceSt *iface, char *errmsg) |
int | yyyUSB_init (yContextSt *ctx, char *errmsg) |
int | yyyUSB_stop (yContextSt *ctx, char *errmsg) |
int | yyyUSBGetInterfaces (yInterfaceSt **ifaces, int *nbifaceDetect, char *errmsg) |
Variables | |
yContextSt * | yContext |
char | ytracefile [] |
#define dbglog | ( | args... | ) | dbglogf(__FILE_ID__,__LINE__, ## args) |
#define FIND_FROM_ANY (FIND_FROM_SERIAL|FIND_FROM_NAME) |
#define NEXT_IFACE_NO | ( | current, | |
total | |||
) | (current+1<total?current+1:0) |
#define YASSERT | ( | x | ) | if(!(x)){dbglog("ASSERT FAILED:%s:%d\n",__FILE_ID__ , __LINE__);YDEBUG_BREAK} |
#define YERR | ( | code | ) | ySetErr(code,errmsg,NULL,__FILE_ID__,__LINE__) |
#define YERRMSG | ( | code, | |
message | |||
) | ySetErr(code,errmsg,message,__FILE_ID__,__LINE__) |
#define YERRMSGSILENT | ( | code, | |
message | |||
) | ySetErr(code, errmsg, message, NULL, 0) |
#define YERRMSGTO | ( | code, | |
message, | |||
buffer | |||
) | ySetErr(code,buffer,message,__FILE_ID__,__LINE__) |
#define YERRTO | ( | code, | |
buffer | |||
) | ySetErr(code,buffer,NULL,__FILE_ID__,__LINE__) |
#define YPANIC {dbglog("YPANIC:%s:%d\n",__FILE_ID__ , __LINE__);YDEBUG_BREAK} |
#define YSPRINTF ysprintf_s |
#define YSTRCAT | ( | dst, | |
dstsize, | |||
src | |||
) | ystrcat_s(dst,dstsize,src) |
#define YSTRCPY | ( | dst, | |
dstsize, | |||
src | |||
) | ystrcpy_s(dst,dstsize,src) |
#define YSTRNCAT | ( | dst, | |
dstsize, | |||
src, | |||
len | |||
) | ystrncat_s(dst,dstsize,src,len) |
#define YSTRNCPY | ( | dst, | |
dstsize, | |||
src, | |||
len | |||
) | ystrncpy_s(dst,dstsize,src,len) |
#define YVSPRINTF yvsprintf_s |
typedef struct _HTTPNetHubSt HTTPNetHub |
typedef struct _HTTPReqSt HTTPReqSt |
typedef void(* RequestProgress) (void *context, u32 acked, u32 totalbytes) |
typedef struct _RequestSt RequestSt |
typedef struct _WSNetHubSt WSNetHub |
typedef struct _yGenericDeviceSt yGenericDeviceSt |
typedef struct _yInterfaceSt yInterfaceSt |
typedef struct _YIOHDL_internal YIOHDL_internal |
typedef void(* yNotificCallback) (const char *serial, const char *funcid, const char *funcname, const char *funcval) |
typedef struct _yPrivDeviceSt yPrivDeviceSt |
enum NET_HUB_STATE |
enum RequestState |
enum USB_THREAD_STATE |
enum WS_BASE_STATE |
enum YDEV_STATUS |
enum YENU_ACTION |
enum YHTTP_STATUS |
enum YRUN_STATUS |
int dbglogf | ( | const char * | fileid, |
int | line, | ||
const char * | fmt, | ||
... | |||
) |
void dumpYPerfEntry | ( | yPerfMon * | entry, |
const char * | name | ||
) |
yPrivDeviceSt* findDev | ( | const char * | str, |
u32 | flags | ||
) |
yPrivDeviceSt* findDevFromIOHdl | ( | YIOHDL_internal * | hdl | ) |
int FusionErrmsg | ( | int | code, |
char * | errmsg, | ||
const char * | generr, | ||
const char * | detailerr | ||
) |
int vdbglogf | ( | const char * | fileid, |
int | line, | ||
const char * | fmt, | ||
va_list | args | ||
) |
YRETCODE yapiHTTPRequestSyncStartEx_internal | ( | YIOHDL * | iohdl, |
int | tcpchan, | ||
const char * | device, | ||
const char * | request, | ||
int | requestsize, | ||
char ** | reply, | ||
int * | replysize, | ||
yapiRequestProgressCallback | progress_cb, | ||
void * | progress_ctx, | ||
char * | errmsg | ||
) |
int yapiJsonGetPath_internal | ( | const char * | path, |
const char * | json_data, | ||
int | json_size, | ||
int | withHTTPheader, | ||
const char ** | output, | ||
char * | errmsg | ||
) |
YRETCODE yapiRequestOpen | ( | YIOHDL_internal * | iohdl, |
int | tpchan, | ||
const char * | device, | ||
const char * | request, | ||
int | reqlen, | ||
yapiRequestAsyncCallback | callback, | ||
void * | context, | ||
yapiRequestProgressCallback | progress_cb, | ||
void * | progress_ctx, | ||
char * | errmsg | ||
) |
int YFOPEN | ( | FILE ** | f, |
const char * | filename, | ||
const char * | mode | ||
) |
void yFunctionTimedUpdate | ( | YAPI_FUNCTION | fundescr, |
double | deviceTime, | ||
const u8 * | report, | ||
u32 | len | ||
) |
void yFunctionUpdate | ( | YAPI_FUNCTION | fundescr, |
const char * | value | ||
) |
int ymemfind | ( | const u8 * | haystack, |
u32 | haystack_len, | ||
const u8 * | needle, | ||
u32 | needle_len | ||
) |
YRETCODE yPktQueuePeekH2D | ( | yInterfaceSt * | iface, |
pktItem ** | pkt | ||
) |
YRETCODE yPktQueuePopH2D | ( | yInterfaceSt * | iface, |
pktItem ** | pkt | ||
) |
YRETCODE yPktQueuePushD2H | ( | yInterfaceSt * | iface, |
const USB_Packet * | pkt, | ||
char * | errmsg | ||
) |
YRETCODE yPktQueuePushH2D | ( | yInterfaceSt * | iface, |
const USB_Packet * | pkt, | ||
char * | errmsg | ||
) |
YRETCODE yPktQueueWaitAndPopD2H | ( | yInterfaceSt * | iface, |
pktItem ** | pkt, | ||
int | ms, | ||
char * | errmsg | ||
) |
void ypUpdateHybrid | ( | const char * | serial, |
Notification_funydx | funInfo, | ||
const char * | funcval | ||
) |
void ypUpdateUSB | ( | const char * | serial, |
const char * | funcid, | ||
const char * | funcname, | ||
int | funclass, | ||
int | funydx, | ||
const char * | funcval | ||
) |
void ypUpdateYdx | ( | int | devydx, |
Notification_funydx | funInfo, | ||
const char * | funcval | ||
) |
int ySetErr | ( | int | code, |
char * | outmsg, | ||
const char * | erreur, | ||
const char * | file, | ||
u32 | line | ||
) |
int ysprintf_s | ( | char * | dst, |
unsigned | dstsize, | ||
const char * | fmt, | ||
... | |||
) |
YRETCODE ystrcat_s | ( | char * | dst, |
unsigned | dstsize, | ||
const char * | src | ||
) |
YRETCODE ystrcpy_s | ( | char * | dst, |
unsigned | dstsize, | ||
const char * | src | ||
) |
YRETCODE ystrncat_s | ( | char * | dst, |
unsigned | dstsize, | ||
const char * | src, | ||
unsigned | len | ||
) |
YRETCODE ystrncpy_s | ( | char * | dst, |
unsigned | dstsize, | ||
const char * | src, | ||
unsigned | len | ||
) |
int yUsbClose | ( | YIOHDL_internal * | ioghdl, |
char * | errmsg | ||
) |
int yUsbEOF | ( | YIOHDL_internal * | ioghdl, |
char * | errmsg | ||
) |
int yUsbFree | ( | yContextSt * | ctx, |
char * | errmsg | ||
) |
int yUSBGetBooloader | ( | const char * | serial, |
const char * | name, | ||
yInterfaceSt * | iface, | ||
char * | errmsg | ||
) |
yGenericDeviceSt* yUSBGetGenericInfo | ( | yStrRef | devdescr | ) |
int yUsbInit | ( | yContextSt * | ctx, |
char * | errmsg | ||
) |
int yUsbOpen | ( | YIOHDL_internal * | ioghdl, |
const char * | device, | ||
char * | errmsg | ||
) |
int yUsbOpenDevDescr | ( | YIOHDL_internal * | ioghdl, |
yStrRef | devdescr, | ||
char * | errmsg | ||
) |
int yUsbReadBlock | ( | YIOHDL_internal * | ioghdl, |
char * | buffer, | ||
int | len, | ||
u64 | blockUntil, | ||
char * | errmsg | ||
) |
int yUsbReadNonBlock | ( | YIOHDL_internal * | ioghdl, |
char * | buffer, | ||
int | len, | ||
char * | errmsg | ||
) |
int yUsbSetIOAsync | ( | YIOHDL_internal * | ioghdl, |
yapiRequestAsyncCallback | callback, | ||
void * | context, | ||
char * | errmsg | ||
) |
int yUsbWrite | ( | YIOHDL_internal * | ioghdl, |
const char * | buffer, | ||
int | writelen, | ||
char * | errmsg | ||
) |
int yvsprintf_s | ( | char * | dst, |
unsigned | dstsize, | ||
const char * | fmt, | ||
va_list | arg | ||
) |
int yyyOShdlCompare | ( | yPrivDeviceSt * | dev, |
yInterfaceSt * | newiface | ||
) |
void yyyPacketShutdown | ( | yInterfaceSt * | iface | ) |
YRETCODE yyySendPacket | ( | yInterfaceSt * | iface, |
const USB_Packet * | pkt, | ||
char * | errmsg | ||
) |
int yyySetup | ( | yInterfaceSt * | iface, |
char * | errmsg | ||
) |
int yyySignalOutPkt | ( | yInterfaceSt * | iface, |
char * | errmsg | ||
) |
int yyyUSB_init | ( | yContextSt * | ctx, |
char * | errmsg | ||
) |
int yyyUSB_stop | ( | yContextSt * | ctx, |
char * | errmsg | ||
) |
int yyyUSBGetInterfaces | ( | yInterfaceSt ** | ifaces, |
int * | nbifaceDetect, | ||
char * | errmsg | ||
) |
yContextSt* yContext |