flooder.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /**
  2. * @file flooder.c
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the author nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #include <stdint.h>
  30. #include <stdlib.h>
  31. #include <string.h>
  32. #include <stdio.h>
  33. #include <protocol/addr.h>
  34. #include <protocol/scproto.h>
  35. #include <misc/loglevel.h>
  36. #include <misc/version.h>
  37. #include <misc/nsskey.h>
  38. #include <misc/byteorder.h>
  39. #include <misc/loggers_string.h>
  40. #include <misc/open_standard_streams.h>
  41. #include <base/BLog.h>
  42. #include <system/BReactor.h>
  43. #include <system/BSignal.h>
  44. #include <system/BNetwork.h>
  45. #include <flow/SinglePacketBuffer.h>
  46. #include <flow/PacketProtoEncoder.h>
  47. #include <nspr_support/BSSLConnection.h>
  48. #include <server_connection/ServerConnection.h>
  49. #ifndef BADVPN_USE_WINAPI
  50. #include <base/BLog_syslog.h>
  51. #endif
  52. #include <flooder/flooder.h>
  53. #include <generated/blog_channel_flooder.h>
  54. #define LOGGER_STDOUT 1
  55. #define LOGGER_SYSLOG 2
  56. // command-line options
  57. struct {
  58. int help;
  59. int version;
  60. int logger;
  61. #ifndef BADVPN_USE_WINAPI
  62. char *logger_syslog_facility;
  63. char *logger_syslog_ident;
  64. #endif
  65. int loglevel;
  66. int loglevels[BLOG_NUM_CHANNELS];
  67. int ssl;
  68. char *nssdb;
  69. char *client_cert_name;
  70. char *server_name;
  71. char *server_addr;
  72. peerid_t floods[MAX_FLOODS];
  73. int num_floods;
  74. } options;
  75. // server address we connect to
  76. BAddr server_addr;
  77. // server name to use for SSL
  78. char server_name[256];
  79. // reactor
  80. BReactor ss;
  81. // client certificate if using SSL
  82. CERTCertificate *client_cert;
  83. // client private key if using SSL
  84. SECKEYPrivateKey *client_key;
  85. // server connection
  86. ServerConnection server;
  87. // whether server is ready
  88. int server_ready;
  89. // my ID, defined only after server_ready
  90. peerid_t my_id;
  91. // flooding output
  92. PacketRecvInterface flood_source;
  93. PacketProtoEncoder flood_encoder;
  94. SinglePacketBuffer flood_buffer;
  95. // whether we were asked for a packet and blocked
  96. int flood_blocking;
  97. // index of next peer to send packet too
  98. int flood_next;
  99. /**
  100. * Cleans up everything that can be cleaned up from inside the event loop.
  101. */
  102. static void terminate (void);
  103. /**
  104. * Prints command line help.
  105. */
  106. static void print_help (const char *name);
  107. /**
  108. * Prints program name, version and copyright notice.
  109. */
  110. static void print_version (void);
  111. /**
  112. * Parses command line options into the options strucute.
  113. *
  114. * @return 1 on success, 0 on failure
  115. */
  116. static int parse_arguments (int argc, char *argv[]);
  117. /**
  118. * Processes command line options.
  119. *
  120. * @return 1 on success, 0 on failure
  121. */
  122. static int resolve_arguments (void);
  123. /**
  124. * Handler invoked when program termination is requested.
  125. */
  126. static void signal_handler (void *unused);
  127. static void server_handler_error (void *user);
  128. static void server_handler_ready (void *user, peerid_t param_my_id, uint32_t ext_ip);
  129. static void server_handler_newclient (void *user, peerid_t peer_id, int flags, const uint8_t *cert, int cert_len);
  130. static void server_handler_endclient (void *user, peerid_t peer_id);
  131. static void server_handler_message (void *user, peerid_t peer_id, uint8_t *data, int data_len);
  132. static void flood_source_handler_recv (void *user, uint8_t *data);
  133. int main (int argc, char *argv[])
  134. {
  135. if (argc <= 0) {
  136. return 1;
  137. }
  138. // open standard streams
  139. open_standard_streams();
  140. // parse command-line arguments
  141. if (!parse_arguments(argc, argv)) {
  142. fprintf(stderr, "Failed to parse arguments\n");
  143. print_help(argv[0]);
  144. goto fail0;
  145. }
  146. // handle --help and --version
  147. if (options.help) {
  148. print_version();
  149. print_help(argv[0]);
  150. return 0;
  151. }
  152. if (options.version) {
  153. print_version();
  154. return 0;
  155. }
  156. // initialize logger
  157. switch (options.logger) {
  158. case LOGGER_STDOUT:
  159. BLog_InitStdout();
  160. break;
  161. #ifndef BADVPN_USE_WINAPI
  162. case LOGGER_SYSLOG:
  163. if (!BLog_InitSyslog(options.logger_syslog_ident, options.logger_syslog_facility)) {
  164. fprintf(stderr, "Failed to initialize syslog logger\n");
  165. goto fail0;
  166. }
  167. break;
  168. #endif
  169. default:
  170. ASSERT(0);
  171. }
  172. // configure logger channels
  173. for (int i = 0; i < BLOG_NUM_CHANNELS; i++) {
  174. if (options.loglevels[i] >= 0) {
  175. BLog_SetChannelLoglevel(i, options.loglevels[i]);
  176. }
  177. else if (options.loglevel >= 0) {
  178. BLog_SetChannelLoglevel(i, options.loglevel);
  179. }
  180. }
  181. BLog(BLOG_NOTICE, "initializing "GLOBAL_PRODUCT_NAME" "PROGRAM_NAME" "GLOBAL_VERSION);
  182. // initialize network
  183. if (!BNetwork_GlobalInit()) {
  184. BLog(BLOG_ERROR, "BNetwork_GlobalInit failed");
  185. goto fail1;
  186. }
  187. // init time
  188. BTime_Init();
  189. // resolve addresses
  190. if (!resolve_arguments()) {
  191. BLog(BLOG_ERROR, "Failed to resolve arguments");
  192. goto fail1;
  193. }
  194. // init reactor
  195. if (!BReactor_Init(&ss)) {
  196. BLog(BLOG_ERROR, "BReactor_Init failed");
  197. goto fail1;
  198. }
  199. // setup signal handler
  200. if (!BSignal_Init(&ss, signal_handler, NULL)) {
  201. BLog(BLOG_ERROR, "BSignal_Init failed");
  202. goto fail1a;
  203. }
  204. if (options.ssl) {
  205. // init NSPR
  206. PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
  207. // register local NSPR file types
  208. if (!BSSLConnection_GlobalInit()) {
  209. BLog(BLOG_ERROR, "BSSLConnection_GlobalInit failed");
  210. goto fail3;
  211. }
  212. // init NSS
  213. if (NSS_Init(options.nssdb) != SECSuccess) {
  214. BLog(BLOG_ERROR, "NSS_Init failed (%d)", (int)PR_GetError());
  215. goto fail2;
  216. }
  217. // set cipher policy
  218. if (NSS_SetDomesticPolicy() != SECSuccess) {
  219. BLog(BLOG_ERROR, "NSS_SetDomesticPolicy failed (%d)", (int)PR_GetError());
  220. goto fail3;
  221. }
  222. // init server cache
  223. if (SSL_ConfigServerSessionIDCache(0, 0, 0, NULL) != SECSuccess) {
  224. BLog(BLOG_ERROR, "SSL_ConfigServerSessionIDCache failed (%d)", (int)PR_GetError());
  225. goto fail3;
  226. }
  227. // open server certificate and private key
  228. if (!open_nss_cert_and_key(options.client_cert_name, &client_cert, &client_key)) {
  229. BLog(BLOG_ERROR, "Cannot open certificate and key");
  230. goto fail4;
  231. }
  232. }
  233. // start connecting to server
  234. if (!ServerConnection_Init(
  235. &server, &ss, NULL, server_addr, SC_KEEPALIVE_INTERVAL, SERVER_BUFFER_MIN_PACKETS, options.ssl, 0, client_cert, client_key, server_name, NULL,
  236. server_handler_error, server_handler_ready, server_handler_newclient, server_handler_endclient, server_handler_message
  237. )) {
  238. BLog(BLOG_ERROR, "ServerConnection_Init failed");
  239. goto fail5;
  240. }
  241. // set server not ready
  242. server_ready = 0;
  243. // enter event loop
  244. BLog(BLOG_NOTICE, "entering event loop");
  245. BReactor_Exec(&ss);
  246. if (server_ready) {
  247. ServerConnection_ReleaseBuffers(&server);
  248. SinglePacketBuffer_Free(&flood_buffer);
  249. PacketProtoEncoder_Free(&flood_encoder);
  250. PacketRecvInterface_Free(&flood_source);
  251. }
  252. ServerConnection_Free(&server);
  253. fail5:
  254. if (options.ssl) {
  255. CERT_DestroyCertificate(client_cert);
  256. SECKEY_DestroyPrivateKey(client_key);
  257. fail4:
  258. ASSERT_FORCE(SSL_ShutdownServerSessionIDCache() == SECSuccess)
  259. fail3:
  260. SSL_ClearSessionCache();
  261. ASSERT_FORCE(NSS_Shutdown() == SECSuccess)
  262. fail2:
  263. ASSERT_FORCE(PR_Cleanup() == PR_SUCCESS)
  264. PL_ArenaFinish();
  265. }
  266. BSignal_Finish();
  267. fail1a:
  268. BReactor_Free(&ss);
  269. fail1:
  270. BLog(BLOG_NOTICE, "exiting");
  271. BLog_Free();
  272. fail0:
  273. DebugObjectGlobal_Finish();
  274. return 1;
  275. }
  276. void terminate (void)
  277. {
  278. BLog(BLOG_NOTICE, "tearing down");
  279. // exit event loop
  280. BReactor_Quit(&ss, 0);
  281. }
  282. void print_help (const char *name)
  283. {
  284. printf(
  285. "Usage:\n"
  286. " %s\n"
  287. " [--help]\n"
  288. " [--version]\n"
  289. " [--logger <"LOGGERS_STRING">]\n"
  290. #ifndef BADVPN_USE_WINAPI
  291. " (logger=syslog?\n"
  292. " [--syslog-facility <string>]\n"
  293. " [--syslog-ident <string>]\n"
  294. " )\n"
  295. #endif
  296. " [--loglevel <0-5/none/error/warning/notice/info/debug>]\n"
  297. " [--channel-loglevel <channel-name> <0-5/none/error/warning/notice/info/debug>] ...\n"
  298. " [--ssl --nssdb <string> --client-cert-name <string>]\n"
  299. " [--server-name <string>]\n"
  300. " --server-addr <addr>\n"
  301. " [--flood-id <id>] ...\n"
  302. "Address format is a.b.c.d:port (IPv4) or [addr]:port (IPv6).\n",
  303. name
  304. );
  305. }
  306. void print_version (void)
  307. {
  308. printf(GLOBAL_PRODUCT_NAME" "PROGRAM_NAME" "GLOBAL_VERSION"\n"GLOBAL_COPYRIGHT_NOTICE"\n");
  309. }
  310. int parse_arguments (int argc, char *argv[])
  311. {
  312. if (argc <= 0) {
  313. return 0;
  314. }
  315. options.help = 0;
  316. options.version = 0;
  317. options.logger = LOGGER_STDOUT;
  318. #ifndef BADVPN_USE_WINAPI
  319. options.logger_syslog_facility = "daemon";
  320. options.logger_syslog_ident = argv[0];
  321. #endif
  322. options.loglevel = -1;
  323. for (int i = 0; i < BLOG_NUM_CHANNELS; i++) {
  324. options.loglevels[i] = -1;
  325. }
  326. options.ssl = 0;
  327. options.nssdb = NULL;
  328. options.client_cert_name = NULL;
  329. options.server_name = NULL;
  330. options.server_addr = NULL;
  331. options.num_floods = 0;
  332. int i;
  333. for (i = 1; i < argc; i++) {
  334. char *arg = argv[i];
  335. if (!strcmp(arg, "--help")) {
  336. options.help = 1;
  337. }
  338. else if (!strcmp(arg, "--version")) {
  339. options.version = 1;
  340. }
  341. else if (!strcmp(arg, "--logger")) {
  342. if (1 >= argc - i) {
  343. fprintf(stderr, "%s: requires an argument\n", arg);
  344. return 0;
  345. }
  346. char *arg2 = argv[i + 1];
  347. if (!strcmp(arg2, "stdout")) {
  348. options.logger = LOGGER_STDOUT;
  349. }
  350. #ifndef BADVPN_USE_WINAPI
  351. else if (!strcmp(arg2, "syslog")) {
  352. options.logger = LOGGER_SYSLOG;
  353. }
  354. #endif
  355. else {
  356. fprintf(stderr, "%s: wrong argument\n", arg);
  357. return 0;
  358. }
  359. i++;
  360. }
  361. #ifndef BADVPN_USE_WINAPI
  362. else if (!strcmp(arg, "--syslog-facility")) {
  363. if (1 >= argc - i) {
  364. fprintf(stderr, "%s: requires an argument\n", arg);
  365. return 0;
  366. }
  367. options.logger_syslog_facility = argv[i + 1];
  368. i++;
  369. }
  370. else if (!strcmp(arg, "--syslog-ident")) {
  371. if (1 >= argc - i) {
  372. fprintf(stderr, "%s: requires an argument\n", arg);
  373. return 0;
  374. }
  375. options.logger_syslog_ident = argv[i + 1];
  376. i++;
  377. }
  378. #endif
  379. else if (!strcmp(arg, "--loglevel")) {
  380. if (1 >= argc - i) {
  381. fprintf(stderr, "%s: requires an argument\n", arg);
  382. return 0;
  383. }
  384. if ((options.loglevel = parse_loglevel(argv[i + 1])) < 0) {
  385. fprintf(stderr, "%s: wrong argument\n", arg);
  386. return 0;
  387. }
  388. i++;
  389. }
  390. else if (!strcmp(arg, "--channel-loglevel")) {
  391. if (2 >= argc - i) {
  392. fprintf(stderr, "%s: requires two arguments\n", arg);
  393. return 0;
  394. }
  395. int channel = BLogGlobal_GetChannelByName(argv[i + 1]);
  396. if (channel < 0) {
  397. fprintf(stderr, "%s: wrong channel argument\n", arg);
  398. return 0;
  399. }
  400. int loglevel = parse_loglevel(argv[i + 2]);
  401. if (loglevel < 0) {
  402. fprintf(stderr, "%s: wrong loglevel argument\n", arg);
  403. return 0;
  404. }
  405. options.loglevels[channel] = loglevel;
  406. i += 2;
  407. }
  408. else if (!strcmp(arg, "--ssl")) {
  409. options.ssl = 1;
  410. }
  411. else if (!strcmp(arg, "--nssdb")) {
  412. if (1 >= argc - i) {
  413. fprintf(stderr, "%s: requires an argument\n", arg);
  414. return 0;
  415. }
  416. options.nssdb = argv[i + 1];
  417. i++;
  418. }
  419. else if (!strcmp(arg, "--client-cert-name")) {
  420. if (1 >= argc - i) {
  421. fprintf(stderr, "%s: requires an argument\n", arg);
  422. return 0;
  423. }
  424. options.client_cert_name = argv[i + 1];
  425. i++;
  426. }
  427. else if (!strcmp(arg, "--server-name")) {
  428. if (1 >= argc - i) {
  429. fprintf(stderr, "%s: requires an argument\n", arg);
  430. return 0;
  431. }
  432. options.server_name = argv[i + 1];
  433. i++;
  434. }
  435. else if (!strcmp(arg, "--server-addr")) {
  436. if (1 >= argc - i) {
  437. fprintf(stderr, "%s: requires an argument\n", arg);
  438. return 0;
  439. }
  440. options.server_addr = argv[i + 1];
  441. i++;
  442. }
  443. else if (!strcmp(arg, "--flood-id")) {
  444. if (1 >= argc - i) {
  445. fprintf(stderr, "%s: requires an argument\n", arg);
  446. return 0;
  447. }
  448. if (options.num_floods == MAX_FLOODS) {
  449. fprintf(stderr, "%s: too many\n", arg);
  450. return 0;
  451. }
  452. options.floods[options.num_floods] = atoi(argv[i + 1]);
  453. options.num_floods++;
  454. i++;
  455. }
  456. else {
  457. fprintf(stderr, "unknown option: %s\n", arg);
  458. return 0;
  459. }
  460. }
  461. if (options.help || options.version) {
  462. return 1;
  463. }
  464. if (options.ssl != !!options.nssdb) {
  465. fprintf(stderr, "False: --ssl <=> --nssdb\n");
  466. return 0;
  467. }
  468. if (options.ssl != !!options.client_cert_name) {
  469. fprintf(stderr, "False: --ssl <=> --client-cert-name\n");
  470. return 0;
  471. }
  472. if (!options.server_addr) {
  473. fprintf(stderr, "False: --server-addr\n");
  474. return 0;
  475. }
  476. return 1;
  477. }
  478. int resolve_arguments (void)
  479. {
  480. // resolve server address
  481. ASSERT(options.server_addr)
  482. if (!BAddr_Parse(&server_addr, options.server_addr, server_name, sizeof(server_name))) {
  483. BLog(BLOG_ERROR, "server addr: BAddr_Parse failed");
  484. return 0;
  485. }
  486. if (!addr_supported(server_addr)) {
  487. BLog(BLOG_ERROR, "server addr: not supported");
  488. return 0;
  489. }
  490. // override server name if requested
  491. if (options.server_name) {
  492. if (strlen(options.server_name) >= sizeof(server_name)) {
  493. BLog(BLOG_ERROR, "server name: too long");
  494. return 0;
  495. }
  496. strcpy(server_name, options.server_name);
  497. }
  498. return 1;
  499. }
  500. void signal_handler (void *unused)
  501. {
  502. BLog(BLOG_NOTICE, "termination requested");
  503. terminate();
  504. }
  505. void server_handler_error (void *user)
  506. {
  507. BLog(BLOG_ERROR, "server connection failed, exiting");
  508. terminate();
  509. }
  510. void server_handler_ready (void *user, peerid_t param_my_id, uint32_t ext_ip)
  511. {
  512. ASSERT(!server_ready)
  513. // remember our ID
  514. my_id = param_my_id;
  515. // init flooding
  516. // init source
  517. PacketRecvInterface_Init(&flood_source, SC_MAX_ENC, flood_source_handler_recv, NULL, BReactor_PendingGroup(&ss));
  518. // init encoder
  519. PacketProtoEncoder_Init(&flood_encoder, &flood_source, BReactor_PendingGroup(&ss));
  520. // init buffer
  521. if (!SinglePacketBuffer_Init(&flood_buffer, PacketProtoEncoder_GetOutput(&flood_encoder), ServerConnection_GetSendInterface(&server), BReactor_PendingGroup(&ss))) {
  522. BLog(BLOG_ERROR, "SinglePacketBuffer_Init failed, exiting");
  523. goto fail1;
  524. }
  525. // set not blocking
  526. flood_blocking = 0;
  527. // set server ready
  528. server_ready = 1;
  529. BLog(BLOG_INFO, "server: ready, my ID is %d", (int)my_id);
  530. return;
  531. fail1:
  532. PacketProtoEncoder_Free(&flood_encoder);
  533. PacketRecvInterface_Free(&flood_source);
  534. terminate();
  535. }
  536. void server_handler_newclient (void *user, peerid_t peer_id, int flags, const uint8_t *cert, int cert_len)
  537. {
  538. ASSERT(server_ready)
  539. BLog(BLOG_INFO, "newclient %d", (int)peer_id);
  540. }
  541. void server_handler_endclient (void *user, peerid_t peer_id)
  542. {
  543. ASSERT(server_ready)
  544. BLog(BLOG_INFO, "endclient %d", (int)peer_id);
  545. }
  546. void server_handler_message (void *user, peerid_t peer_id, uint8_t *data, int data_len)
  547. {
  548. ASSERT(server_ready)
  549. ASSERT(data_len >= 0)
  550. ASSERT(data_len <= SC_MAX_MSGLEN)
  551. BLog(BLOG_INFO, "message from %d", (int)peer_id);
  552. }
  553. void flood_source_handler_recv (void *user, uint8_t *data)
  554. {
  555. ASSERT(server_ready)
  556. ASSERT(!flood_blocking)
  557. if (options.num_floods > 0) {
  558. ASSERT(flood_next >= 0)
  559. ASSERT(flood_next < options.num_floods)
  560. }
  561. if (options.num_floods == 0) {
  562. flood_blocking = 1;
  563. return;
  564. }
  565. peerid_t peer_id = options.floods[flood_next];
  566. flood_next = (flood_next + 1) % options.num_floods;
  567. BLog(BLOG_INFO, "message to %d", (int)peer_id);
  568. struct sc_header header;
  569. header.type = SCID_OUTMSG;
  570. memcpy(data, &header, sizeof(header));
  571. struct sc_client_outmsg omsg;
  572. omsg.clientid = htol16(peer_id);
  573. memcpy(data + sizeof(header), &omsg, sizeof(omsg));
  574. memset(data + sizeof(struct sc_header) + sizeof(struct sc_client_outmsg), 0, SC_MAX_MSGLEN);
  575. PacketRecvInterface_Done(&flood_source, sizeof(struct sc_header) + sizeof(struct sc_client_outmsg) + SC_MAX_MSGLEN);
  576. }