maintidi.c 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196
  1. /*
  2. *
  3. Copyright (c) Eicon Networks, 2000.
  4. *
  5. This source file is supplied for the use with
  6. Eicon Networks range of DIVA Server Adapters.
  7. *
  8. Eicon File Revision : 1.9
  9. *
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2, or (at your option)
  13. any later version.
  14. *
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY
  17. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. See the GNU General Public License for more details.
  19. *
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. *
  24. */
  25. #include "platform.h"
  26. #include "kst_ifc.h"
  27. #include "di_defs.h"
  28. #include "maintidi.h"
  29. #include "pc.h"
  30. #include "man_defs.h"
  31. extern void diva_mnt_internal_dprintf (dword drv_id, dword type, char* p, ...);
  32. #define MODEM_PARSE_ENTRIES 16 /* amount of variables of interest */
  33. #define FAX_PARSE_ENTRIES 12 /* amount of variables of interest */
  34. #define LINE_PARSE_ENTRIES 15 /* amount of variables of interest */
  35. #define STAT_PARSE_ENTRIES 70 /* amount of variables of interest */
  36. /*
  37. LOCAL FUNCTIONS
  38. */
  39. static int DivaSTraceLibraryStart (void* hLib);
  40. static int DivaSTraceLibraryStop (void* hLib);
  41. static int SuperTraceLibraryFinit (void* hLib);
  42. static void* SuperTraceGetHandle (void* hLib);
  43. static int SuperTraceMessageInput (void* hLib);
  44. static int SuperTraceSetAudioTap (void* hLib, int Channel, int on);
  45. static int SuperTraceSetBChannel (void* hLib, int Channel, int on);
  46. static int SuperTraceSetDChannel (void* hLib, int on);
  47. static int SuperTraceSetInfo (void* hLib, int on);
  48. static int SuperTraceClearCall (void* hLib, int Channel);
  49. static int SuperTraceGetOutgoingCallStatistics (void* hLib);
  50. static int SuperTraceGetIncomingCallStatistics (void* hLib);
  51. static int SuperTraceGetModemStatistics (void* hLib);
  52. static int SuperTraceGetFaxStatistics (void* hLib);
  53. static int SuperTraceGetBLayer1Statistics (void* hLib);
  54. static int SuperTraceGetBLayer2Statistics (void* hLib);
  55. static int SuperTraceGetDLayer1Statistics (void* hLib);
  56. static int SuperTraceGetDLayer2Statistics (void* hLib);
  57. /*
  58. LOCAL FUNCTIONS
  59. */
  60. static int ScheduleNextTraceRequest (diva_strace_context_t* pLib);
  61. static int process_idi_event (diva_strace_context_t* pLib,
  62. diva_man_var_header_t* pVar);
  63. static int process_idi_info (diva_strace_context_t* pLib,
  64. diva_man_var_header_t* pVar);
  65. static int diva_modem_event (diva_strace_context_t* pLib, int Channel);
  66. static int diva_fax_event (diva_strace_context_t* pLib, int Channel);
  67. static int diva_line_event (diva_strace_context_t* pLib, int Channel);
  68. static int diva_modem_info (diva_strace_context_t* pLib,
  69. int Channel,
  70. diva_man_var_header_t* pVar);
  71. static int diva_fax_info (diva_strace_context_t* pLib,
  72. int Channel,
  73. diva_man_var_header_t* pVar);
  74. static int diva_line_info (diva_strace_context_t* pLib,
  75. int Channel,
  76. diva_man_var_header_t* pVar);
  77. static int diva_ifc_statistics (diva_strace_context_t* pLib,
  78. diva_man_var_header_t* pVar);
  79. static diva_man_var_header_t* get_next_var (diva_man_var_header_t* pVar);
  80. static diva_man_var_header_t* find_var (diva_man_var_header_t* pVar,
  81. const char* name);
  82. static int diva_strace_read_int (diva_man_var_header_t* pVar, int* var);
  83. static int diva_strace_read_uint (diva_man_var_header_t* pVar, dword* var);
  84. static int diva_strace_read_asz (diva_man_var_header_t* pVar, char* var);
  85. static int diva_strace_read_asc (diva_man_var_header_t* pVar, char* var);
  86. static int diva_strace_read_ie (diva_man_var_header_t* pVar,
  87. diva_trace_ie_t* var);
  88. static void diva_create_parse_table (diva_strace_context_t* pLib);
  89. static void diva_trace_error (diva_strace_context_t* pLib,
  90. int error, const char* file, int line);
  91. static void diva_trace_notify_user (diva_strace_context_t* pLib,
  92. int Channel,
  93. int notify_subject);
  94. static int diva_trace_read_variable (diva_man_var_header_t* pVar,
  95. void* variable);
  96. /*
  97. Initialize the library and return context
  98. of the created trace object that will represent
  99. the IDI adapter.
  100. Return 0 on error.
  101. */
  102. diva_strace_library_interface_t* DivaSTraceLibraryCreateInstance (int Adapter,
  103. const diva_trace_library_user_interface_t* user_proc,
  104. byte* pmem) {
  105. diva_strace_context_t* pLib = (diva_strace_context_t*)pmem;
  106. int i;
  107. if (!pLib) {
  108. return NULL;
  109. }
  110. pmem += sizeof(*pLib);
  111. memset(pLib, 0x00, sizeof(*pLib));
  112. pLib->Adapter = Adapter;
  113. /*
  114. Set up Library Interface
  115. */
  116. pLib->instance.hLib = pLib;
  117. pLib->instance.DivaSTraceLibraryStart = DivaSTraceLibraryStart;
  118. pLib->instance.DivaSTraceLibraryStop = DivaSTraceLibraryStop;
  119. pLib->instance.DivaSTraceLibraryFinit = SuperTraceLibraryFinit;
  120. pLib->instance.DivaSTraceMessageInput = SuperTraceMessageInput;
  121. pLib->instance.DivaSTraceGetHandle = SuperTraceGetHandle;
  122. pLib->instance.DivaSTraceSetAudioTap = SuperTraceSetAudioTap;
  123. pLib->instance.DivaSTraceSetBChannel = SuperTraceSetBChannel;
  124. pLib->instance.DivaSTraceSetDChannel = SuperTraceSetDChannel;
  125. pLib->instance.DivaSTraceSetInfo = SuperTraceSetInfo;
  126. pLib->instance.DivaSTraceGetOutgoingCallStatistics = \
  127. SuperTraceGetOutgoingCallStatistics;
  128. pLib->instance.DivaSTraceGetIncomingCallStatistics = \
  129. SuperTraceGetIncomingCallStatistics;
  130. pLib->instance.DivaSTraceGetModemStatistics = \
  131. SuperTraceGetModemStatistics;
  132. pLib->instance.DivaSTraceGetFaxStatistics = \
  133. SuperTraceGetFaxStatistics;
  134. pLib->instance.DivaSTraceGetBLayer1Statistics = \
  135. SuperTraceGetBLayer1Statistics;
  136. pLib->instance.DivaSTraceGetBLayer2Statistics = \
  137. SuperTraceGetBLayer2Statistics;
  138. pLib->instance.DivaSTraceGetDLayer1Statistics = \
  139. SuperTraceGetDLayer1Statistics;
  140. pLib->instance.DivaSTraceGetDLayer2Statistics = \
  141. SuperTraceGetDLayer2Statistics;
  142. pLib->instance.DivaSTraceClearCall = SuperTraceClearCall;
  143. if (user_proc) {
  144. pLib->user_proc_table.user_context = user_proc->user_context;
  145. pLib->user_proc_table.notify_proc = user_proc->notify_proc;
  146. pLib->user_proc_table.trace_proc = user_proc->trace_proc;
  147. pLib->user_proc_table.error_notify_proc = user_proc->error_notify_proc;
  148. }
  149. if (!(pLib->hAdapter = SuperTraceOpenAdapter (Adapter))) {
  150. diva_mnt_internal_dprintf (0, DLI_ERR, "Can not open XDI adapter");
  151. return NULL;
  152. }
  153. pLib->Channels = SuperTraceGetNumberOfChannels (pLib->hAdapter);
  154. /*
  155. Calculate amount of parte table entites necessary to translate
  156. information from all events of onterest
  157. */
  158. pLib->parse_entries = (MODEM_PARSE_ENTRIES + FAX_PARSE_ENTRIES + \
  159. STAT_PARSE_ENTRIES + \
  160. LINE_PARSE_ENTRIES + 1) * pLib->Channels;
  161. pLib->parse_table = (diva_strace_path2action_t*)pmem;
  162. for (i = 0; i < 30; i++) {
  163. pLib->lines[i].pInterface = &pLib->Interface;
  164. pLib->lines[i].pInterfaceStat = &pLib->InterfaceStat;
  165. }
  166. pLib->e.R = &pLib->RData;
  167. pLib->req_busy = 1;
  168. pLib->rc_ok = ASSIGN_OK;
  169. diva_create_parse_table (pLib);
  170. return ((diva_strace_library_interface_t*)pLib);
  171. }
  172. static int DivaSTraceLibraryStart (void* hLib) {
  173. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  174. return (SuperTraceASSIGN (pLib->hAdapter, pLib->buffer));
  175. }
  176. /*
  177. Return (-1) on error
  178. Return (0) if was initiated or pending
  179. Return (1) if removal is complete
  180. */
  181. static int DivaSTraceLibraryStop (void* hLib) {
  182. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  183. if (!pLib->e.Id) { /* Was never started/assigned */
  184. return (1);
  185. }
  186. switch (pLib->removal_state) {
  187. case 0:
  188. pLib->removal_state = 1;
  189. ScheduleNextTraceRequest(pLib);
  190. break;
  191. case 3:
  192. return (1);
  193. }
  194. return (0);
  195. }
  196. static int SuperTraceLibraryFinit (void* hLib) {
  197. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  198. if (pLib) {
  199. if (pLib->hAdapter) {
  200. SuperTraceCloseAdapter (pLib->hAdapter);
  201. }
  202. return (0);
  203. }
  204. return (-1);
  205. }
  206. static void* SuperTraceGetHandle (void* hLib) {
  207. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  208. return (&pLib->e);
  209. }
  210. /*
  211. After library handle object is gone in signaled state
  212. this function should be called and will pick up incoming
  213. IDI messages (return codes and indications).
  214. */
  215. static int SuperTraceMessageInput (void* hLib) {
  216. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  217. int ret = 0;
  218. byte Rc, Ind;
  219. if (pLib->e.complete == 255) {
  220. /*
  221. Process return code
  222. */
  223. pLib->req_busy = 0;
  224. Rc = pLib->e.Rc;
  225. pLib->e.Rc = 0;
  226. if (pLib->removal_state == 2) {
  227. pLib->removal_state = 3;
  228. return (0);
  229. }
  230. if (Rc != pLib->rc_ok) {
  231. int ignore = 0;
  232. /*
  233. Auto-detect amount of events/channels and features
  234. */
  235. if (pLib->general_b_ch_event == 1) {
  236. pLib->general_b_ch_event = 2;
  237. ignore = 1;
  238. } else if (pLib->general_fax_event == 1) {
  239. pLib->general_fax_event = 2;
  240. ignore = 1;
  241. } else if (pLib->general_mdm_event == 1) {
  242. pLib->general_mdm_event = 2;
  243. ignore = 1;
  244. } else if ((pLib->ChannelsTraceActive < pLib->Channels) && pLib->ChannelsTraceActive) {
  245. pLib->ChannelsTraceActive = pLib->Channels;
  246. ignore = 1;
  247. } else if (pLib->ModemTraceActive < pLib->Channels) {
  248. pLib->ModemTraceActive = pLib->Channels;
  249. ignore = 1;
  250. } else if (pLib->FaxTraceActive < pLib->Channels) {
  251. pLib->FaxTraceActive = pLib->Channels;
  252. ignore = 1;
  253. } else if (pLib->audio_trace_init == 2) {
  254. ignore = 1;
  255. pLib->audio_trace_init = 1;
  256. } else if (pLib->eye_pattern_pending) {
  257. pLib->eye_pattern_pending = 0;
  258. ignore = 1;
  259. } else if (pLib->audio_tap_pending) {
  260. pLib->audio_tap_pending = 0;
  261. ignore = 1;
  262. }
  263. if (!ignore) {
  264. return (-1); /* request failed */
  265. }
  266. } else {
  267. if (pLib->general_b_ch_event == 1) {
  268. pLib->ChannelsTraceActive = pLib->Channels;
  269. pLib->general_b_ch_event = 2;
  270. } else if (pLib->general_fax_event == 1) {
  271. pLib->general_fax_event = 2;
  272. pLib->FaxTraceActive = pLib->Channels;
  273. } else if (pLib->general_mdm_event == 1) {
  274. pLib->general_mdm_event = 2;
  275. pLib->ModemTraceActive = pLib->Channels;
  276. }
  277. }
  278. if (pLib->audio_trace_init == 2) {
  279. pLib->audio_trace_init = 1;
  280. }
  281. pLib->rc_ok = 0xff; /* default OK after assign was done */
  282. if ((ret = ScheduleNextTraceRequest(pLib))) {
  283. return (-1);
  284. }
  285. } else {
  286. /*
  287. Process indication
  288. Always 'RNR' indication if return code is pending
  289. */
  290. Ind = pLib->e.Ind;
  291. pLib->e.Ind = 0;
  292. if (pLib->removal_state) {
  293. pLib->e.RNum = 0;
  294. pLib->e.RNR = 2;
  295. } else if (pLib->req_busy) {
  296. pLib->e.RNum = 0;
  297. pLib->e.RNR = 1;
  298. } else {
  299. if (pLib->e.complete != 0x02) {
  300. /*
  301. Look-ahead call, set up buffers
  302. */
  303. pLib->e.RNum = 1;
  304. pLib->e.R->P = (byte*)&pLib->buffer[0];
  305. pLib->e.R->PLength = (word)(sizeof(pLib->buffer) - 1);
  306. } else {
  307. /*
  308. Indication reception complete, process it now
  309. */
  310. byte* p = (byte*)&pLib->buffer[0];
  311. pLib->buffer[pLib->e.R->PLength] = 0; /* terminate I.E. with zero */
  312. switch (Ind) {
  313. case MAN_COMBI_IND: {
  314. int total_length = pLib->e.R->PLength;
  315. word this_ind_length;
  316. while (total_length > 3 && *p) {
  317. Ind = *p++;
  318. this_ind_length = (word)p[0] | ((word)p[1] << 8);
  319. p += 2;
  320. switch (Ind) {
  321. case MAN_INFO_IND:
  322. if (process_idi_info (pLib, (diva_man_var_header_t*)p)) {
  323. return (-1);
  324. }
  325. break;
  326. case MAN_EVENT_IND:
  327. if (process_idi_event (pLib, (diva_man_var_header_t*)p)) {
  328. return (-1);
  329. }
  330. break;
  331. case MAN_TRACE_IND:
  332. if (pLib->trace_on == 1) {
  333. /*
  334. Ignore first trace event that is result of
  335. EVENT_ON operation
  336. */
  337. pLib->trace_on++;
  338. } else {
  339. /*
  340. Delivery XLOG buffer to application
  341. */
  342. if (pLib->user_proc_table.trace_proc) {
  343. (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context,
  344. &pLib->instance, pLib->Adapter,
  345. p, this_ind_length);
  346. }
  347. }
  348. break;
  349. default:
  350. diva_mnt_internal_dprintf (0, DLI_ERR, "Unknown IDI Ind (DMA mode): %02x", Ind);
  351. }
  352. p += (this_ind_length+1);
  353. total_length -= (4 + this_ind_length);
  354. }
  355. } break;
  356. case MAN_INFO_IND:
  357. if (process_idi_info (pLib, (diva_man_var_header_t*)p)) {
  358. return (-1);
  359. }
  360. break;
  361. case MAN_EVENT_IND:
  362. if (process_idi_event (pLib, (diva_man_var_header_t*)p)) {
  363. return (-1);
  364. }
  365. break;
  366. case MAN_TRACE_IND:
  367. if (pLib->trace_on == 1) {
  368. /*
  369. Ignore first trace event that is result of
  370. EVENT_ON operation
  371. */
  372. pLib->trace_on++;
  373. } else {
  374. /*
  375. Delivery XLOG buffer to application
  376. */
  377. if (pLib->user_proc_table.trace_proc) {
  378. (*(pLib->user_proc_table.trace_proc))(pLib->user_proc_table.user_context,
  379. &pLib->instance, pLib->Adapter,
  380. p, pLib->e.R->PLength);
  381. }
  382. }
  383. break;
  384. default:
  385. diva_mnt_internal_dprintf (0, DLI_ERR, "Unknown IDI Ind: %02x", Ind);
  386. }
  387. }
  388. }
  389. }
  390. if ((ret = ScheduleNextTraceRequest(pLib))) {
  391. return (-1);
  392. }
  393. return (ret);
  394. }
  395. /*
  396. Internal state machine responsible for scheduling of requests
  397. */
  398. static int ScheduleNextTraceRequest (diva_strace_context_t* pLib) {
  399. char name[64];
  400. int ret = 0;
  401. int i;
  402. if (pLib->req_busy) {
  403. return (0);
  404. }
  405. if (pLib->removal_state == 1) {
  406. if (SuperTraceREMOVE (pLib->hAdapter)) {
  407. pLib->removal_state = 3;
  408. } else {
  409. pLib->req_busy = 1;
  410. pLib->removal_state = 2;
  411. }
  412. return (0);
  413. }
  414. if (pLib->removal_state) {
  415. return (0);
  416. }
  417. if (!pLib->general_b_ch_event) {
  418. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, "State\\B Event", pLib->buffer))) {
  419. return (-1);
  420. }
  421. pLib->general_b_ch_event = 1;
  422. pLib->req_busy = 1;
  423. return (0);
  424. }
  425. if (!pLib->general_fax_event) {
  426. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, "State\\FAX Event", pLib->buffer))) {
  427. return (-1);
  428. }
  429. pLib->general_fax_event = 1;
  430. pLib->req_busy = 1;
  431. return (0);
  432. }
  433. if (!pLib->general_mdm_event) {
  434. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, "State\\Modem Event", pLib->buffer))) {
  435. return (-1);
  436. }
  437. pLib->general_mdm_event = 1;
  438. pLib->req_busy = 1;
  439. return (0);
  440. }
  441. if (pLib->ChannelsTraceActive < pLib->Channels) {
  442. pLib->ChannelsTraceActive++;
  443. sprintf (name, "State\\B%d\\Line", pLib->ChannelsTraceActive);
  444. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) {
  445. pLib->ChannelsTraceActive--;
  446. return (-1);
  447. }
  448. pLib->req_busy = 1;
  449. return (0);
  450. }
  451. if (pLib->ModemTraceActive < pLib->Channels) {
  452. pLib->ModemTraceActive++;
  453. sprintf (name, "State\\B%d\\Modem\\Event", pLib->ModemTraceActive);
  454. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) {
  455. pLib->ModemTraceActive--;
  456. return (-1);
  457. }
  458. pLib->req_busy = 1;
  459. return (0);
  460. }
  461. if (pLib->FaxTraceActive < pLib->Channels) {
  462. pLib->FaxTraceActive++;
  463. sprintf (name, "State\\B%d\\FAX\\Event", pLib->FaxTraceActive);
  464. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) {
  465. pLib->FaxTraceActive--;
  466. return (-1);
  467. }
  468. pLib->req_busy = 1;
  469. return (0);
  470. }
  471. if (!pLib->trace_mask_init) {
  472. word tmp = 0x0000;
  473. if (SuperTraceWriteVar (pLib->hAdapter,
  474. pLib->buffer,
  475. "Trace\\Event Enable",
  476. &tmp,
  477. 0x87, /* MI_BITFLD */
  478. sizeof(tmp))) {
  479. return (-1);
  480. }
  481. pLib->trace_mask_init = 1;
  482. pLib->req_busy = 1;
  483. return (0);
  484. }
  485. if (!pLib->audio_trace_init) {
  486. dword tmp = 0x00000000;
  487. if (SuperTraceWriteVar (pLib->hAdapter,
  488. pLib->buffer,
  489. "Trace\\AudioCh# Enable",
  490. &tmp,
  491. 0x87, /* MI_BITFLD */
  492. sizeof(tmp))) {
  493. return (-1);
  494. }
  495. pLib->audio_trace_init = 2;
  496. pLib->req_busy = 1;
  497. return (0);
  498. }
  499. if (!pLib->bchannel_init) {
  500. dword tmp = 0x00000000;
  501. if (SuperTraceWriteVar (pLib->hAdapter,
  502. pLib->buffer,
  503. "Trace\\B-Ch# Enable",
  504. &tmp,
  505. 0x87, /* MI_BITFLD */
  506. sizeof(tmp))) {
  507. return (-1);
  508. }
  509. pLib->bchannel_init = 1;
  510. pLib->req_busy = 1;
  511. return (0);
  512. }
  513. if (!pLib->trace_length_init) {
  514. word tmp = 30;
  515. if (SuperTraceWriteVar (pLib->hAdapter,
  516. pLib->buffer,
  517. "Trace\\Max Log Length",
  518. &tmp,
  519. 0x82, /* MI_UINT */
  520. sizeof(tmp))) {
  521. return (-1);
  522. }
  523. pLib->trace_length_init = 1;
  524. pLib->req_busy = 1;
  525. return (0);
  526. }
  527. if (!pLib->trace_on) {
  528. if (SuperTraceTraceOnRequest (pLib->hAdapter,
  529. "Trace\\Log Buffer",
  530. pLib->buffer)) {
  531. return (-1);
  532. }
  533. pLib->trace_on = 1;
  534. pLib->req_busy = 1;
  535. return (0);
  536. }
  537. if (pLib->trace_event_mask != pLib->current_trace_event_mask) {
  538. if (SuperTraceWriteVar (pLib->hAdapter,
  539. pLib->buffer,
  540. "Trace\\Event Enable",
  541. &pLib->trace_event_mask,
  542. 0x87, /* MI_BITFLD */
  543. sizeof(pLib->trace_event_mask))) {
  544. return (-1);
  545. }
  546. pLib->current_trace_event_mask = pLib->trace_event_mask;
  547. pLib->req_busy = 1;
  548. return (0);
  549. }
  550. if ((pLib->audio_tap_pending >= 0) && (pLib->audio_tap_mask != pLib->current_audio_tap_mask)) {
  551. if (SuperTraceWriteVar (pLib->hAdapter,
  552. pLib->buffer,
  553. "Trace\\AudioCh# Enable",
  554. &pLib->audio_tap_mask,
  555. 0x87, /* MI_BITFLD */
  556. sizeof(pLib->audio_tap_mask))) {
  557. return (-1);
  558. }
  559. pLib->current_audio_tap_mask = pLib->audio_tap_mask;
  560. pLib->audio_tap_pending = 1;
  561. pLib->req_busy = 1;
  562. return (0);
  563. }
  564. if ((pLib->eye_pattern_pending >= 0) && (pLib->audio_tap_mask != pLib->current_eye_pattern_mask)) {
  565. if (SuperTraceWriteVar (pLib->hAdapter,
  566. pLib->buffer,
  567. "Trace\\EyeCh# Enable",
  568. &pLib->audio_tap_mask,
  569. 0x87, /* MI_BITFLD */
  570. sizeof(pLib->audio_tap_mask))) {
  571. return (-1);
  572. }
  573. pLib->current_eye_pattern_mask = pLib->audio_tap_mask;
  574. pLib->eye_pattern_pending = 1;
  575. pLib->req_busy = 1;
  576. return (0);
  577. }
  578. if (pLib->bchannel_trace_mask != pLib->current_bchannel_trace_mask) {
  579. if (SuperTraceWriteVar (pLib->hAdapter,
  580. pLib->buffer,
  581. "Trace\\B-Ch# Enable",
  582. &pLib->bchannel_trace_mask,
  583. 0x87, /* MI_BITFLD */
  584. sizeof(pLib->bchannel_trace_mask))) {
  585. return (-1);
  586. }
  587. pLib->current_bchannel_trace_mask = pLib->bchannel_trace_mask;
  588. pLib->req_busy = 1;
  589. return (0);
  590. }
  591. if (!pLib->trace_events_down) {
  592. if (SuperTraceTraceOnRequest (pLib->hAdapter,
  593. "Events Down",
  594. pLib->buffer)) {
  595. return (-1);
  596. }
  597. pLib->trace_events_down = 1;
  598. pLib->req_busy = 1;
  599. return (0);
  600. }
  601. if (!pLib->l1_trace) {
  602. if (SuperTraceTraceOnRequest (pLib->hAdapter,
  603. "State\\Layer1",
  604. pLib->buffer)) {
  605. return (-1);
  606. }
  607. pLib->l1_trace = 1;
  608. pLib->req_busy = 1;
  609. return (0);
  610. }
  611. if (!pLib->l2_trace) {
  612. if (SuperTraceTraceOnRequest (pLib->hAdapter,
  613. "State\\Layer2 No1",
  614. pLib->buffer)) {
  615. return (-1);
  616. }
  617. pLib->l2_trace = 1;
  618. pLib->req_busy = 1;
  619. return (0);
  620. }
  621. for (i = 0; i < 30; i++) {
  622. if (pLib->pending_line_status & (1L << i)) {
  623. sprintf (name, "State\\B%d", i+1);
  624. if (SuperTraceReadRequest (pLib->hAdapter, name, pLib->buffer)) {
  625. return (-1);
  626. }
  627. pLib->pending_line_status &= ~(1L << i);
  628. pLib->req_busy = 1;
  629. return (0);
  630. }
  631. if (pLib->pending_modem_status & (1L << i)) {
  632. sprintf (name, "State\\B%d\\Modem", i+1);
  633. if (SuperTraceReadRequest (pLib->hAdapter, name, pLib->buffer)) {
  634. return (-1);
  635. }
  636. pLib->pending_modem_status &= ~(1L << i);
  637. pLib->req_busy = 1;
  638. return (0);
  639. }
  640. if (pLib->pending_fax_status & (1L << i)) {
  641. sprintf (name, "State\\B%d\\FAX", i+1);
  642. if (SuperTraceReadRequest (pLib->hAdapter, name, pLib->buffer)) {
  643. return (-1);
  644. }
  645. pLib->pending_fax_status &= ~(1L << i);
  646. pLib->req_busy = 1;
  647. return (0);
  648. }
  649. if (pLib->clear_call_command & (1L << i)) {
  650. sprintf (name, "State\\B%d\\Clear Call", i+1);
  651. if (SuperTraceExecuteRequest (pLib->hAdapter, name, pLib->buffer)) {
  652. return (-1);
  653. }
  654. pLib->clear_call_command &= ~(1L << i);
  655. pLib->req_busy = 1;
  656. return (0);
  657. }
  658. }
  659. if (pLib->outgoing_ifc_stats) {
  660. if (SuperTraceReadRequest (pLib->hAdapter,
  661. "Statistics\\Outgoing Calls",
  662. pLib->buffer)) {
  663. return (-1);
  664. }
  665. pLib->outgoing_ifc_stats = 0;
  666. pLib->req_busy = 1;
  667. return (0);
  668. }
  669. if (pLib->incoming_ifc_stats) {
  670. if (SuperTraceReadRequest (pLib->hAdapter,
  671. "Statistics\\Incoming Calls",
  672. pLib->buffer)) {
  673. return (-1);
  674. }
  675. pLib->incoming_ifc_stats = 0;
  676. pLib->req_busy = 1;
  677. return (0);
  678. }
  679. if (pLib->modem_ifc_stats) {
  680. if (SuperTraceReadRequest (pLib->hAdapter,
  681. "Statistics\\Modem",
  682. pLib->buffer)) {
  683. return (-1);
  684. }
  685. pLib->modem_ifc_stats = 0;
  686. pLib->req_busy = 1;
  687. return (0);
  688. }
  689. if (pLib->fax_ifc_stats) {
  690. if (SuperTraceReadRequest (pLib->hAdapter,
  691. "Statistics\\FAX",
  692. pLib->buffer)) {
  693. return (-1);
  694. }
  695. pLib->fax_ifc_stats = 0;
  696. pLib->req_busy = 1;
  697. return (0);
  698. }
  699. if (pLib->b1_ifc_stats) {
  700. if (SuperTraceReadRequest (pLib->hAdapter,
  701. "Statistics\\B-Layer1",
  702. pLib->buffer)) {
  703. return (-1);
  704. }
  705. pLib->b1_ifc_stats = 0;
  706. pLib->req_busy = 1;
  707. return (0);
  708. }
  709. if (pLib->b2_ifc_stats) {
  710. if (SuperTraceReadRequest (pLib->hAdapter,
  711. "Statistics\\B-Layer2",
  712. pLib->buffer)) {
  713. return (-1);
  714. }
  715. pLib->b2_ifc_stats = 0;
  716. pLib->req_busy = 1;
  717. return (0);
  718. }
  719. if (pLib->d1_ifc_stats) {
  720. if (SuperTraceReadRequest (pLib->hAdapter,
  721. "Statistics\\D-Layer1",
  722. pLib->buffer)) {
  723. return (-1);
  724. }
  725. pLib->d1_ifc_stats = 0;
  726. pLib->req_busy = 1;
  727. return (0);
  728. }
  729. if (pLib->d2_ifc_stats) {
  730. if (SuperTraceReadRequest (pLib->hAdapter,
  731. "Statistics\\D-Layer2",
  732. pLib->buffer)) {
  733. return (-1);
  734. }
  735. pLib->d2_ifc_stats = 0;
  736. pLib->req_busy = 1;
  737. return (0);
  738. }
  739. if (!pLib->IncomingCallsCallsActive) {
  740. pLib->IncomingCallsCallsActive = 1;
  741. sprintf (name, "%s", "Statistics\\Incoming Calls\\Calls");
  742. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) {
  743. pLib->IncomingCallsCallsActive = 0;
  744. return (-1);
  745. }
  746. pLib->req_busy = 1;
  747. return (0);
  748. }
  749. if (!pLib->IncomingCallsConnectedActive) {
  750. pLib->IncomingCallsConnectedActive = 1;
  751. sprintf (name, "%s", "Statistics\\Incoming Calls\\Connected");
  752. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) {
  753. pLib->IncomingCallsConnectedActive = 0;
  754. return (-1);
  755. }
  756. pLib->req_busy = 1;
  757. return (0);
  758. }
  759. if (!pLib->OutgoingCallsCallsActive) {
  760. pLib->OutgoingCallsCallsActive = 1;
  761. sprintf (name, "%s", "Statistics\\Outgoing Calls\\Calls");
  762. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) {
  763. pLib->OutgoingCallsCallsActive = 0;
  764. return (-1);
  765. }
  766. pLib->req_busy = 1;
  767. return (0);
  768. }
  769. if (!pLib->OutgoingCallsConnectedActive) {
  770. pLib->OutgoingCallsConnectedActive = 1;
  771. sprintf (name, "%s", "Statistics\\Outgoing Calls\\Connected");
  772. if ((ret = SuperTraceTraceOnRequest(pLib->hAdapter, name, pLib->buffer))) {
  773. pLib->OutgoingCallsConnectedActive = 0;
  774. return (-1);
  775. }
  776. pLib->req_busy = 1;
  777. return (0);
  778. }
  779. return (0);
  780. }
  781. static int process_idi_event (diva_strace_context_t* pLib,
  782. diva_man_var_header_t* pVar) {
  783. const char* path = (char*)&pVar->path_length+1;
  784. char name[64];
  785. int i;
  786. if (!strncmp("State\\B Event", path, pVar->path_length)) {
  787. dword ch_id;
  788. if (!diva_trace_read_variable (pVar, &ch_id)) {
  789. if (!pLib->line_init_event && !pLib->pending_line_status) {
  790. for (i = 1; i <= pLib->Channels; i++) {
  791. diva_line_event(pLib, i);
  792. }
  793. return (0);
  794. } else if (ch_id && ch_id <= pLib->Channels) {
  795. return (diva_line_event(pLib, (int)ch_id));
  796. }
  797. return (0);
  798. }
  799. return (-1);
  800. }
  801. if (!strncmp("State\\FAX Event", path, pVar->path_length)) {
  802. dword ch_id;
  803. if (!diva_trace_read_variable (pVar, &ch_id)) {
  804. if (!pLib->pending_fax_status && !pLib->fax_init_event) {
  805. for (i = 1; i <= pLib->Channels; i++) {
  806. diva_fax_event(pLib, i);
  807. }
  808. return (0);
  809. } else if (ch_id && ch_id <= pLib->Channels) {
  810. return (diva_fax_event(pLib, (int)ch_id));
  811. }
  812. return (0);
  813. }
  814. return (-1);
  815. }
  816. if (!strncmp("State\\Modem Event", path, pVar->path_length)) {
  817. dword ch_id;
  818. if (!diva_trace_read_variable (pVar, &ch_id)) {
  819. if (!pLib->pending_modem_status && !pLib->modem_init_event) {
  820. for (i = 1; i <= pLib->Channels; i++) {
  821. diva_modem_event(pLib, i);
  822. }
  823. return (0);
  824. } else if (ch_id && ch_id <= pLib->Channels) {
  825. return (diva_modem_event(pLib, (int)ch_id));
  826. }
  827. return (0);
  828. }
  829. return (-1);
  830. }
  831. /*
  832. First look for Line Event
  833. */
  834. for (i = 1; i <= pLib->Channels; i++) {
  835. sprintf (name, "State\\B%d\\Line", i);
  836. if (find_var (pVar, name)) {
  837. return (diva_line_event(pLib, i));
  838. }
  839. }
  840. /*
  841. Look for Moden Progress Event
  842. */
  843. for (i = 1; i <= pLib->Channels; i++) {
  844. sprintf (name, "State\\B%d\\Modem\\Event", i);
  845. if (find_var (pVar, name)) {
  846. return (diva_modem_event (pLib, i));
  847. }
  848. }
  849. /*
  850. Look for Fax Event
  851. */
  852. for (i = 1; i <= pLib->Channels; i++) {
  853. sprintf (name, "State\\B%d\\FAX\\Event", i);
  854. if (find_var (pVar, name)) {
  855. return (diva_fax_event (pLib, i));
  856. }
  857. }
  858. /*
  859. Notification about loss of events
  860. */
  861. if (!strncmp("Events Down", path, pVar->path_length)) {
  862. if (pLib->trace_events_down == 1) {
  863. pLib->trace_events_down = 2;
  864. } else {
  865. diva_trace_error (pLib, 1, "Events Down", 0);
  866. }
  867. return (0);
  868. }
  869. if (!strncmp("State\\Layer1", path, pVar->path_length)) {
  870. diva_strace_read_asz (pVar, &pLib->lines[0].pInterface->Layer1[0]);
  871. if (pLib->l1_trace == 1) {
  872. pLib->l1_trace = 2;
  873. } else {
  874. diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_INTERFACE_CHANGE);
  875. }
  876. return (0);
  877. }
  878. if (!strncmp("State\\Layer2 No1", path, pVar->path_length)) {
  879. char* tmp = &pLib->lines[0].pInterface->Layer2[0];
  880. dword l2_state;
  881. if (diva_strace_read_uint(pVar, &l2_state))
  882. return -1;
  883. switch (l2_state) {
  884. case 0:
  885. strcpy (tmp, "Idle");
  886. break;
  887. case 1:
  888. strcpy (tmp, "Layer2 UP");
  889. break;
  890. case 2:
  891. strcpy (tmp, "Layer2 Disconnecting");
  892. break;
  893. case 3:
  894. strcpy (tmp, "Layer2 Connecting");
  895. break;
  896. case 4:
  897. strcpy (tmp, "SPID Initializing");
  898. break;
  899. case 5:
  900. strcpy (tmp, "SPID Initialised");
  901. break;
  902. case 6:
  903. strcpy (tmp, "Layer2 Connecting");
  904. break;
  905. case 7:
  906. strcpy (tmp, "Auto SPID Stopped");
  907. break;
  908. case 8:
  909. strcpy (tmp, "Auto SPID Idle");
  910. break;
  911. case 9:
  912. strcpy (tmp, "Auto SPID Requested");
  913. break;
  914. case 10:
  915. strcpy (tmp, "Auto SPID Delivery");
  916. break;
  917. case 11:
  918. strcpy (tmp, "Auto SPID Complete");
  919. break;
  920. default:
  921. sprintf (tmp, "U:%d", (int)l2_state);
  922. }
  923. if (pLib->l2_trace == 1) {
  924. pLib->l2_trace = 2;
  925. } else {
  926. diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_INTERFACE_CHANGE);
  927. }
  928. return (0);
  929. }
  930. if (!strncmp("Statistics\\Incoming Calls\\Calls", path, pVar->path_length) ||
  931. !strncmp("Statistics\\Incoming Calls\\Connected", path, pVar->path_length)) {
  932. return (SuperTraceGetIncomingCallStatistics (pLib));
  933. }
  934. if (!strncmp("Statistics\\Outgoing Calls\\Calls", path, pVar->path_length) ||
  935. !strncmp("Statistics\\Outgoing Calls\\Connected", path, pVar->path_length)) {
  936. return (SuperTraceGetOutgoingCallStatistics (pLib));
  937. }
  938. return (-1);
  939. }
  940. static int diva_line_event (diva_strace_context_t* pLib, int Channel) {
  941. pLib->pending_line_status |= (1L << (Channel-1));
  942. return (0);
  943. }
  944. static int diva_modem_event (diva_strace_context_t* pLib, int Channel) {
  945. pLib->pending_modem_status |= (1L << (Channel-1));
  946. return (0);
  947. }
  948. static int diva_fax_event (diva_strace_context_t* pLib, int Channel) {
  949. pLib->pending_fax_status |= (1L << (Channel-1));
  950. return (0);
  951. }
  952. /*
  953. Process INFO indications that arrive from the card
  954. Uses path of first I.E. to detect the source of the
  955. infication
  956. */
  957. static int process_idi_info (diva_strace_context_t* pLib,
  958. diva_man_var_header_t* pVar) {
  959. const char* path = (char*)&pVar->path_length+1;
  960. char name[64];
  961. int i, len;
  962. /*
  963. First look for Modem Status Info
  964. */
  965. for (i = pLib->Channels; i > 0; i--) {
  966. len = sprintf (name, "State\\B%d\\Modem", i);
  967. if (!strncmp(name, path, len)) {
  968. return (diva_modem_info (pLib, i, pVar));
  969. }
  970. }
  971. /*
  972. Look for Fax Status Info
  973. */
  974. for (i = pLib->Channels; i > 0; i--) {
  975. len = sprintf (name, "State\\B%d\\FAX", i);
  976. if (!strncmp(name, path, len)) {
  977. return (diva_fax_info (pLib, i, pVar));
  978. }
  979. }
  980. /*
  981. Look for Line Status Info
  982. */
  983. for (i = pLib->Channels; i > 0; i--) {
  984. len = sprintf (name, "State\\B%d", i);
  985. if (!strncmp(name, path, len)) {
  986. return (diva_line_info (pLib, i, pVar));
  987. }
  988. }
  989. if (!diva_ifc_statistics (pLib, pVar)) {
  990. return (0);
  991. }
  992. return (-1);
  993. }
  994. /*
  995. MODEM INSTANCE STATE UPDATE
  996. Update Modem Status Information and issue notification to user,
  997. that will inform about change in the state of modem instance, that is
  998. associuated with this channel
  999. */
  1000. static int diva_modem_info (diva_strace_context_t* pLib,
  1001. int Channel,
  1002. diva_man_var_header_t* pVar) {
  1003. diva_man_var_header_t* cur;
  1004. int i, nr = Channel - 1;
  1005. for (i = pLib->modem_parse_entry_first[nr];
  1006. i <= pLib->modem_parse_entry_last[nr]; i++) {
  1007. if ((cur = find_var (pVar, pLib->parse_table[i].path))) {
  1008. if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) {
  1009. diva_trace_error (pLib, -3 , __FILE__, __LINE__);
  1010. return (-1);
  1011. }
  1012. } else {
  1013. diva_trace_error (pLib, -2 , __FILE__, __LINE__);
  1014. return (-1);
  1015. }
  1016. }
  1017. /*
  1018. We do not use first event to notify user - this is the event that is
  1019. generated as result of EVENT ON operation and is used only to initialize
  1020. internal variables of application
  1021. */
  1022. if (pLib->modem_init_event & (1L << nr)) {
  1023. diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_MODEM_CHANGE);
  1024. } else {
  1025. pLib->modem_init_event |= (1L << nr);
  1026. }
  1027. return (0);
  1028. }
  1029. static int diva_fax_info (diva_strace_context_t* pLib,
  1030. int Channel,
  1031. diva_man_var_header_t* pVar) {
  1032. diva_man_var_header_t* cur;
  1033. int i, nr = Channel - 1;
  1034. for (i = pLib->fax_parse_entry_first[nr];
  1035. i <= pLib->fax_parse_entry_last[nr]; i++) {
  1036. if ((cur = find_var (pVar, pLib->parse_table[i].path))) {
  1037. if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) {
  1038. diva_trace_error (pLib, -3 , __FILE__, __LINE__);
  1039. return (-1);
  1040. }
  1041. } else {
  1042. diva_trace_error (pLib, -2 , __FILE__, __LINE__);
  1043. return (-1);
  1044. }
  1045. }
  1046. /*
  1047. We do not use first event to notify user - this is the event that is
  1048. generated as result of EVENT ON operation and is used only to initialize
  1049. internal variables of application
  1050. */
  1051. if (pLib->fax_init_event & (1L << nr)) {
  1052. diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_FAX_CHANGE);
  1053. } else {
  1054. pLib->fax_init_event |= (1L << nr);
  1055. }
  1056. return (0);
  1057. }
  1058. /*
  1059. LINE STATE UPDATE
  1060. Update Line Status Information and issue notification to user,
  1061. that will inform about change in the line state.
  1062. */
  1063. static int diva_line_info (diva_strace_context_t* pLib,
  1064. int Channel,
  1065. diva_man_var_header_t* pVar) {
  1066. diva_man_var_header_t* cur;
  1067. int i, nr = Channel - 1;
  1068. for (i = pLib->line_parse_entry_first[nr];
  1069. i <= pLib->line_parse_entry_last[nr]; i++) {
  1070. if ((cur = find_var (pVar, pLib->parse_table[i].path))) {
  1071. if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) {
  1072. diva_trace_error (pLib, -3 , __FILE__, __LINE__);
  1073. return (-1);
  1074. }
  1075. } else {
  1076. diva_trace_error (pLib, -2 , __FILE__, __LINE__);
  1077. return (-1);
  1078. }
  1079. }
  1080. /*
  1081. We do not use first event to notify user - this is the event that is
  1082. generated as result of EVENT ON operation and is used only to initialize
  1083. internal variables of application
  1084. Exception is is if the line is "online". In this case we have to notify
  1085. user about this confition.
  1086. */
  1087. if (pLib->line_init_event & (1L << nr)) {
  1088. diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE);
  1089. } else {
  1090. pLib->line_init_event |= (1L << nr);
  1091. if (strcmp (&pLib->lines[nr].Line[0], "Idle")) {
  1092. diva_trace_notify_user (pLib, nr, DIVA_SUPER_TRACE_NOTIFY_LINE_CHANGE);
  1093. }
  1094. }
  1095. return (0);
  1096. }
  1097. /*
  1098. Move position to next vatianle in the chain
  1099. */
  1100. static diva_man_var_header_t* get_next_var (diva_man_var_header_t* pVar) {
  1101. byte* msg = (byte*)pVar;
  1102. byte* start;
  1103. int msg_length;
  1104. if (*msg != ESC) return NULL;
  1105. start = msg + 2;
  1106. msg_length = *(msg+1);
  1107. msg = (start+msg_length);
  1108. if (*msg != ESC) return NULL;
  1109. return ((diva_man_var_header_t*)msg);
  1110. }
  1111. /*
  1112. Move position to variable with given name
  1113. */
  1114. static diva_man_var_header_t* find_var (diva_man_var_header_t* pVar,
  1115. const char* name) {
  1116. const char* path;
  1117. do {
  1118. path = (char*)&pVar->path_length+1;
  1119. if (!strncmp (name, path, pVar->path_length)) {
  1120. break;
  1121. }
  1122. } while ((pVar = get_next_var (pVar)));
  1123. return (pVar);
  1124. }
  1125. static void diva_create_line_parse_table (diva_strace_context_t* pLib,
  1126. int Channel) {
  1127. diva_trace_line_state_t* pLine = &pLib->lines[Channel];
  1128. int nr = Channel+1;
  1129. if ((pLib->cur_parse_entry + LINE_PARSE_ENTRIES) >= pLib->parse_entries) {
  1130. diva_trace_error (pLib, -1, __FILE__, __LINE__);
  1131. return;
  1132. }
  1133. pLine->ChannelNumber = nr;
  1134. pLib->line_parse_entry_first[Channel] = pLib->cur_parse_entry;
  1135. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1136. "State\\B%d\\Framing", nr);
  1137. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Framing[0];
  1138. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1139. "State\\B%d\\Line", nr);
  1140. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Line[0];
  1141. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1142. "State\\B%d\\Layer2", nr);
  1143. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Layer2[0];
  1144. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1145. "State\\B%d\\Layer3", nr);
  1146. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Layer3[0];
  1147. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1148. "State\\B%d\\Remote Address", nr);
  1149. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1150. &pLine->RemoteAddress[0];
  1151. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1152. "State\\B%d\\Remote SubAddr", nr);
  1153. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1154. &pLine->RemoteSubAddress[0];
  1155. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1156. "State\\B%d\\Local Address", nr);
  1157. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1158. &pLine->LocalAddress[0];
  1159. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1160. "State\\B%d\\Local SubAddr", nr);
  1161. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1162. &pLine->LocalSubAddress[0];
  1163. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1164. "State\\B%d\\BC", nr);
  1165. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->call_BC;
  1166. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1167. "State\\B%d\\HLC", nr);
  1168. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->call_HLC;
  1169. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1170. "State\\B%d\\LLC", nr);
  1171. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->call_LLC;
  1172. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1173. "State\\B%d\\Charges", nr);
  1174. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->Charges;
  1175. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1176. "State\\B%d\\Call Reference", nr);
  1177. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->CallReference;
  1178. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1179. "State\\B%d\\Last Disc Cause", nr);
  1180. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1181. &pLine->LastDisconnecCause;
  1182. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1183. "State\\B%d\\User ID", nr);
  1184. pLib->parse_table[pLib->cur_parse_entry++].variable = &pLine->UserID[0];
  1185. pLib->line_parse_entry_last[Channel] = pLib->cur_parse_entry - 1;
  1186. }
  1187. static void diva_create_fax_parse_table (diva_strace_context_t* pLib,
  1188. int Channel) {
  1189. diva_trace_fax_state_t* pFax = &pLib->lines[Channel].fax;
  1190. int nr = Channel+1;
  1191. if ((pLib->cur_parse_entry + FAX_PARSE_ENTRIES) >= pLib->parse_entries) {
  1192. diva_trace_error (pLib, -1, __FILE__, __LINE__);
  1193. return;
  1194. }
  1195. pFax->ChannelNumber = nr;
  1196. pLib->fax_parse_entry_first[Channel] = pLib->cur_parse_entry;
  1197. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1198. "State\\B%d\\FAX\\Event", nr);
  1199. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Event;
  1200. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1201. "State\\B%d\\FAX\\Page Counter", nr);
  1202. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Page_Counter;
  1203. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1204. "State\\B%d\\FAX\\Features", nr);
  1205. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Features;
  1206. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1207. "State\\B%d\\FAX\\Station ID", nr);
  1208. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Station_ID[0];
  1209. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1210. "State\\B%d\\FAX\\Subaddress", nr);
  1211. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Subaddress[0];
  1212. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1213. "State\\B%d\\FAX\\Password", nr);
  1214. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Password[0];
  1215. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1216. "State\\B%d\\FAX\\Speed", nr);
  1217. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Speed;
  1218. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1219. "State\\B%d\\FAX\\Resolution", nr);
  1220. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Resolution;
  1221. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1222. "State\\B%d\\FAX\\Paper Width", nr);
  1223. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Paper_Width;
  1224. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1225. "State\\B%d\\FAX\\Paper Length", nr);
  1226. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Paper_Length;
  1227. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1228. "State\\B%d\\FAX\\Scanline Time", nr);
  1229. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Scanline_Time;
  1230. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1231. "State\\B%d\\FAX\\Disc Reason", nr);
  1232. pLib->parse_table[pLib->cur_parse_entry++].variable = &pFax->Disc_Reason;
  1233. pLib->fax_parse_entry_last[Channel] = pLib->cur_parse_entry - 1;
  1234. }
  1235. static void diva_create_modem_parse_table (diva_strace_context_t* pLib,
  1236. int Channel) {
  1237. diva_trace_modem_state_t* pModem = &pLib->lines[Channel].modem;
  1238. int nr = Channel+1;
  1239. if ((pLib->cur_parse_entry + MODEM_PARSE_ENTRIES) >= pLib->parse_entries) {
  1240. diva_trace_error (pLib, -1, __FILE__, __LINE__);
  1241. return;
  1242. }
  1243. pModem->ChannelNumber = nr;
  1244. pLib->modem_parse_entry_first[Channel] = pLib->cur_parse_entry;
  1245. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1246. "State\\B%d\\Modem\\Event", nr);
  1247. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->Event;
  1248. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1249. "State\\B%d\\Modem\\Norm", nr);
  1250. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->Norm;
  1251. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1252. "State\\B%d\\Modem\\Options", nr);
  1253. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->Options;
  1254. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1255. "State\\B%d\\Modem\\TX Speed", nr);
  1256. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->TxSpeed;
  1257. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1258. "State\\B%d\\Modem\\RX Speed", nr);
  1259. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RxSpeed;
  1260. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1261. "State\\B%d\\Modem\\Roundtrip ms", nr);
  1262. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RoundtripMsec;
  1263. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1264. "State\\B%d\\Modem\\Symbol Rate", nr);
  1265. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->SymbolRate;
  1266. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1267. "State\\B%d\\Modem\\RX Level dBm", nr);
  1268. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RxLeveldBm;
  1269. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1270. "State\\B%d\\Modem\\Echo Level dBm", nr);
  1271. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->EchoLeveldBm;
  1272. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1273. "State\\B%d\\Modem\\SNR dB", nr);
  1274. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->SNRdb;
  1275. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1276. "State\\B%d\\Modem\\MAE", nr);
  1277. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->MAE;
  1278. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1279. "State\\B%d\\Modem\\Local Retrains", nr);
  1280. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->LocalRetrains;
  1281. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1282. "State\\B%d\\Modem\\Remote Retrains", nr);
  1283. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RemoteRetrains;
  1284. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1285. "State\\B%d\\Modem\\Local Resyncs", nr);
  1286. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->LocalResyncs;
  1287. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1288. "State\\B%d\\Modem\\Remote Resyncs", nr);
  1289. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->RemoteResyncs;
  1290. sprintf (pLib->parse_table[pLib->cur_parse_entry].path,
  1291. "State\\B%d\\Modem\\Disc Reason", nr);
  1292. pLib->parse_table[pLib->cur_parse_entry++].variable = &pModem->DiscReason;
  1293. pLib->modem_parse_entry_last[Channel] = pLib->cur_parse_entry - 1;
  1294. }
  1295. static void diva_create_parse_table (diva_strace_context_t* pLib) {
  1296. int i;
  1297. for (i = 0; i < pLib->Channels; i++) {
  1298. diva_create_line_parse_table (pLib, i);
  1299. diva_create_modem_parse_table (pLib, i);
  1300. diva_create_fax_parse_table (pLib, i);
  1301. }
  1302. pLib->statistic_parse_first = pLib->cur_parse_entry;
  1303. /*
  1304. Outgoing Calls
  1305. */
  1306. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1307. "Statistics\\Outgoing Calls\\Calls");
  1308. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1309. &pLib->InterfaceStat.outg.Calls;
  1310. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1311. "Statistics\\Outgoing Calls\\Connected");
  1312. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1313. &pLib->InterfaceStat.outg.Connected;
  1314. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1315. "Statistics\\Outgoing Calls\\User Busy");
  1316. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1317. &pLib->InterfaceStat.outg.User_Busy;
  1318. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1319. "Statistics\\Outgoing Calls\\No Answer");
  1320. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1321. &pLib->InterfaceStat.outg.No_Answer;
  1322. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1323. "Statistics\\Outgoing Calls\\Wrong Number");
  1324. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1325. &pLib->InterfaceStat.outg.Wrong_Number;
  1326. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1327. "Statistics\\Outgoing Calls\\Call Rejected");
  1328. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1329. &pLib->InterfaceStat.outg.Call_Rejected;
  1330. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1331. "Statistics\\Outgoing Calls\\Other Failures");
  1332. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1333. &pLib->InterfaceStat.outg.Other_Failures;
  1334. /*
  1335. Incoming Calls
  1336. */
  1337. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1338. "Statistics\\Incoming Calls\\Calls");
  1339. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1340. &pLib->InterfaceStat.inc.Calls;
  1341. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1342. "Statistics\\Incoming Calls\\Connected");
  1343. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1344. &pLib->InterfaceStat.inc.Connected;
  1345. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1346. "Statistics\\Incoming Calls\\User Busy");
  1347. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1348. &pLib->InterfaceStat.inc.User_Busy;
  1349. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1350. "Statistics\\Incoming Calls\\Call Rejected");
  1351. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1352. &pLib->InterfaceStat.inc.Call_Rejected;
  1353. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1354. "Statistics\\Incoming Calls\\Wrong Number");
  1355. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1356. &pLib->InterfaceStat.inc.Wrong_Number;
  1357. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1358. "Statistics\\Incoming Calls\\Incompatible Dst");
  1359. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1360. &pLib->InterfaceStat.inc.Incompatible_Dst;
  1361. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1362. "Statistics\\Incoming Calls\\Out of Order");
  1363. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1364. &pLib->InterfaceStat.inc.Out_of_Order;
  1365. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1366. "Statistics\\Incoming Calls\\Ignored");
  1367. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1368. &pLib->InterfaceStat.inc.Ignored;
  1369. /*
  1370. Modem Statistics
  1371. */
  1372. pLib->mdm_statistic_parse_first = pLib->cur_parse_entry;
  1373. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1374. "Statistics\\Modem\\Disc Normal");
  1375. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1376. &pLib->InterfaceStat.mdm.Disc_Normal;
  1377. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1378. "Statistics\\Modem\\Disc Unspecified");
  1379. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1380. &pLib->InterfaceStat.mdm.Disc_Unspecified;
  1381. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1382. "Statistics\\Modem\\Disc Busy Tone");
  1383. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1384. &pLib->InterfaceStat.mdm.Disc_Busy_Tone;
  1385. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1386. "Statistics\\Modem\\Disc Congestion");
  1387. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1388. &pLib->InterfaceStat.mdm.Disc_Congestion;
  1389. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1390. "Statistics\\Modem\\Disc Carr. Wait");
  1391. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1392. &pLib->InterfaceStat.mdm.Disc_Carr_Wait;
  1393. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1394. "Statistics\\Modem\\Disc Trn Timeout");
  1395. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1396. &pLib->InterfaceStat.mdm.Disc_Trn_Timeout;
  1397. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1398. "Statistics\\Modem\\Disc Incompat.");
  1399. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1400. &pLib->InterfaceStat.mdm.Disc_Incompat;
  1401. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1402. "Statistics\\Modem\\Disc Frame Rej.");
  1403. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1404. &pLib->InterfaceStat.mdm.Disc_Frame_Rej;
  1405. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1406. "Statistics\\Modem\\Disc V42bis");
  1407. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1408. &pLib->InterfaceStat.mdm.Disc_V42bis;
  1409. pLib->mdm_statistic_parse_last = pLib->cur_parse_entry - 1;
  1410. /*
  1411. Fax Statistics
  1412. */
  1413. pLib->fax_statistic_parse_first = pLib->cur_parse_entry;
  1414. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1415. "Statistics\\FAX\\Disc Normal");
  1416. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1417. &pLib->InterfaceStat.fax.Disc_Normal;
  1418. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1419. "Statistics\\FAX\\Disc Not Ident.");
  1420. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1421. &pLib->InterfaceStat.fax.Disc_Not_Ident;
  1422. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1423. "Statistics\\FAX\\Disc No Response");
  1424. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1425. &pLib->InterfaceStat.fax.Disc_No_Response;
  1426. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1427. "Statistics\\FAX\\Disc Retries");
  1428. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1429. &pLib->InterfaceStat.fax.Disc_Retries;
  1430. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1431. "Statistics\\FAX\\Disc Unexp. Msg.");
  1432. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1433. &pLib->InterfaceStat.fax.Disc_Unexp_Msg;
  1434. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1435. "Statistics\\FAX\\Disc No Polling.");
  1436. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1437. &pLib->InterfaceStat.fax.Disc_No_Polling;
  1438. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1439. "Statistics\\FAX\\Disc Training");
  1440. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1441. &pLib->InterfaceStat.fax.Disc_Training;
  1442. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1443. "Statistics\\FAX\\Disc Unexpected");
  1444. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1445. &pLib->InterfaceStat.fax.Disc_Unexpected;
  1446. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1447. "Statistics\\FAX\\Disc Application");
  1448. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1449. &pLib->InterfaceStat.fax.Disc_Application;
  1450. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1451. "Statistics\\FAX\\Disc Incompat.");
  1452. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1453. &pLib->InterfaceStat.fax.Disc_Incompat;
  1454. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1455. "Statistics\\FAX\\Disc No Command");
  1456. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1457. &pLib->InterfaceStat.fax.Disc_No_Command;
  1458. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1459. "Statistics\\FAX\\Disc Long Msg");
  1460. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1461. &pLib->InterfaceStat.fax.Disc_Long_Msg;
  1462. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1463. "Statistics\\FAX\\Disc Supervisor");
  1464. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1465. &pLib->InterfaceStat.fax.Disc_Supervisor;
  1466. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1467. "Statistics\\FAX\\Disc SUB SEP PWD");
  1468. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1469. &pLib->InterfaceStat.fax.Disc_SUB_SEP_PWD;
  1470. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1471. "Statistics\\FAX\\Disc Invalid Msg");
  1472. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1473. &pLib->InterfaceStat.fax.Disc_Invalid_Msg;
  1474. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1475. "Statistics\\FAX\\Disc Page Coding");
  1476. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1477. &pLib->InterfaceStat.fax.Disc_Page_Coding;
  1478. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1479. "Statistics\\FAX\\Disc App Timeout");
  1480. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1481. &pLib->InterfaceStat.fax.Disc_App_Timeout;
  1482. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1483. "Statistics\\FAX\\Disc Unspecified");
  1484. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1485. &pLib->InterfaceStat.fax.Disc_Unspecified;
  1486. pLib->fax_statistic_parse_last = pLib->cur_parse_entry - 1;
  1487. /*
  1488. B-Layer1"
  1489. */
  1490. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1491. "Statistics\\B-Layer1\\X-Frames");
  1492. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1493. &pLib->InterfaceStat.b1.X_Frames;
  1494. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1495. "Statistics\\B-Layer1\\X-Bytes");
  1496. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1497. &pLib->InterfaceStat.b1.X_Bytes;
  1498. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1499. "Statistics\\B-Layer1\\X-Errors");
  1500. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1501. &pLib->InterfaceStat.b1.X_Errors;
  1502. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1503. "Statistics\\B-Layer1\\R-Frames");
  1504. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1505. &pLib->InterfaceStat.b1.R_Frames;
  1506. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1507. "Statistics\\B-Layer1\\R-Bytes");
  1508. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1509. &pLib->InterfaceStat.b1.R_Bytes;
  1510. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1511. "Statistics\\B-Layer1\\R-Errors");
  1512. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1513. &pLib->InterfaceStat.b1.R_Errors;
  1514. /*
  1515. B-Layer2
  1516. */
  1517. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1518. "Statistics\\B-Layer2\\X-Frames");
  1519. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1520. &pLib->InterfaceStat.b2.X_Frames;
  1521. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1522. "Statistics\\B-Layer2\\X-Bytes");
  1523. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1524. &pLib->InterfaceStat.b2.X_Bytes;
  1525. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1526. "Statistics\\B-Layer2\\X-Errors");
  1527. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1528. &pLib->InterfaceStat.b2.X_Errors;
  1529. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1530. "Statistics\\B-Layer2\\R-Frames");
  1531. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1532. &pLib->InterfaceStat.b2.R_Frames;
  1533. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1534. "Statistics\\B-Layer2\\R-Bytes");
  1535. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1536. &pLib->InterfaceStat.b2.R_Bytes;
  1537. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1538. "Statistics\\B-Layer2\\R-Errors");
  1539. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1540. &pLib->InterfaceStat.b2.R_Errors;
  1541. /*
  1542. D-Layer1
  1543. */
  1544. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1545. "Statistics\\D-Layer1\\X-Frames");
  1546. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1547. &pLib->InterfaceStat.d1.X_Frames;
  1548. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1549. "Statistics\\D-Layer1\\X-Bytes");
  1550. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1551. &pLib->InterfaceStat.d1.X_Bytes;
  1552. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1553. "Statistics\\D-Layer1\\X-Errors");
  1554. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1555. &pLib->InterfaceStat.d1.X_Errors;
  1556. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1557. "Statistics\\D-Layer1\\R-Frames");
  1558. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1559. &pLib->InterfaceStat.d1.R_Frames;
  1560. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1561. "Statistics\\D-Layer1\\R-Bytes");
  1562. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1563. &pLib->InterfaceStat.d1.R_Bytes;
  1564. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1565. "Statistics\\D-Layer1\\R-Errors");
  1566. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1567. &pLib->InterfaceStat.d1.R_Errors;
  1568. /*
  1569. D-Layer2
  1570. */
  1571. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1572. "Statistics\\D-Layer2\\X-Frames");
  1573. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1574. &pLib->InterfaceStat.d2.X_Frames;
  1575. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1576. "Statistics\\D-Layer2\\X-Bytes");
  1577. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1578. &pLib->InterfaceStat.d2.X_Bytes;
  1579. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1580. "Statistics\\D-Layer2\\X-Errors");
  1581. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1582. &pLib->InterfaceStat.d2.X_Errors;
  1583. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1584. "Statistics\\D-Layer2\\R-Frames");
  1585. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1586. &pLib->InterfaceStat.d2.R_Frames;
  1587. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1588. "Statistics\\D-Layer2\\R-Bytes");
  1589. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1590. &pLib->InterfaceStat.d2.R_Bytes;
  1591. strcpy (pLib->parse_table[pLib->cur_parse_entry].path,
  1592. "Statistics\\D-Layer2\\R-Errors");
  1593. pLib->parse_table[pLib->cur_parse_entry++].variable = \
  1594. &pLib->InterfaceStat.d2.R_Errors;
  1595. pLib->statistic_parse_last = pLib->cur_parse_entry - 1;
  1596. }
  1597. static void diva_trace_error (diva_strace_context_t* pLib,
  1598. int error, const char* file, int line) {
  1599. if (pLib->user_proc_table.error_notify_proc) {
  1600. (*(pLib->user_proc_table.error_notify_proc))(\
  1601. pLib->user_proc_table.user_context,
  1602. &pLib->instance, pLib->Adapter,
  1603. error, file, line);
  1604. }
  1605. }
  1606. /*
  1607. Delivery notification to user
  1608. */
  1609. static void diva_trace_notify_user (diva_strace_context_t* pLib,
  1610. int Channel,
  1611. int notify_subject) {
  1612. if (pLib->user_proc_table.notify_proc) {
  1613. (*(pLib->user_proc_table.notify_proc))(pLib->user_proc_table.user_context,
  1614. &pLib->instance,
  1615. pLib->Adapter,
  1616. &pLib->lines[Channel],
  1617. notify_subject);
  1618. }
  1619. }
  1620. /*
  1621. Read variable value to they destination based on the variable type
  1622. */
  1623. static int diva_trace_read_variable (diva_man_var_header_t* pVar,
  1624. void* variable) {
  1625. switch (pVar->type) {
  1626. case 0x03: /* MI_ASCIIZ - syting */
  1627. return (diva_strace_read_asz (pVar, (char*)variable));
  1628. case 0x04: /* MI_ASCII - string */
  1629. return (diva_strace_read_asc (pVar, (char*)variable));
  1630. case 0x05: /* MI_NUMBER - counted sequence of bytes */
  1631. return (diva_strace_read_ie (pVar, (diva_trace_ie_t*)variable));
  1632. case 0x81: /* MI_INT - signed integer */
  1633. return (diva_strace_read_int (pVar, (int*)variable));
  1634. case 0x82: /* MI_UINT - unsigned integer */
  1635. return (diva_strace_read_uint (pVar, (dword*)variable));
  1636. case 0x83: /* MI_HINT - unsigned integer, hex representetion */
  1637. return (diva_strace_read_uint (pVar, (dword*)variable));
  1638. case 0x87: /* MI_BITFLD - unsigned integer, bit representation */
  1639. return (diva_strace_read_uint (pVar, (dword*)variable));
  1640. }
  1641. /*
  1642. This type of variable is not handled, indicate error
  1643. Or one problem in management interface, or in application recodeing
  1644. table, or this application should handle it.
  1645. */
  1646. return (-1);
  1647. }
  1648. /*
  1649. Read signed integer to destination
  1650. */
  1651. static int diva_strace_read_int (diva_man_var_header_t* pVar, int* var) {
  1652. byte* ptr = (char*)&pVar->path_length;
  1653. int value;
  1654. ptr += (pVar->path_length + 1);
  1655. switch (pVar->value_length) {
  1656. case 1:
  1657. value = *(char*)ptr;
  1658. break;
  1659. case 2:
  1660. value = (short)GET_WORD(ptr);
  1661. break;
  1662. case 4:
  1663. value = (int)GET_DWORD(ptr);
  1664. break;
  1665. default:
  1666. return (-1);
  1667. }
  1668. *var = value;
  1669. return (0);
  1670. }
  1671. static int diva_strace_read_uint (diva_man_var_header_t* pVar, dword* var) {
  1672. byte* ptr = (char*)&pVar->path_length;
  1673. dword value;
  1674. ptr += (pVar->path_length + 1);
  1675. switch (pVar->value_length) {
  1676. case 1:
  1677. value = (byte)(*ptr);
  1678. break;
  1679. case 2:
  1680. value = (word)GET_WORD(ptr);
  1681. break;
  1682. case 3:
  1683. value = (dword)GET_DWORD(ptr);
  1684. value &= 0x00ffffff;
  1685. break;
  1686. case 4:
  1687. value = (dword)GET_DWORD(ptr);
  1688. break;
  1689. default:
  1690. return (-1);
  1691. }
  1692. *var = value;
  1693. return (0);
  1694. }
  1695. /*
  1696. Read zero terminated ASCII string
  1697. */
  1698. static int diva_strace_read_asz (diva_man_var_header_t* pVar, char* var) {
  1699. char* ptr = (char*)&pVar->path_length;
  1700. int length;
  1701. ptr += (pVar->path_length + 1);
  1702. if (!(length = pVar->value_length)) {
  1703. length = strlen (ptr);
  1704. }
  1705. memcpy (var, ptr, length);
  1706. var[length] = 0;
  1707. return (0);
  1708. }
  1709. /*
  1710. Read counted (with leading length byte) ASCII string
  1711. */
  1712. static int diva_strace_read_asc (diva_man_var_header_t* pVar, char* var) {
  1713. char* ptr = (char*)&pVar->path_length;
  1714. ptr += (pVar->path_length + 1);
  1715. memcpy (var, ptr+1, *ptr);
  1716. var[(int)*ptr] = 0;
  1717. return (0);
  1718. }
  1719. /*
  1720. Read one information element - i.e. one string of byte values with
  1721. one length byte in front
  1722. */
  1723. static int diva_strace_read_ie (diva_man_var_header_t* pVar,
  1724. diva_trace_ie_t* var) {
  1725. char* ptr = (char*)&pVar->path_length;
  1726. ptr += (pVar->path_length + 1);
  1727. var->length = *ptr;
  1728. memcpy (&var->data[0], ptr+1, *ptr);
  1729. return (0);
  1730. }
  1731. static int SuperTraceSetAudioTap (void* hLib, int Channel, int on) {
  1732. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1733. if ((Channel < 1) || (Channel > pLib->Channels)) {
  1734. return (-1);
  1735. }
  1736. Channel--;
  1737. if (on) {
  1738. pLib->audio_tap_mask |= (1L << Channel);
  1739. } else {
  1740. pLib->audio_tap_mask &= ~(1L << Channel);
  1741. }
  1742. /*
  1743. EYE patterns have TM_M_DATA set as additional
  1744. condition
  1745. */
  1746. if (pLib->audio_tap_mask) {
  1747. pLib->trace_event_mask |= TM_M_DATA;
  1748. } else {
  1749. pLib->trace_event_mask &= ~TM_M_DATA;
  1750. }
  1751. return (ScheduleNextTraceRequest (pLib));
  1752. }
  1753. static int SuperTraceSetBChannel (void* hLib, int Channel, int on) {
  1754. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1755. if ((Channel < 1) || (Channel > pLib->Channels)) {
  1756. return (-1);
  1757. }
  1758. Channel--;
  1759. if (on) {
  1760. pLib->bchannel_trace_mask |= (1L << Channel);
  1761. } else {
  1762. pLib->bchannel_trace_mask &= ~(1L << Channel);
  1763. }
  1764. return (ScheduleNextTraceRequest (pLib));
  1765. }
  1766. static int SuperTraceSetDChannel (void* hLib, int on) {
  1767. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1768. if (on) {
  1769. pLib->trace_event_mask |= (TM_D_CHAN | TM_C_COMM | TM_DL_ERR | TM_LAYER1);
  1770. } else {
  1771. pLib->trace_event_mask &= ~(TM_D_CHAN | TM_C_COMM | TM_DL_ERR | TM_LAYER1);
  1772. }
  1773. return (ScheduleNextTraceRequest (pLib));
  1774. }
  1775. static int SuperTraceSetInfo (void* hLib, int on) {
  1776. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1777. if (on) {
  1778. pLib->trace_event_mask |= TM_STRING;
  1779. } else {
  1780. pLib->trace_event_mask &= ~TM_STRING;
  1781. }
  1782. return (ScheduleNextTraceRequest (pLib));
  1783. }
  1784. static int SuperTraceClearCall (void* hLib, int Channel) {
  1785. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1786. if ((Channel < 1) || (Channel > pLib->Channels)) {
  1787. return (-1);
  1788. }
  1789. Channel--;
  1790. pLib->clear_call_command |= (1L << Channel);
  1791. return (ScheduleNextTraceRequest (pLib));
  1792. }
  1793. /*
  1794. Parse and update cumulative statistice
  1795. */
  1796. static int diva_ifc_statistics (diva_strace_context_t* pLib,
  1797. diva_man_var_header_t* pVar) {
  1798. diva_man_var_header_t* cur;
  1799. int i, one_updated = 0, mdm_updated = 0, fax_updated = 0;
  1800. for (i = pLib->statistic_parse_first; i <= pLib->statistic_parse_last; i++) {
  1801. if ((cur = find_var (pVar, pLib->parse_table[i].path))) {
  1802. if (diva_trace_read_variable (cur, pLib->parse_table[i].variable)) {
  1803. diva_trace_error (pLib, -3 , __FILE__, __LINE__);
  1804. return (-1);
  1805. }
  1806. one_updated = 1;
  1807. if ((i >= pLib->mdm_statistic_parse_first) && (i <= pLib->mdm_statistic_parse_last)) {
  1808. mdm_updated = 1;
  1809. }
  1810. if ((i >= pLib->fax_statistic_parse_first) && (i <= pLib->fax_statistic_parse_last)) {
  1811. fax_updated = 1;
  1812. }
  1813. }
  1814. }
  1815. /*
  1816. We do not use first event to notify user - this is the event that is
  1817. generated as result of EVENT ON operation and is used only to initialize
  1818. internal variables of application
  1819. */
  1820. if (mdm_updated) {
  1821. diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_NOTIFY_MDM_STAT_CHANGE);
  1822. } else if (fax_updated) {
  1823. diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_NOTIFY_FAX_STAT_CHANGE);
  1824. } else if (one_updated) {
  1825. diva_trace_notify_user (pLib, 0, DIVA_SUPER_TRACE_NOTIFY_STAT_CHANGE);
  1826. }
  1827. return (one_updated ? 0 : -1);
  1828. }
  1829. static int SuperTraceGetOutgoingCallStatistics (void* hLib) {
  1830. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1831. pLib->outgoing_ifc_stats = 1;
  1832. return (ScheduleNextTraceRequest (pLib));
  1833. }
  1834. static int SuperTraceGetIncomingCallStatistics (void* hLib) {
  1835. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1836. pLib->incoming_ifc_stats = 1;
  1837. return (ScheduleNextTraceRequest (pLib));
  1838. }
  1839. static int SuperTraceGetModemStatistics (void* hLib) {
  1840. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1841. pLib->modem_ifc_stats = 1;
  1842. return (ScheduleNextTraceRequest (pLib));
  1843. }
  1844. static int SuperTraceGetFaxStatistics (void* hLib) {
  1845. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1846. pLib->fax_ifc_stats = 1;
  1847. return (ScheduleNextTraceRequest (pLib));
  1848. }
  1849. static int SuperTraceGetBLayer1Statistics (void* hLib) {
  1850. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1851. pLib->b1_ifc_stats = 1;
  1852. return (ScheduleNextTraceRequest (pLib));
  1853. }
  1854. static int SuperTraceGetBLayer2Statistics (void* hLib) {
  1855. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1856. pLib->b2_ifc_stats = 1;
  1857. return (ScheduleNextTraceRequest (pLib));
  1858. }
  1859. static int SuperTraceGetDLayer1Statistics (void* hLib) {
  1860. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1861. pLib->d1_ifc_stats = 1;
  1862. return (ScheduleNextTraceRequest (pLib));
  1863. }
  1864. static int SuperTraceGetDLayer2Statistics (void* hLib) {
  1865. diva_strace_context_t* pLib = (diva_strace_context_t*)hLib;
  1866. pLib->d2_ifc_stats = 1;
  1867. return (ScheduleNextTraceRequest (pLib));
  1868. }
  1869. dword DivaSTraceGetMemotyRequirement (int channels) {
  1870. dword parse_entries = (MODEM_PARSE_ENTRIES + FAX_PARSE_ENTRIES + \
  1871. STAT_PARSE_ENTRIES + \
  1872. LINE_PARSE_ENTRIES + 1) * channels;
  1873. return (sizeof(diva_strace_context_t) + \
  1874. (parse_entries * sizeof(diva_strace_path2action_t)));
  1875. }