Lines Matching refs:packet
221 static int init_connpack(char *packet, char *remain, int remain_pos) in init_connpack() argument
225 packet[0] = MQTT_MSG_CONNECT; in init_connpack()
227 memcpy(&packet[1], remain, remain_pos); in init_connpack()
232 packet[remain_pos + 1] = 0x00; in init_connpack()
233 packet[remain_pos + 2] = 0x04; in init_connpack()
235 packet[remain_pos + 3] = 'M'; in init_connpack()
236 packet[remain_pos + 4] = 'Q'; in init_connpack()
237 packet[remain_pos + 5] = 'T'; in init_connpack()
238 packet[remain_pos + 6] = 'T'; in init_connpack()
240 packet[remain_pos + 7] = 0x04; in init_connpack()
242 packet[remain_pos + 8] = 0x02; in init_connpack()
244 packet[remain_pos + 9] = 0x00; in init_connpack()
245 packet[remain_pos + 10] = 0x3c; in init_connpack()
264 char *packet = NULL; in mqtt_connect() local
292 packet = malloc(packetlen); in mqtt_connect()
293 if(!packet) in mqtt_connect()
295 memset(packet, 0, packetlen); in mqtt_connect()
298 pos = init_connpack(packet, remain, remain_pos); in mqtt_connect()
303 rc = add_client_id(client_id, strlen(client_id), packet, pos + 1); in mqtt_connect()
320 (unsigned char *)packet, start_user, remain_pos); in mqtt_connect()
330 rc = add_passwd(passwd, plen, packet, start_pwd, remain_pos); in mqtt_connect()
339 result = mqtt_send(data, packet, packetlen); in mqtt_connect()
342 if(packet) in mqtt_connect()
343 free(packet); in mqtt_connect()
441 unsigned char *packet = NULL; in mqtt_subscribe() local
458 packet = malloc(packetlen); in mqtt_subscribe()
459 if(!packet) { in mqtt_subscribe()
464 packet[0] = MQTT_MSG_SUBSCRIBE; in mqtt_subscribe()
465 memcpy(&packet[1], encodedsize, n); in mqtt_subscribe()
466 packet[1 + n] = (conn->proto.mqtt.packetid >> 8) & 0xff; in mqtt_subscribe()
467 packet[2 + n] = conn->proto.mqtt.packetid & 0xff; in mqtt_subscribe()
468 packet[3 + n] = (topiclen >> 8) & 0xff; in mqtt_subscribe()
469 packet[4 + n ] = topiclen & 0xff; in mqtt_subscribe()
470 memcpy(&packet[5 + n], topic, topiclen); in mqtt_subscribe()
471 packet[5 + n + topiclen] = 0; /* QoS zero */ in mqtt_subscribe()
473 result = mqtt_send(data, (char *)packet, packetlen); in mqtt_subscribe()
477 free(packet); in mqtt_subscribe()
629 unsigned char packet; in mqtt_read_publish() local
644 packet = mq->firstbyte & 0xf0; in mqtt_read_publish()
645 if(packet == MQTT_MSG_PUBLISH) in mqtt_read_publish()
647 else if(packet == MQTT_MSG_SUBACK) { in mqtt_read_publish()
651 else if(packet == MQTT_MSG_DISCONNECT) { in mqtt_read_publish()