Merge branch 'change_setipaddress_retcode' into develop
This commit is contained in:
commit
f2f7d66de7
@ -33,6 +33,7 @@
|
||||
* from gw_read_gwbuff()
|
||||
* 25-09-2013 Massimiliano Pinto setipaddress uses getaddrinfo
|
||||
* 06-02-2014 Mark Riddoch Added parse_bindconfig
|
||||
* 10-02-2014 Massimiliano Pinto Added return code to setipaddress
|
||||
*
|
||||
*@endverbatim
|
||||
*/
|
||||
@ -53,8 +54,9 @@ extern int lm_enabled_logfiles_bitmask;
|
||||
*
|
||||
* @param a Pointer to a struct in_addr into which the address is written
|
||||
* @param p The hostname to lookup
|
||||
* @return 1 on success, 0 on failure
|
||||
*/
|
||||
void
|
||||
int
|
||||
setipaddress(struct in_addr *a, char *p) {
|
||||
#ifdef __USE_POSIX
|
||||
struct addrinfo *ai = NULL, hint;
|
||||
@ -73,14 +75,26 @@ setipaddress(struct in_addr *a, char *p) {
|
||||
hint.ai_flags = AI_PASSIVE;
|
||||
hint.ai_family = AF_UNSPEC;
|
||||
if ((rc = getaddrinfo(p, NULL, &hint, &ai)) != 0) {
|
||||
fprintf(stderr, "getaddrinfo(%s) failed with %s", p, gai_strerror(rc));
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : getaddrinfo failed for [%s] due [%s]",
|
||||
p,
|
||||
gai_strerror(rc))));
|
||||
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
hint.ai_flags = AI_CANONNAME;
|
||||
hint.ai_family = AF_INET;
|
||||
|
||||
if ((rc = getaddrinfo(p, NULL, &hint, &ai)) != 0) {
|
||||
fprintf(stderr, "getaddrinfo(%s) failed with %s", p, gai_strerror(rc));
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : getaddrinfo failed for [%s] due [%s]",
|
||||
p,
|
||||
gai_strerror(rc))));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,9 +102,11 @@ setipaddress(struct in_addr *a, char *p) {
|
||||
if (ai != NULL) {
|
||||
res_addr = (struct sockaddr_in *)(ai->ai_addr);
|
||||
memcpy(a, &res_addr->sin_addr, sizeof(struct in_addr));
|
||||
}
|
||||
|
||||
freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
struct hostent *h;
|
||||
|
||||
@ -100,11 +116,18 @@ setipaddress(struct in_addr *a, char *p) {
|
||||
|
||||
if (h == NULL) {
|
||||
if ((a->s_addr = inet_addr(p)) == -1) {
|
||||
fprintf(stderr, "unknown or invalid address [%s]\n", p);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : gethostbyname failed for [%s]",
|
||||
p)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
/* take the first one */
|
||||
memcpy(a, h->h_addr, h->h_length);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -28,6 +28,8 @@
|
||||
* 04-07-2013 Massimiliano Pinto Added new MySQL protocol status for asynchronous connection
|
||||
* Added authentication reply status
|
||||
* 12-07-2013 Massimiliano Pinto Added routines for change_user
|
||||
* 14-02-2014 Massimiliano Pinto setipaddress returns int
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -289,10 +291,10 @@ void gw_str_xor(
|
||||
const uint8_t *input1,
|
||||
const uint8_t *input2,
|
||||
unsigned int len);
|
||||
char *gw_bin2hex(char *out, const uint8_t *in, unsigned int len);
|
||||
int gw_hex2bin(uint8_t *out, const char *in, unsigned int len);
|
||||
int gw_generate_random_str(char *output, int len);
|
||||
char *gw_strend(register const char *s);
|
||||
int setnonblocking(int fd);
|
||||
void setipaddress(struct in_addr *a, char *p);
|
||||
int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b);
|
||||
char *gw_bin2hex(char *out, const uint8_t *in, unsigned int len);
|
||||
int gw_hex2bin(uint8_t *out, const char *in, unsigned int len);
|
||||
int gw_generate_random_str(char *output, int len);
|
||||
char *gw_strend(register const char *s);
|
||||
int setnonblocking(int fd);
|
||||
int setipaddress(struct in_addr *a, char *p);
|
||||
int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b);
|
||||
|
Loading…
x
Reference in New Issue
Block a user