Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1.  
  2. const c = @cImport({
  3. @cInclude("stdio.h");
  4. @cInclude("sys/types.h");
  5. @cInclude("sys/socket.h");
  6. @cInclude("arpa/inet.h");
  7. @cInclude("netinet/in.h");
  8. @cInclude("string.h");
  9. @cInclude("stdio.h");
  10. @cInclude("unistd.h");
  11. @cInclude("pthread.h");
  12. @cInclude("semaphore.h");
  13. @cInclude("libnetfilter_queue/libnetfilter_queue.h");
  14. });
  15.  
  16. const std = @import("std");
  17. const ChildProcess = std.os.ChildProcess;
  18. const warn = std.debug.warn;
  19.  
  20. pub fn main() void {
  21. const h = c.nfq_open();
  22.  
  23. // ~/Downloads/zig-linux-x86_64-0.2.0.b65203f5/zig build-exe zf.zig --library c --library netfilter_queue
  24. // /home/juturnas/Desktop/zigfilter/zf.zig:45:16: error: cast discards const qualifier
  25. const cb = @ptrCast(?[*]extern fn(?*c.nfq_q_handle, ?[*]c.nfgenmsg, ?*c.nfq_data, ?*c_void) c_int, callback);
  26.  
  27. const queue_handle = c.nfq_create_queue(h, 0, cb, null);
  28.  
  29. if (queue_handle == null) {
  30. warn("nfq_create_queue() failed");
  31. return;
  32. }
  33. }
  34.  
  35. extern fn callback(qh: ?*c.nfq_q_handle, nfmsg: ?[*]c.nfgenmsg, nfa: ?*c.nfq_data, data: ?*c_void) c_int {
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement