Debian Codegraph @

crt/aws-c-mqtt/source/v5/mqtt5_topic_alias.c

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/mqtt/private/v5/mqtt5_topic_alias.h>
7
8 #include <aws/common/lru_cache.h>
9 #include <aws/common/string.h>
10 #include <aws/mqtt/private/client_impl_shared.h>
11 #include <aws/mqtt/private/v5/mqtt5_utils.h>
12
13 int aws_mqtt5_inbound_topic_alias_resolver_init(
14 struct aws_mqtt5_inbound_topic_alias_resolver *resolver,
15 struct aws_allocator *allocator) {
16 AWS_ZERO_STRUCT(*resolver);
17 resolver->allocator = allocator;
18
19 if (aws_array_list_init_dynamic(&resolver->topic_aliases, allocator, 0, sizeof(struct aws_string *))) {
20 return AWS_OP_ERR;
21 }
22
23 return AWS_OP_SUCCESS;
24 }
25
26 static void s_release_aliases(struct aws_mqtt5_inbound_topic_alias_resolver *resolver) {
27 if (!aws_array_list_is_valid(&resolver->topic_aliases)) {
28 return;
29 }
30
31 size_t cache_size = aws_array_list_length(&resolver->topic_aliases);
32 for (size_t i = 0; i < cache_size; ++i) {
33 struct aws_string *topic = NULL;
34
35 aws_array_list_get_at(&resolver->topic_aliases, &topic, i);
36 aws_string_destroy(topic);
37 }
38 }
39
40 void aws_mqtt5_inbound_topic_alias_resolver_clean_up(struct aws_mqtt5_inbound_topic_alias_resolver *resolver) {
41 s_release_aliases(resolver);
42 aws_array_list_clean_up(&resolver->topic_aliases);
43 }
44
45 int aws_mqtt5_inbound_topic_alias_resolver_reset(
46 struct aws_mqtt5_inbound_topic_alias_resolver *resolver,
47 uint16_t cache_size) {
48
49 aws_mqtt5_inbound_topic_alias_resolver_clean_up(resolver);
50 AWS_ZERO_STRUCT(resolver->topic_aliases);
51
52 if (aws_array_list_init_dynamic(
53 &resolver->topic_aliases, resolver->allocator, cache_size, sizeof(struct aws_string *))) {
54 return AWS_OP_ERR;
55 }
56
57 for (size_t i = 0; i < cache_size; ++i) {
58 struct aws_string *topic = NULL;
59 aws_array_list_push_back(&resolver->topic_aliases, &topic);
60 }
61
62 return AWS_OP_SUCCESS;
63 }
64
65 int aws_mqtt5_inbound_topic_alias_resolver_resolve_alias(
66 struct aws_mqtt5_inbound_topic_alias_resolver *resolver,
67 uint16_t alias,
68 struct aws_byte_cursor *topic_out) {
69 size_t cache_size = aws_array_list_length(&resolver->topic_aliases);
70
71 if (alias > cache_size || alias == 0) {
72 return aws_raise_error(AWS_ERROR_MQTT5_INVALID_INBOUND_TOPIC_ALIAS);
73 }
74
75 size_t alias_index = alias - 1;
76 struct aws_string *topic = NULL;
77 aws_array_list_get_at(&resolver->topic_aliases, &topic, alias_index);
78
79 if (topic == NULL) {
80 return aws_raise_error(AWS_ERROR_MQTT5_INVALID_INBOUND_TOPIC_ALIAS);
81 }
82
83 *topic_out = aws_byte_cursor_from_string(topic);
84 return AWS_OP_SUCCESS;
85 }
86
87 int aws_mqtt5_inbound_topic_alias_resolver_register_alias(
88 struct aws_mqtt5_inbound_topic_alias_resolver *resolver,
89 uint16_t alias,
90 struct aws_byte_cursor topic) {
91 size_t cache_size = aws_array_list_length(&resolver->topic_aliases);
92
93 if (alias > cache_size || alias == 0) {
94 return aws_raise_error(AWS_ERROR_MQTT5_INVALID_INBOUND_TOPIC_ALIAS);
95 }
96
97 struct aws_string *new_entry = aws_string_new_from_cursor(resolver->allocator, &topic);
98 if (new_entry == NULL) {
99 return AWS_OP_ERR;
100 }
101
102 size_t alias_index = alias - 1;
103 struct aws_string *existing_entry = NULL;
104 aws_array_list_get_at(&resolver->topic_aliases, &existing_entry, alias_index);
105 aws_string_destroy(existing_entry);
106
107 aws_array_list_set_at(&resolver->topic_aliases, &new_entry, alias_index);
108
109 return AWS_OP_SUCCESS;
110 }
111
112 /****************************************************************************************************************/
113
114 struct aws_mqtt5_outbound_topic_alias_resolver_vtable {
115 void (*destroy_fn)(struct aws_mqtt5_outbound_topic_alias_resolver *);
116 int (*reset_fn)(struct aws_mqtt5_outbound_topic_alias_resolver *, uint16_t);
117 int (*resolve_outbound_publish_fn)(
118 struct aws_mqtt5_outbound_topic_alias_resolver *,
119 const struct aws_mqtt5_packet_publish_view *,
120 uint16_t *,
121 struct aws_byte_cursor *);
122 };
123
124 struct aws_mqtt5_outbound_topic_alias_resolver {
125 struct aws_allocator *allocator;
126
127 struct aws_mqtt5_outbound_topic_alias_resolver_vtable *vtable;
128 void *impl;
129 };
130
131 static struct aws_mqtt5_outbound_topic_alias_resolver *s_aws_mqtt5_outbound_topic_alias_resolver_disabled_new(
132 struct aws_allocator *allocator);
133 static struct aws_mqtt5_outbound_topic_alias_resolver *s_aws_mqtt5_outbound_topic_alias_resolver_lru_new(
134 struct aws_allocator *allocator);
135 static struct aws_mqtt5_outbound_topic_alias_resolver *s_aws_mqtt5_outbound_topic_alias_resolver_manual_new(
136 struct aws_allocator *allocator);
137
138 struct aws_mqtt5_outbound_topic_alias_resolver *aws_mqtt5_outbound_topic_alias_resolver_new(
139 struct aws_allocator *allocator,
140 enum aws_mqtt5_client_outbound_topic_alias_behavior_type outbound_alias_behavior) {
141
142 switch (aws_mqtt5_outbound_topic_alias_behavior_type_to_non_default(outbound_alias_behavior)) {
143 case AWS_MQTT5_COTABT_MANUAL:
144 return s_aws_mqtt5_outbound_topic_alias_resolver_manual_new(allocator);
145
146 case AWS_MQTT5_COTABT_LRU:
147 return s_aws_mqtt5_outbound_topic_alias_resolver_lru_new(allocator);
148
149 case AWS_MQTT5_COTABT_DISABLED:
150 return s_aws_mqtt5_outbound_topic_alias_resolver_disabled_new(allocator);
151
152 default:
153 return NULL;
154 }
155 }
156
157 void aws_mqtt5_outbound_topic_alias_resolver_destroy(struct aws_mqtt5_outbound_topic_alias_resolver *resolver) {
158 if (resolver == NULL) {
159 return;
160 }
161
162 (*resolver->vtable->destroy_fn)(resolver);
163 }
164
165 int aws_mqtt5_outbound_topic_alias_resolver_reset(
166 struct aws_mqtt5_outbound_topic_alias_resolver *resolver,
167 uint16_t topic_alias_maximum) {
168
169 if (resolver == NULL) {
170 return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
171 }
172
173 return (*resolver->vtable->reset_fn)(resolver, topic_alias_maximum);
174 }
175
176 int aws_mqtt5_outbound_topic_alias_resolver_resolve_outbound_publish(
177 struct aws_mqtt5_outbound_topic_alias_resolver *resolver,
178 const struct aws_mqtt5_packet_publish_view *publish_view,
179 uint16_t *topic_alias_out,
180 struct aws_byte_cursor *topic_out) {
181 if (resolver == NULL) {
182 return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
183 }
184
185 return (*resolver->vtable->resolve_outbound_publish_fn)(resolver, publish_view, topic_alias_out, topic_out);
186 }
187
188 /*
189 * Disabled resolver
190 */
191
192 static void s_aws_mqtt5_outbound_topic_alias_resolver_disabled_destroy(
193 struct aws_mqtt5_outbound_topic_alias_resolver *resolver) {
194 if (resolver == NULL) {
195 return;
196 }
197
198 aws_mem_release(resolver->allocator, resolver);
199 }
200
201 static int s_aws_mqtt5_outbound_topic_alias_resolver_disabled_reset(
202 struct aws_mqtt5_outbound_topic_alias_resolver *resolver,
203 uint16_t topic_alias_maximum) {
204 (void)resolver;
205 (void)topic_alias_maximum;
206
207 return AWS_OP_SUCCESS;
208 }
209
210 static int s_aws_mqtt5_outbound_topic_alias_resolver_disabled_resolve_outbound_publish_fn(
211 struct aws_mqtt5_outbound_topic_alias_resolver *resolver,
212 const struct aws_mqtt5_packet_publish_view *publish_view,
213 uint16_t *topic_alias_out,
214 struct aws_byte_cursor *topic_out) {
215 (void)resolver;
216
217 if (publish_view->topic.len == 0) {
218 return aws_raise_error(AWS_ERROR_MQTT5_PUBLISH_OPTIONS_VALIDATION);
219 }
220
221 *topic_alias_out = 0;
222 *topic_out = publish_view->topic;
223
224 return AWS_OP_SUCCESS;
225 }
226
227 static struct aws_mqtt5_outbound_topic_alias_resolver_vtable s_aws_mqtt5_outbound_topic_alias_resolver_disabled_vtable =
228 {
229 .destroy_fn = s_aws_mqtt5_outbound_topic_alias_resolver_disabled_destroy,
230 .reset_fn = s_aws_mqtt5_outbound_topic_alias_resolver_disabled_reset,
231 .resolve_outbound_publish_fn = s_aws_mqtt5_outbound_topic_alias_resolver_disabled_resolve_outbound_publish_fn,
232 };
233
234 static struct aws_mqtt5_outbound_topic_alias_resolver *s_aws_mqtt5_outbound_topic_alias_resolver_disabled_new(
235 struct aws_allocator *allocator) {
236 struct aws_mqtt5_outbound_topic_alias_resolver *resolver =
237 aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt5_outbound_topic_alias_resolver));
238
239 resolver->allocator = allocator;
240 resolver->vtable = &s_aws_mqtt5_outbound_topic_alias_resolver_disabled_vtable;
241
242 return resolver;
243 }
244
245 /*
246 * Manual resolver
247 *
248 * Manual resolution implies the user is controlling the topic alias assignments, but we still want to validate their
249 * actions. In particular, we track the currently valid set of aliases (based on previous outbound publishes)
250 * and only use an alias when the submitted publish is an exact match for the current assignment.
251 */
252
253 struct aws_mqtt5_outbound_topic_alias_resolver_manual {
254 struct aws_mqtt5_outbound_topic_alias_resolver base;
255
256 struct aws_array_list aliases;
257 };
258
259 static void s_cleanup_manual_aliases(struct aws_mqtt5_outbound_topic_alias_resolver_manual *manual_resolver) {
260 for (size_t i = 0; i < aws_array_list_length(&manual_resolver->aliases); ++i) {
261 struct aws_string *alias = NULL;
262 aws_array_list_get_at(&manual_resolver->aliases, &alias, i);
263
264 aws_string_destroy(alias);
265 }
266
267 aws_array_list_clean_up(&manual_resolver->aliases);
268 AWS_ZERO_STRUCT(manual_resolver->aliases);
269 }
270
271 static void s_aws_mqtt5_outbound_topic_alias_resolver_manual_destroy(
272 struct aws_mqtt5_outbound_topic_alias_resolver *resolver) {
273 if (resolver == NULL) {
274 return;
275 }
276
277 struct aws_mqtt5_outbound_topic_alias_resolver_manual *manual_resolver = resolver->impl;
278 s_cleanup_manual_aliases(manual_resolver);
279
280 aws_mem_release(resolver->allocator, manual_resolver);
281 }
282
283 static int s_aws_mqtt5_outbound_topic_alias_resolver_manual_reset(
284 struct aws_mqtt5_outbound_topic_alias_resolver *resolver,
285 uint16_t topic_alias_maximum) {
286 struct aws_mqtt5_outbound_topic_alias_resolver_manual *manual_resolver = resolver->impl;
287 s_cleanup_manual_aliases(manual_resolver);
288
289 aws_array_list_init_dynamic(
290 &manual_resolver->aliases, resolver->allocator, topic_alias_maximum, sizeof(struct aws_string *));
291 for (size_t i = 0; i < topic_alias_maximum; ++i) {
292 struct aws_string *invalid_alias = NULL;
293 aws_array_list_push_back(&manual_resolver->aliases, &invalid_alias);
294 }
295
296 return AWS_OP_SUCCESS;
297 }
298
299 static int s_aws_mqtt5_outbound_topic_alias_resolver_manual_resolve_outbound_publish_fn(
300 struct aws_mqtt5_outbound_topic_alias_resolver *resolver,
301 const struct aws_mqtt5_packet_publish_view *publish_view,
302 uint16_t *topic_alias_out,
303 struct aws_byte_cursor *topic_out) {
304
305 if (publish_view->topic_alias == NULL) {
306 /* not using a topic alias, nothing to do */
307 *topic_alias_out = 0;
308 *topic_out = publish_view->topic;
309
310 return AWS_OP_SUCCESS;
311 }
312
313 uint16_t user_alias = *publish_view->topic_alias;
314 if (user_alias == 0) {
315 /* should have been caught by publish validation */
316 return aws_raise_error(AWS_ERROR_MQTT5_INVALID_OUTBOUND_TOPIC_ALIAS);
317 }
318
319 struct aws_mqtt5_outbound_topic_alias_resolver_manual *manual_resolver = resolver->impl;
320 uint16_t user_alias_index = user_alias - 1;
321 if (user_alias_index >= aws_array_list_length(&manual_resolver->aliases)) {
322 /* should have been caught by dynamic publish validation */
323 return aws_raise_error(AWS_ERROR_MQTT5_INVALID_OUTBOUND_TOPIC_ALIAS);
324 }
325
326 struct aws_string *current_assignment = NULL;
327 aws_array_list_get_at(&manual_resolver->aliases, &current_assignment, user_alias_index);
328
329 *topic_alias_out = user_alias;
330
331 bool can_use_alias = false;
332 if (current_assignment != NULL) {
333 struct aws_byte_cursor assignment_cursor = aws_byte_cursor_from_string(current_assignment);
334 if (aws_byte_cursor_eq(&assignment_cursor, &publish_view->topic)) {
335 can_use_alias = true;
336 }
337 }
338
339 if (can_use_alias) {
340 AWS_ZERO_STRUCT(*topic_out);
341 } else {
342 *topic_out = publish_view->topic;
343 }
344
345 /* mark this alias as seen */
346 if (!can_use_alias) {
347 aws_string_destroy(current_assignment);
348 current_assignment = aws_string_new_from_cursor(resolver->allocator, &publish_view->topic);
349 aws_array_list_set_at(&manual_resolver->aliases, &current_assignment, user_alias_index);
350 }
351
352 return AWS_OP_SUCCESS;
353 }
354
355 static struct aws_mqtt5_outbound_topic_alias_resolver_vtable s_aws_mqtt5_outbound_topic_alias_resolver_manual_vtable = {
356 .destroy_fn = s_aws_mqtt5_outbound_topic_alias_resolver_manual_destroy,
357 .reset_fn = s_aws_mqtt5_outbound_topic_alias_resolver_manual_reset,
358 .resolve_outbound_publish_fn = s_aws_mqtt5_outbound_topic_alias_resolver_manual_resolve_outbound_publish_fn,
359 };
360
361 static struct aws_mqtt5_outbound_topic_alias_resolver *s_aws_mqtt5_outbound_topic_alias_resolver_manual_new(
362 struct aws_allocator *allocator) {
363 struct aws_mqtt5_outbound_topic_alias_resolver_manual *resolver =
364 aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt5_outbound_topic_alias_resolver_manual));
365
366 resolver->base.allocator = allocator;
367 resolver->base.vtable = &s_aws_mqtt5_outbound_topic_alias_resolver_manual_vtable;
368 resolver->base.impl = resolver;
369
370 aws_array_list_init_dynamic(&resolver->aliases, allocator, 0, sizeof(struct aws_string *));
371
372 return &resolver->base;
373 }
374
375 /*
376 * LRU resolver
377 *
378 * This resolver uses an LRU cache to automatically create topic alias assignments for the user. With a reasonable
379 * cache size, this should perform well for the majority of MQTT workloads. For workloads it does not perform well
380 * with, the user should control the assignment (or disable entirely). Even for workloads where the LRU cache fails
381 * to reuse an assignment every single time, the overall cost is 3 extra bytes per publish. As a rough estimate, this
382 * means that LRU topic aliasing is "worth it" if an existing alias can be used at least once every
383 * (AverageTopicLength / 3) publishes.
384 */
385
386 struct aws_mqtt5_outbound_topic_alias_resolver_lru {
387 struct aws_mqtt5_outbound_topic_alias_resolver base;
388
389 struct aws_cache *lru_cache;
390 size_t max_aliases;
391 };
392
393 static void s_aws_mqtt5_outbound_topic_alias_resolver_lru_destroy(
394 struct aws_mqtt5_outbound_topic_alias_resolver *resolver) {
395 if (resolver == NULL) {
396 return;
397 }
398
399 struct aws_mqtt5_outbound_topic_alias_resolver_lru *lru_resolver = resolver->impl;
400
401 if (lru_resolver->lru_cache != NULL) {
402 aws_cache_destroy(lru_resolver->lru_cache);
403 }
404
405 aws_mem_release(resolver->allocator, lru_resolver);
406 }
407
408 struct aws_topic_alias_assignment {
409 struct aws_byte_cursor topic_cursor;
410 struct aws_byte_buf topic;
411 uint16_t alias;
412 struct aws_allocator *allocator;
413 };
414
415 static void s_aws_topic_alias_assignment_destroy(struct aws_topic_alias_assignment *alias_assignment) {
416 if (alias_assignment == NULL) {
417 return;
418 }
419
420 aws_byte_buf_clean_up(&alias_assignment->topic);
421
422 aws_mem_release(alias_assignment->allocator, alias_assignment);
423 }
424
425 static struct aws_topic_alias_assignment *s_aws_topic_alias_assignment_new(
426 struct aws_allocator *allocator,
427 struct aws_byte_cursor topic,
428 uint16_t alias) {
429 struct aws_topic_alias_assignment *assignment =
430 aws_mem_calloc(allocator, 1, sizeof(struct aws_topic_alias_assignment));
431
432 assignment->allocator = allocator;
433 assignment->alias = alias;
434
435 if (aws_byte_buf_init_copy_from_cursor(&assignment->topic, allocator, topic)) {
436 goto on_error;
437 }
438
439 assignment->topic_cursor = aws_byte_cursor_from_buf(&assignment->topic);
440
441 return assignment;
442
443 on_error:
444
445 s_aws_topic_alias_assignment_destroy(assignment);
446
447 return NULL;
448 }
449
450 static void s_destroy_assignment_value(void *value) {
451 s_aws_topic_alias_assignment_destroy(value);
452 }
453
454 static int s_aws_mqtt5_outbound_topic_alias_resolver_lru_reset(
455 struct aws_mqtt5_outbound_topic_alias_resolver *resolver,
456 uint16_t topic_alias_maximum) {
457 struct aws_mqtt5_outbound_topic_alias_resolver_lru *lru_resolver = resolver->impl;
458
459 if (lru_resolver->lru_cache != NULL) {
460 aws_cache_destroy(lru_resolver->lru_cache);
461 lru_resolver->lru_cache = NULL;
462 }
463
464 if (topic_alias_maximum > 0) {
465 lru_resolver->lru_cache = aws_cache_new_lru(
466 lru_resolver->base.allocator,
467 aws_hash_byte_cursor_ptr,
468 aws_mqtt_byte_cursor_hash_equality,
469 NULL,
470 s_destroy_assignment_value,
471 topic_alias_maximum);
472 }
473
474 lru_resolver->max_aliases = topic_alias_maximum;
475
476 return AWS_OP_SUCCESS;
477 }
478
479 static int s_aws_mqtt5_outbound_topic_alias_resolver_lru_resolve_outbound_publish_fn(
480 struct aws_mqtt5_outbound_topic_alias_resolver *resolver,
481 const struct aws_mqtt5_packet_publish_view *publish_view,
482 uint16_t *topic_alias_out,
483 struct aws_byte_cursor *topic_out) {
484
485 /* No cache => no aliasing done */
486 struct aws_mqtt5_outbound_topic_alias_resolver_lru *lru_resolver = resolver->impl;
487 if (lru_resolver->lru_cache == NULL || lru_resolver->max_aliases == 0) {
488 *topic_alias_out = 0;
489 *topic_out = publish_view->topic;
490 return AWS_OP_SUCCESS;
491 }
492
493 /* Look for the topic in the cache */
494 struct aws_byte_cursor topic = publish_view->topic;
495 void *existing_element = NULL;
496 if (aws_cache_find(lru_resolver->lru_cache, &topic, &existing_element)) {
497 return AWS_OP_ERR;
498 }
499
500 struct aws_topic_alias_assignment *existing_assignment = existing_element;
501 if (existing_assignment != NULL) {
502 /*
503 * Topic exists, so use the assignment. The LRU cache find implementation has already promoted the element
504 * to MRU.
505 */
506 *topic_alias_out = existing_assignment->alias;
507 AWS_ZERO_STRUCT(*topic_out);
508
509 return AWS_OP_SUCCESS;
510 }
511
512 /* Topic doesn't exist in the cache. */
513 uint16_t new_alias_id = 0;
514 size_t assignment_count = aws_cache_get_element_count(lru_resolver->lru_cache);
515 if (assignment_count == lru_resolver->max_aliases) {
516 /*
517 * The cache is full. Get the LRU element to figure out what id we're going to reuse. There's no way to get
518 * the LRU element without promoting it. So we get the element, save the discovered alias id, then remove
519 * the element.
520 */
521 void *lru_element = aws_lru_cache_use_lru_element(lru_resolver->lru_cache);
522
523 struct aws_topic_alias_assignment *replaced_assignment = lru_element;
524 new_alias_id = replaced_assignment->alias;
525 struct aws_byte_cursor replaced_topic = replaced_assignment->topic_cursor;
526
527 /*
528 * This is a little uncomfortable but valid. The cursor we're passing in will get invalidated (and the backing
529 * memory deleted) as part of the removal process but it is only used to find the element to remove. Once
530 * destruction begins it is no longer accessed.
531 */
532 aws_cache_remove(lru_resolver->lru_cache, &replaced_topic);
533 } else {
534 /*
535 * The cache never shrinks and the first N adds are the N valid topic aliases. Since the cache isn't full,
536 * we know the next alias that hasn't been used. This invariant only holds given that we will tear down
537 * the connection (invalidating the cache) on errors from this function (ie, continuing on from a put
538 * error would break the invariant and create duplicated ids).
539 */
540 new_alias_id = (uint16_t)(assignment_count + 1);
541 }
542
543 /*
544 * We have a topic alias to use. Add our new assignment.
545 */
546 struct aws_topic_alias_assignment *new_assignment =
547 s_aws_topic_alias_assignment_new(resolver->allocator, topic, new_alias_id);
548 if (new_assignment == NULL) {
549 return AWS_OP_ERR;
550 }
551
552 /* the LRU cache put implementation automatically makes the newly added element MRU */
553 if (aws_cache_put(lru_resolver->lru_cache, &new_assignment->topic_cursor, new_assignment)) {
554 s_aws_topic_alias_assignment_destroy(new_assignment);
555 return AWS_OP_ERR;
556 }
557
558 *topic_alias_out = new_assignment->alias;
559 *topic_out = topic; /* this is a new assignment so topic must go out too */
560
561 return AWS_OP_SUCCESS;
562 }
563
564 static struct aws_mqtt5_outbound_topic_alias_resolver_vtable s_aws_mqtt5_outbound_topic_alias_resolver_lru_vtable = {
565 .destroy_fn = s_aws_mqtt5_outbound_topic_alias_resolver_lru_destroy,
566 .reset_fn = s_aws_mqtt5_outbound_topic_alias_resolver_lru_reset,
567 .resolve_outbound_publish_fn = s_aws_mqtt5_outbound_topic_alias_resolver_lru_resolve_outbound_publish_fn,
568 };
569
570 static struct aws_mqtt5_outbound_topic_alias_resolver *s_aws_mqtt5_outbound_topic_alias_resolver_lru_new(
571 struct aws_allocator *allocator) {
572 struct aws_mqtt5_outbound_topic_alias_resolver_lru *resolver =
573 aws_mem_calloc(allocator, 1, sizeof(struct aws_mqtt5_outbound_topic_alias_resolver_lru));
574
575 resolver->base.allocator = allocator;
576 resolver->base.vtable = &s_aws_mqtt5_outbound_topic_alias_resolver_lru_vtable;
577 resolver->base.impl = resolver;
578
579 return &resolver->base;
580 }