Merge "Debian: Redfishtool requests fail when IPV4 address has square brackets"
This commit is contained in:
commit
ad1c87669f
|
@ -1129,3 +1129,51 @@ int msgClassTx::initSocket()
|
||||||
}
|
}
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to validate and distinguish between IPV4 and IPV6 addresses.
|
||||||
|
*
|
||||||
|
* @return PF_UNSPEC for unknown IP address format
|
||||||
|
* AF_INET for IPV4 addresses
|
||||||
|
* AF_INET6 for IPV6 addresses
|
||||||
|
*/
|
||||||
|
int get_address_ai_family ( const char * addr_ptr )
|
||||||
|
{
|
||||||
|
if ( addr_ptr == NULL )
|
||||||
|
{
|
||||||
|
slog ("null string pointer");
|
||||||
|
return ( PF_UNSPEC );
|
||||||
|
}
|
||||||
|
|
||||||
|
struct addrinfo *res = NULL;
|
||||||
|
struct addrinfo hint ;
|
||||||
|
MEMSET_ZERO ( hint);
|
||||||
|
|
||||||
|
hint.ai_family = PF_UNSPEC;
|
||||||
|
hint.ai_flags = AI_NUMERICHOST;
|
||||||
|
|
||||||
|
if ( getaddrinfo(addr_ptr, NULL, &hint, &res) )
|
||||||
|
{
|
||||||
|
wlog ("Invalid address: %s", addr_ptr );
|
||||||
|
return ( PF_UNSPEC );
|
||||||
|
}
|
||||||
|
|
||||||
|
int ai_family = res->ai_family ;
|
||||||
|
freeaddrinfo(res);
|
||||||
|
|
||||||
|
if ( ai_family == AF_INET )
|
||||||
|
{
|
||||||
|
dlog1 ("%s is an ipv4 address\n", addr_ptr );
|
||||||
|
}
|
||||||
|
else if ( ai_family == AF_INET6 )
|
||||||
|
{
|
||||||
|
dlog1 ("%s is an ipv6 address\n", addr_ptr );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slog ("unknown address format: %s ; ai_family:%d\n",
|
||||||
|
addr_ptr, ai_family );
|
||||||
|
ai_family = PF_UNSPEC ;
|
||||||
|
}
|
||||||
|
return (ai_family) ;
|
||||||
|
}
|
||||||
|
|
|
@ -213,4 +213,7 @@ private:
|
||||||
int initSocket();
|
int initSocket();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Used to validate and distinguish between IPV4 and IPV6 addresses */
|
||||||
|
int get_address_ai_family ( const char * addr_ptr );
|
||||||
|
|
||||||
#endif /* __INCLUDE_MSGCLASS_H__ */
|
#endif /* __INCLUDE_MSGCLASS_H__ */
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "nodeBase.h" /* for ... mtce node common definitions */
|
#include "nodeBase.h" /* for ... mtce node common definitions */
|
||||||
|
#include "msgClass.h" /* for ... get_address_ai_family */
|
||||||
#include "nodeUtil.h" /* for ... tolowercase */
|
#include "nodeUtil.h" /* for ... tolowercase */
|
||||||
#include "hostUtil.h" /* for ... mtce host common definitions */
|
#include "hostUtil.h" /* for ... mtce host common definitions */
|
||||||
#include "jsonUtil.h" /* for ... */
|
#include "jsonUtil.h" /* for ... */
|
||||||
|
@ -353,10 +354,21 @@ string redfishUtil_create_request ( string cmd,
|
||||||
* defaulting to 20 sec timeout */
|
* defaulting to 20 sec timeout */
|
||||||
command_request.append(" -T 30");
|
command_request.append(" -T 30");
|
||||||
|
|
||||||
/* specify the bmc ip address */
|
/* The square brackets around the ip address in Debian
|
||||||
command_request.append(" -r [");
|
* cause the redfishtool request to fail */
|
||||||
command_request.append(ip);
|
if ( daemon_is_os_debian() && get_address_ai_family(ip.data()) == AF_INET )
|
||||||
command_request.append("]");
|
{
|
||||||
|
/* add the bmc ip address option */
|
||||||
|
command_request.append(" -r ");
|
||||||
|
command_request.append(ip);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* specify the bmc ip address option with square brackets */
|
||||||
|
command_request.append(" -r [");
|
||||||
|
command_request.append(ip);
|
||||||
|
command_request.append("]");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WANT_INLINE_CREDS
|
#ifdef WANT_INLINE_CREDS
|
||||||
if ( daemon_is_file_present ( MTC_CMD_FIT__INLINE_CREDS ) )
|
if ( daemon_is_file_present ( MTC_CMD_FIT__INLINE_CREDS ) )
|
||||||
|
|
|
@ -160,7 +160,7 @@ using namespace std;
|
||||||
|
|
||||||
#define THREAD_INIT_SIG (0xbabef00d)
|
#define THREAD_INIT_SIG (0xbabef00d)
|
||||||
#define MAX_PTHREADS (1) /* max number concurrent pthreads */
|
#define MAX_PTHREADS (1) /* max number concurrent pthreads */
|
||||||
#define DEFAULT_THREAD_TIMEOUT_SECS (60) /* default pthread exec timout */
|
#define DEFAULT_THREAD_TIMEOUT_SECS (100) /* default pthread exec timout */
|
||||||
#define MAX_LOG_PREFIX_LEN (MAX_CHARS_ON_LINE)
|
#define MAX_LOG_PREFIX_LEN (MAX_CHARS_ON_LINE)
|
||||||
#define THREAD_POST_KILL_WAIT (10) /* wait time between KILL and IDLE */
|
#define THREAD_POST_KILL_WAIT (10) /* wait time between KILL and IDLE */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue