New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplest implementation of promisc flag on open_link, works on Linux #13

Open
wants to merge 3 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@gabrik
Copy link

gabrik commented Jan 29, 2019

Simple implementation of the promisc parameter on open_link
to enable promiscuos mode on a interface while opening it, tested on
Ubuntu 16.04.5
Ocaml 4.07.1
dune 1.6.3

See #12

Signed-off-by: gabrik gabriele.baldoni@gmail.com

simplest implementation of promisc flag on open_link, works on Linux
Signed-off-by: gabrik <gabriele.baldoni@gmail.com>
@haesbaert
Copy link
Owner

haesbaert left a comment

I'll pick this up and give you credit, will try to push until tomorrow, need to test on bpf first.
many thanks !


strncpy(ifopts.ifr_name, ifname, IFNAMSIZ - 1);
caml_enter_blocking_section();
r = ioctl(fd, SIOCGIFFLAGS, &ifopts);

This comment has been minimized.

@haesbaert

haesbaert Jan 29, 2019

Owner

You have to test the error of each syscall and abort, also ifopts should be bzroed before.

int af_packet_set_promisc(int fd, int promisc, char *ifname)
{
struct ifreq ifopts;
int r;

This comment has been minimized.

@haesbaert

haesbaert Jan 29, 2019

Owner

new line after declarations, also keep same indentation style.

let open_link ?filter ifname =
{ fd = opensock ?filter:filter ifname;
let open_link ?promisc ?filter ifname =
{ fd = opensock ?promisc:promisc ?filter:filter ifname;

This comment has been minimized.

@hannesm

hannesm Jan 30, 2019

Collaborator

FWIW, you can drop :promisc and :filter here:

let fd = opensock ?promisc ?filter ifname in
{ fd ; packets = ref [] ; buffer = Cstruct.create 65536 }
Addressing comments
Signed-off-by: gabrik <gabriele.baldoni@gmail.com>
@gabrik

This comment has been minimized.

Copy link
Author

gabrik commented Jan 30, 2019

Hi both, I have updated the PR addressing the comments, the indentation style should be the right one, so feel free to borrow this last version for the feature branch, also I have a question on the Lwt version, why Lwt_rawlink.open_link return t instead of returing t Lwt.t ?

fixes and comment addressing
Signed-off-by: gabrik <gabriele.baldoni@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment