partysip-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Partysip-dev] modification for Solaris


From: Tim Na
Subject: [Partysip-dev] modification for Solaris
Date: Mon, 03 Jun 2002 16:51:44 +0900

Hi, Aymeric and Solaris users.
 
I tried to add some lines to the current CVS to make it compatible with Solaris Box.
I successfully compiled it with my Solaris 7, but didn't know how to test its correct bahavior regarding dns stuff... :-(
I tested with Subscribe and Notify and other stuffs and it works fine. :-)
 
I made a few changes in ppl_dns.h.
First one is to include <sys/socket.h> since compile wasn't able to see AF_INET within ppldns.c.
The other one is changing the value of GETHOSTBYNAME_BUFLEN to 8193 as
UNIX NETWORK programming says as follows...
 
"Current implementation of gethostbyname can return upto 35 alias pointers, 35 address pointers, and internally use an 8192-byte buffer to hold the alias names and addresses. So a buffer size of 8192 bytes should be adeuqate."
 
I am not sure if the same applies in Linux box. I am sure you have good
reasons to use 512 bytes for it.  Please let me know.  :-)
 
Below is the parts of code where I made modification for Solaris compatibility.
I am sure there would be mistakes in the modification... :-)
 
In file "ppldns.c"
==================================================================================
 
fifo_t *dns_entries;   /* list of domain or FQDN strings to resolv */
smutex_t *m_dns_result;
ppl_dns_entry_t *dns_results;
ppl_dns_error_t *dns_errors;
 
extern int _getshort(unsigned char *);  /* Tim Na added for happy compiler in Solaris*/
extern int _getlong(unsigned char *);
 
static int ppl_dns_lock_result_access(void) {
  return smutex_lock(m_dns_result);
}
....
 

PPL_DECLARE(int) ppl_dns_query_host(ppl_dns_entry_t **dest, char *hostname, int port)
{
#ifndef sun
  struct hostent result_buffer;
#endif
 
  char tmp[GETHOSTBYNAME_BUFLEN];
  struct hostent *result;
  int my_error;
 
  ppl_dns_entry_t *dns;
  ppl_dns_ip_t * first_ip;
  ppl_dns_ip_t **array;
  char *hostbuf;
  int curaddr=0;
  int n;
 
  *dest = NULL;
/* Jay changed according to TRU64 plateform */
 
#ifdef _OSF_SOURCE
  gethostbyname_r(hostname,       /* the FQDN */
    &result_buffer,  /* the result buffer */
    &result
    );
#elif linux
  gethostbyname_r(hostname,        /* the FQDN */
    &result_buffer,  /* the result buffer */
    tmp,
    GETHOSTBYNAME_BUFLEN - 1,
    &result,
    &my_error);
/* Tim Na added for sun compatibility */
#else
  if ( gethostbyname_r(hostname,
       result,
       tmp,
       GETHOSTBYNAME_BUFLEN - 1,
       &my_error) == NULL )
   return my_error;
#endif

#ifndef sun
  if (!result)
    return my_error;
#endif
 
....
 

PPL_DECLARE(int) ppl_dns_gethostbyname(struct sockaddr_in *sin, char *hostname, int port)
{
#ifndef sun
  struct hostent result_buffer;
#endif
  char tmp[GETHOSTBYNAME_BUFLEN];
  struct hostent *result;
  int my_error;
 
/* Jay changed according to TRU64 plateform */
/* #if defined(HAVE_FUNC_GETHOSTBYNAME_R_3) => is this working?? :*/
 
#ifdef _OSF_SOURCE
  gethostbyname_r(hostname,       /* the FQDN */
                  &result_buffer,  /* the result buffer */
                  &result
                  );
/* #elif defined(HAVE_FUNC_GETHOSTBYNAME_R_6) */
#elif linux
  gethostbyname_r(hostname,        /* the FQDN */
                  &result_buffer,  /* the result buffer */
                  tmp,
                  GETHOSTBYNAME_BUFLEN - 1,
                  &result,
                  &my_error);
/* #elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5) */
#else
  /* SunOS 2.x gethostbyname_r version */
  if ( gethostbyname_r(hostname,
        result,
        tmp,
        GETHOSTBYNAME_BUFLEN - 1,
        &my_error) == NULL )
   return my_error;
#endif
 
#ifndef sun
  if (!result)
    return my_error;
#endif
 
...
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]