ServerConnection.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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_error (ServerConnection *o);
  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. if (!PacketProtoDecoder_Init(&o->input_decoder, recv_iface, &o->input_interface, BReactor_PendingGroup(o->reactor), o, (PacketProtoDecoder_handler_error)decoder_handler_error)) {
  103. BLog(BLOG_ERROR, "PacketProtoDecoder_Init failed");
  104. goto fail2;
  105. }
  106. // set job to send hello
  107. // this needs to be in here because hello sending must be done after sending started (so we can write into the send buffer),
  108. // but before receiving started (so we don't get into conflict with the user sending packets)
  109. BPending_Init(&o->start_job, BReactor_PendingGroup(o->reactor), (BPending_handler)pending_handler, o);
  110. BPending_Set(&o->start_job);
  111. // init keepalive output branch
  112. SCKeepaliveSource_Init(&o->output_ka_zero, BReactor_PendingGroup(o->reactor));
  113. PacketProtoEncoder_Init(&o->output_ka_encoder, SCKeepaliveSource_GetOutput(&o->output_ka_zero), BReactor_PendingGroup(o->reactor));
  114. // init output common
  115. // init sender
  116. PacketStreamSender_Init(&o->output_sender, send_iface, PACKETPROTO_ENCLEN(SC_MAX_ENC), BReactor_PendingGroup(o->reactor));
  117. // init keepalives
  118. if (!KeepaliveIO_Init(&o->output_keepaliveio, o->reactor, PacketStreamSender_GetInput(&o->output_sender), PacketProtoEncoder_GetOutput(&o->output_ka_encoder), o->keepalive_interval)) {
  119. BLog(BLOG_ERROR, "KeepaliveIO_Init failed");
  120. goto fail3;
  121. }
  122. // init queue
  123. PacketPassPriorityQueue_Init(&o->output_queue, KeepaliveIO_GetInput(&o->output_keepaliveio), BReactor_PendingGroup(o->reactor), 0);
  124. // init output local flow
  125. // init queue flow
  126. PacketPassPriorityQueueFlow_Init(&o->output_local_qflow, &o->output_queue, 0);
  127. // init PacketProtoFlow
  128. if (!PacketProtoFlow_Init(&o->output_local_oflow, SC_MAX_ENC, o->buffer_size, PacketPassPriorityQueueFlow_GetInput(&o->output_local_qflow), BReactor_PendingGroup(o->reactor))) {
  129. BLog(BLOG_ERROR, "PacketProtoFlow_Init failed");
  130. goto fail4;
  131. }
  132. o->output_local_if = PacketProtoFlow_GetInput(&o->output_local_oflow);
  133. // have no output packet
  134. o->output_local_packet_len = -1;
  135. // init output user flow
  136. PacketPassPriorityQueueFlow_Init(&o->output_user_qflow, &o->output_queue, 1);
  137. // update state
  138. o->state = STATE_WAITINIT;
  139. return;
  140. fail4:
  141. PacketPassPriorityQueueFlow_Free(&o->output_local_qflow);
  142. PacketPassPriorityQueue_Free(&o->output_queue);
  143. KeepaliveIO_Free(&o->output_keepaliveio);
  144. fail3:
  145. PacketStreamSender_Free(&o->output_sender);
  146. PacketProtoEncoder_Free(&o->output_ka_encoder);
  147. SCKeepaliveSource_Free(&o->output_ka_zero);
  148. BPending_Free(&o->start_job);
  149. PacketProtoDecoder_Free(&o->input_decoder);
  150. fail2:
  151. PacketPassInterface_Free(&o->input_interface);
  152. if (o->have_ssl) {
  153. BSSLConnection_Free(&o->sslcon);
  154. fail1:
  155. ASSERT_FORCE(PR_Close(o->ssl_prfd) == PR_SUCCESS)
  156. }
  157. fail0a:
  158. BConnection_RecvAsync_Free(&o->con);
  159. BConnection_SendAsync_Free(&o->con);
  160. BConnection_Free(&o->con);
  161. fail0:
  162. // report error
  163. report_error(o);
  164. }
  165. void pending_handler (ServerConnection *o)
  166. {
  167. ASSERT(o->state == STATE_WAITINIT)
  168. DebugObject_Access(&o->d_obj);
  169. // send hello
  170. struct sc_client_hello *packet;
  171. if (!start_packet(o, (void **)&packet, sizeof(struct sc_client_hello))) {
  172. BLog(BLOG_ERROR, "no buffer for hello");
  173. report_error(o);
  174. return;
  175. }
  176. packet->version = htol16(SC_VERSION);
  177. end_packet(o, SCID_CLIENTHELLO);
  178. }
  179. SECStatus client_auth_data_callback (ServerConnection *o, PRFileDesc *fd, CERTDistNames *caNames, CERTCertificate **pRetCert, SECKEYPrivateKey **pRetKey)
  180. {
  181. ASSERT(o->have_ssl)
  182. DebugObject_Access(&o->d_obj);
  183. CERTCertificate *newcert;
  184. if (!(newcert = CERT_DupCertificate(o->client_cert))) {
  185. return SECFailure;
  186. }
  187. SECKEYPrivateKey *newkey;
  188. if (!(newkey = SECKEY_CopyPrivateKey(o->client_key))) {
  189. CERT_DestroyCertificate(newcert);
  190. return SECFailure;
  191. }
  192. *pRetCert = newcert;
  193. *pRetKey = newkey;
  194. return SECSuccess;
  195. }
  196. void connection_handler (ServerConnection *o, int event)
  197. {
  198. DebugObject_Access(&o->d_obj);
  199. ASSERT(o->state >= STATE_WAITINIT)
  200. if (event == BCONNECTION_EVENT_RECVCLOSED) {
  201. BLog(BLOG_INFO, "connection closed");
  202. } else {
  203. BLog(BLOG_INFO, "connection error");
  204. }
  205. report_error(o);
  206. return;
  207. }
  208. void sslcon_handler (ServerConnection *o, int event)
  209. {
  210. DebugObject_Access(&o->d_obj);
  211. ASSERT(o->have_ssl)
  212. ASSERT(o->state >= STATE_WAITINIT)
  213. ASSERT(event == BSSLCONNECTION_EVENT_ERROR)
  214. BLog(BLOG_ERROR, "SSL error");
  215. report_error(o);
  216. return;
  217. }
  218. void decoder_handler_error (ServerConnection *o)
  219. {
  220. DebugObject_Access(&o->d_obj);
  221. ASSERT(o->state >= STATE_WAITINIT)
  222. BLog(BLOG_ERROR, "decoder error");
  223. report_error(o);
  224. return;
  225. }
  226. void input_handler_send (ServerConnection *o, uint8_t *data, int data_len)
  227. {
  228. ASSERT(o->state >= STATE_WAITINIT)
  229. ASSERT(data_len >= 0)
  230. ASSERT(data_len <= SC_MAX_ENC)
  231. DebugObject_Access(&o->d_obj);
  232. // accept packet
  233. PacketPassInterface_Done(&o->input_interface);
  234. // parse header
  235. if (data_len < sizeof(struct sc_header)) {
  236. BLog(BLOG_ERROR, "packet too short (no sc header)");
  237. report_error(o);
  238. return;
  239. }
  240. struct sc_header *header = (struct sc_header *)data;
  241. data += sizeof(*header);
  242. data_len -= sizeof(*header);
  243. uint8_t type = ltoh8(header->type);
  244. // call appropriate handler based on packet type
  245. switch (type) {
  246. case SCID_SERVERHELLO:
  247. packet_hello(o, data, data_len);
  248. return;
  249. case SCID_NEWCLIENT:
  250. packet_newclient(o, data, data_len);
  251. return;
  252. case SCID_ENDCLIENT:
  253. packet_endclient(o, data, data_len);
  254. return;
  255. case SCID_INMSG:
  256. packet_inmsg(o, data, data_len);
  257. return;
  258. default:
  259. BLog(BLOG_ERROR, "unknown packet type %d", (int)type);
  260. report_error(o);
  261. return;
  262. }
  263. }
  264. void packet_hello (ServerConnection *o, uint8_t *data, int data_len)
  265. {
  266. if (o->state != STATE_WAITINIT) {
  267. BLog(BLOG_ERROR, "hello: not expected");
  268. report_error(o);
  269. return;
  270. }
  271. if (data_len != sizeof(struct sc_server_hello)) {
  272. BLog(BLOG_ERROR, "hello: invalid length");
  273. report_error(o);
  274. return;
  275. }
  276. struct sc_server_hello *msg = (struct sc_server_hello *)data;
  277. peerid_t id = ltoh16(msg->id);
  278. // change state
  279. o->state = STATE_COMPLETE;
  280. // report
  281. o->handler_ready(o->user, id, msg->clientAddr);
  282. return;
  283. }
  284. void packet_newclient (ServerConnection *o, uint8_t *data, int data_len)
  285. {
  286. if (o->state != STATE_COMPLETE) {
  287. BLog(BLOG_ERROR, "newclient: not expected");
  288. report_error(o);
  289. return;
  290. }
  291. if (data_len < sizeof(struct sc_server_newclient) || data_len > sizeof(struct sc_server_newclient) + SCID_NEWCLIENT_MAX_CERT_LEN) {
  292. BLog(BLOG_ERROR, "newclient: invalid length");
  293. report_error(o);
  294. return;
  295. }
  296. struct sc_server_newclient *msg = (struct sc_server_newclient *)data;
  297. peerid_t id = ltoh16(msg->id);
  298. int flags = ltoh16(msg->flags);
  299. uint8_t *cert_data = (uint8_t *)msg + sizeof(struct sc_server_newclient);
  300. int cert_len = data_len - sizeof(struct sc_server_newclient);
  301. // report
  302. o->handler_newclient(o->user, id, flags, cert_data, cert_len);
  303. return;
  304. }
  305. void packet_endclient (ServerConnection *o, uint8_t *data, int data_len)
  306. {
  307. if (o->state != STATE_COMPLETE) {
  308. BLog(BLOG_ERROR, "endclient: not expected");
  309. report_error(o);
  310. return;
  311. }
  312. if (data_len != sizeof(struct sc_server_endclient)) {
  313. BLog(BLOG_ERROR, "endclient: invalid length");
  314. report_error(o);
  315. return;
  316. }
  317. struct sc_server_endclient *msg = (struct sc_server_endclient *)data;
  318. peerid_t id = ltoh16(msg->id);
  319. // report
  320. o->handler_endclient(o->user, id);
  321. return;
  322. }
  323. void packet_inmsg (ServerConnection *o, uint8_t *data, int data_len)
  324. {
  325. if (o->state != STATE_COMPLETE) {
  326. BLog(BLOG_ERROR, "inmsg: not expected");
  327. report_error(o);
  328. return;
  329. }
  330. if (data_len < sizeof(struct sc_server_inmsg)) {
  331. BLog(BLOG_ERROR, "inmsg: missing header");
  332. report_error(o);
  333. return;
  334. }
  335. if (data_len > sizeof(struct sc_server_inmsg) + SC_MAX_MSGLEN) {
  336. BLog(BLOG_ERROR, "inmsg: too long");
  337. report_error(o);
  338. return;
  339. }
  340. struct sc_server_inmsg *msg = (struct sc_server_inmsg *)data;
  341. peerid_t peer_id = ltoh16(msg->clientid);
  342. uint8_t *payload = data + sizeof(struct sc_server_inmsg);
  343. int payload_len = data_len - sizeof(struct sc_server_inmsg);
  344. // report
  345. o->handler_message(o->user, peer_id, payload, payload_len);
  346. return;
  347. }
  348. int start_packet (ServerConnection *o, void **data, int len)
  349. {
  350. ASSERT(o->state >= STATE_WAITINIT)
  351. ASSERT(o->output_local_packet_len == -1)
  352. ASSERT(len >= 0)
  353. ASSERT(len <= SC_MAX_PAYLOAD)
  354. ASSERT(data || len == 0)
  355. // obtain memory location
  356. if (!BufferWriter_StartPacket(o->output_local_if, &o->output_local_packet)) {
  357. BLog(BLOG_ERROR, "out of buffer");
  358. return 0;
  359. }
  360. o->output_local_packet_len = len;
  361. if (data) {
  362. *data = o->output_local_packet + sizeof(struct sc_header);
  363. }
  364. return 1;
  365. }
  366. void end_packet (ServerConnection *o, uint8_t type)
  367. {
  368. ASSERT(o->state >= STATE_WAITINIT)
  369. ASSERT(o->output_local_packet_len >= 0)
  370. ASSERT(o->output_local_packet_len <= SC_MAX_PAYLOAD)
  371. // write header
  372. struct sc_header *header = (struct sc_header *)o->output_local_packet;
  373. header->type = htol8(type);
  374. // finish writing packet
  375. BufferWriter_EndPacket(o->output_local_if, sizeof(struct sc_header) + o->output_local_packet_len);
  376. o->output_local_packet_len = -1;
  377. }
  378. int ServerConnection_Init (
  379. ServerConnection *o,
  380. BReactor *reactor,
  381. BAddr addr,
  382. int keepalive_interval,
  383. int buffer_size,
  384. int have_ssl,
  385. CERTCertificate *client_cert,
  386. SECKEYPrivateKey *client_key,
  387. const char *server_name,
  388. void *user,
  389. ServerConnection_handler_error handler_error,
  390. ServerConnection_handler_ready handler_ready,
  391. ServerConnection_handler_newclient handler_newclient,
  392. ServerConnection_handler_endclient handler_endclient,
  393. ServerConnection_handler_message handler_message
  394. )
  395. {
  396. ASSERT(addr.type == BADDR_TYPE_IPV4 || addr.type == BADDR_TYPE_IPV6)
  397. ASSERT(keepalive_interval > 0)
  398. ASSERT(buffer_size > 0)
  399. ASSERT(have_ssl == 0 || have_ssl == 1)
  400. // init arguments
  401. o->reactor = reactor;
  402. o->keepalive_interval = keepalive_interval;
  403. o->buffer_size = buffer_size;
  404. o->have_ssl = have_ssl;
  405. if (have_ssl) {
  406. o->client_cert = client_cert;
  407. o->client_key = client_key;
  408. snprintf(o->server_name, sizeof(o->server_name), "%s", server_name);
  409. }
  410. o->user = user;
  411. o->handler_error = handler_error;
  412. o->handler_ready = handler_ready;
  413. o->handler_newclient = handler_newclient;
  414. o->handler_endclient = handler_endclient;
  415. o->handler_message = handler_message;
  416. // init connector
  417. if (!BConnector_Init(&o->connector, addr, o->reactor, o, (BConnector_handler)connector_handler)) {
  418. BLog(BLOG_ERROR, "BConnector_Init failed");
  419. goto fail0;
  420. }
  421. // set state
  422. o->state = STATE_CONNECTING;
  423. DebugError_Init(&o->d_err, BReactor_PendingGroup(o->reactor));
  424. DebugObject_Init(&o->d_obj);
  425. return 1;
  426. fail0:
  427. return 0;
  428. }
  429. void ServerConnection_Free (ServerConnection *o)
  430. {
  431. DebugObject_Free(&o->d_obj);
  432. DebugError_Free(&o->d_err);
  433. if (o->state > STATE_CONNECTING) {
  434. // allow freeing queue flows
  435. PacketPassPriorityQueue_PrepareFree(&o->output_queue);
  436. // free output user flow
  437. PacketPassPriorityQueueFlow_Free(&o->output_user_qflow);
  438. // free output local flow
  439. PacketProtoFlow_Free(&o->output_local_oflow);
  440. PacketPassPriorityQueueFlow_Free(&o->output_local_qflow);
  441. // free output common
  442. PacketPassPriorityQueue_Free(&o->output_queue);
  443. KeepaliveIO_Free(&o->output_keepaliveio);
  444. PacketStreamSender_Free(&o->output_sender);
  445. // free output keep-alive branch
  446. PacketProtoEncoder_Free(&o->output_ka_encoder);
  447. SCKeepaliveSource_Free(&o->output_ka_zero);
  448. // free job
  449. BPending_Free(&o->start_job);
  450. // free input chain
  451. PacketProtoDecoder_Free(&o->input_decoder);
  452. PacketPassInterface_Free(&o->input_interface);
  453. // free SSL
  454. if (o->have_ssl) {
  455. BSSLConnection_Free(&o->sslcon);
  456. ASSERT_FORCE(PR_Close(o->ssl_prfd) == PR_SUCCESS)
  457. }
  458. // free connection interfaces
  459. BConnection_RecvAsync_Free(&o->con);
  460. BConnection_SendAsync_Free(&o->con);
  461. // free connection
  462. BConnection_Free(&o->con);
  463. }
  464. // free connector
  465. BConnector_Free(&o->connector);
  466. }
  467. int ServerConnection_IsReady (ServerConnection *o)
  468. {
  469. DebugObject_Access(&o->d_obj);
  470. return (o->state == STATE_COMPLETE);
  471. }
  472. int ServerConnection_StartMessage (ServerConnection *o, uint8_t **data, peerid_t peer_id, int len)
  473. {
  474. ASSERT(o->state == STATE_COMPLETE)
  475. ASSERT(o->output_local_packet_len == -1)
  476. ASSERT(len >= 0)
  477. ASSERT(len <= SC_MAX_MSGLEN)
  478. ASSERT(data || len == 0)
  479. DebugError_AssertNoError(&o->d_err);
  480. DebugObject_Access(&o->d_obj);
  481. uint8_t *packet;
  482. if (!start_packet(o, (void **)&packet, sizeof(struct sc_client_outmsg) + len)) {
  483. return 0;
  484. }
  485. struct sc_client_outmsg *msg = (struct sc_client_outmsg *)packet;
  486. msg->clientid = htol16(peer_id);
  487. if (data) {
  488. *data = packet + sizeof(struct sc_client_outmsg);
  489. }
  490. return 1;
  491. }
  492. void ServerConnection_EndMessage (ServerConnection *o)
  493. {
  494. ASSERT(o->state == STATE_COMPLETE)
  495. ASSERT(o->output_local_packet_len >= 0)
  496. DebugError_AssertNoError(&o->d_err);
  497. DebugObject_Access(&o->d_obj);
  498. end_packet(o, SCID_OUTMSG);
  499. }
  500. PacketPassInterface * ServerConnection_GetSendInterface (ServerConnection *o)
  501. {
  502. ASSERT(o->state == STATE_COMPLETE)
  503. DebugError_AssertNoError(&o->d_err);
  504. DebugObject_Access(&o->d_obj);
  505. return PacketPassPriorityQueueFlow_GetInput(&o->output_user_qflow);
  506. }