Trouble accessing C struct's fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const c = @cImport ({ | |
@cInclude("libnetfilter_queue/libnetfilter_queue.h"); | |
}); | |
fn callback(queue: ?*c.nfq_q_handle, msg: ?[*]c.nfgenmsg, data: ?*c.nfq_data, arbitrary: ?*c_void) c_int { | |
const packet_header = try c.nfq_get_msg_packet_hdr(data) orelse return 0; | |
const packet_id = c.ntohl(packet_header.*.packet_id); | |
var payload: [*]u8 = undefined; | |
const payload_len = c.nfq_get_payload(data, @ptrCast(?[*]?[*]u8, &payload)); | |
const payload_slice: []u8 = payload[0..@intCast(usize, payload_len)]; | |
var test_packet: Packet = undefined; | |
_ = packets.parse_ip_packet(&test_packet, payload_slice); | |
// Attempting to access `id` field of nfq_q_handle struct here | |
if (queue.?.id == OUTPUT_QUEUE_ID) { | |
warn("OUT "); | |
} else { | |
warn("IN "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment