Home | History | Annotate | Download | only in android-clat

Lines Matching defs:tunnel

69  * tries to open the tunnel device
154 * configures the ipv4 and ipv6 addresses on the tunnel interface
155 * tunnel - tun device data
157 void configure_tun_ip(const struct tun_data *tunnel) {
178 status = add_address(tunnel->device4, AF_INET, &Global_Clatd_Config.ipv4_local_subnet,
187 logmsg(ANDROID_LOG_INFO, "Using IPv4 address %s on %s", addrstr, tunnel->device4);
189 if((status = if_up(tunnel->device4, Global_Clatd_Config.ipv4mtu)) < 0) {
233 * tunnel - tun device data
236 void open_sockets(struct tun_data *tunnel, uint32_t mark) {
251 tunnel->write_fd6 = rawsock;
259 tunnel->read_fd6 = packetsock;
264 * tunnel - tun device data
268 int update_clat_ipv6_address(const struct tun_data *tunnel, const char *interface) {
298 del_anycast_address(tunnel->write_fd6, &Global_Clatd_Config.ipv6_local_subnet);
303 add_anycast_address(tunnel->write_fd6, &Global_Clatd_Config.ipv6_local_subnet, interface);
307 if (!configure_packet_socket(tunnel->read_fd6)) {
320 * tunnel - tun device data
323 void configure_interface(const char *uplink_interface, const char *plat_prefix, struct tun_data *tunnel, unsigned net_id) {
350 error = tun_alloc(tunnel->device4, tunnel->fd4);
356 configure_tun_ip(tunnel);
360 * reads a packet from the tunnel fd and passes it down the stack
362 * tunnel - tun device data
364 void read_packet(int active_fd, const struct tun_data *tunnel) {
380 if (active_fd == tunnel->fd4) {
399 fd = tunnel->write_fd6;
403 fd = tunnel->fd4;
407 translate_packet(fd, (fd == tunnel->write_fd6), packet, readlen);
412 * tunnel - tun device data
414 void event_loop(const struct tun_data *tunnel) {
417 { tunnel->read_fd6, POLLIN, 0 },
418 { tunnel->fd4, POLLIN, 0 },
438 read_packet(wait_fd[i].fd,tunnel);
445 update_clat_ipv6_address(tunnel, Global_Clatd_Config.default_pdp_interface);
477 struct tun_data tunnel;
522 len = snprintf(tunnel.device4, sizeof(tunnel.device4), "%s%s", DEVICEPREFIX, uplink_interface);
523 if (len >= sizeof(tunnel.device4)) {
524 logmsg(ANDROID_LOG_FATAL, "interface name too long '%s'", tunnel.device4);
534 open_sockets(&tunnel, mark);
540 tunnel.fd4 = tun_open();
541 if(tunnel.fd4 < 0) {
550 configure_interface(uplink_interface, plat_prefix, &tunnel, net_id);
552 update_clat_ipv6_address(&tunnel, uplink_interface);
560 event_loop(&tunnel);
563 del_anycast_address(tunnel.write_fd6, &Global_Clatd_Config.ipv6_local_subnet);