blob: 745785e6c54af92a8dba7237f563720c54b45d17 [file] [log] [blame]
Andrew Jeffery4fe996c2018-02-27 12:16:48 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
Cyril Burc85e34d2016-11-15 11:50:41 +11003
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +11004#define _GNU_SOURCE
Cyril Burc85e34d2016-11-15 11:50:41 +11005#include <assert.h>
6#include <errno.h>
7#include <fcntl.h>
8#include <getopt.h>
9#include <limits.h>
10#include <poll.h>
11#include <stdbool.h>
12#include <stdint.h>
13#include <stdio.h>
14#include <stdlib.h>
15#include <string.h>
16#include <syslog.h>
Michael Neuling899ebac2017-01-14 11:20:26 -060017#include <signal.h>
Cyril Burc85e34d2016-11-15 11:50:41 +110018#include <sys/ioctl.h>
19#include <sys/mman.h>
20#include <sys/stat.h>
21#include <sys/timerfd.h>
22#include <sys/types.h>
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110023#include <sys/signalfd.h>
Cyril Burc85e34d2016-11-15 11:50:41 +110024#include <time.h>
25#include <unistd.h>
Andrew Jeffery78210b92017-01-13 13:06:09 +103026#include <inttypes.h>
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110027#include <systemd/sd-bus.h>
Cyril Burc85e34d2016-11-15 11:50:41 +110028
Suraj Jitindar Singh8d65bb42017-05-01 16:05:17 +100029#include "config.h"
Andrew Jeffery26558db2018-08-10 00:22:38 +093030#include "mboxd.h"
Cyril Burc85e34d2016-11-15 11:50:41 +110031#include "common.h"
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110032#include "dbus.h"
Andrew Jeffery55f4d6f2018-08-06 12:26:44 +093033#include "control_dbus.h"
Andrew Jefferyeebc6bd2018-08-08 10:38:19 +093034#include "flash.h"
Andrew Jefferycd186112018-08-08 10:47:55 +093035#include "lpc.h"
Andrew Jeffery457a6e52018-08-08 11:21:08 +093036#include "transport_mbox.h"
Andrew Jeffery23140be2018-09-05 14:15:07 +093037#include "transport_dbus.h"
Andrew Jefferyf593b1b2018-08-08 11:01:04 +093038#include "windows.h"
Andrew Jeffery53c21aa2018-03-26 11:56:16 +103039#include "vpnor/mboxd_pnor_partition_table.h"
Cyril Burc85e34d2016-11-15 11:50:41 +110040
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110041#define USAGE \
42"\nUsage: %s [-V | --version] [-h | --help] [-v[v] | --verbose] [-s | --syslog]\n" \
Suraj Jitindar Singhc29172e2017-04-12 14:26:47 +100043"\t\t[-n | --window-num <num>]\n" \
44"\t\t[-w | --window-size <size>M]\n" \
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110045"\t\t-f | --flash <size>[K|M]\n\n" \
46"\t-v | --verbose\t\tBe [more] verbose\n" \
47"\t-s | --syslog\t\tLog output to syslog (pointless without -v)\n" \
48"\t-n | --window-num\tThe number of windows\n" \
Suraj Jitindar Singhc29172e2017-04-12 14:26:47 +100049"\t\t\t\t(default: fill the reserved memory region)\n" \
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110050"\t-w | --window-size\tThe window size (power of 2) in MB\n" \
Suraj Jitindar Singhc29172e2017-04-12 14:26:47 +100051"\t\t\t\t(default: 1MB)\n" \
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110052"\t-f | --flash\t\tSize of flash in [K|M] bytes\n\n"
Cyril Burc85e34d2016-11-15 11:50:41 +110053
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +103054static int dbus_init(struct mbox_context *context,
55 const struct transport_ops **ops)
Andrew Jefferyef9e62d2018-08-08 15:48:27 +093056{
57 int rc;
58
59 rc = sd_bus_default_system(&context->bus);
60 if (rc < 0) {
61 MSG_ERR("Failed to connect to the system bus: %s\n",
62 strerror(-rc));
63 return rc;
64 }
65
66 rc = control_legacy_init(context);
67 if (rc < 0) {
68 MSG_ERR("Failed to initialise legacy DBus interface: %s\n",
69 strerror(-rc));
70 return rc;
71 }
72
73 rc = control_dbus_init(context);
74 if (rc < 0) {
75 MSG_ERR("Failed to initialise DBus control interface: %s\n",
76 strerror(-rc));
77 return rc;
78 }
79
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +103080 rc = transport_dbus_init(context, ops);
Andrew Jeffery23140be2018-09-05 14:15:07 +093081 if (rc < 0) {
82 MSG_ERR("Failed to initialise DBus protocol interface: %s\n",
83 strerror(-rc));
84 return rc;
85 }
86
Andrew Jefferyef9e62d2018-08-08 15:48:27 +093087 rc = sd_bus_request_name(context->bus, MBOX_DBUS_NAME,
88 SD_BUS_NAME_ALLOW_REPLACEMENT |
89 SD_BUS_NAME_REPLACE_EXISTING);
90 if (rc < 0) {
Andrew Jeffery23140be2018-09-05 14:15:07 +093091 MSG_ERR("Failed to request DBus name: %s\n", strerror(-rc));
Andrew Jefferyef9e62d2018-08-08 15:48:27 +093092 return rc;
93 }
94
95 rc = sd_bus_get_fd(context->bus);
96 if (rc < 0) {
97 MSG_ERR("Failed to get bus fd: %s\n", strerror(-rc));
98 return rc;
99 }
100
101 context->fds[DBUS_FD].fd = rc;
102
103 return 0;
104}
105
106static void dbus_free(struct mbox_context *context)
107{
Andrew Jeffery23140be2018-09-05 14:15:07 +0930108 transport_dbus_free(context);
Andrew Jefferyef9e62d2018-08-08 15:48:27 +0930109 control_dbus_free(context);
110 control_legacy_free(context);
111 sd_bus_unref(context->bus);
112}
Andrew Jeffery55f4d6f2018-08-06 12:26:44 +0930113
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100114static int poll_loop(struct mbox_context *context)
Cyril Burc85e34d2016-11-15 11:50:41 +1100115{
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100116 int rc = 0, i;
Cyril Bur46233672017-01-16 13:33:26 +1100117
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100118 /* Set POLLIN on polling file descriptors */
119 for (i = 0; i < POLL_FDS; i++) {
120 context->fds[i].events = POLLIN;
Cyril Bur46233672017-01-16 13:33:26 +1100121 }
122
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100123 while (1) {
124 rc = poll(context->fds, POLL_FDS, -1);
125
126 if (rc < 0) { /* Error */
127 MSG_ERR("Error from poll(): %s\n", strerror(errno));
128 break; /* This should mean we clean up nicely */
129 }
130
131 /* Event on Polled File Descriptor - Handle It */
132 if (context->fds[SIG_FD].revents & POLLIN) { /* Signal */
133 struct signalfd_siginfo info = { 0 };
134
135 rc = read(context->fds[SIG_FD].fd, (void *) &info,
136 sizeof(info));
137 if (rc != sizeof(info)) {
138 MSG_ERR("Error reading signal event: %s\n",
139 strerror(errno));
140 }
141
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000142 MSG_DBG("Received signal: %d\n", info.ssi_signo);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100143 switch (info.ssi_signo) {
144 case SIGINT:
145 case SIGTERM:
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000146 MSG_INFO("Caught Signal - Exiting...\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100147 context->terminate = true;
148 break;
149 case SIGHUP:
150 /* Host didn't request reset -> Notify it */
Andrew Jeffery2ebfd202018-08-20 11:46:28 +0930151 if (windows_reset_all(context)) {
152 rc = protocol_events_set(context,
153 BMC_EVENT_WINDOW_RESET);
154 if (rc < 0) {
155 MSG_ERR("Failed to notify host of reset, expect host-side corruption\n");
156 break;
157 }
158 }
Andrew Jeffery17971e42018-08-08 16:36:10 +0930159 rc = lpc_reset(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100160 if (rc < 0) {
161 MSG_ERR("WARNING: Failed to point the "
162 "LPC bus back to flash on "
163 "SIGHUP\nIf the host requires "
164 "this expect problems...\n");
165 }
166 break;
167 default:
168 MSG_ERR("Unhandled Signal: %d\n",
169 info.ssi_signo);
170 break;
171 }
172 }
173 if (context->fds[DBUS_FD].revents & POLLIN) { /* DBUS */
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000174 while ((rc = sd_bus_process(context->bus, NULL)) > 0) {
175 MSG_DBG("DBUS Event\n");
176 }
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100177 if (rc < 0) {
178 MSG_ERR("Error handling DBUS event: %s\n",
179 strerror(-rc));
180 }
181 }
182 if (context->terminate) {
183 break; /* This should mean we clean up nicely */
184 }
185 if (context->fds[MBOX_FD].revents & POLLIN) { /* MBOX */
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000186 MSG_DBG("MBOX Event\n");
Andrew Jefferyd86141b2018-08-09 14:58:53 +0930187 rc = transport_mbox_dispatch(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100188 if (rc < 0) {
189 MSG_ERR("Error handling MBOX event\n");
190 }
191 }
192 }
193
Deepak Kodihalli017e45c2017-07-12 01:06:30 -0500194 /* Best to reset windows and the lpc mapping for safety */
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100195 /* Host didn't request reset -> Notify it */
Andrew Jeffery2ebfd202018-08-20 11:46:28 +0930196 if (windows_reset_all(context)) {
197 rc = protocol_events_set(context, BMC_EVENT_WINDOW_RESET);
198 if (rc < 0) {
199 MSG_ERR("Failed to notify host of reset, expect host-side corruption\n");
200 return rc;
201 }
202 }
Andrew Jeffery17971e42018-08-08 16:36:10 +0930203 rc = lpc_reset(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100204 /* Not much we can do if this fails */
205 if (rc < 0) {
206 MSG_ERR("WARNING: Failed to point the LPC bus back to flash\n"
207 "If the host requires this expect problems...\n");
208 }
209
210 return rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100211}
212
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100213static int init_signals(struct mbox_context *context, sigset_t *set)
Cyril Burc85e34d2016-11-15 11:50:41 +1100214{
215 int rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100216
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100217 /* Block SIGHUPs, SIGTERMs and SIGINTs */
218 sigemptyset(set);
219 sigaddset(set, SIGHUP);
220 sigaddset(set, SIGINT);
221 sigaddset(set, SIGTERM);
222 rc = sigprocmask(SIG_BLOCK, set, NULL);
223 if (rc < 0) {
224 MSG_ERR("Failed to set SIG_BLOCK mask %s\n", strerror(errno));
225 return rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100226 }
227
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100228 /* Get Signal File Descriptor */
229 rc = signalfd(-1, set, SFD_NONBLOCK);
230 if (rc < 0) {
231 MSG_ERR("Failed to get signalfd %s\n", strerror(errno));
232 return rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100233 }
234
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100235 context->fds[SIG_FD].fd = rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100236 return 0;
237}
238
Cyril Burc85e34d2016-11-15 11:50:41 +1100239static void usage(const char *name)
240{
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100241 printf(USAGE, name);
Cyril Burc85e34d2016-11-15 11:50:41 +1100242}
243
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100244static bool parse_cmdline(int argc, char **argv,
245 struct mbox_context *context)
Cyril Burc85e34d2016-11-15 11:50:41 +1100246{
Cyril Bure8f2de12017-01-17 16:56:02 +1100247 char *endptr;
Suraj Jitindar Singhc29172e2017-04-12 14:26:47 +1000248 int opt;
Cyril Burc85e34d2016-11-15 11:50:41 +1100249
250 static const struct option long_options[] = {
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100251 { "flash", required_argument, 0, 'f' },
252 { "window-size", optional_argument, 0, 'w' },
253 { "window-num", optional_argument, 0, 'n' },
254 { "verbose", no_argument, 0, 'v' },
255 { "syslog", no_argument, 0, 's' },
256 { "version", no_argument, 0, 'V' },
257 { "help", no_argument, 0, 'h' },
258 { 0, 0, 0, 0 }
Cyril Burc85e34d2016-11-15 11:50:41 +1100259 };
260
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100261 verbosity = MBOX_LOG_NONE;
Cyril Burc85e34d2016-11-15 11:50:41 +1100262 mbox_vlog = &mbox_log_console;
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100263
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100264 context->current = NULL; /* No current window */
265
266 while ((opt = getopt_long(argc, argv, "f:w::n::vsVh", long_options, NULL))
267 != -1) {
Cyril Burc85e34d2016-11-15 11:50:41 +1100268 switch (opt) {
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100269 case 0:
270 break;
271 case 'f':
272 context->flash_size = strtol(optarg, &endptr, 10);
273 if (optarg == endptr) {
274 fprintf(stderr, "Unparseable flash size\n");
275 return false;
276 }
277 switch (*endptr) {
278 case '\0':
Cyril Burc85e34d2016-11-15 11:50:41 +1100279 break;
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100280 case 'M':
281 context->flash_size <<= 10;
282 case 'K':
283 context->flash_size <<= 10;
Cyril Burc85e34d2016-11-15 11:50:41 +1100284 break;
285 default:
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100286 fprintf(stderr, "Unknown units '%c'\n",
287 *endptr);
288 return false;
289 }
290 break;
291 case 'n':
292 context->windows.num = strtol(argv[optind], &endptr,
293 10);
294 if (optarg == endptr || *endptr != '\0') {
295 fprintf(stderr, "Unparseable window num\n");
296 return false;
297 }
298 break;
299 case 'w':
300 context->windows.default_size = strtol(argv[optind],
301 &endptr, 10);
302 context->windows.default_size <<= 20; /* Given in MB */
303 if (optarg == endptr || (*endptr != '\0' &&
304 *endptr != 'M')) {
305 fprintf(stderr, "Unparseable window size\n");
306 return false;
307 }
Suraj Jitindar Singh0aff80c2017-04-12 14:37:24 +1000308 if (!is_power_of_2(context->windows.default_size)) {
309 fprintf(stderr, "Window size not power of 2\n");
310 return false;
311 }
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100312 break;
313 case 'v':
314 verbosity++;
315 break;
316 case 's':
317 /* Avoid a double openlog() */
318 if (mbox_vlog != &vsyslog) {
319 openlog(PREFIX, LOG_ODELAY, LOG_DAEMON);
320 mbox_vlog = &vsyslog;
321 }
322 break;
323 case 'V':
Suraj Jitindar Singh8d65bb42017-05-01 16:05:17 +1000324 printf("%s V%s\n", THIS_NAME, PACKAGE_VERSION);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100325 exit(0);
326 case 'h':
327 return false; /* This will print the usage message */
328 default:
329 return false;
Cyril Burc85e34d2016-11-15 11:50:41 +1100330 }
331 }
332
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100333 if (!context->flash_size) {
Cyril Bure8f2de12017-01-17 16:56:02 +1100334 fprintf(stderr, "Must specify a non-zero flash size\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100335 return false;
Cyril Bure8f2de12017-01-17 16:56:02 +1100336 }
337
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000338 MSG_INFO("Flash size: 0x%.8x\n", context->flash_size);
Cyril Burc85e34d2016-11-15 11:50:41 +1100339
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100340 if (verbosity) {
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000341 MSG_INFO("%s logging\n", verbosity == MBOX_LOG_DEBUG ? "Debug" :
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100342 "Verbose");
Cyril Burc85e34d2016-11-15 11:50:41 +1100343 }
344
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100345 return true;
Cyril Burc85e34d2016-11-15 11:50:41 +1100346}
347
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100348int main(int argc, char **argv)
349{
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030350 const struct transport_ops *mbox_ops, *dbus_ops;
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100351 struct mbox_context *context;
352 char *name = argv[0];
353 sigset_t set;
354 int rc, i;
355
356 context = calloc(1, sizeof(*context));
357 if (!context) {
358 fprintf(stderr, "Memory allocation failed\n");
359 exit(1);
360 }
361
362 if (!parse_cmdline(argc, argv, context)) {
363 usage(name);
364 free(context);
365 exit(0);
366 }
367
368 for (i = 0; i < TOTAL_FDS; i++) {
369 context->fds[i].fd = -1;
370 }
371
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000372 MSG_INFO("Starting Daemon\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100373
374 rc = init_signals(context, &set);
375 if (rc) {
376 goto finish;
377 }
378
Andrew Jeffery1e531af2018-08-07 13:32:57 +0930379 rc = protocol_init(context);
380 if (rc) {
381 goto finish;
382 }
383
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030384 rc = transport_mbox_init(context, &mbox_ops);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100385 if (rc) {
386 goto finish;
387 }
388
Andrew Jefferycb9b2102018-08-08 16:31:07 +0930389 rc = lpc_dev_init(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100390 if (rc) {
391 goto finish;
392 }
393
394 /* We've found the reserved memory region -> we can assign to windows */
Andrew Jefferyc1a67fa2018-08-08 17:07:38 +0930395 rc = windows_init(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100396 if (rc) {
397 goto finish;
398 }
399
Andrew Jefferyd6b09bc2018-08-08 16:47:54 +0930400 rc = flash_dev_init(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100401 if (rc) {
402 goto finish;
403 }
404
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030405 rc = dbus_init(context, &dbus_ops);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100406 if (rc) {
407 goto finish;
408 }
409
Deepak Kodihalli017e45c2017-07-12 01:06:30 -0500410#ifdef VIRTUAL_PNOR_ENABLED
Deepak Kodihalli64ec3e42017-07-17 06:15:16 -0500411 init_vpnor(context);
Deepak Kodihalli017e45c2017-07-12 01:06:30 -0500412#endif
413
414 /* Set the LPC bus mapping */
Andrew Jeffery17971e42018-08-08 16:36:10 +0930415 rc = lpc_reset(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100416 if (rc) {
Andrew Jeffery8fe809e2018-05-17 09:54:32 +0930417 MSG_ERR("LPC configuration failed, RESET required: %d\n", rc);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100418 }
419
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030420 /* We're ready to go, alert the host */
421 context->bmc_events |= BMC_EVENT_DAEMON_READY;
422
423 /* Alert on all supported transports */
424 rc = protocol_events_put(context, mbox_ops);
425 if (rc) {
426 goto finish;
427 }
428
429 rc = protocol_events_put(context, dbus_ops);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100430 if (rc) {
431 goto finish;
432 }
433
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000434 MSG_INFO("Entering Polling Loop\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100435 rc = poll_loop(context);
436
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000437 MSG_INFO("Exiting Poll Loop: %d\n", rc);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100438
439finish:
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000440 MSG_INFO("Daemon Exiting...\n");
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030441 context->bmc_events &= ~BMC_EVENT_DAEMON_READY;
442
443 /* Alert on all supported transports */
444 protocol_events_put(context, mbox_ops);
445 protocol_events_put(context, dbus_ops);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100446
Andrew Jeffery1e531af2018-08-07 13:32:57 +0930447#ifdef VIRTUAL_PNOR_ENABLED
448 destroy_vpnor(context);
449#endif
Andrew Jefferyef9e62d2018-08-08 15:48:27 +0930450 dbus_free(context);
Andrew Jefferydec6ca62018-08-08 16:49:43 +0930451 flash_dev_free(context);
Andrew Jeffery2e2df282018-08-08 16:32:22 +0930452 lpc_dev_free(context);
Andrew Jeffery55260ce2018-08-09 15:05:59 +0930453 transport_mbox_free(context);
Andrew Jefferyf5f51422018-08-08 17:08:33 +0930454 windows_free(context);
Andrew Jeffery1e531af2018-08-07 13:32:57 +0930455 protocol_free(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100456 free(context);
457
458 return rc;
459}