Savagedlight / libifconfig

A C API to do most things done by the FreeBSD 'ifconfig' program today
Other
26 stars 7 forks source link

libifc_create() for creating cloned interfaces #12

Closed Savagedlight closed 7 years ago

Savagedlight commented 8 years ago

Allow creation of clonable interfaces, such as vlan, tap, etc.

Suggested pattern: int libifc_create(libifc_handle_t h, const char name, char **ifname);

Look at ifconfig's ifclone.c, around line 120. The interesting code is in ifclonecreate(...) and its support functions.

Savagedlight commented 8 years ago

ifclonecreate() checks for special snowflake callbacks (listed below) and executes the first matching one if found. If none is found, it does a simple ioctl() call w/ SIOCIFCREATE2 and ifr.ifr_name having the requested interface name set. If the name was something like "bridge", ioctl() will assign an appropriately numbered interface name (say, bridge0) to the ifr.ifr_name member.

Start with implementing the generic behaviour, then add special snowflake handling. The special snowflake handling should be invisible outside of the library, but should probably add some way for calling application to add their own callbacks for custom interfaces. Copy the ifconfig callback methology for this.

Special snowflake callbacks:

Savagedlight commented 7 years ago

On further thought, the special snowflake handling should not be invisible to calling application, as they require specific data to be provided (which is probably why they're special snowflake). This means the calling application has to know how to deal with that anyway, and it's preferred to have less obfuscating abstractions.

In conclusion: Create methods for the special snowflake creation (and destruction) routines which take the required parameters, hopefully making it simpler for application developers to see what's required to get the job done.

Savagedlight commented 7 years ago

As this issue requires a lot of work, I've split it up into several issues for further development: vlan: #18 vxlan: #39 wlan: #40

Closing this issue.