Lines Matching full:tunnel
79 * tries to open the tunnel device
118 * tunnel - tun device data
120 void deconfigure_tun_ipv6(const struct tun_data *tunnel) {
123 status = if_route(tunnel->device6, AF_INET6, &Global_Clatd_Config.ipv6_local_subnet,
133 * tunnel - tun device data
135 void configure_tun_ipv6(const struct tun_data *tunnel) {
138 status = if_route(tunnel->device6, AF_INET6, &Global_Clatd_Config.ipv6_local_subnet,
148 * tunnel - tun device data
150 void interface_poll(const struct tun_data *tunnel) {
168 deconfigure_tun_ipv6(tunnel);
172 configure_tun_ipv6(tunnel);
179 * configures the ipv4 and ipv6 addresses on the tunnel interface
180 * tunnel - tun device data
182 void configure_tun_ip(const struct tun_data *tunnel) {
187 status = add_address(tunnel->device4, AF_INET, &Global_Clatd_Config.ipv4_local_subnet,
194 status = add_address(tunnel->device6, AF_INET6, &Global_Clatd_Config.ipv6_local_address,
201 if((status = if_up(tunnel->device6, Global_Clatd_Config.mtu)) < 0) {
206 if((status = if_up(tunnel->device4, Global_Clatd_Config.ipv4mtu)) < 0) {
211 configure_tun_ipv6(tunnel);
254 * tunnel - tun device data
256 void configure_interface(const char *uplink_interface, const char *plat_prefix, struct tun_data *tunnel) {
283 error = tun_alloc(tunnel->device6, tunnel->fd6);
289 error = tun_alloc(tunnel->device4, tunnel->fd4);
295 configure_tun_ip(tunnel);
299 * reads a packet from the tunnel fd and passes it down the stack
301 * tunnel - tun device data
303 void read_packet(int active_fd, const struct tun_data *tunnel) {
326 translate_packet(tunnel, (struct tun_pi *) packet, packet + header_size, readlen - header_size);
332 * tunnel - tun device data
334 void event_loop(const struct tun_data *tunnel) {
341 wait_fd[0].fd = tunnel->fd6;
344 wait_fd[1].fd = tunnel->fd4;
357 read_packet(wait_fd[i].fd,tunnel);
364 interface_poll(tunnel);
383 struct tun_data tunnel;
387 strcpy(tunnel.device6, DEVICENAME6);
388 strcpy(tunnel.device4, DEVICENAME4);
413 // open the tunnel device before dropping privs
414 tunnel.fd6 = tun_open();
415 if(tunnel.fd6 < 0) {
420 tunnel.fd4 = tun_open();
421 if(tunnel.fd4 < 0) {
441 configure_interface(uplink_interface, plat_prefix, &tunnel);
450 event_loop(&tunnel);