コード例 #1
0
ファイル: m_invite.c プロジェクト: darcyg/chaosircd
/* -------------------------------------------------------------------------- *
 * argv[0] - prefix                                                           *
 * argv[1] - 'invite'                                                         *
 * argv[2] - nick                                                             *
 * argv[3] - channel                                                          *
 * -------------------------------------------------------------------------- */
static void m_invite(struct lclient *lcptr, struct client *cptr,
                     int             argc,  char         **argv)
{
  struct channel *chptr;
  struct client  *acptr;

  if(client_is_local(cptr) && client_is_user(cptr))
  {
    if((acptr = client_find_nickhw(cptr, argv[2])) == NULL)
      return;
  }
  else
  {
    if((acptr = client_find_uid(argv[2])) == NULL)
      if((acptr = client_find_name(argv[2])) == NULL)
      {
        log(server_log, L_warning, "Dropping INVITE for invalid user %s.",
            argv[2]);
        return;
      }
  }

  if((chptr = channel_find_warn(cptr, argv[3])) == NULL)
    return;

  if(client_is_local(cptr))
    numeric_send(cptr, RPL_INVITING, acptr->name, chptr->name);

  if(client_is_service(acptr))
  {
    service_handle(acptr->service, lcptr, cptr, chptr, "INVITE", "%s",
                   argv[4] ? argv[4] : "");
  }
  else
  {
    if(client_is_remote(acptr))
    {
      if(argv[4])
        client_send(acptr, ":%C INVITE %C %s :%s",
                    cptr, acptr, chptr->name, argv[4]);
      else
        client_send(acptr, ":%C INVITE %C %s",
                    cptr, acptr, chptr->name);
    }
    else
    {
      user_invite(acptr->user, chptr);

      if(argv[4])
        client_send(acptr, ":%N!%U@%H INVITE %N %s :%s",
                    cptr, cptr, cptr, acptr, chptr->name, argv[4]);
      else
        client_send(acptr, ":%N!%U@%H INVITE %N %s",
                    cptr, cptr, cptr, acptr, chptr->name);
    }
  }
}
コード例 #2
0
/* wathchdog is runned in NORMAL_PERIOD, 1 seconds
 * check in each NORMAL_PERIOD
 *	1. button
 *
 * check in each NORAML_PERIOD*10
 *
 *      1. ntptime 
 *      2. time-dependent service
 *      3. http-process
 *      4. usb hotplug status
 */
void watchdog(void)
{
	/* handle button */
	btn_check();

	/* if timer is set to less than 1 sec, then bypass the following */
	if (itv.it_value.tv_sec == 0) return;

	if (nvram_match("asus_mfg", "1"))
	{
		system("rmmod hw_nat");
		if (pids("ntp"))
			system("killall -SIGTERM ntp");
		if (pids("ntpclient"))
			system("killall ntpclient");
		if (pids("udhcpc"))
			system("killall -SIGTERM udhcpc");
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
		if (pids("ots"))
			system("killall ots");
#endif
		stop_wanduck();
		stop_logger();
		stop_upnp();	// it may cause upnp cannot run
		stop_dhcpd();
		stop_dns();
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
		stop_pspfix();
#endif
		stop_wsc();
		stop_wsc_2g();
		stop_lltd();
		stop_networkmap();
		stop_httpd();
		stop_lpd();
		stop_u2ec();
		kill_pidfile_s("/var/run/linkstatus_monitor.pid", SIGTERM);
		if (pids("detectWan"))
			system("killall detectWan");
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
		stop_rstats();
		kill_pidfile_s("/var/run/detect_internet.pid", SIGTERM);
#endif
		if (pids("tcpcheck"))
			system("killall -SIGTERM tcpcheck");
#ifdef HTTPD_CHECK
		if (pids("httpdcheck"))
			system("killall -SIGTERM httpdcheck");
#endif
		if (pids("traceroute"))
			system("killall traceroute");
		if (pids("usbled"))
			system("killall -SIGTERM usbled");

		nvram_set("asus_mfg", "2");
	}

#if 0
	// reboot signal checking
	if (nvram_match("reboot", "1"))
	{
		printf("[watchdog] nvram match reboot\n");

		reboot_count++;
		if (reboot_count >= 2) 
		{
//			kill(1, SIGTERM);
			sys_exit();
		}

		return;
	}
#else
	if (nvram_match("reboot", "1")) return;
#endif

	if (stop_service_type_99) return;

	if (!nvram_match("asus_mfg", "0")) return;

	watchdog_period = (watchdog_period + 1) % 10;

	if (watchdog_period) return;

#ifdef BTN_SETUP
	if (btn_pressed_setup >= BTNSETUP_START) return;
#endif

#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
	if (count_to_stop_wps > 0)
	{
		count_to_stop_wps--;

		if (!count_to_stop_wps)
		{
//			if (nvram_match("wl_radio_x", "1"))
			stop_wsc();			// psp fix
//			if (nvram_match("rt_radio_x", "1"))
			stop_wsc_2g();			// psp fix
			nvram_set("wps_enable", "0");	// psp fix
		}
	}
#endif

	ddns_timer = (ddns_timer + 1) % 4320;

	if (nvram_match("asus_debug", "1"))
		mem_timer = (mem_timer + 1) % 60;

	if (!watchdog_count)
		watchdog_count++;
	else if (watchdog_count++ == 1)
	{
#if 0
		if (!strcmp(nvram_safe_get("rc_service"), "restart_upnp"))
			service_handle();
		else
#endif
		if (	nvram_match("router_disable", "0") &&
			nvram_match("upnp_enable", "1") &&
			nvram_match("upnp_started", "0")	)
		{
//			if (has_wan_ip())
			{
				dbg("[watchdog] starting upnp...\n");
				stop_upnp();
				start_upnp();
			}
		}
	}

	/* check for time-dependent services */
	svc_timecheck();

	/* http server check */
	httpd_processcheck();

	u2ec_processcheck();

	media_processcheck();
#if 0
	samba_processcheck();
#endif
	pppd_processcheck();

	if (nvram_match("wan_route_x", "IP_Routed"))
		nm_processcheck();

	cpu_usage_minotor();

	dm_block_chk();

	if (nvram_match("asus_debug", "1") && !mem_timer)
	{
		print_num_of_connections();
		dbg("Hardware NAT: %s\n", is_hwnat_loaded() ? "Enabled": "Disabled");
		dbg("Software QoS: %s\n", nvram_match("qos_enable", "1") ? "Enabled": "Disabled");
		dbg("pppd running: %s\n", pids("pppd") ? "Yes": "No");
#if 0
		dbg("CPU usage: %d%%\n", get_cpu_usage());
#else
		dbg("CPU usage: %d%%\n", cpu_main(0, NULL, 0));
#endif
		system("free");
		system("date");
		print_uptime();
	}

#ifdef CDMA
	/* CDMA_DOWN = 99, none
	 * CDMA_DOWN = 1, currently down
	 * CDMA_DOWN = 2, currently up
	 * CDMA_DOWN = 0, currently trying to connect
	 */
	if (nvram_match("cdma_down", "1"))
	{
		logmessage("CDMA client", "cdma is down(%d)!", cdma_down);

		cdma_down++;
		cdma_connec t = 0;

		if (cdma_down == 2)
		{
			printf("[watchdog] stop wan\n");
			stop_wan();
			start_wan();
		}
		else if (cdma_down >= 12) /* 2 minutes timeout for retry */
		{
			cdma_down = 0;
		}
	}
	else if (nvram_match("cdma_down", "0"))
	{
		logmessage("CDMA client", "cdma try connect(%d)!", cdma_connect);
		cdma_down = 0;
		cdma_connect++;

		if (cdma_connect > 12) /* 2 minitues timeout for connecting */
		{
			nvram_set("cdma_down", "1");
		}
	}
	else
	{
		cdma_down = 0;
		cdma_connect = 0;
	}
#endif

	if (nvram_match("wan_route_x", "IP_Routed"))
	{
		if (!is_phyconnected() || !has_wan_ip())
			return;

		/* sync time to ntp server if necessary */
		if (!nvram_match("wan_dns_t", "") && !nvram_match("wan_gateway_t", ""))
		{
			ntp_timesync();
		}

		if (	nvram_match("ddns_enable_x", "1") && 
			(!nvram_match("ddns_updated", "1") || !ddns_timer)
		)
		{
			logmessage("RT-N56U", "[start ddns] watchdog");
			start_ddns();
		}

		if (!ddns_timer)
		{
			stop_networkmap();
			start_networkmap();
		}
	}
	else
	{
		if (/*!nvram_match("lan_dns_t", "") && */!nvram_match("lan_gateway_t", ""))
			ntp_timesync();
	}
}
コード例 #3
0
static void catch_sig(int sig)
{
	if (sig == SIGUSR1)
	{
		dbg("[watchdog] Catch SIGUSR1 for rc_service\n");
		if (nvram_get("rc_service"))
			service_handle();
	}
	else if (sig == SIGUSR2)
	{
//		dbg("[watchdog] Catch Reset to Default Signal 2\n");
	}
	else if (sig == SIGTSTP && !nvram_match("sw_mode_ex", "3"))
	{
		if (nvram_match("wps_oob_flag", "1"))
		{
#if defined (W7_LOGO) || defined (WIFI_LOGO)
			if (nvram_match("wps_band", "0"))
				if (nvram_match("wl_radio_x", "0"))
					return;
			else
				if (nvram_match("rt_radio_x", "0"))
					return;
#else
#if 0
			if (nvram_match("wl_radio_x", "0") || nvram_match("rt_radio_x", "0"))
#else
			if (nvram_match("wl_radio_x", "0") && nvram_match("rt_radio_x", "0"))
#endif
				return;
#endif
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 0;
#endif
			nvram_set("wps_oob_flag", "0");
			wsc_timeout = 0;
			btn_pressed_setup = BTNSETUP_NONE;
			btn_count_setup = 0;
			LED_CONTROL(LED_POWER, LED_ON);
			alarmtimer(NORMAL_PERIOD, 0);

#if defined (W7_LOGO) || defined (WIFI_LOGO)
			if (nvram_match("wps_band", "0"))
				wps_oob();
			else
				wps_oob_2g();
#else
			wps_oob_both();
#endif
			WscStatus_old = -1;
			WscStatus_old_2g = -1;
		}
		else if (nvram_match("wps_start_flag", "3") || nvram_match("wps_start_flag", "4"))	// let the SW push button be the same as the HW push button
		{
#if defined (W7_LOGO) || defined (WIFI_LOGO)
			if (nvram_match("wps_band", "0"))
				if (nvram_match("wl_radio_x", "0"))
					return;
			else
				if (nvram_match("rt_radio_x", "0"))
					return;
#else
#if 0
			if (nvram_match("wl_radio_x", "0") || nvram_match("rt_radio_x", "0"))
#else
			if (nvram_match("wl_radio_x", "0") && nvram_match("rt_radio_x", "0"))
#endif
				return;
#endif
//			if (nvram_match("wl_radio_x", "1"))
			stop_wsc();
//			if (nvram_match("rt_radio_x", "1"))
			stop_wsc_2g();
			nvram_set("wps_enable", "0");
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 0;
			if (nvram_match("wps_start_flag", "3"))
                                nvram_set("wps_band", "1");
                        else
				nvram_set("wps_band", "0");
#endif
			nvram_set("wps_start_flag", "0");
			alarmtimer(NORMAL_PERIOD, 0);
			btn_pressed_setup = BTNSETUP_START;
			btn_count_setup = 0;
			btn_count_setup_second = 0;
#if defined (W7_LOGO) || defined (WIFI_LOGO)
			if (nvram_match("wps_band", "0"))
				start_wsc_pbc();
			else
				start_wsc_pbc_2g();
#else
#if 0
			start_wsc_pbc_both();
#else
			if (nvram_match("wps_band", "1"))
				start_wsc_pbc_2g();
			else
				start_wsc_pbc();
#endif
#endif
			WscStatus_old = -1;
			WscStatus_old_2g = -1;
			wsc_timeout = 120*20;
			alarmtimer(0, RUSHURGENT_PERIOD);
		}
		else if (nvram_match("wps_enable", "0"))
		{
#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 0;
#endif
			wsc_timeout = 1;
			btn_pressed_setup = BTNSETUP_NONE;
			btn_count_setup = 0;
			LED_CONTROL(LED_POWER, LED_ON);
			alarmtimer(NORMAL_PERIOD, 0);
//			if (nvram_match("wps_band", "0"))
//				if (nvram_match("wl_radio_x", "1"))
					stop_wsc();
//			else
//				if (nvram_match("rt_radio_x", "1"))
					stop_wsc_2g();
		}
		else if (nvram_match("wps_start_flag", "1"))
		{
			if (nvram_match("wps_band", "0"))
				if (nvram_match("wl_radio_x", "0"))
					return;
			else
				if (nvram_match("rt_radio_x", "0"))
					return;

#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 15;
#endif
			nvram_set("wps_start_flag", "0");

			wsc_timeout = 1;
			btn_pressed_setup = BTNSETUP_NONE;
			btn_count_setup = 0;
			LED_CONTROL(LED_POWER, LED_ON);
			alarmtimer(NORMAL_PERIOD, 0);

			WscStatus_old = -1;
			WscStatus_old_2g = -1;
			if (nvram_match("wps_band", "0"))
				start_wsc();
			else
				start_wsc_2g();
		}
		else if (nvram_match("wps_start_flag", "2"))
		{
			if (nvram_match("wps_mode", "1"))
			{
				if (nvram_match("wps_band", "0"))
					if (nvram_match("wl_radio_x", "0"))
						return;
				else
					if (nvram_match("rt_radio_x", "0"))
						return;
			}
			else
			{
#if defined (W7_LOGO) || defined (WIFI_LOGO)
				if (nvram_match("wps_band", "0"))
					if (nvram_match("wl_radio_x", "0"))
						return;
				else
					if (nvram_match("rt_radio_x", "0"))
						return;
#else
#if 0
				if (nvram_match("wl_radio_x", "0") || nvram_match("rt_radio_x", "0"))
#else
				if (nvram_match("wl_radio_x", "0") && nvram_match("rt_radio_x", "0"))
#endif
					return;
#endif
			}

#if (!defined(W7_LOGO) && !defined(WIFI_LOGO))
			nvram_set("wps_triggered", "1");	// psp fix
			count_to_stop_wps = 0;
#endif
			nvram_set("wps_start_flag", "0");
			alarmtimer(NORMAL_PERIOD, 0);
			btn_pressed_setup = BTNSETUP_START;
			btn_count_setup = 0;

			if (nvram_match("wps_mode", "1"))
			{
				if (nvram_match("wps_pin_web", ""))
				{
					if (nvram_match("wps_band", "0"))
						wps_pin("0");
					else
						wps_pin_2g("0");
				}
				else
				{
					if (nvram_match("wps_band", "0"))
						wps_pin(nvram_safe_get("wps_pin_web"));
					else
						wps_pin_2g(nvram_safe_get("wps_pin_web"));
				}
			}
			else
			{
#if defined (W7_LOGO) || defined (WIFI_LOGO)
				if (nvram_match("wps_band", "0"))
					wps_pbc();
				else
					wps_pbc_2g();
#else
#if 0
				wps_pbc_both();
#else
				nvram_set("wps_band", "1");
				wps_pbc_2g();
#endif
#endif
			}

			WscStatus_old = -1;
			WscStatus_old_2g = -1;
			wsc_timeout = 120*20;
			alarmtimer(0, RUSHURGENT_PERIOD);
		}
	}
	else if (sig == SIGTTIN)
	{
		wsc_user_commit();
	}
}