Пример #1
0
static int do_add(int argc, char **argv)
{
	struct l2tp_parm p;
	int ret = 0;

	if (parse_args(argc, argv, L2TP_ADD, &p) < 0)
		return -1;

	if (!p.tunnel && !p.session)
		missarg("tunnel or session");

	if (p.tunnel_id == 0)
		missarg("tunnel_id");

	/* session_id and peer_session_id must be provided for sessions */
	if ((p.session) && (p.peer_session_id == 0))
		missarg("peer_session_id");
	if ((p.session) && (p.session_id == 0))
		missarg("session_id");

	/* peer_tunnel_id is needed for tunnels */
	if ((p.tunnel) && (p.peer_tunnel_id == 0))
		missarg("peer_tunnel_id");

	if (p.tunnel) {
		if (p.local_ip.family == AF_UNSPEC)
			missarg("local");

		if (p.peer_ip.family == AF_UNSPEC)
			missarg("remote");

		if (p.encap == L2TP_ENCAPTYPE_UDP) {
			if (p.local_udp_port == 0)
				missarg("udp_sport");
			if (p.peer_udp_port == 0)
				missarg("udp_dport");
		}

		ret = create_tunnel(&p);
	}

	if (p.session) {
		/* Only ethernet pseudowires supported */
		p.pw_type = L2TP_PWTYPE_ETH;

		ret = create_session(&p);
	}

	return ret;
}
Пример #2
0
void pma_bcache::register_callback(in_addr_t hoa, in_addr_t ha, in_addr_t coa)
{
  char const *ifname = miface_[hoa].c_str();

  if (ha_refcnt_[ha]++ == 0)
    create_tunnel(coa, ha);

  int &tab = tunnel_tab_[ha];
  if (mif_refcnt_[ifname]++ == 0) {
    tab = allocate_rtable();
    register_route_to_tunnel(ha, tab);
    set_proxy_arp(ifname, 1);
  }

  register_source_route(hoa, tab, ifname);

  /* register to PMA: ARP are sent for MN to update HOME CN's MAC */
  syslog(LOG_DEBUG, "send %d ARP", num_homecn_);
  send_grat_arp(ifname, homecn_, num_homecn_);
}
Пример #3
0
void on_device_connected(struct am_device *device)
{
  if (command.type == GetUDID)
  {
    get_udid(device);
  }
  else if (command.type == InstallApp)
  {
    install_app(device);
  }
  else if (command.type == UninstallApp)
  {
    uninstall_app(device);
  }
  else if (command.type == ListInstalledApps)
  {
    list_installed_apps(device);
  }
  else if (command.type == Tunnel)
  {
    connect_to_device(device);
    create_tunnel(device, command.src_port, command.dst_port);
  }
}
Пример #4
0
void ha_bcache::register_callback(in_addr_t hoa, in_addr_t ha, in_addr_t coa)
{
  if (coa_refcnt_[coa]++ == 0)
    create_tunnel(ha, coa);
  register_hoa_route(hoa, coa, hif_.name());
}