Annotation of mqtt/src/utils.c, revision 1.2.2.6
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:
35: return s;
36: }
37:
1.2.2.5 misho 38: inline int
1.2 misho 39: srv_Close(int s)
40: {
41: ioTRACE(2);
42:
1.2.2.5 misho 43: return mqtt_srv_Destroy(s);
1.2 misho 44: }
1.2.2.6 ! misho 45:
! 46: inline int
! 47: srv_Will(struct tagSession * __restrict sess)
! 48: {
! 49: int ret = 0;
! 50:
! 51: ioTRACE(2);
! 52:
! 53: ret = mqtt_msgPUBLISH(sess->sess_buf, sess->sess_will.topic, 0xDEAD, 0, 1, 0,
! 54: sess->sess_will.msg, sess->sess_will.msg ? strlen(sess->sess_will.msg) : 0);
! 55: if (ret == -1)
! 56: return -1; /* error */
! 57: else
! 58: return cmdPUBLISH(sess->sess_srv, ret, sess);
! 59: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>