예제 #1
0
void subnet::calc_netmask(){
	int power = 0;
	int divided;
	int rest;
	for(power; (1 << power) < get_hosts(); power++);
	set_netmask_slash(32-power);

	divided = (32-power)/8;
	rest = (32-power)%8;

	switch(divided)
	{
	case 4:
		set_netmask(255, 255, 255, 255);
		break;

	case 3:
		set_netmask(255, 255, 255, (256-(1<<(8-rest))));
		break;

	case 2:
		set_netmask(255, 255, (256 - (1 << (8-rest))), 0);
		break;

	case 1:
		set_netmask(255, (256 - (1 << (8-rest))), 0, 0);
		break;

	case 0:
		set_netmask((256 - (1 << (8-rest))), 0, 0, 0);
		break;

	} //switch
} //calc_netmask
예제 #2
0
/**
 * @brief Start operations to retrieve data from the data file and make the new
 * hosts file for the current operating system.
 */
void MakeHosts::make()
{
    RetrieveData::Instance()->connect_db();
    make_time = QDateTime::currentDateTime();
    hosts_file->open(QIODevice::WriteOnly);
    write_head();
    write_info();
    get_hosts(make_cfg);
    hosts_file->close();
    RetrieveData::Instance()->disconnect_db();
}
예제 #3
0
파일: client.c 프로젝트: Nakrez/multi
int launch_client(int argc, char *argv[])
{
    int ret = 0;

    /* Error on processing arguments */
    if ((config = process_args(argc, argv)) == NULL)
        return 1;

    /* Local compilation needed */
    if (config->local)
        full_compilation(config->argc, config->argv);

    if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
    {
        /* TODO : ERROR HANDLING */
    }

    if (!config->file->input_file || !config->file->output_file)
        full_compilation(config->argc, config->argv);

    /*
     * Process the hosts list (use split argv because it uses
     * the same method)
     */
    config->nb_server = split_argv(get_hosts(), &config->servers);

    for (int i = 0; i < config->nb_server; ++i)
    {
        if ((config->socket_fd = create_client_socket(config->servers[i],
                                                      get_port())) < 0)
        {
            ERROR_MSG("[multi] Can not connect to %s\n", config->servers[i]);
            continue;
        }

        /* Process file with server */
        ret = core_client(config);

        if (ret >= 0)
            return ret;
    }

    /* If this point is reached then no server found or available */
    full_compilation(config->argc, config->argv);

    return 0;
}
예제 #4
0
bool
http_hosts_fetcher_t::get_hosts(inetv4_endpoints_t& endpoints, service_info_t& service_info) {
	bool hosts_retreval_success = get_hosts(endpoints, m_service_info.hosts_source);
	service_info = m_service_info;
	return hosts_retreval_success;
}
예제 #5
0
ParsedURL *LoadRelayUrls(OneQueItem *MyQItem,
			 char *Author,
			 char *Address)
{
	int nRelays = 0;
	ParsedURL *RelayUrls = NULL;
	char mxbuf[SIZ];
	ParsedURL **Url = &MyQItem->URL;

	nRelays = get_hosts(mxbuf, "fallbackhost");
	if (nRelays > 0) {
		StrBuf *All;
		StrBuf *One;
		const char *Pos = NULL;
		All = NewStrBufPlain(mxbuf, -1);
		One = NewStrBufPlain(NULL, StrLength(All) + 1);
		
		while ((Pos != StrBufNOTNULL) &&
		       ((Pos == NULL) ||
			!IsEmptyStr(Pos)))
		{
			StrBufExtract_NextToken(One, All, &Pos, '|');
			if (!ParseURL(Url, One, DefaultMXPort)) {
				SMTPC_syslog(LOG_DEBUG,
					     "Failed to parse: %s\n",
					     ChrPtr(One));
			}
			else {
				(*Url)->IsRelay = 1;
				MyQItem->HaveRelay = 1;
			}
		}
		FreeStrBuf(&All);
		FreeStrBuf(&One);
	}
	nRelays = get_hosts(mxbuf, "smarthost");
	if (nRelays > 0) {
		char *User;
		StrBuf *All;
		StrBuf *One;
		const char *Pos = NULL;
		All = NewStrBufPlain(mxbuf, -1);
		One = NewStrBufPlain(NULL, StrLength(All) + 1);
		
		while ((Pos != StrBufNOTNULL) &&
		       ((Pos == NULL) ||
			!IsEmptyStr(Pos)))
		{
			StrBufExtract_NextToken(One, All, &Pos, '|');
			User = strchr(ChrPtr(One), ' ');
			if (User != NULL) {
				if (!strcmp(User + 1, Author) ||
				    !strcmp(User + 1, Address))
					StrBufCutAt(One, 0, User);
				else {
					MyQItem->HaveRelay = 1;
					continue;
				}
			}
			if (!ParseURL(Url, One, DefaultMXPort)) {
				SMTPC_syslog(LOG_DEBUG,
					     "Failed to parse: %s\n",
					     ChrPtr(One));
			}
			else {
				///if (!Url->IsIP)) // todo dupe me fork ipv6
				(*Url)->IsRelay = 1;
				MyQItem->HaveRelay = 1;
			}
		}
		FreeStrBuf(&All);
		FreeStrBuf(&One);
	}
	return RelayUrls;
}