1: #include "global.h"
2: #include "mqttd.h"
3: #include "mqttd_calls.h"
4:
5:
6: inline int
7: srv_Socket(cfg_root_t * __restrict cfg)
8: {
9: int s = -1;
10: ait_val_t v;
11: u_short port;
12: io_sockaddr_t sa = {{ 0 }};
13:
14: ioTRACE(2);
15:
16: assert(cfg);
17:
18: cfg_loadAttribute(cfg, "mqttd", "port", &v, MQTT_PORT);
19: port = strtol(AIT_GET_STR(&v), NULL, 0);
20: AIT_FREE_VAL(&v);
21: cfg_loadAttribute(cfg, "mqttd", "listen", &v, MQTT_HOST);
22: if (!io_gethostbyname(AIT_GET_STR(&v), port, &sa)) {
23: ioLIBERR(io);
24: AIT_FREE_VAL(&v);
25: return -1;
26: } else
27: AIT_FREE_VAL(&v);
28:
29: s = mqtt_srv_Create(&sa.sa, sa.sa.sa_len);
30: if (s == -1) {
31: ioLIBERR(mqtt);
32: return -1;
33: }
34:
35: ioDEBUG(7, "Created socket=%d\n", s);
36: return s;
37: }
38:
39: inline int
40: srv_Close(int s)
41: {
42: ioTRACE(2);
43:
44: ioDEBUG(7, "Closing socket=%d\n", s);
45: return mqtt_srv_Destroy(s);
46: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>