This makes it clear which lines are no longer required. It also obviates the need to document NFQNL_CFG_CMD_PF_(UN)BIND. Add comment with sed command to re-enable commented-out code. Use // comments because my sed-fu is not up to reversing a /* comment block Signed-off-by: Duncan Roe <duncan_roe@xxxxxxxxxxxxxxx> --- examples/nf-queue.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/examples/nf-queue.c b/examples/nf-queue.c index f6d254a..ee9e4f4 100644 --- a/examples/nf-queue.c +++ b/examples/nf-queue.c @@ -151,29 +151,31 @@ int main(int argc, char *argv[]) } /* PF_(UN)BIND is not needed with kernels 3.8 and later */ - nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); - nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_UNBIND); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { - perror("mnl_socket_send"); - exit(EXIT_FAILURE); - } - - nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); - nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_BIND); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { - perror("mnl_socket_send"); - exit(EXIT_FAILURE); - } - - nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, queue_num); - nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_BIND); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { - perror("mnl_socket_send"); - exit(EXIT_FAILURE); - } + /* Uncomment this code block if you need to cater for an older kernel */ + /* E.g. sed -i '156,178s+//++' examples/nf-queue.c */ + //nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); + //nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_UNBIND); + // + //if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { + // perror("mnl_socket_send"); + // exit(EXIT_FAILURE); + //} + // + //nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, 0); + //nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_PF_BIND); + // + //if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { + // perror("mnl_socket_send"); + // exit(EXIT_FAILURE); + //} + // + //nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, queue_num); + //nfq_nlmsg_cfg_put_cmd(nlh, AF_INET, NFQNL_CFG_CMD_BIND); + // + //if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) { + // perror("mnl_socket_send"); + // exit(EXIT_FAILURE); + //} nlh = nfq_hdr_put(buf, NFQNL_MSG_CONFIG, queue_num); nfq_nlmsg_cfg_put_params(nlh, NFQNL_COPY_PACKET, 0xffff); -- 2.14.5