tncattach/TAP.h
Tristan B. Velloza Kildaire c910421796
Add IPv6 support (command-line and tuntap) (#16)
* tncattach

- Added `set_ipv6`, `ipv6_addr` and `netmask_v6` globals
- Added `--ipv6` option
- If `n` is specified (i.e. `--noipv6`) then bail out if the user specified IPv6 addressing with `--ipv6 <arg>`
- Added `6` parsing, this is for when we have an `--ipv6` and want to set the address

* tncattach

- Removed global `netmask_v6` which is never used

* TAP

- Added initial code that I have been working on

* TAP

- Removed old (bad) code `trySixSet2(...)`

* TAP

- Clean up

* TAP

- Clean up

* TAP

- Added device type checl

* TAP

- Randomize the remaining octets of the link-local address

* TAP

- Seed random number generatro based off of current time

* TAP

- Removed TODO

* TAP_

- Cleaned up a little bit
- The `mtu` (on Luinux) must be `1280` of greater, else IPv6 won't work (and the address will not be allowed to be added)

* TAP

- More clean up

* TAP

- Moved mtu check for Ipv6 to be earlier

* TAP

- Added missing `cleanup()` calls

* TAP

- Aded newline

* TAP

- Now link-local and normal v6 can be requested independently

tncattach

- Added `--ll` mode to add link-local

* TAP

- More cleanup

* TAP

- Removed code to generate a link-local address

* tncattach

- Added error handling for mtu with IPv6 support

* TAP

- Removed uneeded imports

* TAP

- Cleaned up

* Cleaned up

* TAP

- Removed duplicate import

* TAP

- Removed error checking code from there

* TAP

- Cleaned up
- Remove dneed for `link_local_v6`

tncattach

- Removed `link_local_v6`

* TAP

- Close control socket when done

* tncattach

- Removed debug print

* TAP

- Cleaned up

* TAP

- Cleaned up

* TAP

- Cleaned up

* TAP

- Added check for bad open

* TAP

- Added another check

* tncattach

- Now parse IPv6 address and prefix in opt-args

TAP

- Removed parsing from here

* Fixed mtu stuff

* tncattach

- Typo fix

* Work

* tncattach

- WHen parsing the `prefixPart_s` (the prefix length), only continue if
the text is a number, if not then bail out with an error

* tncattach

- Only allow prefix length of between 0 to 128

* TAP

- Cleaned up

* TAP

- Cleaned up

* tncattach

- Cleaned up
2024-12-22 14:27:16 +01:00

16 lines
329 B
C

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <linux/if_tun.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <linux/ipv6.h>
#include "Constants.h"
int open_tap(void);
int close_tap(int tap_fd);