I'm trying to convert a system()
call I have in C that calls ip tuntap add ...
to C code that doesn't rely on the system()
call.
Basically, it's a problem that the tunnel adapter that I use the system("ip tuntap add ...")
call to bring up is left there when my application is forcibly terminated.
I've been told I can use rtnetlink to achieve my goal. I'd like to convert the following line into C code that doesn't rely on the system()
call. I believe if I use rtnetlink that the tunnel adapter I bring up will be destroyed by the kernel when my application is terminated, which is the main reason I want to do this.
This is my current line in C:
system("ip tuntap add dev tun1 mode tun");
If rtnetlink isn't how I would go about doing this, is there another method that would destroy the tunnel when my application is forcibly terminated?