theGuard 10.0
Loading...
Searching...
No Matches
aguard.c
Go to the documentation of this file.
1
9/* LABEL-START */
10
11#define META_FILE_NAME "AGuard.c"
12
13/* LABEL-END */
14
15#include "common.h"
16
17#define META_CONTEXT_S mqctx
18
19#define ENCRYPT true
20#define DECRYPT false
21
22#if defined(MQ_BUILD_EXAMPLE)
23 #define IDENT "AGuard"
24static void guard_crypt (register MK_BINN data, MK_SIZE size, bool const flag) {
25 // this is the tunnel entry
26}
27#else
28 #include "aguard_crypt.h"
29#endif
30
31static MK_TYP AGuardTT = NULL;
32#define AGuardT ((typeof(MqContextC_T)) AGuardTT)
33
34// select features to test
35//#define USE_BG_ERROR
36
37/*****************************************************************************/
38/* */
39/* Request Handler */
40/* */
41/*****************************************************************************/
42
43#define check_MqError(E) if (MkErrorCheckI(E))
44
45struct AGuardCtxS {
47 struct MqDumpS *dump;
48};
49
50#define myctx ((struct AGuardCtxS*)META_CONTEXT_S)
51
52static enum MkErrorE
53sProxySubCall ( MK_RT_ARGS MQ_CTX const targetCtx, MK_PTR const data)
54{
55 MQ_CTX sourceCtx = (MQ_CTX ) data;
56 if (strncmp(MqServiceTokenGet (targetCtx), "_RSB",5) == 0) {
58 MkErrorCheck (MqProxyPackage (targetCtx, sourceCtx, NULL));
59 MkErrorCheck (MqSendRETURN_SUB(sourceCtx));
60 }
61 return MK_OK;
62error:
63 MqContextErrorCopy(targetCtx, sourceCtx);
64 return MkErrorStack_1X(targetCtx);
65}
66
67inline static enum MkErrorE
69 MK_RT_ARGS MQ_CTX const mqctx,
70 struct MqDumpS ** dumpP
71) {
72 MkBinaryR out;
73 enum MkErrorE ret = MqReadBIN (mqctx, &out);
74 *dumpP = (struct MqDumpS *)out.data;
75 MkErrorReturn (ret);
76}
77
78#define MqReadDump_E(mqctx,dumpP) if (MkErrorCheckI(MqReadDump( MK_RT_CALL mqctx,dumpP))) goto error
79
80static enum MkErrorE
82 MK_RT_ARGS MQ_CTX const mqctx,
83 MQ_TOK const token,
84 MQ_CTX const otherCtx,
85 MQ_LTR otherLId
86)
87{
88 enum MqHandShakeE hs = mqctx->link.protect.handShake;
89 enum MqTransTypeE tt = mqctx->link.protect.transType;
90 enum MkErrorE ret = MK_OK;
91 MkBinaryR bdat = {0};
92
93/*
94->GONE by split PRIVATE and PUBLIC
95
96 if (otherCtx->link.send == NULL) {
97 return MkErrorSetV_1XS("the '%s' object link is '%s' connected", "msgque", "not");
98 }
99*/
100
101//printLV("objsize=%zd, dump=%p\n",mqctx->obj.type->objsize, myctx->dump)
102
103 MqDumpExport_E (mqctx, &myctx->dump);
104
105 MkBinaryR bin = MqDumpBinGet(myctx->dump);
106
107 guard_crypt (bin.data, bin.size, ENCRYPT);
108 MqSendSTART_E (otherCtx);
109 MqSendSetHandShake_E (otherCtx, hs);
110
111 if (tt == MQ_TRANS_TYPE_TRANS) {
112 // in a "longterm-transaction" with "MqProxyForward" and "MqSendRETURN"…
113 // we DONT want any additional message from "MqSendRETURN" send to the "client".
114 // with "link.protect.bits.LIdLck = true" the shortterm-transaction will be deleted in
115 // "MqSendRETURN->sSendEND" → same as in "MqStorageInsert" or "MqDumpExport"
116 //
117 // client.exe
118 // Send("T"…) ->
119 // Filter.exe
120 // Send("R"…) <- ANSWER database INSERT
121 // EventProc
122 // MqProxyForward // forward to "targetctx"
123 // …
124 // MqSendRETURN // THIS is the problem, we DON'T want ANY package from there send to client.exe
125 //
126 mqctx->link.protect.bits.LIdLck = true;
127
128 // set the "transLId"
129 MqSendLTR_E (otherCtx, otherLId);
130 }
131
132 MqSendBIN_E (otherCtx, bin);
133
134 // direction: client -> server = call a service
135 if (hs == MQ_HANDSHAKE_START) {
136
137 // basically… MqSendEND_AND_WAIT can fail if an ASYNCRONE error arrive… even if
138 // LTT was successfull send… if "refCount" will be incr AFTER send… an final "+TRT" will NOT find
139 // the according transaction… and will create an ERROR
140 if (tt == MQ_TRANS_TYPE_TRANS) {
141 MkErrorCheck(MqStorageIncrRef(mqctx,otherLId));
142 }
143
144 if (mqctx->link.protect.transSId != 0) { // shortterm-transaction
145
146 // direction: mqctx -> otherCtx
147 switch (tt) {
148 case MQ_TRANS_TYPE_CB:
150 ret = MqSendEND_AND_WAIT (otherCtx, token, MK_TIMEOUT_DEFAULT);
151 break;
153 ret = MqSendEND_AND_SUB (otherCtx, token, sProxySubCall, mqctx, NULL, MK_TIMEOUT_DEFAULT);
154 break;
156 ret = MqSendEND_AND_TRANSACTION (otherCtx, token, NULL, MK_TIMEOUT_DEFAULT);
157 break;
158 default:
159 ret = MkErrorSetV_1XS("protocol-error -> invalid transaction-type: %s", MqTransTypeE_ToString(tt));
160 break;
161 }
162 MkErrorCheck (ret);
163
164 // start the answer
165 MqSendSTART_E (mqctx);
166
167 // Forward the "answer" of a STT… but only if "other-context" expect an answer
168 if (tt != MQ_TRANS_TYPE_TRANS) {
169
170 // read the answer
171 MqReadBIN_E (otherCtx, &bdat);
172
173 guard_crypt (bdat.data, bdat.size, DECRYPT);
174
175 // copy the answer from "otherCtx" to "mqctx"
176 MqProxyPackage_E (otherCtx, mqctx, (struct MqDumpS *) bdat.data);
177 }
178 } else { // transSId == 0
179 // direction: mqctx -> otherCtx
180 switch (tt) {
181 case MQ_TRANS_TYPE_NO:
182 ret = MqSendEND (otherCtx, token, MK_TIMEOUT_DEFAULT);
183 break;
185 ret = MqSendEND_AND_TRANSACTION (otherCtx, token, NULL, 0);
186 break;
187 default:
188 ret = MkErrorSetV_1XS("protocol-error -> invalid transaction-type: %s", MqTransTypeE_ToString(tt));
189 break;
190 }
191 MkErrorCheck (ret);
192 }
193
194 // direction: client <- server = answer from the service → handShake "O" or "E"
195 } else {
196
197 if (mqctx->link.protect.transSId != 0) { // shortterm-transaction, this is only valid for "+TRT"
198 switch (tt) {
200 ret = MqSendEND_AND_TRANSACTION (otherCtx, token, NULL, MK_TIMEOUT_DEFAULT);
201 break;
202 default:
203 ret = MkErrorSetV_1XS("protocol-error -> invalid transaction-type: %s", MqTransTypeE_ToString(tt));
204 break;
205 }
206 } else { // everything NOT "+TRT"
207 switch (tt) {
208 case MQ_TRANS_TYPE_NO:
209 ret = MqSendEND (otherCtx, token, MK_TIMEOUT_DEFAULT);
210 break;
212 ret = MqSendEND_AND_TRANSACTION (otherCtx, token, NULL, 0);
213 break;
214 default:
215 ret = MkErrorSetV_1XS("protocol-error -> invalid transaction-type: %s", MqTransTypeE_ToString(tt));
216 break;
217 }
218 }
219 MkErrorCheck (ret);
220 }
221
222done:
223 return MkErrorGetCode_0E();
224
225error:
226 MqContextErrorCopy(mqctx, otherCtx);
227 MkErrorStack_1X(mqctx);
228 goto done;
229}
230
231static enum MkErrorE
233{
234 enum MkErrorE ret;
235
236 MQ_CTX otherCtx = MqSlaveGetProxy_e (mqctx, MQ_SLAVE_OTHER);
237 MqEnvProtect(otherCtx);
238 ret = PkgToGrx2 ( MK_RT_CALL mqctx, "+GRP", otherCtx, mqctx->link.protect.transLId);
239 MqEnvRestore(otherCtx);
240 MkErrorCheck (ret);
241
242done:
243 return MqSendRETURN(mqctx);
244error:
245 MkErrorStack_1X(mqctx);
246 goto done;
247}
248
249// this code is used on a client to read the answer of a \e longterm-transaction
250static enum MkErrorE
252{
253 MQ_LTR rmtTransLIdOrig = mqctx->link.protect.rmtTransLId;
254
255 MkDLogV(mqctx,6,"work on 'transLId=" MK_FORMAT_T "'\n", rmtTransLIdOrig);
256
257 if (rmtTransLIdOrig < 0) {
258
259 MkErrorSetC_1XS ("internal-error: unable to GUARD a SEND-LTT");
260 goto error;
261
262 } else if (rmtTransLIdOrig > 0) {
263 MQ_LTR otherLId;
264 MQ_CTX otherCtx;
265 enum MkErrorE ret;
266
267 // step 1. -> get the "original" transaction of "mqctx->link.protect.rmtTransLId" from DB
268 MkErrorCheck (MqStorageResolve (mqctx, &otherCtx, &otherLId));
269
270 // step 2. -> send data
271 MqEnvProtect(otherCtx);
272 ret = PkgToGrx2 ( MK_RT_CALL mqctx, "+GRT", otherCtx, otherLId);
273 MqEnvRestore(otherCtx);
274 MkErrorCheck (ret);
275
276 } else {
277 MkPanicSYS (mqctx);
278 }
279
280done:
281 MqStorageDelete (mqctx, &mqctx->link.protect.transLId);
282 return MqSendRETURN(mqctx);
283error:
284 MkErrorStack_1X (mqctx);
285 goto done;
286}
287
288// goal is to "RETURN" an Error in an encrypted package.
289static enum MkErrorE
291 MK_RT_ARGS MQ_CTX const mqctx
292) {
293 if (MkErrorIsEXIT_0E()) {
294 return MkErrorGetCode_0E();
295 } else {
296
297 // goal → make a "guard" error package
298 check_MqError (MqDumpError (mqctx, &myctx->dump)) goto error_in_error;
299
300 MkBinaryR bin = MqDumpBinGet (myctx->dump);
301
302 // encrypt
303 guard_crypt (bin.data, bin.size, ENCRYPT);
304
305 // prepare binary package
306 check_MqError (MqSendSTART (mqctx)) goto error_in_error;
307 check_MqError (MqSendBIN (mqctx, bin)) goto error_in_error;
308 return MK_CONTINUE;
309 }
310
311error_in_error:
312 MkErrorPrintln_1M (mqctx);
313 return MK_OK;
314}
315
316#define GuardReturn(PROC) \
317switch (PROC) {\
318 case MK_OK: return MK_OK; \
319 case MK_CONTINUE: goto done; \
320 default: return MkErrorStack_1X (META_CONTEXT_S); \
321}
322
323static enum MkErrorE
325 MK_RT_ARGS MQ_CTX const mqctx,
326 MQ_TOK const intoken,
327 MQ_CTX const otherCtx,
328 MQ_LTR otherLId
329) {
330 enum MqHandShakeE hs = mqctx->link.protect.handShake;
331 enum MqTransTypeE tt = mqctx->link.protect.transType;
332 struct MqDumpS *dump = NULL;
333 enum MkErrorE ret = MK_OK;
334 MK_STRB token[5] = "";
335 MkBinaryR bdat = {0};
336
337/*
338->GONE by split PRIVATE and PUBLIC
339 if (otherCtx->link.send == NULL) {
340 return MkErrorSetV_1XS("the '%s' object link is '%s' connected", "msgque", "not");
341 } else
342*/
343 if (strncmp (intoken, MqServiceTokenGet(mqctx), 5) != 0) {
344 return MkErrorSetV_1XS("expect token '%s' but got token '%s", intoken, MqServiceTokenGet(mqctx));
345 }
346
347 MqReadBIN_E (mqctx, &bdat);
348 guard_crypt (bdat.data, bdat.size, DECRYPT);
349 MqSendSTART_E (otherCtx);
350
351 if (tt == MQ_TRANS_TYPE_TRANS) {
352 // in a "longterm-transaction" with "MqProxyForward" and "MqSendRETURN"…
353 // we DONT want any additional message from "MqSendRETURN" send to the "client".
354 // with "link.protect.bits.LIdLck = true" the shortterm-transaction will be deleted in
355 // "MqSendRETURN->sSendEND" → same as in "MqStorageInsert" or "MqDumpExport"
356 //
357 // client.exe
358 // Send("T"…) ->
359 // Filter.exe
360 // Send("R"…) <- ANSWER database INSERT
361 // EventProc
362 // MqProxyForward // forward to "targetctx"
363 // …
364 // MqSendRETURN // THIS is the problem, we DON'T want ANY package from there send to client.exe
365 //
366 mqctx->link.protect.bits.LIdLck = true;
367 }
368
369 // the "Dump" is from an other "filter"… the environment is WRONG
370 dump = (struct MqDumpS*) bdat.data;
371
372 MqDumpTransLIdSet (dump, mqctx->link.protect.transLId);
373 MqDumpRmtTransLIdSet (dump, mqctx->link.protect.rmtTransLId);
374 strncpy (token, MqDumpTokenGet(dump), 4);
375 token[4] = '\0';
376
377 // this code write the "transLId" also
378 MqProxyPackage_E (mqctx, otherCtx, dump);
379
380 if (hs == MQ_HANDSHAKE_START) {
381
382 // basically… MqSendEND_AND_WAIT can fail if an ASYNCRONE error arrive… even if
383 // LTT was successfull send… if "refCount" will be incr AFTER send… an final "+TRT" will NOT find
384 // the according transaction… and will create an ERROR
385 if (tt == MQ_TRANS_TYPE_TRANS) {
386 MkErrorCheck(MqStorageIncrRef(mqctx,otherLId));
387 }
388
389 if (mqctx->link.protect.transSId > 0) { // shortterm-transaction
390
391 // direction: mqctx -> otherCtx
392 switch (tt) {
393 case MQ_TRANS_TYPE_CB:
395 ret = MqSendEND_AND_WAIT (otherCtx, token, MK_TIMEOUT_DEFAULT);
396 break;
398 // protecting of "mqctx" using "refCount" is dangerous… every error break refCount
399 ret = MqSendEND_AND_SUB (otherCtx, token, sProxySubCall, mqctx, NULL, MK_TIMEOUT_DEFAULT);
400 break;
402 ret = MqSendEND_AND_TRANSACTION (otherCtx, token, NULL, MK_TIMEOUT_DEFAULT);
403 break;
404 default:
405 ret = MkErrorSetV_1XS("protocol-error -> invalid transaction-type: %s", MqTransTypeE_ToString(tt));
406 break;
407 }
408 MkErrorCheck (ret);
409
410 // start the answer
411 MqSendSTART_E (mqctx);
412
413 // Forward the "answer" of a STT… but only if "other-context" expect an answer
414 if (tt != MQ_TRANS_TYPE_TRANS) {
415 // answer
416 MqDumpExport_E (otherCtx, &myctx->dump);
417 MkBinaryR bin = MqDumpBinGet(myctx->dump);
418
419 // encrypt
420 guard_crypt (bin.data, bin.size, ENCRYPT);
421 // prepare binary package
422 MqSendBIN_E (mqctx, bin);
423 }
424
425 } else { // transSId == 0
426 // direction: mqctx -> otherCtx
427 switch (tt) {
428 case MQ_TRANS_TYPE_NO:
429 ret = MqSendEND (otherCtx, token, MK_TIMEOUT_DEFAULT);
430 break;
432 ret = MqSendEND_AND_TRANSACTION (otherCtx, token, NULL, 0);
433 break;
434 default:
435 ret = MkErrorSetV_1XS("protocol-error -> invalid transaction-type: %s", MqTransTypeE_ToString(tt));
436 break;
437 }
438 MkErrorCheck (ret);
439 }
440
441 // direction: client <- server = answer from the service → handShake "O" or "E"
442 } else {
443 if (mqctx->link.protect.transSId > 0) { // shortterm-transaction, this is only valid for "+TRT"
444 switch (tt) {
446 ret = MqSendEND_AND_TRANSACTION (otherCtx, token, NULL, MK_TIMEOUT_DEFAULT);
447 break;
448 default:
449 ret = MkErrorSetV_1XS("protocol-error -> invalid transaction-type: %s", MqTransTypeE_ToString(tt));
450 break;
451 }
452 } else { // everything NOT "+TRT"
453 switch (tt) {
454 case MQ_TRANS_TYPE_NO:
455 ret = MqSendEND (otherCtx, token, MK_TIMEOUT_DEFAULT);
456 break;
458 ret = MqSendEND_AND_TRANSACTION (otherCtx, token, NULL, 0);
459 break;
460 default:
461 ret = MkErrorSetV_1XS("protocol-error -> invalid transaction-type: %s", MqTransTypeE_ToString(tt));
462 break;
463 }
464 }
465 MkErrorCheck (ret);
466 }
467
468 return MK_OK;
469
470error:
471 MqContextErrorCopy(mqctx, otherCtx);
472 return MkErrorStack_1X(mqctx);
473}
474
475static enum MkErrorE
477{
478 MQ_CTX otherCtx;
479
480 MkErrorCheck (MqSlaveGetProxy (mqctx, MQ_SLAVE_OTHER, &otherCtx));
481 MkErrorCheck (GrxToPkg2 ( MK_RT_CALL mqctx, "+GRP", otherCtx, mqctx->link.protect.transLId));
482
483done:
484 return MqSendRETURN(mqctx);
485error:
486 MkErrorStack_1X(mqctx);
488}
489
490// this code is used on a client to read the answer of a \e longterm-transaction
491static enum MkErrorE
493{
494 MQ_LTR rmtTransLIdOrig = mqctx->link.protect.rmtTransLId;
495
496 MkDLogV(mqctx,6,"work on 'transLId=" MK_FORMAT_T "'\n", rmtTransLIdOrig);
497
498 if (rmtTransLIdOrig < 0) {
499
500 MkErrorSetC_1XS ("internal-error: unable to GUARD a SEND-LTT");
501 goto error;
502
503 } else if (rmtTransLIdOrig > 0) {
504
505 MQ_CTX otherCtx;
506 MQ_LTR otherLId;
507
508 // step 1. -> get the "original" transaction of "mqctx->link.protect.rmtTransLId" from DB
509 MkErrorCheck (MqStorageResolve (mqctx, &otherCtx, &otherLId));
510
511 // step 2. -> "MqSendSTART" use "link.protect.rmtTransLId" to add the LTT to the data-package
512 mqctx->link.protect.rmtTransLId = otherLId;
513
514 // step 3. -> send data
515 MkErrorCheck (GrxToPkg2 ( MK_RT_CALL mqctx, "+GRT", otherCtx, mqctx->link.protect.rmtTransLId));
516
517 } else {
518 MkErrorSetC_1XS ("internal-error: transLId = 0");
519 goto error;
520 }
521
522done:
523 MqStorageDelete (mqctx, &mqctx->link.protect.transLId);
524 return MqSendRETURN(mqctx);
525error:
526 MqStorageDelete (mqctx, &mqctx->link.protect.transLId);
527 MkErrorStack_1X (mqctx);
529}
530
531/*****************************************************************************/
532/* */
533/* context_init */
534/* */
535/*****************************************************************************/
536
537#if defined(MQ_BUILD_EXAMPLE)
538static void __attribute__ ((noreturn))
539FilterHelp (const char * base)
540{
541 fputs("\n", stderr);
542 fprintf(stderr, "usage: %s [OPTION]... [ARGUMENT]...\n", base);
543 fputs("\n", stderr);
544 fputs(" This tool is the data protection filter of NHI1.\n", stderr);
545 fputs("\n", stderr);
546 fprintf(stderr, " %s [ARGUMENT]... syntax:\n", base);
547 fprintf(stderr, " aclient... %c %s ... [tunnel] ... %c %s ... %c aserver\n", MK_ALFA, base, MK_ALFA, base, MK_ALFA);
548 fputs("\n", stderr);
549 fputs(MqHelp (NULL), stderr);
550 fputs("\n", stderr);
551 fprintf(stderr, " %s [OPTION]:\n", base);
552 fputs( " -h, --help print this help\n", stderr);
553 fputs("\n", stderr);
554
555 exit(EXIT_SUCCESS);
556}
557#endif
558
559static enum MkErrorE
561{
562 MqDumpDelete(myctx->dump);
563 return MK_OK;
564}
565
566static enum MkErrorE
568{
569 MQ_CTX ftrctx = MqSlaveGetFilter_e (mqctx);
570
571 myctx->dump = NULL;
572
573 // SERVER: every token (+ALL) have to be "guard_encrypted"
574 MkErrorCheck (MqServiceCreate (mqctx, "+ALL", PkgToGrp, NULL, NULL, NULL));
575 // SERVER: but "+TRT" is special
576 MkErrorCheck (MqServiceCreate (mqctx, "+TRT", TrtToGrt, NULL, NULL, NULL));
577 // SERVER: only the "+GR?" token is "guard_decrypted"
578 MkErrorCheck (MqServiceCreate (mqctx, "+GRP", GrpToPkg, NULL, NULL, NULL));
579 MkErrorCheck (MqServiceCreate (mqctx, "+GRT", GrtToTrt, NULL, NULL, NULL));
580
581 // CLIENT: every token (+ALL) have to be "guard_encrypted"
582 MkErrorCheck (MqServiceCreate (ftrctx, "+ALL", PkgToGrp, NULL, NULL, NULL));
583 // CLIENT: but "+TRT" is special
584 MkErrorCheck (MqServiceCreate (ftrctx, "+TRT", TrtToGrt, NULL, NULL, NULL));
585 // CLIENT: only the "+GR?" token is "guard_decrypted"
586 MkErrorCheck (MqServiceCreate (ftrctx, "+GRP", GrpToPkg, NULL, NULL, NULL));
587 MkErrorCheck (MqServiceCreate (ftrctx, "+GRT", GrtToTrt, NULL, NULL, NULL));
588
589 return MK_OK;
590error:
591 return MkErrorStack_1X(mqctx);
592}
593
594#if defined(USE_BG_ERROR)
595static enum MkErrorE
596FilterError ( MQ_SERVICE_CALL_ARGS )
597{
598 // the error-package has the source-context of the error at "MkErrorTLS.errctx"
599 // the "other-side" is the target
600 MQ_CTX ftrctx = NULL;
601 MQ_CTX errctx = MkErrorGetContextI(mqctx);
602
603 check_MqError (MqSlaveGetProxy (errctx, MQ_SLAVE_OTHER, &ftrctx)) {
604 MqContextErrorCopy(mqctx,errctx);
605 return MkErrorStack_1X(mqctx);
606 }
607
608 // 1. if "ftrctx" != "mqctx"… Master "BgError" was called on slave "_ERR" (token.c)
609 // 2. if "ftrctx" == "mqctx"… Master get "_ERR" from client
610
611 // shift the error to the "other-side"
612 MqContextErrorCopy(ftrctx,mqctx);
613 // the "_ERR" has an EMPTY environment… the "MqContextErrorCopy" preserve the LOCAL environment
614 // let the environment be EMPTY again
615 MkErrorEnvReset();
616
617 if (mqctx->link.bits.onCreateEnd == 1) {
618
619 // during normal processing
620 switch (GrxToPkgError( MK_RT_CALL ftrctx)) {
621 case MK_CONTINUE: MqSendEND (ftrctx, "+GRP", MK_TIMEOUT_DEFAULT);
622 case MK_OK: break;
623 case MK_ERROR: break;
624 }
625 } else {
626 // early startup... services are NOT available…
627 return MqSendERROR(ftrctx);
628 }
629
630 // has "MqSendEND" from abova an error ?
631 MqContextErrorCopy(mqctx,ftrctx);
632 return MkErrorStack_1X(mqctx);
633}
634#endif
635
636/*****************************************************************************/
637/* */
638/* main */
639/* */
640/*****************************************************************************/
641
642static enum MkErrorE
644{
645 MQ_CTX const mqctx = *contextP = MqContextCreate(AGuardTT,tmpl);
646
647 mqctx->setup.isServer = true;
650#if defined(USE_BG_ERROR)
651 mqctx->setup.BgError.fCall = FilterError;
652#endif
653
654 return MK_OK;
655}
656
657#if defined(MQ_BUILD_EXAMPLE)
658static enum MkErrorE
660{
661 return MK_OK;
662}
663#endif
664
665int main ( const int argc, MK_STRN argv[])
666{
668
669 // define the new type
671 AGuardTT->objsize = sizeof(struct AGuardCtxS);
672 AGuardT->fHelp = FilterHelp;
673
674 // parse the command-line
675 MK_BFL args = MkBufferListCreateVC (argc, argv);
676 MQ_CTX mqctx = NULL;
677
678 // call Factory
679 MQ_FCT fct = MqFactoryAdd(MK_ERROR_PANIC, FilterFactory, NULL, NULL, NULL, NULL, NULL, NULL, NULL, IDENT);
680 MqFactoryNew_E (fct, NULL, &mqctx);
681
682 // filter args
683 MkContinueCheck(FilterArgs(MK_RT_CALL mqctx,args));
684
685 // create the Link
686 MqLinkCreate_E (mqctx, args);
687
688 // start event-loop and wait forever
690
691 // finish and exit
692cont:
693error:
694 MkBufferListDelete(args);
695 MqExit_1 (mqctx);
696}
697
static enum MkErrorE MqReadDump(MK_RT_ARGS MQ_CTX const mqctx, struct MqDumpS **dumpP)
Definition aguard.c:68
#define check_MqError(E)
Definition aguard.c:43
#define GuardReturn(PROC)
Definition aguard.c:316
static enum MkErrorE FilterSetup(MQ_SERVICE_CALL_ARGS)
Definition aguard.c:567
static enum MkErrorE FilterFactory(MQ_CALLBACK_FACTORY_CTOR_ARGS)
Definition aguard.c:643
#define ENCRYPT
Definition aguard.c:19
#define DECRYPT
Definition aguard.c:20
static enum MkErrorE PkgToGrp(MQ_SERVICE_CALL_ARGS)
Definition aguard.c:232
static enum MkErrorE GrpToPkg(MQ_SERVICE_CALL_ARGS)
Definition aguard.c:476
#define myctx
Definition aguard.c:50
int main(const int argc, MK_STRN argv[])
Definition aguard.c:665
static enum MkErrorE GrxToPkgError(MK_RT_ARGS MQ_CTX const mqctx)
Definition aguard.c:290
static enum MkErrorE sProxySubCall(MK_RT_ARGS MQ_CTX const targetCtx, MK_PTR const data)
Definition aguard.c:53
#define AGuardT
Definition aguard.c:32
static enum MkErrorE FilterCleanup(MQ_SERVICE_CALL_ARGS)
Definition aguard.c:560
static enum MkErrorE TrtToGrt(MQ_SERVICE_CALL_ARGS)
Definition aguard.c:251
static enum MkErrorE GrtToTrt(MQ_SERVICE_CALL_ARGS)
Definition aguard.c:492
static MK_TYP AGuardTT
Definition aguard.c:31
static enum MkErrorE PkgToGrx2(MK_RT_ARGS MQ_CTX const mqctx, MQ_TOK const token, MQ_CTX const otherCtx, MQ_LTR otherLId)
Definition aguard.c:81
static enum MkErrorE GrxToPkg2(MK_RT_ARGS MQ_CTX const mqctx, MQ_TOK const intoken, MQ_CTX const otherCtx, MQ_LTR otherLId)
Definition aguard.c:324
tag: nhi1-release-250425
#define IDENT
static enum MkErrorE FilterArgs(MK_RT_ARGS MQ_CTX mqctx, MK_BFL args)
static void FilterHelp(const char *base)
static void guard_crypt(register MK_BINN data, MK_SIZE size, bool const flag)
#define MkBufferListCreateVC(...)
#define MkBufferListDelete(x)
#define MkErrorGetCode_0E()
#define MkErrorStack_1X(...)
#define MkErrorPrintln_1M(err)
#define MkErrorSetV_1XS(printfmt,...)
#define MkErrorSetC_1XS(message)
#define MkPanicSYS(mngx)
#define MkErrorIsEXIT_0E()
#define MK_ERROR_PANIC
MkErrorE
MK_TIMEOUT_DEFAULT
MK_ERROR
MK_CONTINUE
MK_OK
MK_PTRB * MK_PTR
const MK_STRB * MK_STRN
char MK_STRB
#define MK_ALFA
long MK_SIZE
MK_BINB const * MK_BINN
#define MkDLogV(x, _debug, printfmt,...)
#define MK_RT_CALL
#define AllRtSetup_NULL
#define MK_RT_ARGS
#define MkTypeDup2(...)
struct MqContextS * MQ_CTX
#define MqContextC_TT
#define MQ_SERVICE_CALL_ARGS
void MqEnvRestore(MQ_CTX ctx)
#define MqEnvProtect(...)
#define MqContextErrorCopy(...)
#define MqExit_1(ctx)
#define MqProcessEvent_E(...)
#define MqProxyPackage_E(...)
#define MqProxyPackage(...)
#define MqReadBIN_E(...)
#define MqReadBIN(...)
#define MqSendBIN(...)
#define MqSendBIN_E(...)
#define MqSendSetHandShake_E(...)
#define MqSendLTR_E(...)
#define MqSendSTART(...)
#define MqSendEND_AND_TRANSACTION(...)
#define MqSendSTART_E(...)
#define MqSendEND_AND_SUB(...)
#define MqSendEND_AND_WAIT(...)
#define MqSendEND(...)
#define MqSendRETURN_SUB(...)
#define MqSendERROR(...)
#define MqSendRETURN(...)
MQ_TOK MqServiceTokenGet(MQ_CTX const ctx)
#define MqServiceCreate(...)
MK_STRN MQ_TOK
#define MqSlaveGetProxy_e(...)
#define MqSlaveGetProxy(...)
#define MqSlaveGetFilter_e(...)
#define MqStorageIncrRef(...)
#define MqStorageResolve(...)
#define MqStorageDelete(...)
#define MqContextCreate(...)
void MqDumpRmtTransLIdSet(MQ_DMP const dump, MQ_LTR rmtTransLId)
void MqDumpTransLIdSet(MQ_DMP const dump, MQ_LTR transLId)
MK_STRN MqDumpTokenGet(MQ_DMPN const dump)
#define MqDumpExport_E(...)
#define MqDumpError(...)
#define MqDumpDelete(x)
MkBinaryR MqDumpBinGet(MQ_DMPN const dump)
#define MQ_CALLBACK_FACTORY_CTOR_ARGS
#define MqFactoryNew_E(...)
#define MqFactoryAdd(...)
MqHandShakeE
MqTransTypeE
MK_STRN MqTransTypeE_ToString(enum MqTransTypeE value)
MQ_WAIT_FOREVER
MQ_SLAVE_OTHER
MQ_HANDSHAKE_START
MQ_TRANS_TYPE_WAIT
MQ_TRANS_TYPE_SUB
MQ_TRANS_TYPE_CB
MQ_TRANS_TYPE_NO
MQ_TRANS_TYPE_TRANS
MK_STR MqHelp(MK_STRN tool)
int MQ_LTR
struct MqDumpS * dump
Definition aguard.c:47
struct MqContextS mqctx
Definition aguard.c:46
MK_SIZE size
MK_BINN data
size_t objsize
MqTokenF fCall
struct MqSetupS setup
struct MqLinkS link
MQ_LTR transLId
enum MqHandShakeE handShake
MQ_LTR rmtTransLId
struct MqCallbackS ServerCleanup
struct MqCallbackS BgError
struct MqCallbackS ServerSetup
bool isServer