Skip to content

Commit

Permalink
packet: add sss_packet_set_body
Browse files Browse the repository at this point in the history
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
  • Loading branch information
pbrezina authored and sumit-bose committed Dec 16, 2020
1 parent 45f2eb5 commit 3b0e48c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/responder/common/responder_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,25 @@ void sss_packet_get_body(struct sss_packet *packet, uint8_t **body, size_t *blen
*blen = sss_packet_get_len(packet) - SSS_NSS_HEADER_SIZE;
}

errno_t sss_packet_set_body(struct sss_packet *packet,
uint8_t *body,
size_t blen)
{
uint8_t *pbody;
size_t plen;
errno_t ret;

ret = sss_packet_grow(packet, blen);
if (ret != EOK) {
return ret;
}

sss_packet_get_body(packet, &pbody, &plen);
memcpy(pbody, body, blen);

return EOK;
}

void sss_packet_set_error(struct sss_packet *packet, int error)
{
SAFEALIGN_SETMEM_UINT32(packet->buffer + SSS_PACKET_ERR_OFFSET, error,
Expand Down
5 changes: 5 additions & 0 deletions src/responder/common/responder_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ uint32_t sss_packet_get_status(struct sss_packet *packet);
void sss_packet_get_body(struct sss_packet *packet, uint8_t **body, size_t *blen);
void sss_packet_set_error(struct sss_packet *packet, int error);

/* Grow packet and set its body. */
errno_t sss_packet_set_body(struct sss_packet *packet,
uint8_t *body,
size_t blen);

#endif /* __SSSSRV_PACKET_H__ */

0 comments on commit 3b0e48c

Please sign in to comment.