ServerConnection.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /**
  2. * @file ServerConnection.c
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #include <stdio.h>
  23. #include <misc/debug.h>
  24. #include <base/BLog.h>
  25. #include <server_connection/ServerConnection.h>
  26. #include <generated/blog_channel_ServerConnection.h>
  27. #define STATE_CONNECTING 1
  28. #define STATE_WAITINIT 2
  29. #define STATE_COMPLETE 3
  30. static void report_error (ServerConnection *o);
  31. static void connector_handler (ServerConnection *o, int is_error);
  32. static void pending_handler (ServerConnection *o);
  33. static SECStatus client_auth_data_callback (ServerConnection *o, PRFileDesc *fd, CERTDistNames *caNames, CERTCertificate **pRetCert, SECKEYPrivateKey **pRetKey);
  34. static void connection_handler (ServerConnection *o, int event);
  35. static void sslcon_handler (ServerConnection *o, int event);
  36. static void decoder_handler (ServerConnection *o, int component, int code);
  37. static void input_handler_send (ServerConnection *o, uint8_t *data, int data_len);
  38. static void packet_hello (ServerConnection *o, uint8_t *data, int data_len);
  39. static void packet_newclient (ServerConnection *o, uint8_t *data, int data_len);
  40. static void packet_endclient (ServerConnection *o, uint8_t *data, int data_len);
  41. static void packet_inmsg (ServerConnection *o, uint8_t *data, int data_len);
  42. static int start_packet (ServerConnection *o, void **data, int len);
  43. static void end_packet (ServerConnection *o, uint8_t type);
  44. void report_error (ServerConnection *o)
  45. {
  46. DEBUGERROR(&o->d_err, o->handler_error(o->user))
  47. }
  48. void connector_handler (ServerConnection *o, int is_error)
  49. {
  50. DebugObject_Access(&o->d_obj);
  51. ASSERT(o->state == STATE_CONNECTING)
  52. // check connection attempt result
  53. if (is_error) {
  54. BLog(BLOG_ERROR, "connection failed");
  55. goto fail0;
  56. }
  57. BLog(BLOG_NOTICE, "connected");
  58. // init connection
  59. if (!BConnection_Init(&o->con, BCONNECTION_SOURCE_CONNECTOR(&o->connector), o->reactor, o, (BConnection_handler)connection_handler)) {
  60. BLog(BLOG_ERROR, "BConnection_Init failed");
  61. goto fail0;
  62. }
  63. // init connection interfaces
  64. BConnection_SendAsync_Init(&o->con);
  65. BConnection_RecvAsync_Init(&o->con);
  66. StreamPassInterface *send_iface = BConnection_SendAsync_GetIf(&o->con);
  67. StreamRecvInterface *recv_iface = BConnection_RecvAsync_GetIf(&o->con);
  68. if (o->have_ssl) {
  69. // create bottom NSPR file descriptor
  70. if (!BSSLConnection_MakeBackend(&o->bottom_prfd, send_iface, recv_iface)) {
  71. BLog(BLOG_ERROR, "BSSLConnection_MakeBackend failed");
  72. goto fail0a;
  73. }
  74. // create SSL file descriptor from the bottom NSPR file descriptor
  75. if (!(o->ssl_prfd = SSL_ImportFD(NULL, &o->bottom_prfd))) {
  76. BLog(BLOG_ERROR, "SSL_ImportFD failed");
  77. ASSERT_FORCE(PR_Close(&o->bottom_prfd) == PR_SUCCESS)
  78. goto fail0a;
  79. }
  80. // set client mode
  81. if (SSL_ResetHandshake(o->ssl_prfd, PR_FALSE) != SECSuccess) {
  82. BLog(BLOG_ERROR, "SSL_ResetHandshake failed");
  83. goto fail1;
  84. }
  85. // set server name
  86. if (SSL_SetURL(o->ssl_prfd, o->server_name) != SECSuccess) {
  87. BLog(BLOG_ERROR, "SSL_SetURL failed");
  88. goto fail1;
  89. }
  90. // set client certificate callback
  91. if (SSL_GetClientAuthDataHook(o->ssl_prfd, (SSLGetClientAuthData)client_auth_data_callback, o) != SECSuccess) {
  92. BLog(BLOG_ERROR, "SSL_GetClientAuthDataHook failed");
  93. goto fail1;
  94. }
  95. // init BSSLConnection
  96. BSSLConnection_Init(&o->sslcon, o->ssl_prfd, 0, o->reactor, o, (BSSLConnection_handler)sslcon_handler);
  97. send_iface = BSSLConnection_GetSendIf(&o->sslcon);
  98. recv_iface = BSSLConnection_GetRecvIf(&o->sslcon);
  99. }
  100. // init input chain
  101. PacketPassInterface_Init(&o->input_interface, SC_MAX_ENC, (PacketPassInterface_handler_send)input_handler_send, o, BReactor_PendingGroup(o->reactor));
  102. FlowErrorDomain_Init(&o->input_decoder_domain, (FlowErrorDomain_handler)decoder_handler, o);
  103. if (!PacketProtoDecoder_Init(&o->input_decoder, FlowErrorReporter_Create(&o->input_decoder_domain, 0), recv_iface, &o->input_interface, BReactor_PendingGroup(o->reactor))) {
  104. BLog(BLOG_ERROR, "PacketProtoDecoder_Init failed");
  105. goto fail2;
  106. }
  107. // set job to send hello
  108. // this needs to be in here because hello sending must be done after sending started (so we can write into the send buffer),
  109. // but before receiving started (so we don't get into conflict with the user sending packets)
  110. BPending_Init(&o->start_job, BReactor_PendingGroup(o->reactor), (BPending_handler)pending_handler, o);
  111. BPending_Set(&o->start_job);
  112. // init keepalive output branch
  113. SCKeepaliveSource_Init(&o->output_ka_zero, BReactor_PendingGroup(o->reactor));
  114. PacketProtoEncoder_Init(&o->output_ka_encoder, SCKeepaliveSource_GetOutput(&o->output_ka_zero), BReactor_PendingGroup(o->reactor));
  115. // init output common
  116. // init sender
  117. PacketStreamSender_Init(&o->output_sender, send_iface, PACKETPROTO_ENCLEN(SC_MAX_ENC), BReactor_PendingGroup(o->reactor));
  118. // init keepalives
  119. if (!KeepaliveIO_Init(&o->output_keepaliveio, o->reactor, PacketStreamSender_GetInput(&o->output_sender), PacketProtoEncoder_GetOutput(&o->output_ka_encoder), o->keepalive_interval)) {
  120. BLog(BLOG_ERROR, "KeepaliveIO_Init failed");
  121. goto fail3;
  122. }
  123. // init queue
  124. PacketPassPriorityQueue_Init(&o->output_queue, KeepaliveIO_GetInput(&o->output_keepaliveio), BReactor_PendingGroup(o->reactor), 0);
  125. // init output local flow
  126. // init queue flow
  127. PacketPassPriorityQueueFlow_Init(&o->output_local_qflow, &o->output_queue, 0);
  128. // init PacketProtoFlow
  129. if (!PacketProtoFlow_Init(&o->output_local_oflow, SC_MAX_ENC, o->buffer_size, PacketPassPriorityQueueFlow_GetInput(&o->output_local_qflow), BReactor_PendingGroup(o->reactor))) {
  130. BLog(BLOG_ERROR, "PacketProtoFlow_Init failed");
  131. goto fail4;
  132. }
  133. o->output_local_if = PacketProtoFlow_GetInput(&o->output_local_oflow);
  134. // have no output packet
  135. o->output_local_packet_len = -1;
  136. // init output user flow
  137. PacketPassPriorityQueueFlow_Init(&o->output_user_qflow, &o->output_queue, 1);
  138. // update state
  139. o->state = STATE_WAITINIT;
  140. return;
  141. fail4:
  142. PacketPassPriorityQueueFlow_Free(&o->output_local_qflow);
  143. PacketPassPriorityQueue_Free(&o->output_queue);
  144. KeepaliveIO_Free(&o->output_keepaliveio);
  145. fail3:
  146. PacketStreamSender_Free(&o->output_sender);
  147. PacketProtoEncoder_Free(&o->output_ka_encoder);
  148. SCKeepaliveSource_Free(&o->output_ka_zero);
  149. BPending_Free(&o->start_job);
  150. PacketProtoDecoder_Free(&o->input_decoder);
  151. fail2:
  152. PacketPassInterface_Free(&o->input_interface);
  153. if (o->have_ssl) {
  154. BSSLConnection_Free(&o->sslcon);
  155. fail1:
  156. ASSERT_FORCE(PR_Close(o->ssl_prfd) == PR_SUCCESS)
  157. }
  158. fail0a:
  159. BConnection_RecvAsync_Free(&o->con);
  160. BConnection_SendAsync_Free(&o->con);
  161. BConnection_Free(&o->con);
  162. fail0:
  163. // report error
  164. report_error(o);
  165. }
  166. void pending_handler (ServerConnection *o)
  167. {
  168. ASSERT(o->state == STATE_WAITINIT)
  169. DebugObject_Access(&o->d_obj);
  170. // send hello
  171. struct sc_client_hello *packet;
  172. if (!start_packet(o, (void **)&packet, sizeof(struct sc_client_hello))) {
  173. BLog(BLOG_ERROR, "no buffer for hello");
  174. report_error(o);
  175. return;
  176. }
  177. packet->version = htol16(SC_VERSION);
  178. end_packet(o, SCID_CLIENTHELLO);
  179. }
  180. SECStatus client_auth_data_callback (ServerConnection *o, PRFileDesc *fd, CERTDistNames *caNames, CERTCertificate **pRetCert, SECKEYPrivateKey **pRetKey)
  181. {
  182. ASSERT(o->have_ssl)
  183. DebugObject_Access(&o->d_obj);
  184. CERTCertificate *newcert;
  185. if (!(newcert = CERT_DupCertificate(o->client_cert))) {
  186. return SECFailure;
  187. }
  188. SECKEYPrivateKey *newkey;
  189. if (!(newkey = SECKEY_CopyPrivateKey(o->client_key))) {
  190. CERT_DestroyCertificate(newcert);
  191. return SECFailure;
  192. }
  193. *pRetCert = newcert;
  194. *pRetKey = newkey;
  195. return SECSuccess;
  196. }
  197. void connection_handler (ServerConnection *o, int event)
  198. {
  199. DebugObject_Access(&o->d_obj);
  200. ASSERT(o->state >= STATE_WAITINIT)
  201. if (event == BCONNECTION_EVENT_RECVCLOSED) {
  202. BLog(BLOG_INFO, "connection closed");
  203. } else {
  204. BLog(BLOG_INFO, "connection error");
  205. }
  206. report_error(o);
  207. return;
  208. }
  209. void sslcon_handler (ServerConnection *o, int event)
  210. {
  211. DebugObject_Access(&o->d_obj);
  212. ASSERT(o->have_ssl)
  213. ASSERT(o->state >= STATE_WAITINIT)
  214. ASSERT(event == BSSLCONNECTION_EVENT_ERROR)
  215. BLog(BLOG_ERROR, "SSL error");
  216. report_error(o);
  217. return;
  218. }
  219. void decoder_handler (ServerConnection *o, int component, int code)
  220. {
  221. DebugObject_Access(&o->d_obj);
  222. ASSERT(o->state >= STATE_WAITINIT)
  223. BLog(BLOG_ERROR, "decoder error");
  224. report_error(o);
  225. return;
  226. }
  227. void input_handler_send (ServerConnection *o, uint8_t *data, int data_len)
  228. {
  229. ASSERT(o->state >= STATE_WAITINIT)
  230. ASSERT(data_len >= 0)
  231. ASSERT(data_len <= SC_MAX_ENC)
  232. DebugObject_Access(&o->d_obj);
  233. // accept packet
  234. PacketPassInterface_Done(&o->input_interface);
  235. // parse header
  236. if (data_len < sizeof(struct sc_header)) {
  237. BLog(BLOG_ERROR, "packet too short (no sc header)");
  238. report_error(o);
  239. return;
  240. }
  241. struct sc_header *header = (struct sc_header *)data;
  242. data += sizeof(*header);
  243. data_len -= sizeof(*header);
  244. uint8_t type = ltoh8(header->type);
  245. // call appropriate handler based on packet type
  246. switch (type) {
  247. case SCID_SERVERHELLO:
  248. packet_hello(o, data, data_len);
  249. return;
  250. case SCID_NEWCLIENT:
  251. packet_newclient(o, data, data_len);
  252. return;
  253. case SCID_ENDCLIENT:
  254. packet_endclient(o, data, data_len);
  255. return;
  256. case SCID_INMSG:
  257. packet_inmsg(o, data, data_len);
  258. return;
  259. default:
  260. BLog(BLOG_ERROR, "unknown packet type %d", (int)type);
  261. report_error(o);
  262. return;
  263. }
  264. }
  265. void packet_hello (ServerConnection *o, uint8_t *data, int data_len)
  266. {
  267. if (o->state != STATE_WAITINIT) {
  268. BLog(BLOG_ERROR, "hello: not expected");
  269. report_error(o);
  270. return;
  271. }
  272. if (data_len != sizeof(struct sc_server_hello)) {
  273. BLog(BLOG_ERROR, "hello: invalid length");
  274. report_error(o);
  275. return;
  276. }
  277. struct sc_server_hello *msg = (struct sc_server_hello *)data;
  278. peerid_t id = ltoh16(msg->id);
  279. // change state
  280. o->state = STATE_COMPLETE;
  281. // report
  282. o->handler_ready(o->user, id, msg->clientAddr);
  283. return;
  284. }
  285. void packet_newclient (ServerConnection *o, uint8_t *data, int data_len)
  286. {
  287. if (o->state != STATE_COMPLETE) {
  288. BLog(BLOG_ERROR, "newclient: not expected");
  289. report_error(o);
  290. return;
  291. }
  292. if (data_len < sizeof(struct sc_server_newclient) || data_len > sizeof(struct sc_server_newclient) + SCID_NEWCLIENT_MAX_CERT_LEN) {
  293. BLog(BLOG_ERROR, "newclient: invalid length");
  294. report_error(o);
  295. return;
  296. }
  297. struct sc_server_newclient *msg = (struct sc_server_newclient *)data;
  298. peerid_t id = ltoh16(msg->id);
  299. int flags = ltoh16(msg->flags);
  300. uint8_t *cert_data = (uint8_t *)msg + sizeof(struct sc_server_newclient);
  301. int cert_len = data_len - sizeof(struct sc_server_newclient);
  302. // report
  303. o->handler_newclient(o->user, id, flags, cert_data, cert_len);
  304. return;
  305. }
  306. void packet_endclient (ServerConnection *o, uint8_t *data, int data_len)
  307. {
  308. if (o->state != STATE_COMPLETE) {
  309. BLog(BLOG_ERROR, "endclient: not expected");
  310. report_error(o);
  311. return;
  312. }
  313. if (data_len != sizeof(struct sc_server_endclient)) {
  314. BLog(BLOG_ERROR, "endclient: invalid length");
  315. report_error(o);
  316. return;
  317. }
  318. struct sc_server_endclient *msg = (struct sc_server_endclient *)data;
  319. peerid_t id = ltoh16(msg->id);
  320. // report
  321. o->handler_endclient(o->user, id);
  322. return;
  323. }
  324. void packet_inmsg (ServerConnection *o, uint8_t *data, int data_len)
  325. {
  326. if (o->state != STATE_COMPLETE) {
  327. BLog(BLOG_ERROR, "inmsg: not expected");
  328. report_error(o);
  329. return;
  330. }
  331. if (data_len < sizeof(struct sc_server_inmsg)) {
  332. BLog(BLOG_ERROR, "inmsg: missing header");
  333. report_error(o);
  334. return;
  335. }
  336. if (data_len > sizeof(struct sc_server_inmsg) + SC_MAX_MSGLEN) {
  337. BLog(BLOG_ERROR, "inmsg: too long");
  338. report_error(o);
  339. return;
  340. }
  341. struct sc_server_inmsg *msg = (struct sc_server_inmsg *)data;
  342. peerid_t peer_id = ltoh16(msg->clientid);
  343. uint8_t *payload = data + sizeof(struct sc_server_inmsg);
  344. int payload_len = data_len - sizeof(struct sc_server_inmsg);
  345. // report
  346. o->handler_message(o->user, peer_id, payload, payload_len);
  347. return;
  348. }
  349. int start_packet (ServerConnection *o, void **data, int len)
  350. {
  351. ASSERT(o->state >= STATE_WAITINIT)
  352. ASSERT(o->output_local_packet_len == -1)
  353. ASSERT(len >= 0)
  354. ASSERT(len <= SC_MAX_PAYLOAD)
  355. ASSERT(data || len == 0)
  356. // obtain memory location
  357. if (!BufferWriter_StartPacket(o->output_local_if, &o->output_local_packet)) {
  358. BLog(BLOG_ERROR, "out of buffer");
  359. return 0;
  360. }
  361. o->output_local_packet_len = len;
  362. if (data) {
  363. *data = o->output_local_packet + sizeof(struct sc_header);
  364. }
  365. return 1;
  366. }
  367. void end_packet (ServerConnection *o, uint8_t type)
  368. {
  369. ASSERT(o->state >= STATE_WAITINIT)
  370. ASSERT(o->output_local_packet_len >= 0)
  371. ASSERT(o->output_local_packet_len <= SC_MAX_PAYLOAD)
  372. // write header
  373. struct sc_header *header = (struct sc_header *)o->output_local_packet;
  374. header->type = htol8(type);
  375. // finish writing packet
  376. BufferWriter_EndPacket(o->output_local_if, sizeof(struct sc_header) + o->output_local_packet_len);
  377. o->output_local_packet_len = -1;
  378. }
  379. int ServerConnection_Init (
  380. ServerConnection *o,
  381. BReactor *reactor,
  382. BAddr addr,
  383. int keepalive_interval,
  384. int buffer_size,
  385. int have_ssl,
  386. CERTCertificate *client_cert,
  387. SECKEYPrivateKey *client_key,
  388. const char *server_name,
  389. void *user,
  390. ServerConnection_handler_error handler_error,
  391. ServerConnection_handler_ready handler_ready,
  392. ServerConnection_handler_newclient handler_newclient,
  393. ServerConnection_handler_endclient handler_endclient,
  394. ServerConnection_handler_message handler_message
  395. )
  396. {
  397. ASSERT(addr.type == BADDR_TYPE_IPV4 || addr.type == BADDR_TYPE_IPV6)
  398. ASSERT(keepalive_interval > 0)
  399. ASSERT(buffer_size > 0)
  400. ASSERT(have_ssl == 0 || have_ssl == 1)
  401. // init arguments
  402. o->reactor = reactor;
  403. o->keepalive_interval = keepalive_interval;
  404. o->buffer_size = buffer_size;
  405. o->have_ssl = have_ssl;
  406. if (have_ssl) {
  407. o->client_cert = client_cert;
  408. o->client_key = client_key;
  409. snprintf(o->server_name, sizeof(o->server_name), "%s", server_name);
  410. }
  411. o->user = user;
  412. o->handler_error = handler_error;
  413. o->handler_ready = handler_ready;
  414. o->handler_newclient = handler_newclient;
  415. o->handler_endclient = handler_endclient;
  416. o->handler_message = handler_message;
  417. // init connector
  418. if (!BConnector_Init(&o->connector, addr, o->reactor, o, (BConnector_handler)connector_handler)) {
  419. BLog(BLOG_ERROR, "BConnector_Init failed");
  420. goto fail0;
  421. }
  422. // set state
  423. o->state = STATE_CONNECTING;
  424. DebugError_Init(&o->d_err, BReactor_PendingGroup(o->reactor));
  425. DebugObject_Init(&o->d_obj);
  426. return 1;
  427. fail0:
  428. return 0;
  429. }
  430. void ServerConnection_Free (ServerConnection *o)
  431. {
  432. DebugObject_Free(&o->d_obj);
  433. DebugError_Free(&o->d_err);
  434. if (o->state > STATE_CONNECTING) {
  435. // allow freeing queue flows
  436. PacketPassPriorityQueue_PrepareFree(&o->output_queue);
  437. // free output user flow
  438. PacketPassPriorityQueueFlow_Free(&o->output_user_qflow);
  439. // free output local flow
  440. PacketProtoFlow_Free(&o->output_local_oflow);
  441. PacketPassPriorityQueueFlow_Free(&o->output_local_qflow);
  442. // free output common
  443. PacketPassPriorityQueue_Free(&o->output_queue);
  444. KeepaliveIO_Free(&o->output_keepaliveio);
  445. PacketStreamSender_Free(&o->output_sender);
  446. // free output keep-alive branch
  447. PacketProtoEncoder_Free(&o->output_ka_encoder);
  448. SCKeepaliveSource_Free(&o->output_ka_zero);
  449. // free job
  450. BPending_Free(&o->start_job);
  451. // free input chain
  452. PacketProtoDecoder_Free(&o->input_decoder);
  453. PacketPassInterface_Free(&o->input_interface);
  454. // free SSL
  455. if (o->have_ssl) {
  456. BSSLConnection_Free(&o->sslcon);
  457. ASSERT_FORCE(PR_Close(o->ssl_prfd) == PR_SUCCESS)
  458. }
  459. // free connection interfaces
  460. BConnection_RecvAsync_Free(&o->con);
  461. BConnection_SendAsync_Free(&o->con);
  462. // free connection
  463. BConnection_Free(&o->con);
  464. }
  465. // free connector
  466. BConnector_Free(&o->connector);
  467. }
  468. int ServerConnection_IsReady (ServerConnection *o)
  469. {
  470. DebugObject_Access(&o->d_obj);
  471. return (o->state == STATE_COMPLETE);
  472. }
  473. int ServerConnection_StartMessage (ServerConnection *o, uint8_t **data, peerid_t peer_id, int len)
  474. {
  475. ASSERT(o->state == STATE_COMPLETE)
  476. ASSERT(o->output_local_packet_len == -1)
  477. ASSERT(len >= 0)
  478. ASSERT(len <= SC_MAX_MSGLEN)
  479. ASSERT(data || len == 0)
  480. DebugError_AssertNoError(&o->d_err);
  481. DebugObject_Access(&o->d_obj);
  482. uint8_t *packet;
  483. if (!start_packet(o, (void **)&packet, sizeof(struct sc_client_outmsg) + len)) {
  484. return 0;
  485. }
  486. struct sc_client_outmsg *msg = (struct sc_client_outmsg *)packet;
  487. msg->clientid = htol16(peer_id);
  488. if (data) {
  489. *data = packet + sizeof(struct sc_client_outmsg);
  490. }
  491. return 1;
  492. }
  493. void ServerConnection_EndMessage (ServerConnection *o)
  494. {
  495. ASSERT(o->state == STATE_COMPLETE)
  496. ASSERT(o->output_local_packet_len >= 0)
  497. DebugError_AssertNoError(&o->d_err);
  498. DebugObject_Access(&o->d_obj);
  499. end_packet(o, SCID_OUTMSG);
  500. }
  501. PacketPassInterface * ServerConnection_GetSendInterface (ServerConnection *o)
  502. {
  503. ASSERT(o->state == STATE_COMPLETE)
  504. DebugError_AssertNoError(&o->d_err);
  505. DebugObject_Access(&o->d_obj);
  506. return PacketPassPriorityQueueFlow_GetInput(&o->output_user_qflow);
  507. }