Annotation of mqtt/src/utils.c, revision 1.2.2.7
1.2 misho 1: #include "global.h"
1.2.2.5 misho 2: #include "mqttd.h"
1.2.2.6 misho 3: #include "mqttd_calls.h"
1.2 misho 4:
5:
1.2.2.5 misho 6: inline int
1.2.2.1 misho 7: srv_Socket(cfg_root_t * __restrict cfg)
1.2 misho 8: {
1.2.2.5 misho 9: int s = -1;
1.2.2.1 misho 10: ait_val_t v;
1.2 misho 11: u_short port;
1.2.2.4 misho 12: io_sockaddr_t sa = {{ 0 }};
1.2 misho 13:
14: ioTRACE(2);
15:
1.2.2.4 misho 16: assert(cfg);
17:
1.2.2.1 misho 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);
1.2.2.3 misho 22: if (!io_gethostbyname(AIT_GET_STR(&v), port, &sa)) {
23: ioLIBERR(io);
24: AIT_FREE_VAL(&v);
1.2 misho 25: return -1;
1.2.2.3 misho 26: } else
27: AIT_FREE_VAL(&v);
1.2 misho 28:
1.2.2.5 misho 29: s = mqtt_srv_Create(&sa.sa, sa.sa.sa_len);
1.2 misho 30: if (s == -1) {
1.2.2.5 misho 31: ioLIBERR(mqtt);
1.2 misho 32: return -1;
33: }
34:
1.2.2.7 ! misho 35: ioDEBUG(7, "Created socket=%d\n", s);
1.2 misho 36: return s;
37: }
38:
1.2.2.5 misho 39: inline int
1.2 misho 40: srv_Close(int s)
41: {
42: ioTRACE(2);
43:
1.2.2.7 ! misho 44: ioDEBUG(7, "Closing socket=%d\n", s);
1.2.2.5 misho 45: return mqtt_srv_Destroy(s);
1.2 misho 46: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>