Add two new helper functions to skip memcpy()'ing the payload from the netlink message. Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- include/libnetfilter_queue/pktbuff.h | 3 +++ src/extra/pktbuff.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/libnetfilter_queue/pktbuff.h b/include/libnetfilter_queue/pktbuff.h index 42bc153ec337..f9bddaf072fb 100644 --- a/include/libnetfilter_queue/pktbuff.h +++ b/include/libnetfilter_queue/pktbuff.h @@ -4,8 +4,11 @@ struct pkt_buff; struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra); +struct pkt_buff *pktb_alloc_head(void); void pktb_free(struct pkt_buff *pktb); +void pktb_build_data(struct pkt_buff *pktb, uint8_t *payload, uint32_t len); + uint8_t *pktb_data(struct pkt_buff *pktb); uint32_t pktb_len(struct pkt_buff *pktb); diff --git a/src/extra/pktbuff.c b/src/extra/pktbuff.c index 6dd0ca98aff2..a93e72ac7795 100644 --- a/src/extra/pktbuff.c +++ b/src/extra/pktbuff.c @@ -93,6 +93,26 @@ struct pkt_buff *pktb_alloc(int family, void *data, size_t len, size_t extra) return pktb; } +EXPORT_SYMBOL +struct pkt_buff *pktb_alloc_head(void) +{ + struct pkt_buff *pktb; + + pktb = calloc(1, sizeof(struct pkt_buff)); + if (pktb == NULL) + return NULL; + + return pktb; +} + +EXPORT_SYMBOL +void pktb_build_data(struct pkt_buff *pktb, uint8_t *payload, uint32_t len) +{ + pktb->len = len; + pktb->data_len = len; + pktb->data = payload; +} + /** * pktb_data - get pointer to network packet * \param pktb Pointer to userspace packet buffer -- 2.20.1