Beispiel #1
0
bool AtDrv::setWiFiConfig(char *ssid, int type, const char * password, long timeout)
{
	bool ret = false;
	char wifiConfBuf[MAX_WIFI_CONF_BUF_SIZE];
	char conSetting[MAX_TEMP_BUF_SIZE];

	if(type == ENC_TYPE_NONE)
		sprintf(conSetting, "%s,none,", ssid);
	else if(type == ENC_TYPE_WEP_OPEN)
		sprintf(conSetting, "%s,wep_open,%s", ssid, password);
	else
		sprintf(conSetting, "%s,auto,%s", ssid, password);

	sprintf(wifiConfBuf, at_wifi_conf, conSetting);
	
	clearSerialRxData();
	INFO1(wifiConfBuf);
	serialPort[0]->print(wifiConfBuf);
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	if(!serialPort[0]->find(wifiConfBuf) || !serialPort[0]->find(at_ok)) {
		INFO1("Fail to set wifi conf");
		goto end;
	}
	
	ret = true;		
end:	
	return ret;
}
Beispiel #2
0
void AtDrv::getFwVersion(char fwVersion[], uint8_t bufLength, long timeout)
{
	int bytes;

	if(!isAtMode()) {
		if(!switchToAtMode()) {
			INFO1("Can't switch to at mode");
			goto end;
		}
	}

	clearSerialRxData();
	INFO1(at_ver);
	serialPort[0]->print(at_ver);
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);

	// skip cmd response and '\n'
	if(!serialPort[0]->find(at_ver) || !serialPort[0]->find("\n")) {
		INFO1("fail to get firmware version");
		goto end;
	}
	
	bytes = serialPort[0]->readBytesUntil('\r', fwVersion, bufLength);
	fwVersion[bytes] = NULL;

end:
	clearSerialRxData();
	return;
}
Beispiel #3
0
int format_get_plugin (format_plugin_t *plugin)
{
    int ret = -1;

    if (plugin->_state)
    {
        INFO1 ("internal format details already created for %s", plugin->mount);
        return 0;
    }
    switch (plugin->type)
    {
        case FORMAT_TYPE_OGG:
            ret = format_ogg_get_plugin (plugin);
            break;
        case FORMAT_TYPE_AAC:
        case FORMAT_TYPE_MPEG:
            ret = format_mp3_get_plugin (plugin);
            break;
        case FORMAT_TYPE_EBML:
            ret = format_ebml_get_plugin (plugin);
            break;
        default:
            INFO1 ("unparsed format detected for %s", plugin->mount);
            break;
    }

    return ret;
}
Beispiel #4
0
bool AtDrv::setNetDns(uint32_t dns1, uint32_t dns2, long timeout)
{
	bool ret = false;
	char netDnsBuf[MAX_DHCPD_IP_BUF_SIZE];
	char tempBuf[MAX_DHCPD_IP_BUF_SIZE];
	char dns1Buf[MAX_IP_BUF_SIZE];
	char dns2Buf[MAX_IP_BUF_SIZE];

 	uint8_t *pIp = (uint8_t*) &dns1;
	sprintf(dns1Buf, "%u.%u.%u.%u", pIp[0], pIp[1], pIp[2], pIp[3]);
  
 	pIp = (uint8_t*) &dns2;
	sprintf(dns2Buf, "%u.%u.%u.%u", pIp[0], pIp[1], pIp[2], pIp[3]);
  
	sprintf(tempBuf, "%s,%s", dns1Buf, dns2Buf);

	sprintf(netDnsBuf, at_net_dns, tempBuf);

	clearSerialRxData();
	INFO1(netDnsBuf);
	serialPort[0]->print(netDnsBuf);
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	if(!serialPort[0]->find(netDnsBuf) || !serialPort[0]->find(at_ok)) {
		INFO1("Fail to set dhcpd dns");
		goto end;
	}

	ret = true;		
end:
	return ret;
}
Beispiel #5
0
bool AtDrv::isWiFiConnected(long timeout)
{
	bool ret = false;
	byte respBuf[MAX_RESP_BUF_SIZE];
	
	if(!isAtMode()) {
		if(!switchToAtMode()) {
			INFO1("Can't switch to at mode");
			goto end;
		}
	}	
	
	clearSerialRxData();
	INFO1(at_wifi_ConState);
	serialPort[0]->print(at_wifi_ConState);
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	if(!serialPort[0]->find(at_Connected)) {
		INFO1("Not Connected");
		goto end;
	}
	ret = true;
end:
	return ret;
}
Beispiel #6
0
void AtDrv::getLocalIp(uint8_t *ip, long timeout)
{
	clearSerialRxData();
	INFO1(at_get_ip);
	serialPort[0]->print(at_get_ip);
	serialPort[0]->print("\r\r");
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	
	// skip cmd response
	if(!serialPort[0]->find(at_get_ip)) {
		INFO1("fail to get local IP");
		ip[0] = ip[1] = ip[2] = ip[3] = 0;
		goto end;
	}

	ip[0] = serialPort[0]->parseInt();
	ip[1] = serialPort[0]->parseInt();
	ip[2] = serialPort[0]->parseInt();
	ip[3] = serialPort[0]->parseInt();
	
	INFO("Local IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
	
end:
	clearSerialRxData();
	return;	
}
Beispiel #7
0
bool AtDrv::getRemotePort(uint8_t sock, uint16_t *port, long timeout)
{
	bool ret = false;
	char cmdBuf[MAX_CMD_BUF_SIZE];

	sprintf(cmdBuf, at_remoteport[sock], "?");
	clearSerialRxData();
	INFO1(cmdBuf);
	serialPort[0]->print(cmdBuf);
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	if(!serialPort[0]->find(cmdBuf)) {
		INFO1("fail to get remote port");
		*port = 0;
		goto end;
	}
	
	*port = serialPort[0]->parseInt();
	
	INFO("Remote port: %d", *port);
	
	clearSerialRxData();
	
	ret = true;
end:
	return ret;
}
/** Receiver function  */
int slave(int argc, char *argv[])
{
  m_task_t task = NULL;
  int res;
  int id = -1;

  xbt_assert1(sscanf(argv[1],"%d", &id),
	 "Invalid argument %s\n",argv[1]);

  MSG_process_sleep(1); /* Make sure the master is done creating the mailboxes */
   
  while(1) {
    res = MSG_mailbox_get_task_ext(mb[id], &(task), NULL, -1);
    xbt_assert0(res == MSG_OK, "MSG_task_get failed");

    INFO1("Received \"%s\"", MSG_task_get_name(task));
    if (!strcmp(MSG_task_get_name(task),"finalize")) {
	MSG_task_destroy(task);
	break;
    }
     
    INFO1("Processing \"%s\"", MSG_task_get_name(task));
    MSG_task_execute(task);
    INFO1("\"%s\" done", MSG_task_get_name(task));
    MSG_task_destroy(task);
    task = NULL;
  }
  INFO0("I'm done. See you!");
  return 0;
} /* end_of_slave */
Beispiel #9
0
bool AtDrv::getRemoteIp(uint8_t sock, uint8_t *ip, long timeout)
{
	bool ret = false;
	char cmdBuf[MAX_CMD_BUF_SIZE];

	sprintf(cmdBuf, at_remoteip[sock], "?");
	clearSerialRxData();
	INFO1(cmdBuf);
	serialPort[0]->print(cmdBuf);
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	if(!serialPort[0]->findUntil(cmdBuf, "\r\n")) {
		INFO1("fail to get remote IP");
		ip[0] = ip[1] = ip[2] = ip[3] = 0;
		goto end;
	}
	
	ip[0] = serialPort[0]->parseInt();
	ip[1] = serialPort[0]->parseInt();
	ip[2] = serialPort[0]->parseInt();
	ip[3] = serialPort[0]->parseInt();
	
	INFO("Remote IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
	
	clearSerialRxData();
	
	ret = true;
end:
	return ret;
}
Beispiel #10
0
int32_t AtDrv::getCurrentRSSI(long timeout)
{
	int32_t rssi = 0;
	clearSerialRxData();
	INFO1(at_get_rssi);
	serialPort[0]->print(at_get_rssi);
	serialPort[0]->print("\r\r");
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	
	// skip cmd response
	if(!serialPort[0]->find(at_get_rssi)) {
		INFO1("fail to get rssi");
		goto end;
	}

	// this is link qualit value (0~100)
	rssi = serialPort[0]->parseInt();
	// convert link quality to dbm
	rssi = (rssi/2) - 100;

	INFO("RSSI: %ld dbm", rssi);
	
end:
	clearSerialRxData();
	return rssi;	
}
Beispiel #11
0
void AtDrv::getNetmask(uint8_t *mask, long timeout)
{
	clearSerialRxData();
	INFO1(at_get_mask);
	serialPort[0]->print(at_get_mask);
	serialPort[0]->print("\r\r");
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	
	// skip cmd response
	if(!serialPort[0]->find(at_get_mask)) {
		INFO1("fail to get netmask");
		mask[0] = mask[1] = mask[2] = mask[3] = 0;
		goto end;
	}

	mask[0] = serialPort[0]->parseInt();
	mask[1] = serialPort[0]->parseInt();
	mask[2] = serialPort[0]->parseInt();
	mask[3] = serialPort[0]->parseInt();
	
	INFO("Netmask: %d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3]);
	
end:
	clearSerialRxData();
	return;	
}
Beispiel #12
0
bool AtDrv::getTcpAuto(uint8_t sock, bool *enable, long timeout)
{
	bool ret = false;
	char tcpAutoBuf[MAX_TEMP_BUF_SIZE];

    sprintf(tcpAutoBuf, at_tcp_auto[sock], '?');
  
	clearSerialRxData();
	INFO1(tcpAutoBuf);
	serialPort[0]->print(tcpAutoBuf);
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	if(!serialPort[0]->find(tcpAutoBuf)) {
		INFO1("Fail to get tcp auto");
		goto end;
	}

	*enable = serialPort[0]->parseInt();

	INFO("tcp auto: %d", *enable);

	clearSerialRxData();

	ret = true;		
end:
	return ret;
}
Beispiel #13
0
/* only called for native icecast source clients */
static void _handle_source_request (client_t *client, const char *uri)
{
    INFO1("Source logging in at mountpoint \"%s\"", uri);

    if (uri[0] != '/')
    {
        WARN0 ("source mountpoint not starting with /");
        client_send_401 (client);
        return;
    }
    switch (client_check_source_auth (client, uri))
    {
        case 0: /* authenticated from config file */
            source_startup (client, uri, ICECAST_SOURCE_AUTH);
            break;

        case 1: /* auth pending */
            break;

        default: /* failed */
            INFO1("Source (%s) attempted to login with invalid or missing password", uri);
            client_send_401(client);
            break;
    }
}
Beispiel #14
0
uint8_t AtDrv::getCurrentEncryptionType(long timeout)
{
	uint8_t enc = 0;
	int bytes;
	char buf[MAX_TEMP_BUF_SIZE];
	
	if(!isAtMode()) {
		if(!switchToAtMode()) {
			INFO1("Can't switch to at mode");
			goto end;
		}
	}

	clearSerialRxData();
	INFO1(at_get_enc);
	serialPort[0]->print(at_get_enc);
	serialPort[0]->print("\r\r");
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);

	// skip cmd response
	if(!serialPort[0]->find(at_get_enc)) {
		INFO1("fail to get enc type");
		goto end;
	}
	
	bytes = serialPort[0]->readBytesUntil('\n', buf, MAX_TEMP_BUF_SIZE);
	if(bytes >= MAX_TEMP_BUF_SIZE) {
		INFO1("Buffer is not enough");
		goto end;
	}
	
	buf[bytes] = NULL;

	if(strstr(buf, "/TKIPAES") != NULL) {
		enc = ENC_TYPE_AUTO;
	}
	else if(strstr(buf, "NONE") != NULL) {
		enc = ENC_TYPE_NONE;
	}
	else if(strstr(buf, "/AES") != NULL) {
		enc = ENC_TYPE_CCMP;
	}
	else if(strstr(buf, "/TKIP") != NULL) {
		enc = ENC_TYPE_TKIP;
	}
	else if(strstr(buf, "WEP") != NULL) {
		enc = ENC_TYPE_WEP;
	}
	else {
		INFO1("Unknow, treat as error");
	}

end:
	clearSerialRxData();
	return enc;
}
static void _handle_source_request (client_t *client, char *uri, int auth_style)
{
    source_t *source;

    INFO1("Source logging in at mountpoint \"%s\"", uri);

    if (uri[0] != '/')
    {
        WARN0 ("source mountpoint not starting with /");
        client_send_401 (client);
        return;
    }
    if (auth_style == ICECAST_SOURCE_AUTH) {
        if (connection_check_source_pass (client->parser, uri) == 0)
        {
            /* We commonly get this if the source client is using the wrong
             * protocol: attempt to diagnose this and return an error
             */
            /* TODO: Do what the above comment says */
            INFO1("Source (%s) attempted to login with invalid or missing password", uri);
            client_send_401(client);
            return;
        }
    }
    source = source_reserve (uri);
    if (source)
    {
        if (auth_style == SHOUTCAST_SOURCE_AUTH) {
            source->shoutcast_compat = 1;
        }
        source->client = client;
        source->parser = client->parser;
        source->con = client->con;
        if (connection_complete_source (source, 1) < 0)
        {
            source_clear_source (source);
            source_free_source (source);
        }
        else
        {
            refbuf_t *ok = refbuf_new (PER_CLIENT_REFBUF_SIZE);
            client->respcode = 200;
            snprintf (ok->data, PER_CLIENT_REFBUF_SIZE,
                    "HTTP/1.0 200 OK\r\n\r\n");
            ok->len = strlen (ok->data);
            /* we may have unprocessed data read in, so don't overwrite it */
            ok->associated = client->refbuf;
            client->refbuf = ok;
            fserve_add_client_callback (client, source_client_callback, source);
        }
    }
    else
    {
        client_send_404 (client, "Mountpoint in use");
        WARN1 ("Mountpoint %s in use", uri);
    }
}
Beispiel #16
0
bool AtDrv::getProtocol(uint8_t sock, uint8_t *protocol, long timeout)
{
	bool ret = false;
	int bytes;
	char protModeBuf[MAX_TEMP_BUF_SIZE];

	sprintf(protModeBuf, at_remotepro[sock], "?");
	
	clearSerialRxData();
	INFO1(protModeBuf);
	serialPort[0]->print(protModeBuf);
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	if(!serialPort[0]->find(protModeBuf)) {
		INFO1("Fail to get protocol");
		goto end;
	}

	bytes = serialPort[0]->readBytes(protModeBuf, MAX_TEMP_BUF_SIZE);

	if(bytes >= MAX_TEMP_BUF_SIZE) {
		INFO1("Buffer is not enough");
		goto end;
	}
	
	protModeBuf[bytes] = NULL;
	
	if(sock == 0) {
		if(strstr(protModeBuf, "tcp")) {
			*protocol = PROTO_MODE_TCP;
			ret = true;		

		}
		else if(strstr(protModeBuf, "udp")) {
			*protocol = PROTO_MODE_UDP;
			ret = true;		
		}
	}
	else {
		if(strstr(protModeBuf, "1")) {
			*protocol = PROTO_MODE_TCP;
			ret = true;		

		}
		else if(strstr(protModeBuf, "2")) {
			*protocol = PROTO_MODE_UDP;
			ret = true;		
		}
	}

end:
	return ret;
}
Beispiel #17
0
bool AtDrv::getMode(uint8_t sock, int *mode, long timeout)
{
	bool ret = false;
	int bytes;
	char modeBuf[MAX_TEMP_BUF_SIZE];

	sprintf(modeBuf, at_mode[sock], "?");
	
	clearSerialRxData();
	INFO1(modeBuf);
	serialPort[0]->print(modeBuf);
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	if(!serialPort[0]->find(modeBuf)) {
		INFO1("Fail to get mode");
		goto end;
	}

	bytes = serialPort[0]->readBytes(modeBuf, MAX_TEMP_BUF_SIZE);

	if(bytes >= MAX_TEMP_BUF_SIZE) {
		INFO1("Buffer is not enough");
		goto end;
	}
	
	modeBuf[bytes] = NULL;
	
	if(sock == 0) {
		if(strstr(modeBuf, "server")) {
			*mode = MODE_SERVER;
			ret = true;		

		}
		else if(strstr(modeBuf, "client")) {
			*mode = MODE_CLIENT;
			ret = true;		
		}
	}
	else {
		if(strstr(modeBuf, "1")) {
			*mode = MODE_SERVER;
			ret = true;		

		}
		else if(strstr(modeBuf, "2")) {
			*mode = MODE_CLIENT;
			ret = true;		
		}
	}
		
end:
	return ret;
}
Beispiel #18
0
uint16_t AtDrv::readBytes(uint8_t sock, uint8_t *_data, uint16_t *_dataLen)
{
	uint16_t len = 0;
	
	// sock1 (second uart port) is always in data mode, so don't need to switch mode
	if(sock == 0 && isAtMode()) {
		if(!switchToDataMode()) {
			INFO1("Can't switch to data mode");
			goto end;
		}
	}

	// if sock0 && sock0DataQueue has data, then read data in sock0DataQueue first
	if(sock == 0) {
		while(!sock0DataQueue.isEmpty()) {
			_data[len++] = sock0DataQueue.pop();
			// full? then exit
			if(len == *_dataLen)
				goto end;
		}
		// substrate data length we've filled
		*_dataLen -= len;
	}

	len += serialPort[sock]->readBytes((char *)_data+len, *_dataLen);
	*_dataLen = len;
end:
	return len;
}
Beispiel #19
0
/* wrapper function for auth thread to authenticate new listener
 * connection details
 */
static void auth_new_listener (auth_t *auth, auth_client *auth_user)
{
    client_t *client = auth_user->client;

    /* make sure there is still a client at this point, a slow backend request
     * can be avoided if client has disconnected */
    if (is_listener_connected (client) == 0)
    {
        DEBUG0 ("listener is no longer connected");
        client->respcode = 400;
        auth_release (client->auth);
        client->auth = NULL;
        return;
    }
    if (auth->authenticate)
    {
        if (auth->authenticate (auth_user) != AUTH_OK)
        {
            auth_release (client->auth);
            client->auth = NULL;
            return;
        }
    }
    if (auth_postprocess_listener (auth_user) < 0)
    {
        auth_release (client->auth);
        client->auth = NULL;
        INFO1 ("client %lu failed", client->con->id);
    }
}
Beispiel #20
0
bool AtDrv::echoTest(long timeout)
{
	char buf[MAX_TEMP_BUF_SIZE+1];
	int i;
	char *token;
  
	clearSerialRxData();
	serialPort[0]->println("#32767");
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	i = serialPort[0]->readBytes(buf, MAX_TEMP_BUF_SIZE);
	if(i == 0) {
		INFO1("Echo No resp");
		return false;
	}

	buf[i] = NULL;

	token = buf;
	while(*token && *token++ != '#');

	int ret = strtol(token, NULL, 10);

	clearSerialRxData();
	return (ret == 32767)? true:false;
}
Beispiel #21
0
void _sig_die(int signo)
{
    INFO1("Caught signal %d, shutting down...", signo);

    /* inform the server to start shutting down */
    global.running = ICE_HALTING;
}
Beispiel #22
0
static void _handle_source_request(connection_t *con, 
        http_parser_t *parser, char *uri)
{
    client_t *client;
    source_t *source;

    client = client_create(con, parser);

    INFO1("Source logging in at mountpoint \"%s\"", uri);
                
    if (uri[0] != '/')
    {
        WARN0 ("source mountpoint not starting with /");
        client_send_401 (client);
        return;
    }

    if (!connection_check_source_pass(parser, uri)) {
        /* We commonly get this if the source client is using the wrong
         * protocol: attempt to diagnose this and return an error
         */
        /* TODO: Do what the above comment says */
        INFO1("Source (%s) attempted to login with invalid or missing password", uri);
        client_send_401(client);
        return;
    }
    source = source_reserve (uri);
    if (source)
    {
        source->client = client;
        source->parser = parser;
        source->con = con;
        if (connection_complete_source (source) < 0)
        {
            source->client = NULL;
            source_free_source (source);
        }
        else
            thread_create ("Source Thread", source_client_thread,
                    source, THREAD_DETACHED);
    }
    else
    {
        client_send_404 (client, "Mountpoint in use");
        WARN1 ("Mountpoint %s in use", uri);
    }
}
Beispiel #23
0
static void get_ssl_certificate (ice_config_t *config)
{
    ssl_ok = 0;
    do
    {
        long ssl_opts;

        ssl_ctx = NULL;
        if (config->cert_file == NULL)
            break;

        ssl_ctx = SSL_CTX_new (SSLv23_server_method());
        ssl_opts = SSL_CTX_get_options (ssl_ctx);
        SSL_CTX_set_options (ssl_ctx, ssl_opts|SSL_OP_NO_SSLv2);

        if (SSL_CTX_use_certificate_chain_file (ssl_ctx, config->cert_file) <= 0)
        {
            WARN1 ("Invalid cert file %s", config->cert_file);
            break;
        }
        if (SSL_CTX_use_PrivateKey_file (ssl_ctx, config->cert_file, SSL_FILETYPE_PEM) <= 0)
        {
            WARN1 ("Invalid private key file %s", config->cert_file);
            break;
        }
        if (!SSL_CTX_check_private_key (ssl_ctx))
        {
            ERROR1 ("Invalid %s - Private key does not match cert public key", config->cert_file);
            break;
        }
        if (SSL_CTX_set_cipher_list(ssl_ctx, config->cipher_list) <= 0)
        {
            WARN1 ("Invalid cipher list: %s", config->cipher_list);
        }
        ssl_ok = 1;
        INFO1 ("SSL certificate found at %s", config->cert_file);
        INFO1 ("SSL using ciphers %s", config->cipher_list);
        return;
    } while (0);
    if (ssl_ctx)
    {
        WARN2 ("failed to load cert %s (%s)", config->cert_file, ERR_reason_error_string (ERR_peek_last_error()));
        SSL_CTX_free (ssl_ctx);
        ssl_ctx = NULL;
    }
    INFO0 ("No SSL capability on any configured ports");
}
Beispiel #24
0
void AtDrv::netCommit()
{
	clearSerialRxData();
	INFO1(at_net_commit);
	serialPort[0]->print(at_net_commit);
	serialPort[0]->flush();
	delay(30000);
	// No any response
}
Beispiel #25
0
static void get_ssl_certificate (ice_config_t *config)
{
    SSL_METHOD *method;
    long ssl_opts;
    ssl_ok = 0;

    SSL_load_error_strings();                /* readable error messages */
    SSL_library_init();                      /* initialize library */

    method = SSLv23_server_method();
    ssl_ctx = SSL_CTX_new (method);
    ssl_opts = SSL_CTX_get_options (ssl_ctx);
    SSL_CTX_set_options (ssl_ctx, ssl_opts|SSL_OP_NO_SSLv2);

    do
    {
        if (config->cert_file == NULL)
            break;
        if (SSL_CTX_use_certificate_chain_file (ssl_ctx, config->cert_file) <= 0)
        {
            WARN1 ("Invalid cert file %s", config->cert_file);
            break;
        }
        if (SSL_CTX_use_PrivateKey_file (ssl_ctx, config->cert_file, SSL_FILETYPE_PEM) <= 0)
        {
            WARN1 ("Invalid private key file %s", config->cert_file);
            break;
        }
        if (!SSL_CTX_check_private_key (ssl_ctx))
        {
            ERROR1 ("Invalid %s - Private key does not match cert public key", config->cert_file);
            break;
        }
        if (SSL_CTX_set_cipher_list(ssl_ctx, config->cipher_list) <= 0) 
        { 
            WARN1 ("Invalid cipher list: %s", config->cipher_list); 
        } 
        ssl_ok = 1;
        INFO1 ("SSL certificate found at %s", config->cert_file);
        INFO1 ("SSL using ciphers %s", config->cipher_list); 
        return;
    } while (0);
    INFO0 ("No SSL capability on any configured ports");
}
Beispiel #26
0
/*! \fn printVector
 *
 *  \param [in]  [vector]
 *  \param [in]  [size]
 *  \param [in]  [logLevel]
 *  \param [in]  [name]
 *
 *  \author wbraun
 */
static void printVector(const double *vector, integer *size, const int logLevel, const char *name)
{
  int i;

  INFO1(logLevel, "%s", name);
  INDENT(logLevel);
  for(i=0; i<*size; i++)
    INFO2(logLevel, "[%d] %10g", i, vector[i]);
  RELEASE(logLevel);
}
Beispiel #27
0
void AtDrv::getGateway(uint8_t *gwip, long timeout)
{
	int bytes;
	int start;
	char lineBuf[MAX_LINE_BUF_SIZE];
	char *token;

	clearSerialRxData();
	INFO1(at_get_gateway);
	serialPort[0]->print(at_get_gateway);
	serialPort[0]->print("\r\r");
	serialPort[0]->flush();
	serialPort[0]->setTimeout(timeout);
	
	// skip cmd response && skip until "00000000"
	if(!serialPort[0]->find(at_get_gateway) || !serialPort[0]->find("00000000")) {
		INFO1("fail to get gateway");
		gwip[0] = gwip[1] = gwip[2] = gwip[3] = 0;
		goto end;
	}
	
	bytes = serialPort[0]->readBytesUntil('\n', lineBuf, MAX_LINE_BUF_SIZE);
	if(bytes >= MAX_LINE_BUF_SIZE) {
		INFO1("Buffer is not enough");
		goto end;
	}	
	
	token = strtok(lineBuf, " \t");
	
	if(token)
		*((uint32_t *)gwip) = strtol(token, NULL, 16);
	else {
		INFO1("fail to parse netmask");
		gwip[0] = gwip[1] = gwip[2] = gwip[3] = 0;
		goto end;
	}
	
	INFO("Gateway: %d.%d.%d.%d", gwip[0], gwip[1], gwip[2], gwip[3]);
	
end:
	clearSerialRxData();
	return;	
}
Beispiel #28
0
void workers_adjust (int new_count)
{
    INFO1 ("requested worker count %d", new_count);
    while (worker_count != new_count)
    {
        if (worker_count < new_count)
            worker_start ();
        else if (worker_count > new_count)
            worker_stop ();
    }
}
Beispiel #29
0
FDWEpollBackend::FDWEpollBackend(int nfds_)
:FDWBackend(nfds_), sr(0)
{
	if ((epfd = epoll_create(nfds)) < 0)
		throw InitError("failed to open epoll device");
	epevents.reset(new struct epoll_event[nfds]);

	std::memset(epevents.get(), 0, sizeof(struct epoll_event) * nfds);

	INFO1("fdwatch epoll() based layer initialized (max %d sockets)", nfds);
}
Beispiel #30
0
static int admin_handle_general_request (client_t *client, const char *uri)
{
    struct admin_command *cmd;

    if ((client->flags & CLIENT_AUTHENTICATED) == 0)
    {
        INFO1("Bad or missing password on admin command request (%s)", uri);
        return client_send_401 (client, NULL);
    }

    cmd = find_admin_command (admin_general, uri);
    if (cmd == NULL)
    {
        INFO1 ("processing file %s", uri);
        return command_stats (client, uri);
    }
    if (cmd->handle.general == NULL)
        return client_send_400 (client, "unknown request");
    return cmd->handle.general (client, cmd->response);
}