Skip to content

Commit

Permalink
Discover data visible but a bit to much of it.
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Nov 3, 2015
1 parent 534bb33 commit 50aeddf
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 70 deletions.
15 changes: 14 additions & 1 deletion copy_firmware_dups.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@ REM This file is used to make duplicates of critical files for the
REM vscp_firmware repository

copy src\vscp\common\canal.h ..\vscp_firmware\common
copy src\vscp\common\canal.h C:\Users\grodansparadis\development\vscp_install_win32\files\include

copy src\vscp\common\vscp.h ..\vscp_firmware\common
copy src\vscp\common\vscp.h C:\Users\grodansparadis\development\vscp_install_win32\files\include

copy src\vscp\common\vscp_class.h ..\vscp_firmware\common
copy src\vscp\common\vscp_class.h C:\Users\grodansparadis\development\vscp_install_win32\files\include

copy src\vscp\common\vscp_type.h ..\vscp_firmware\common
copy src\vscp\common\vscp_serial.h ..\vscp_firmware\common
copy src\vscp\common\vscp_type.h C:\Users\grodansparadis\development\vscp_install_win32\files\include

copy src\vscp\common\vscp_serial.h ..\vscp_firmware\common
copy src\vscp\common\vscp_serial.h C:\Users\grodansparadis\development\vscp_install_win32\files\include

copy src\vscp\common\canal_macro.h C:\Users\grodansparadis\development\vscp_install_win32\files\include
copy src\vscp\common\canaldlldef.h C:\Users\grodansparadis\development\vscp_install_win32\files\include
copy src\vscp\helperlib\vscphelperlib.h C:\Users\grodansparadis\development\vscp_install_win32\files\include
6 changes: 3 additions & 3 deletions src/common/base64-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ lws_b64_selftest(void)
for (test = 0; test < sizeof plaintext / sizeof(plaintext[0]); test++) {

buf[sizeof(buf) - 1] = '\0';
n = lws_b64_encode_string(plaintext[test],
strlen(plaintext[test]), buf, sizeof buf);
if (n != strlen(coded[test]) || strcmp(buf, coded[test])) {
n = lws_b64_encode_string( plaintext[ test ],
strlen( plaintext[test] ), buf, sizeof buf );
if ( n != strlen(coded[test] ) || strcmp( buf, coded[test] ) ) {
fprintf(stderr, "Failed lws_b64 encode selftest "
"%d result '%s' %d\n", test, buf, n);
return -1;
Expand Down
2 changes: 2 additions & 0 deletions src/vscp/common/knownnodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

CVSCPServerInformation::CVSCPServerInformation()
{
m_bUpdated = false;
m_capabilities = 0;
m_guid.clear();
m_nameOfServer.Empty();
Expand Down Expand Up @@ -129,6 +130,7 @@ CVSCPServerInformation::~CVSCPServerInformation()

CNodeInformation::CNodeInformation()
{
m_bUpdated = false;
m_bInvestigated = false;
m_realguid.clear();
m_interfaceguid.clear();
Expand Down
49 changes: 48 additions & 1 deletion src/vscp/common/knownnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ class CVSCPServerInformation
CVSCPServerInformation();
~CVSCPServerInformation();

CVSCPServerInformation& operator=( const CVSCPServerInformation& node )
{
// Check for self-assignment!
if ( this == &node ) { // Same object?
return *this; // Yes, so skip assignment, and just return *this.
}

m_bUpdated = node.m_bUpdated;
m_capabilities = node.m_capabilities;
m_guid = node.m_guid;
m_nameOfServer = node.m_nameOfServer;
m_ipaddress = node.m_ipaddress;
memcpy( m_ports, node.m_ports, sizeof( m_ports ) );

return *this;
};

// This flag can be used by a client to mark this item as seen
// by an upfate routine.
bool m_bUpdated;

// Capabilities for this server
uint64_t m_capabilities;

Expand Down Expand Up @@ -98,6 +119,33 @@ class CNodeInformation
CNodeInformation();
~CNodeInformation();

CNodeInformation& operator=( const CNodeInformation& node )
{
// Check for self-assignment!
if ( this == &node ) { // Same object?
return *this; // Yes, so skip assignment, and just return *this.
}

m_bUpdated = node.m_bUpdated;
m_bInvestigated = node.m_bInvestigated;
m_bProxy = node.m_bProxy;
m_realguid = node.m_realguid;
m_interfaceguid = node.m_interfaceguid;
m_clientID = node.m_clientID;
m_mdfPath = node.m_mdfPath;
m_lastHeartBeat = node.m_lastHeartBeat;
memcpy( m_stdreg, node.m_stdreg, sizeof( m_stdreg ) );
m_strNodeName = node.m_strNodeName;
m_deviceName = node.m_deviceName;
m_address = node.m_address;

return *this;
};

// This flag can be used by a client to mark this item as seen
// by an upfate routine.
bool m_bUpdated;

// Thru if this node has been checked
bool m_bInvestigated;

Expand Down Expand Up @@ -204,7 +252,6 @@ class CKnownNodes
*/
void load( wxString& path );


// Protect the lists
wxMutex m_mutexKnownNodes;

Expand Down
4 changes: 2 additions & 2 deletions src/vscp/common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#define VSCPD_SUB_VERSION 0


#define VSCPD_SUB_SUB_VERSION 2
#define VSCPD_SUB_SUB_VERSION 4

#define VSCPD_DISPLAY_VERSION "1.1.0.2 Sodium"
#define VSCPD_DISPLAY_VERSION "1.1.0.4 Sodium"

#define VSCPD_COPYRIGHT "Copyright (C) 2000-2015, Paradise of the Frog AB, http://www.paradiseofthefrog.com"
#define VSCPD_COPYRIGHT_HTML "Copyright (C) 2000-2015, <a href=\"mailto:[email protected]\">Paradise of the Frog</a>, <a href=\"http://www.paradiseofthefrog.com\">http://www.paradiseofthefrog.com</a>"
Expand Down
4 changes: 2 additions & 2 deletions src/vscp/common/vscp.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ typedef VSCPChannelInfo *PVSCPCHANNELINFO;

#define VSCP_MULTICAST_IPV4_ADDRESS_STR "224.0.23.158"

#define VSCP_MULTICAST_ANNNOUNCE_PORT 9598 //33333
#define VSCP_MULTICAST_PORT 44444
#define VSCP_MULTICAST_ANNNOUNCE_PORT 9598
#define VSCP_MULTICAST_PORT 33333

// Packet format type = 0
#define VSCP_MULTICATS_PACKET0_HEADER_LENGTH 28
Expand Down
47 changes: 18 additions & 29 deletions src/vscp/common/vscpmulticast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <wx/listimpl.cpp>

#ifdef WIN32

#else

#include <sys/types.h>
Expand Down Expand Up @@ -81,32 +82,20 @@ worksMulticastThread::~worksMulticastThread()

void *worksMulticastThread::Entry()
{
// Must have a valid pointer to the app. object
//if ( NULL == m_pApp ) return NULL;

crcInit();

//*************************************************************************
// Multicast init.
//*************************************************************************

int sock; // socket descriptor
struct sockaddr_in mc_addr; // socket address structure
unsigned short port = VSCP_MULTICAST_ANNNOUNCE_PORT; // multicast port
unsigned char ttl = 1; // time to live (hop count)
int flag_on = 1; // socket option flag
int sock; // socket descriptor
struct sockaddr_in mc_addr; // socket address structure
unsigned short port = VSCP_MULTICAST_ANNNOUNCE_PORT; // multicast port
unsigned char ttl = 1; // time to live (hop count)
int flag_on = 1; // socket option flag

#ifdef WIN32

WSADATA wsaData; // Windows socket DLL structure
struct ip_mreq mc_req; // multicast request structure

// Load Winsock 2.0 DLL
if ( WSAStartup( MAKEWORD( 2, 0 ), &wsaData ) != 0 ) {
fprintf( stderr, "Multicast WSAStartup() failed" );
return NULL;
}

// create a socket for sending to the multicast address
if ( ( sock = socket( PF_INET, SOCK_DGRAM, IPPROTO_UDP ) ) < 0 ) {
perror( "Multicast socket() failed" );
Expand All @@ -121,11 +110,11 @@ void *worksMulticastThread::Entry()
}

// set the TTL (time to live/hop count) for the send
if ( ( setsockopt( sock, IPPROTO_IP, IP_MULTICAST_TTL,
/*if ( ( setsockopt( sock, IPPROTO_IP, IP_MULTICAST_TTL,
( const char* )&ttl, sizeof( ttl ) ) ) < 0 ) {
perror( "Multicast setsockopt() failed" );
return NULL;
}
}*/

// construct a multicast address structure
memset( &mc_addr, 0, sizeof( mc_addr ) );
Expand All @@ -141,6 +130,7 @@ void *worksMulticastThread::Entry()
}

// construct an IGMP join request structure
struct ip_mreq mc_req; // multicast request structure
mc_req.imr_multiaddr.s_addr = inet_addr( VSCP_MULTICAST_IPV4_ADDRESS_STR );
mc_req.imr_interface.s_addr = htonl( INADDR_ANY );

Expand Down Expand Up @@ -182,7 +172,11 @@ void *worksMulticastThread::Entry()
char buf[ 1024 ]; // buffer to receive string
int recv_len; // length of string received
struct sockaddr_in from_addr; // packet source
#ifdef WIN32
int from_len; // source addr length
#else
socklen_t from_len; // source addr length
#endif
int nRcv;

while ( !m_bQuit && !TestDestroy() ) {
Expand All @@ -192,7 +186,7 @@ void *worksMulticastThread::Entry()
FD_SET( sock, &fds );

// Set up the struct timeval for the timeout.
tv.tv_sec = 1;
tv.tv_sec = 2;
tv.tv_usec = 0;

// Wait until timeout or data received.
Expand Down Expand Up @@ -350,12 +344,12 @@ void *worksMulticastThread::Entry()
// This will use the correct GUID as originator

cguid guid;
// INterface GUID is used as identifier
// Interface GUID is used as identifier
guid.getFromArray( ( unsigned const char * )buf + VSCP_MULTICAST_PACKET0_POS_VSCP_DATA + 32 );
CNodeInformation *pNode = m_knownNodes.addNode( guid );
if ( NULL != pNode ) {

// not a proxy
// Not a proxy
pNode->m_bProxy = true;

// Save the nodes real GUID
Expand Down Expand Up @@ -407,11 +401,9 @@ void *worksMulticastThread::Entry()

}

}

}


}
} // while


#ifdef WIN32
Expand All @@ -423,9 +415,6 @@ void *worksMulticastThread::Entry()

// Close the multicast socket
closesocket( sock );

// Cleanup Winsock
WSACleanup();
#else
close( sock );
#endif
Expand Down
Loading

0 comments on commit 50aeddf

Please sign in to comment.