|
|
|
@ -765,12 +765,12 @@ DBC_INT_LIST *argusDBC::listCamMediaStreams( uint32_t CAMID ){ |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
DBC_NET_IF_DATA *argusDBC::getNetworkInterfaceData( uint32_t ID ){ |
|
|
|
DBC_NET_IF_DATA * tVal = NULL; |
|
|
|
DBC_NETWORK_DATA *argusDBC::getNetworkData( uint32_t net_id ){ |
|
|
|
DBC_NETWORK_DATA * tVal = NULL; |
|
|
|
if(m_bIsConnected){ |
|
|
|
char tQBuf[CTEXT]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf(tQBuf, "SELECT * FROM `network_interfaces` WHERE `id`=%d", ID ); |
|
|
|
sprintf(tQBuf, "SELECT * FROM `networks` WHERE `id`=%d", net_id ); |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
@ -778,25 +778,39 @@ DBC_NET_IF_DATA *argusDBC::getNetworkInterfaceData( uint32_t ID ){ |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
tVal = (DBC_NET_IF_DATA*) malloc(sizeof(DBC_NET_IF_DATA)); |
|
|
|
tVal = (DBC_NETWORK_DATA*) malloc(sizeof(DBC_NETWORK_DATA)); |
|
|
|
if( tVal != NULL ) { |
|
|
|
memset(tVal, 0, sizeof(DBC_NETWORK_DATA)); |
|
|
|
Assoc::iterator it; |
|
|
|
tVal->id = net_id; |
|
|
|
cArr = result->at(0); |
|
|
|
it = cArr->find("nif_id"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->nif_id = atoi(it->second.c_str()); |
|
|
|
}; |
|
|
|
it = cArr->find("type"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->type = (ARGUS_NETWORK_TYPE) atoi(it->second.c_str()); |
|
|
|
}; |
|
|
|
it = cArr->find("address"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
strncpy( tVal->address, it->second.c_str(), 64 ); |
|
|
|
strncpy( tVal->address, it->second.c_str(), 65 ); |
|
|
|
tVal->address[64]=(char)0; |
|
|
|
}; |
|
|
|
it = cArr->find("gateway"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
strncpy( tVal->gateway, it->second.c_str(), 64 ); |
|
|
|
strncpy(tVal->gateway, it->second.c_str(), 65); |
|
|
|
tVal->gateway[64]=(char)0; |
|
|
|
}; |
|
|
|
it = cArr->find("mask"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
strncpy( tVal->netmask, it->second.c_str(), 64 ); |
|
|
|
strncpy( tVal->netmask, it->second.c_str(), 65 ); |
|
|
|
tVal->netmask[64]=(char)0; |
|
|
|
}; |
|
|
|
it = cArr->find("broadcast"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
strncpy( tVal->broadcast, it->second.c_str(), 64 ); |
|
|
|
strncpy( tVal->broadcast, it->second.c_str(), 65 ); |
|
|
|
tVal->broadcast[64]=(char)0; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -806,7 +820,55 @@ DBC_NET_IF_DATA *argusDBC::getNetworkInterfaceData( uint32_t ID ){ |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
uint32_t argusDBC::getNetworkInterfaceID( CSTR key ){ |
|
|
|
DBC_NET_IF_DATA *argusDBC::getNIF_Data( uint32_t nif_id ){ |
|
|
|
DBC_NET_IF_DATA * tVal = NULL; |
|
|
|
if(m_bIsConnected){ |
|
|
|
char tQBuf[CTEXT]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf(tQBuf, "SELECT `type`, `mode`, `device_name`, `mac`, `aux_id` FROM `network_interfaces` WHERE `id`=%d", nif_id ); |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDatabase->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
tVal = (DBC_NET_IF_DATA*) malloc(sizeof(DBC_NET_IF_DATA)); |
|
|
|
if( tVal != NULL ) { |
|
|
|
Assoc::iterator it; |
|
|
|
tVal->id = nif_id; |
|
|
|
cArr = result->at(0); |
|
|
|
it = cArr->find("type"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->type = atoi(it->second.c_str()); |
|
|
|
}; |
|
|
|
it = cArr->find("mode"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->mode = atoi(it->second.c_str()); |
|
|
|
}; |
|
|
|
it = cArr->find("device_name"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
strncpy( tVal->device_name, it->second.c_str(),11); |
|
|
|
tVal->device_name[10]=(char)0; |
|
|
|
}; |
|
|
|
it = cArr->find("mac"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
strncpy( tVal->mac, it->second.c_str(), 33 ); |
|
|
|
tVal->mac[32]=(char)0; |
|
|
|
}; |
|
|
|
it = cArr->find("aux_id"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->aux_id = atoi(it->second.c_str()); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
uint32_t argusDBC::getNIF_ID( CSTR key ){ |
|
|
|
uint32_t tVal = 0; |
|
|
|
if(m_bIsConnected){ |
|
|
|
char tQBuf[CTEXT]; |
|
|
|
@ -1575,6 +1637,36 @@ DBC_INT_LIST *argusDBC::listResources( uint32_t NodeID ){ |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
DBC_INT_LIST *argusDBC::listNetworks( uint32_t nif_id ){ |
|
|
|
DBC_INT_LIST * tVal = NULL; |
|
|
|
if(m_bIsConnected){ |
|
|
|
char tQBuf[CTEXT]; |
|
|
|
AAssoc *result; |
|
|
|
sprintf(tQBuf, "SELECT `id` FROM `networks` WHERE `nif_id`=%d", nif_id ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
result = m_pDatabase->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc *cArr; |
|
|
|
tVal = new DBC_INT_LIST(); |
|
|
|
if( tVal != NULL ) { |
|
|
|
Assoc::iterator it; |
|
|
|
for(int i=0;i<result->size();i++) { |
|
|
|
cArr = result->at(i); |
|
|
|
it = cArr->find("id"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
tVal->push_back( atoi( it->second.c_str() )); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
}; |
|
|
|
return tVal; |
|
|
|
}; |
|
|
|
|
|
|
|
DBC_INT_LIST *argusDBC::listNewModules( uint32_t ServerID, DBC_INT_LIST * old_ids ){ |
|
|
|
DBC_INT_LIST * tVal = NULL; |
|
|
|
@ -2430,10 +2522,11 @@ uint32_t argusDBC::addResource( uint32_t NodeID, uint8_t type, CSTR devName, uin |
|
|
|
uint32_t RetVal = 0; |
|
|
|
if( m_bIsConnected ){ |
|
|
|
char tQBuf[2048]; |
|
|
|
CSTR tMD5 = MD5String( devName ); |
|
|
|
if( tMD5 ) { |
|
|
|
sprintf( tQBuf, "INSERT INTO `resources` SET `node_id`=%d, `type`=%d, `md5`='%s', `aux_id`=%d, `device`='%s', `active`=1 ON DUPLICATE KEY UPDATE `active`=1, `aux_id`=%d, `device`='%s'", NodeID, type, tMD5, auxID, devName, auxID, devName ); |
|
|
|
free( tMD5 ); |
|
|
|
//CSTR tMD5 = MD5String( devName );
|
|
|
|
//if( tMD5 ) {
|
|
|
|
//sprintf( tQBuf, "INSERT INTO `resources` SET `node_id`=%d, `type`=%d, `md5`='%s', `aux_id`=%d, `device`='%s', `active`=1 ON DUPLICATE KEY UPDATE `active`=1, `aux_id`=%d, `device`='%s'", NodeID, type, tMD5, auxID, devName, auxID, devName );
|
|
|
|
sprintf( tQBuf, "INSERT INTO `resources` SET `node_id`=%d, `type`=%d, `aux_id`=%d, `device`='%s', `active`=1 ON DUPLICATE KEY UPDATE `active`=1, `aux_id`=%d, `device`='%s'", NodeID, type, auxID, devName, auxID, devName ); |
|
|
|
// free( tMD5 );
|
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
@ -2441,7 +2534,7 @@ uint32_t argusDBC::addResource( uint32_t NodeID, uint8_t type, CSTR devName, uin |
|
|
|
if( RetVal == 0 ) { |
|
|
|
RetVal = getResourceID( NodeID, type, auxID ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
//};
|
|
|
|
}; |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
@ -2478,39 +2571,7 @@ uint32_t argusDBC::getNodeSocketID( uint32_t NodeID, uint32_t auxID, uint8_t So |
|
|
|
return retVal; |
|
|
|
}; |
|
|
|
*/ |
|
|
|
CSTR argusDBC::getNodeIP4( uint32_t NodeID ){ |
|
|
|
return getResourceDevice( NodeID, ARGUS_HARDWARE_NETWORK_IPV4 ); |
|
|
|
}; |
|
|
|
|
|
|
|
CSTR argusDBC::getNodeIP6( uint32_t NodeID ){ |
|
|
|
return getResourceDevice( NodeID, ARGUS_HARDWARE_NETWORK_IPV6 ); |
|
|
|
}; |
|
|
|
|
|
|
|
CSTR argusDBC::getResourceDevice( uint32_t NodeID, uint32_t Type ){ |
|
|
|
if(m_bIsConnected){ |
|
|
|
char tQBuf[CTEXT]; |
|
|
|
sprintf( tQBuf, "SELECT `device` FROM `resources` WHERE `node_id`=%d AND `type`=%d LIMIT 1", NodeID, Type ); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
AAssoc *result; |
|
|
|
result = m_pDatabase->Query( tQBuf ); |
|
|
|
if( result!= NULL ) { |
|
|
|
if( result->size() > 0 ) { |
|
|
|
Assoc * cArr; |
|
|
|
Assoc::iterator it; |
|
|
|
cArr = result->at(0); |
|
|
|
it = cArr->find("path"); |
|
|
|
if( it != cArr->end() ){ |
|
|
|
strncpy( tQBuf, it->second.c_str(), CTEXT ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
deleteResult( result ); |
|
|
|
return strdup(tQBuf); |
|
|
|
}; |
|
|
|
return NULL; |
|
|
|
}; |
|
|
|
/*
|
|
|
|
CSTR argusDBC::getSocketName( uint32_t NodeID, uint32_t Type ){ |
|
|
|
if(m_bIsConnected){ |
|
|
|
@ -2833,37 +2894,59 @@ uint32_t argusDBC::addLocalUART( uint32_t ResID, uint8_t utype, uint32_t speed, |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
uint32_t argusDBC::addLocalNetInterface( CSTR device, CSTR address, CSTR mask, CSTR gateway, CSTR broadcast ){ |
|
|
|
uint32_t argusDBC::addLocalNIF( CSTR device, CSTR mac, ARGUS_NIF_TYPE dtype ){ |
|
|
|
uint32_t RetVal = 0; |
|
|
|
if( m_bIsConnected ) { |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
char * tKey = MD5String( device ); |
|
|
|
if( tKey != NULL ) { |
|
|
|
sprintf( tQBuf, "INSERT INTO `network_interfaces` SET `key`='%s', `address`='%s', `gateway`='%s', `mask`='%s', `broadcast`='%s' ON DUPLICATE KEY UPDATE `address`='%s', `gateway`='%s', `mask`='%s', `broadcast`='%s'", |
|
|
|
sprintf( tQBuf, "INSERT INTO `network_interfaces` SET `type`=%d, `key`='%s', `device_name`='%s', `mac`='%s' ON DUPLICATE KEY UPDATE `id`=`id`", |
|
|
|
dtype, |
|
|
|
tKey, |
|
|
|
address, |
|
|
|
gateway, |
|
|
|
mask, |
|
|
|
broadcast, |
|
|
|
address, |
|
|
|
gateway, |
|
|
|
mask, |
|
|
|
broadcast |
|
|
|
device, |
|
|
|
mac |
|
|
|
); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
#ifdef DEBUG
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
RetVal = m_pDatabase->QueryID( tQBuf ); |
|
|
|
// On Update IF data no need to return ID
|
|
|
|
//if( RetVal == 0 ) {
|
|
|
|
// RetVal = getNetworkInterfaceID( tKey );
|
|
|
|
//};
|
|
|
|
if( RetVal == 0 ) { |
|
|
|
RetVal = getNIF_ID( tKey ); |
|
|
|
}; |
|
|
|
free( tKey ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
uint32_t argusDBC::addLocalNetwork( uint32_t NIF_ID, ARGUS_NETWORK_TYPE net_type, CSTR address, CSTR mask, CSTR gateway, CSTR broadcast ){ |
|
|
|
uint32_t RetVal = 0; |
|
|
|
if( m_bIsConnected ) { |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
sprintf( tQBuf, "INSERT INTO `networks` SET `nif_id`=%d, `type`=%d, `address`='%s', `gateway`='%s', `mask`='%s', `broadcast`='%s' ON DUPLICATE KEY UPDATE `address`='%s', `gateway`='%s', `mask`='%s', `broadcast`='%s'", |
|
|
|
NIF_ID, |
|
|
|
net_type, |
|
|
|
address, |
|
|
|
gateway, |
|
|
|
mask, |
|
|
|
broadcast, |
|
|
|
address, |
|
|
|
gateway, |
|
|
|
mask, |
|
|
|
broadcast |
|
|
|
); |
|
|
|
#ifdef DEBUG_ALL
|
|
|
|
LOG(tQBuf); |
|
|
|
#endif
|
|
|
|
RetVal = m_pDatabase->QueryID( tQBuf ); |
|
|
|
// On Update IF data no need to return ID
|
|
|
|
//if( RetVal == 0 ) {
|
|
|
|
// RetVal = getNetworkInterfaceID( tKey );
|
|
|
|
//};
|
|
|
|
}; |
|
|
|
return RetVal; |
|
|
|
}; |
|
|
|
|
|
|
|
bool argusDBC::addDraw( uint32_t DBID, uint16_t SIZE, CSTR ID ){ |
|
|
|
if( m_bIsConnected ) { |
|
|
|
char tQBuf[MAX_PATH_LEN]; |
|
|
|
|