Lines Matching refs:packet
348 coap_packet_t *packet; in coap_malloc_packet() local
351 packet = (coap_packet_t *)coap_malloc(need); in coap_malloc_packet()
352 if (packet) { in coap_malloc_packet()
353 memset(packet, 0, need); in coap_malloc_packet()
355 return packet; in coap_malloc_packet()
359 coap_free_packet(coap_packet_t *packet) { in coap_free_packet() argument
360 coap_free(packet); in coap_free_packet()
370 coap_free_packet(coap_packet_t *packet) { in coap_free_packet() argument
371 coap_free_type(COAP_PACKET, packet); in coap_free_packet()
376 coap_get_max_packetlength(const coap_packet_t *packet UNUSED_PARAM) { in coap_get_max_packetlength()
381 coap_packet_populate_endpoint(coap_packet_t *packet, coap_endpoint_t *target) in coap_packet_populate_endpoint() argument
383 target->handle = packet->interface->handle; in coap_packet_populate_endpoint()
384 memcpy(&target->addr, &packet->dst, sizeof(target->addr)); in coap_packet_populate_endpoint()
385 target->ifindex = packet->ifindex; in coap_packet_populate_endpoint()
389 coap_packet_copy_source(coap_packet_t *packet, coap_address_t *target) in coap_packet_copy_source() argument
391 memcpy(target, &packet->src, sizeof(coap_address_t)); in coap_packet_copy_source()
394 coap_packet_get_memmapped(coap_packet_t *packet, unsigned char **address, size_t *length) in coap_packet_get_memmapped() argument
396 *address = packet->payload; in coap_packet_get_memmapped()
397 *length = packet->length; in coap_packet_get_memmapped()
412 coap_network_read(coap_endpoint_t *ep, coap_packet_t **packet) { in coap_network_read() argument
422 assert(packet); in coap_network_read()
424 *packet = coap_malloc_packet(); in coap_network_read()
426 if (!*packet) { in coap_network_read()
431 coap_address_init(&(*packet)->dst); /* the local interface address */ in coap_network_read()
432 coap_address_init(&(*packet)->src); /* the remote peer */ in coap_network_read()
435 iov[0].iov_base = (*packet)->payload; in coap_network_read()
436 iov[0].iov_len = coap_get_max_packetlength(*packet); in coap_network_read()
440 mhdr.msg_name = &(*packet)->src.addr.st; in coap_network_read()
441 mhdr.msg_namelen = sizeof((*packet)->src.addr.st); in coap_network_read()
461 (*packet)->dst.size = sizeof((*packet)->dst.addr); in coap_network_read()
462 if (getsockname(ep->handle.fd, &(*packet)->dst.addr.sa, &(*packet)->dst.size) < 0) { in coap_network_read()
467 (*packet)->length = len; in coap_network_read()
480 (*packet)->ifindex = (int)(u.p->ipi6_ifindex); in coap_network_read()
482 memcpy(&(*packet)->dst.addr.sin6.sin6_addr, in coap_network_read()
485 (*packet)->src.size = mhdr.msg_namelen; in coap_network_read()
486 assert((*packet)->src.size == sizeof(struct sockaddr_in6)); in coap_network_read()
488 (*packet)->src.addr.sin6.sin6_family = SIN6(mhdr.msg_name)->sin6_family; in coap_network_read()
489 (*packet)->src.addr.sin6.sin6_addr = SIN6(mhdr.msg_name)->sin6_addr; in coap_network_read()
490 (*packet)->src.addr.sin6.sin6_port = SIN6(mhdr.msg_name)->sin6_port; in coap_network_read()
503 (*packet)->ifindex = u.p->ipi_ifindex; in coap_network_read()
505 memcpy(&(*packet)->dst.addr.sin.sin_addr, in coap_network_read()
508 (*packet)->src.size = mhdr.msg_namelen; in coap_network_read()
509 memcpy(&(*packet)->src.addr.st, mhdr.msg_name, (*packet)->src.size); in coap_network_read()
515 if (!is_local_if(&ep->addr, &(*packet)->dst)) { in coap_network_read()
527 uip_ipaddr_copy(&(*packet)->src.addr, &UIP_IP_BUF->srcipaddr); in coap_network_read()
528 (*packet)->src.port = UIP_UDP_BUF->srcport; in coap_network_read()
529 uip_ipaddr_copy(&(*packet)->dst.addr, &UIP_IP_BUF->destipaddr); in coap_network_read()
530 (*packet)->dst.port = UIP_UDP_BUF->destport; in coap_network_read()
532 if (!is_local_if(&ep->addr, &(*packet)->dst)) { in coap_network_read()
539 if (len > coap_get_max_packetlength(*packet)) { in coap_network_read()
553 if (coap_print_addr(&(*packet)->src, addr_str, INET6_ADDRSTRLEN+8)) { in coap_network_read()
559 (*packet)->length = len; in coap_network_read()
560 memcpy(&(*packet)->payload, uip_appdata, len); in coap_network_read()
570 (*packet)->interface = ep; in coap_network_read()
574 coap_free_packet(*packet); in coap_network_read()
575 *packet = NULL; in coap_network_read()