Skip to content
Snippets Groups Projects
Commit e78c0146 authored by tewk's avatar tewk
Browse files

went back to typedefing sockaddr_in to slurm_addr

parent 735be7c1
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
# include <inttypes.h> # include <inttypes.h>
#endif /* HAVE_CONFIG_H */ #endif /* HAVE_CONFIG_H */
#include <netinet/in.h>
#define AF_SLURM AF_INET #define AF_SLURM AF_INET
#define SLURM_INADDR_ANY 0x00000000 #define SLURM_INADDR_ANY 0x00000000
...@@ -23,12 +24,14 @@ ...@@ -23,12 +24,14 @@
typedef uint32_t slurm_fd ; typedef uint32_t slurm_fd ;
/* this is the slurm equivalent of the BSD sockets sockaddr */ /* this is the slurm equivalent of the BSD sockets sockaddr */
typedef struct { typedef struct sockaddr_in slurm_addr ;
/*struct kevin {
int16_t family ; int16_t family ;
uint16_t port ; uint16_t port ;
uint32_t address ; uint32_t address ;
char pad[16 - sizeof ( int16_t ) - sizeof (uint16_t) - sizeof (uint32_t) ] ; char pad[16 - sizeof ( int16_t ) - sizeof (uint16_t) - sizeof (uint32_t) ] ;
} slurm_addr ; } ;
*/
/* SLURM datatypes */ /* SLURM datatypes */
/* this is a custom data type to describe the slurm msg type type that is placed in the slurm protocol header /* this is a custom data type to describe the slurm msg type type that is placed in the slurm protocol header
......
...@@ -391,9 +391,9 @@ extern int _slurm_ioctl(int d, int request, ...) ...@@ -391,9 +391,9 @@ extern int _slurm_ioctl(int d, int request, ...)
/* sets the fields of a slurm_addr */ /* sets the fields of a slurm_addr */
void _slurm_set_addr_uint ( slurm_addr * slurm_address , uint16_t port , uint32_t ip_address ) void _slurm_set_addr_uint ( slurm_addr * slurm_address , uint16_t port , uint32_t ip_address )
{ {
slurm_address -> family = AF_SLURM ; slurm_address -> sin_family = AF_SLURM ;
slurm_address -> port = htons ( port ) ; slurm_address -> sin_port = htons ( port ) ;
slurm_address -> address = htonl ( ip_address ) ; slurm_address -> sin_addr.s_addr = htonl ( ip_address ) ;
} }
/* sets the fields of a slurm_addr */ /* sets the fields of a slurm_addr */
...@@ -404,14 +404,14 @@ void _slurm_set_addr ( slurm_addr * slurm_address , uint16_t port , char * host ...@@ -404,14 +404,14 @@ void _slurm_set_addr ( slurm_addr * slurm_address , uint16_t port , char * host
void _slurm_set_addr_char ( slurm_addr * slurm_address , uint16_t port , char * host ) void _slurm_set_addr_char ( slurm_addr * slurm_address , uint16_t port , char * host )
{ {
struct hostent * host_info = gethostbyname ( host ) ; struct hostent * host_info = gethostbyname ( host ) ;
memcpy ( & slurm_address -> address , & host_info -> h_addr , host_info -> h_length ) ; memcpy ( & slurm_address -> sin_addr . s_addr , & host_info -> h_addr , host_info -> h_length ) ;
slurm_address -> family = AF_SLURM ; slurm_address -> sin_family = AF_SLURM ;
slurm_address -> port = htons ( port ) ; slurm_address -> sin_port = htons ( port ) ;
} }
void _slurm_get_addr ( slurm_addr * slurm_address , uint16_t * port , char * host , unsigned int buf_len ) void _slurm_get_addr ( slurm_addr * slurm_address , uint16_t * port , char * host , unsigned int buf_len )
{ {
struct hostent * host_info = gethostbyaddr ( ( char * ) &( slurm_address -> address) , sizeof ( slurm_address -> address ) , AF_SLURM ) ; struct hostent * host_info = gethostbyaddr ( ( char * ) &( slurm_address -> sin_addr . s_addr ) , sizeof ( slurm_address -> sin_addr . s_addr ) , AF_SLURM ) ;
*port = slurm_address -> port ; *port = slurm_address -> sin_port ;
strncpy ( host , host_info -> h_name , buf_len ) ; strncpy ( host , host_info -> h_name , buf_len ) ;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment