Coverage Report

Created: 2026-06-15 06:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/librabbitmq/librabbitmq/amqp_connection.c
Line
Count
Source
1
// Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors.
2
// SPDX-License-Identifier: mit
3
4
#ifdef HAVE_CONFIG_H
5
#include "config.h"
6
#endif
7
8
#ifdef _MSC_VER
9
#define _CRT_SECURE_NO_WARNINGS
10
#endif
11
12
#include "amqp_private.h"
13
#include "amqp_time.h"
14
#include "rabbitmq-c/tcp_socket.h"
15
#include <errno.h>
16
#include <stdint.h>
17
#include <stdio.h>
18
#include <stdlib.h>
19
#include <string.h>
20
21
#ifndef AMQP_INITIAL_FRAME_POOL_PAGE_SIZE
22
0
#define AMQP_INITIAL_FRAME_POOL_PAGE_SIZE 65536
23
#endif
24
25
#ifndef AMQP_INITIAL_INBOUND_SOCK_BUFFER_SIZE
26
0
#define AMQP_INITIAL_INBOUND_SOCK_BUFFER_SIZE 131072
27
#endif
28
29
#ifndef AMQP_DEFAULT_LOGIN_TIMEOUT_SEC
30
0
#define AMQP_DEFAULT_LOGIN_TIMEOUT_SEC 12
31
#endif
32
33
#define ENFORCE_STATE(statevec, statenum)                                   \
34
0
  {                                                                         \
35
0
    amqp_connection_state_t _check_state = (statevec);                      \
36
0
    amqp_connection_state_enum _wanted_state = (statenum);                  \
37
0
    if (_check_state->state != _wanted_state)                               \
38
0
      amqp_abort(                                                           \
39
0
          "Programming error: invalid AMQP connection state: expected %d, " \
40
0
          "got %d",                                                         \
41
0
          _wanted_state, _check_state->state);                              \
42
0
  }
43
44
0
amqp_connection_state_t amqp_new_connection(void) {
45
0
  int res;
46
0
  amqp_connection_state_t state = (amqp_connection_state_t)calloc(
47
0
      1, sizeof(struct amqp_connection_state_t_));
48
49
0
  if (state == NULL) {
50
0
    return NULL;
51
0
  }
52
53
0
  res = amqp_tune_connection(state, 0, AMQP_INITIAL_FRAME_POOL_PAGE_SIZE, 0);
54
0
  if (0 != res) {
55
0
    goto out_nomem;
56
0
  }
57
58
0
  state->inbound_buffer.bytes = state->header_buffer;
59
0
  state->inbound_buffer.len = sizeof(state->header_buffer);
60
61
0
  state->state = CONNECTION_STATE_INITIAL;
62
  /* the server protocol version response is 8 bytes, which conveniently
63
     is also the minimum frame size */
64
0
  state->target_size = 8;
65
66
0
  state->sock_inbound_buffer.len = AMQP_INITIAL_INBOUND_SOCK_BUFFER_SIZE;
67
0
  state->sock_inbound_buffer.bytes =
68
0
      malloc(AMQP_INITIAL_INBOUND_SOCK_BUFFER_SIZE);
69
0
  if (state->sock_inbound_buffer.bytes == NULL) {
70
0
    goto out_nomem;
71
0
  }
72
73
0
  init_amqp_pool(&state->properties_pool, 512);
74
75
  /* Use address of the internal_handshake_timeout object by default. */
76
0
  state->internal_handshake_timeout.tv_sec = AMQP_DEFAULT_LOGIN_TIMEOUT_SEC;
77
0
  state->internal_handshake_timeout.tv_usec = 0;
78
0
  state->handshake_timeout = &state->internal_handshake_timeout;
79
80
0
  return state;
81
82
0
out_nomem:
83
0
  free(state->sock_inbound_buffer.bytes);
84
0
  free(state);
85
0
  return NULL;
86
0
}
87
88
0
int amqp_get_sockfd(amqp_connection_state_t state) {
89
0
  return state->socket ? amqp_socket_get_sockfd(state->socket) : -1;
90
0
}
91
92
0
void amqp_set_sockfd(amqp_connection_state_t state, int sockfd) {
93
0
  amqp_socket_t *socket = amqp_tcp_socket_new(state);
94
0
  if (!socket) {
95
0
    amqp_abort("%s", strerror(errno));
96
0
  }
97
0
  amqp_tcp_socket_set_sockfd(socket, sockfd);
98
0
}
99
100
0
void amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket) {
101
0
  amqp_socket_delete(state->socket);
102
0
  state->socket = socket;
103
0
}
104
105
0
amqp_socket_t *amqp_get_socket(amqp_connection_state_t state) {
106
0
  return state->socket;
107
0
}
108
109
int amqp_tune_connection(amqp_connection_state_t state, int channel_max,
110
0
                         int frame_max, int heartbeat) {
111
0
  void *newbuf;
112
0
  int res;
113
114
0
  ENFORCE_STATE(state, CONNECTION_STATE_IDLE);
115
116
0
  if (frame_max < AMQP_FRAME_MIN_SIZE) {
117
0
    frame_max = AMQP_FRAME_MIN_SIZE;
118
0
  }
119
120
0
  state->channel_max = channel_max;
121
0
  state->frame_max = frame_max;
122
123
0
  state->heartbeat = heartbeat;
124
0
  if (0 > state->heartbeat) {
125
0
    state->heartbeat = 0;
126
0
  }
127
128
0
  res = amqp_time_s_from_now(&state->next_send_heartbeat,
129
0
                             amqp_heartbeat_send(state));
130
0
  if (AMQP_STATUS_OK != res) {
131
0
    return res;
132
0
  }
133
0
  res = amqp_time_s_from_now(&state->next_recv_heartbeat,
134
0
                             amqp_heartbeat_recv(state));
135
0
  if (AMQP_STATUS_OK != res) {
136
0
    return res;
137
0
  }
138
139
0
  state->outbound_buffer.len = frame_max;
140
0
  newbuf = realloc(state->outbound_buffer.bytes, frame_max);
141
0
  if (newbuf == NULL) {
142
0
    return AMQP_STATUS_NO_MEMORY;
143
0
  }
144
0
  state->outbound_buffer.bytes = newbuf;
145
146
0
  return AMQP_STATUS_OK;
147
0
}
148
149
0
int amqp_get_channel_max(amqp_connection_state_t state) {
150
0
  return state->channel_max;
151
0
}
152
153
0
int amqp_get_frame_max(amqp_connection_state_t state) {
154
0
  return state->frame_max;
155
0
}
156
157
0
int amqp_get_heartbeat(amqp_connection_state_t state) {
158
0
  return state->heartbeat;
159
0
}
160
161
0
int amqp_destroy_connection(amqp_connection_state_t state) {
162
0
  int status = AMQP_STATUS_OK;
163
0
  if (state) {
164
0
    int i;
165
0
    for (i = 0; i < POOL_TABLE_SIZE; ++i) {
166
0
      amqp_pool_table_entry_t *entry = state->pool_table[i];
167
0
      while (NULL != entry) {
168
0
        amqp_pool_table_entry_t *todelete = entry;
169
0
        empty_amqp_pool(&entry->pool);
170
0
        entry = entry->next;
171
0
        free(todelete);
172
0
      }
173
0
    }
174
175
0
    free(state->outbound_buffer.bytes);
176
0
    free(state->sock_inbound_buffer.bytes);
177
0
    amqp_socket_delete(state->socket);
178
0
    empty_amqp_pool(&state->properties_pool);
179
0
    free(state);
180
0
  }
181
0
  return status;
182
0
}
183
184
0
static void return_to_idle(amqp_connection_state_t state) {
185
0
  state->inbound_buffer.len = sizeof(state->header_buffer);
186
0
  state->inbound_buffer.bytes = state->header_buffer;
187
0
  state->inbound_offset = 0;
188
0
  state->target_size = HEADER_SIZE;
189
0
  state->state = CONNECTION_STATE_IDLE;
190
0
}
191
192
static size_t consume_data(amqp_connection_state_t state,
193
0
                           amqp_bytes_t *received_data) {
194
  /* how much data is available and will fit? */
195
0
  size_t bytes_consumed = state->target_size - state->inbound_offset;
196
0
  if (received_data->len < bytes_consumed) {
197
0
    bytes_consumed = received_data->len;
198
0
  }
199
200
0
  memcpy(amqp_offset(state->inbound_buffer.bytes, state->inbound_offset),
201
0
         received_data->bytes, bytes_consumed);
202
0
  state->inbound_offset += bytes_consumed;
203
0
  received_data->bytes = amqp_offset(received_data->bytes, bytes_consumed);
204
0
  received_data->len -= bytes_consumed;
205
206
0
  return bytes_consumed;
207
0
}
208
209
int amqp_handle_input(amqp_connection_state_t state, amqp_bytes_t received_data,
210
0
                      amqp_frame_t *decoded_frame) {
211
0
  size_t bytes_consumed;
212
0
  void *raw_frame;
213
214
  /* Returning frame_type of zero indicates either insufficient input,
215
     or a complete, ignored frame was read. */
216
0
  decoded_frame->frame_type = 0;
217
218
0
  if (received_data.len == 0) {
219
0
    return AMQP_STATUS_OK;
220
0
  }
221
222
0
  if (state->state == CONNECTION_STATE_IDLE) {
223
0
    state->state = CONNECTION_STATE_HEADER;
224
0
  }
225
226
0
  bytes_consumed = consume_data(state, &received_data);
227
228
  /* do we have target_size data yet? if not, return with the
229
     expectation that more will arrive */
230
0
  if (state->inbound_offset < state->target_size) {
231
0
    return (int)bytes_consumed;
232
0
  }
233
234
0
  raw_frame = state->inbound_buffer.bytes;
235
236
0
  switch (state->state) {
237
0
    case CONNECTION_STATE_INITIAL:
238
      /* check for a protocol header from the server */
239
0
      if (memcmp(raw_frame, "AMQP", 4) == 0) {
240
0
        decoded_frame->frame_type = AMQP_PSEUDOFRAME_PROTOCOL_HEADER;
241
0
        decoded_frame->channel = 0;
242
243
0
        decoded_frame->payload.protocol_header.transport_high =
244
0
            amqp_d8(amqp_offset(raw_frame, 4));
245
0
        decoded_frame->payload.protocol_header.transport_low =
246
0
            amqp_d8(amqp_offset(raw_frame, 5));
247
0
        decoded_frame->payload.protocol_header.protocol_version_major =
248
0
            amqp_d8(amqp_offset(raw_frame, 6));
249
0
        decoded_frame->payload.protocol_header.protocol_version_minor =
250
0
            amqp_d8(amqp_offset(raw_frame, 7));
251
252
0
        return_to_idle(state);
253
0
        return (int)bytes_consumed;
254
0
      }
255
256
      /* it's not a protocol header; fall through to process it as a
257
         regular frame header */
258
259
0
    case CONNECTION_STATE_HEADER: {
260
0
      amqp_channel_t channel;
261
0
      amqp_pool_t *channel_pool;
262
0
      uint32_t frame_size;
263
264
0
      channel = amqp_d16(amqp_offset(raw_frame, 1));
265
266
      /* frame length is 3 bytes in */
267
0
      frame_size = amqp_d32(amqp_offset(raw_frame, 3));
268
      /* To prevent the target_size calculation below from overflowing, check
269
       * that the stated frame_size is smaller than a signed 32-bit. Given
270
       * the library only allows configuring frame_max as an int32_t, and
271
       * frame_size is uint32_t, the math below is safe from overflow. */
272
0
      if (frame_size >= INT32_MAX) {
273
0
        return AMQP_STATUS_BAD_AMQP_DATA;
274
0
      }
275
276
0
      frame_size = frame_size + HEADER_SIZE + FOOTER_SIZE;
277
0
      if ((size_t)state->frame_max < frame_size) {
278
0
        return AMQP_STATUS_BAD_AMQP_DATA;
279
0
      }
280
281
0
      channel_pool = amqp_get_or_create_channel_pool(state, channel);
282
0
      if (NULL == channel_pool) {
283
0
        return AMQP_STATUS_NO_MEMORY;
284
0
      }
285
286
0
      amqp_pool_alloc_bytes(channel_pool, frame_size, &state->inbound_buffer);
287
0
      if (NULL == state->inbound_buffer.bytes) {
288
0
        return AMQP_STATUS_NO_MEMORY;
289
0
      }
290
0
      memcpy(state->inbound_buffer.bytes, state->header_buffer, HEADER_SIZE);
291
0
      raw_frame = state->inbound_buffer.bytes;
292
293
0
      state->state = CONNECTION_STATE_BODY;
294
0
      state->target_size = frame_size;
295
0
      bytes_consumed += consume_data(state, &received_data);
296
297
      /* do we have target_size data yet? if not, return with the
298
         expectation that more will arrive */
299
0
      if (state->inbound_offset < state->target_size) {
300
0
        return (int)bytes_consumed;
301
0
      }
302
0
    }
303
      /* fall through to process body */
304
305
0
    case CONNECTION_STATE_BODY: {
306
0
      amqp_bytes_t encoded;
307
0
      int res;
308
0
      amqp_pool_t *channel_pool;
309
310
      /* Check frame end marker (footer) */
311
0
      if (amqp_d8(amqp_offset(raw_frame, state->target_size - 1)) !=
312
0
          AMQP_FRAME_END) {
313
0
        return AMQP_STATUS_BAD_AMQP_DATA;
314
0
      }
315
316
0
      decoded_frame->frame_type = amqp_d8(amqp_offset(raw_frame, 0));
317
0
      decoded_frame->channel = amqp_d16(amqp_offset(raw_frame, 1));
318
319
0
      channel_pool =
320
0
          amqp_get_or_create_channel_pool(state, decoded_frame->channel);
321
0
      if (NULL == channel_pool) {
322
0
        return AMQP_STATUS_NO_MEMORY;
323
0
      }
324
325
0
      switch (decoded_frame->frame_type) {
326
0
        case AMQP_FRAME_METHOD:
327
          /* A METHOD frame body must contain at least the 4-byte method id.
328
           * Reject undersized frames before subtracting from target_size to
329
           * avoid an unsigned underflow that would yield a huge encoded.len
330
           * and cause out-of-bounds reads in amqp_decode_method(). */
331
0
          if (state->target_size < HEADER_SIZE + 4 + FOOTER_SIZE) {
332
0
            return AMQP_STATUS_BAD_AMQP_DATA;
333
0
          }
334
0
          decoded_frame->payload.method.id =
335
0
              amqp_d32(amqp_offset(raw_frame, HEADER_SIZE));
336
0
          encoded.bytes = amqp_offset(raw_frame, HEADER_SIZE + 4);
337
0
          encoded.len = state->target_size - HEADER_SIZE - 4 - FOOTER_SIZE;
338
339
0
          res = amqp_decode_method(decoded_frame->payload.method.id,
340
0
                                   channel_pool, encoded,
341
0
                                   &decoded_frame->payload.method.decoded);
342
0
          if (res < 0) {
343
0
            return res;
344
0
          }
345
346
0
          break;
347
348
0
        case AMQP_FRAME_HEADER:
349
          /* A HEADER frame body must contain at least 12 bytes (class_id,
350
           * weight, body_size). Reject undersized frames before subtracting
351
           * from target_size to avoid an unsigned underflow that would yield
352
           * a huge encoded.len and cause out-of-bounds reads in
353
           * amqp_decode_properties() / the table decoder
354
           * (CVE: GHSA-9mmv-r8g3-qp46). */
355
0
          if (state->target_size < HEADER_SIZE + 12 + FOOTER_SIZE) {
356
0
            return AMQP_STATUS_BAD_AMQP_DATA;
357
0
          }
358
0
          decoded_frame->payload.properties.class_id =
359
0
              amqp_d16(amqp_offset(raw_frame, HEADER_SIZE));
360
          /* unused 2-byte weight field goes here */
361
0
          decoded_frame->payload.properties.body_size =
362
0
              amqp_d64(amqp_offset(raw_frame, HEADER_SIZE + 4));
363
0
          encoded.bytes = amqp_offset(raw_frame, HEADER_SIZE + 12);
364
0
          encoded.len = state->target_size - HEADER_SIZE - 12 - FOOTER_SIZE;
365
0
          decoded_frame->payload.properties.raw = encoded;
366
367
0
          res = amqp_decode_properties(
368
0
              decoded_frame->payload.properties.class_id, channel_pool, encoded,
369
0
              &decoded_frame->payload.properties.decoded);
370
0
          if (res < 0) {
371
0
            return res;
372
0
          }
373
374
0
          break;
375
376
0
        case AMQP_FRAME_BODY:
377
0
          if (state->target_size < HEADER_SIZE + FOOTER_SIZE) {
378
0
            return AMQP_STATUS_BAD_AMQP_DATA;
379
0
          }
380
0
          decoded_frame->payload.body_fragment.len =
381
0
              state->target_size - HEADER_SIZE - FOOTER_SIZE;
382
0
          decoded_frame->payload.body_fragment.bytes =
383
0
              amqp_offset(raw_frame, HEADER_SIZE);
384
0
          break;
385
386
0
        case AMQP_FRAME_HEARTBEAT:
387
0
          break;
388
389
0
        default:
390
          /* Ignore the frame */
391
0
          decoded_frame->frame_type = 0;
392
0
          break;
393
0
      }
394
395
0
      return_to_idle(state);
396
0
      return (int)bytes_consumed;
397
0
    }
398
399
0
    default:
400
0
      amqp_abort("Internal error: invalid amqp_connection_state_t->state %d",
401
0
                 state->state);
402
0
  }
403
0
}
404
405
0
amqp_boolean_t amqp_release_buffers_ok(amqp_connection_state_t state) {
406
0
  return (state->state == CONNECTION_STATE_IDLE);
407
0
}
408
409
0
void amqp_release_buffers(amqp_connection_state_t state) {
410
0
  int i;
411
0
  ENFORCE_STATE(state, CONNECTION_STATE_IDLE);
412
413
0
  for (i = 0; i < POOL_TABLE_SIZE; ++i) {
414
0
    amqp_pool_table_entry_t *entry = state->pool_table[i];
415
416
0
    for (; NULL != entry; entry = entry->next) {
417
0
      amqp_maybe_release_buffers_on_channel(state, entry->channel);
418
0
    }
419
0
  }
420
0
}
421
422
0
void amqp_maybe_release_buffers(amqp_connection_state_t state) {
423
0
  if (amqp_release_buffers_ok(state)) {
424
0
    amqp_release_buffers(state);
425
0
  }
426
0
}
427
428
void amqp_maybe_release_buffers_on_channel(amqp_connection_state_t state,
429
0
                                           amqp_channel_t channel) {
430
0
  amqp_link_t *queued_link;
431
0
  amqp_pool_t *pool;
432
0
  if (CONNECTION_STATE_IDLE != state->state) {
433
0
    return;
434
0
  }
435
436
0
  queued_link = state->first_queued_frame;
437
438
0
  while (NULL != queued_link) {
439
0
    amqp_frame_t *frame = queued_link->data;
440
0
    if (channel == frame->channel) {
441
0
      return;
442
0
    }
443
444
0
    queued_link = queued_link->next;
445
0
  }
446
447
0
  pool = amqp_get_channel_pool(state, channel);
448
449
0
  if (pool != NULL) {
450
0
    recycle_amqp_pool(pool);
451
0
  }
452
0
}
453
454
static int amqp_frame_to_bytes(const amqp_frame_t *frame, amqp_bytes_t buffer,
455
0
                               amqp_bytes_t *encoded) {
456
0
  void *out_frame = buffer.bytes;
457
0
  size_t out_frame_len;
458
0
  int res;
459
460
0
  amqp_e8(frame->frame_type, amqp_offset(out_frame, 0));
461
0
  amqp_e16(frame->channel, amqp_offset(out_frame, 1));
462
463
0
  switch (frame->frame_type) {
464
0
    case AMQP_FRAME_BODY: {
465
0
      const amqp_bytes_t *body = &frame->payload.body_fragment;
466
467
0
      memcpy(amqp_offset(out_frame, HEADER_SIZE), body->bytes, body->len);
468
469
0
      out_frame_len = body->len;
470
0
      break;
471
0
    }
472
0
    case AMQP_FRAME_METHOD: {
473
0
      amqp_bytes_t method_encoded;
474
475
0
      amqp_e32(frame->payload.method.id, amqp_offset(out_frame, HEADER_SIZE));
476
477
0
      method_encoded.bytes = amqp_offset(out_frame, HEADER_SIZE + 4);
478
0
      method_encoded.len = buffer.len - HEADER_SIZE - 4 - FOOTER_SIZE;
479
480
0
      res = amqp_encode_method(frame->payload.method.id,
481
0
                               frame->payload.method.decoded, method_encoded);
482
0
      if (res < 0) {
483
0
        return res;
484
0
      }
485
486
0
      out_frame_len = res + 4;
487
0
      break;
488
0
    }
489
490
0
    case AMQP_FRAME_HEADER: {
491
0
      amqp_bytes_t properties_encoded;
492
493
0
      amqp_e16(frame->payload.properties.class_id,
494
0
               amqp_offset(out_frame, HEADER_SIZE));
495
0
      amqp_e16(0, amqp_offset(out_frame, HEADER_SIZE + 2)); /* "weight" */
496
0
      amqp_e64(frame->payload.properties.body_size,
497
0
               amqp_offset(out_frame, HEADER_SIZE + 4));
498
499
0
      properties_encoded.bytes = amqp_offset(out_frame, HEADER_SIZE + 12);
500
0
      properties_encoded.len = buffer.len - HEADER_SIZE - 12 - FOOTER_SIZE;
501
502
0
      res = amqp_encode_properties(frame->payload.properties.class_id,
503
0
                                   frame->payload.properties.decoded,
504
0
                                   properties_encoded);
505
0
      if (res < 0) {
506
0
        return res;
507
0
      }
508
509
0
      out_frame_len = res + 12;
510
0
      break;
511
0
    }
512
513
0
    case AMQP_FRAME_HEARTBEAT:
514
0
      out_frame_len = 0;
515
0
      break;
516
517
0
    default:
518
0
      return AMQP_STATUS_INVALID_PARAMETER;
519
0
  }
520
521
0
  amqp_e32((uint32_t)out_frame_len, amqp_offset(out_frame, 3));
522
0
  amqp_e8(AMQP_FRAME_END, amqp_offset(out_frame, HEADER_SIZE + out_frame_len));
523
524
0
  encoded->bytes = out_frame;
525
0
  encoded->len = out_frame_len + HEADER_SIZE + FOOTER_SIZE;
526
527
0
  return AMQP_STATUS_OK;
528
0
}
529
530
0
int amqp_send_frame(amqp_connection_state_t state, const amqp_frame_t *frame) {
531
0
  return amqp_send_frame_inner(state, frame, AMQP_SF_NONE,
532
0
                               amqp_time_infinite());
533
0
}
534
535
int amqp_send_frame_inner(amqp_connection_state_t state,
536
                          const amqp_frame_t *frame, int flags,
537
0
                          amqp_time_t deadline) {
538
0
  int res;
539
0
  ssize_t sent;
540
0
  amqp_bytes_t encoded;
541
0
  amqp_time_t next_timeout;
542
543
  /* TODO: if the AMQP_SF_MORE socket optimization can be shown to work
544
   * correctly, then this could be un-done so that body-frames are sent as 3
545
   * send calls, getting rid of the copy of the body content, some testing
546
   * would need to be done to see if this would actually a win for performance.
547
   * */
548
0
  res = amqp_frame_to_bytes(frame, state->outbound_buffer, &encoded);
549
0
  if (AMQP_STATUS_OK != res) {
550
0
    return res;
551
0
  }
552
553
0
start_send:
554
555
0
  next_timeout = amqp_time_first(deadline, state->next_recv_heartbeat);
556
557
0
  sent = amqp_try_send(state, encoded.bytes, encoded.len, next_timeout, flags);
558
0
  if (0 > sent) {
559
0
    return (int)sent;
560
0
  }
561
562
  /* A partial send has occurred, because of a heartbeat timeout (so try recv
563
   * something) or common timeout (so return AMQP_STATUS_TIMEOUT) */
564
0
  if ((ssize_t)encoded.len != sent) {
565
0
    if (amqp_time_equal(next_timeout, deadline)) {
566
      /* timeout of method was received, so return from method*/
567
0
      return AMQP_STATUS_TIMEOUT;
568
0
    }
569
570
0
    res = amqp_try_recv(state);
571
572
0
    if (AMQP_STATUS_TIMEOUT == res) {
573
0
      return AMQP_STATUS_HEARTBEAT_TIMEOUT;
574
0
    } else if (AMQP_STATUS_OK != res) {
575
0
      return res;
576
0
    }
577
578
0
    encoded.bytes = (uint8_t *)encoded.bytes + sent;
579
0
    encoded.len -= sent;
580
0
    goto start_send;
581
0
  }
582
583
0
  res = amqp_time_s_from_now(&state->next_send_heartbeat,
584
0
                             amqp_heartbeat_send(state));
585
0
  return res;
586
0
}
587
588
0
amqp_table_t *amqp_get_server_properties(amqp_connection_state_t state) {
589
0
  return &state->server_properties;
590
0
}
591
592
0
amqp_table_t *amqp_get_client_properties(amqp_connection_state_t state) {
593
0
  return &state->client_properties;
594
0
}