Skip to content

Commit

Permalink
Added Unix Implementations for Extracting Elements of addrInfo
Browse files Browse the repository at this point in the history
To extract length, family, socktype, protocol from addrInfo of OMRAddrInfoNode struct

- The OMRAddrInfoNode has two elements, which first one, addrInfo,
  is a pointer to the first addrinfo node in a linked list.
- The Unix addrinfo structs contains many elements which stores
  a variety of information about a socket address.
- Extracts unix addrinfo elements by passing in a pointer to a
  OMRAddrInfoNode and the index of which one of the linked list of
  addrinfo nodes to extract.
- Currently implemented the element extractions of what is needed
  to create a socket.

Issue: eclipse-omr#4745

Depends on PR:eclipse-omr#4555

Signed-off-by: Haley Cao <haleycao88@hotmail.com>
  • Loading branch information
Haley Cao committed Jan 22, 2020
1 parent ba84cf1 commit ea48852
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions port/unix/omrsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,50 @@ omrsock_getaddrinfo(struct OMRPortLibrary *portLibrary, char *node, char *servic
int32_t
omrsock_getaddrinfo_length(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t handle, uint32_t *length)
{
return OMRPORT_ERROR_NOT_SUPPORTED_ON_THIS_PLATFORM;
*length = handle->length;
return 0;
}

int32_t
omrsock_getaddrinfo_family(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t handle, int32_t *family, int32_t index)
{
return OMRPORT_ERROR_NOT_SUPPORTED_ON_THIS_PLATFORM;
omr_os_addrinfo *info = handle->addrInfo;
int32_t i = 0;

for(i = 0; i < index; i++) {
info = info->ai_next;
}

*family = info->ai_family;
return 0;
}

int32_t
omrsock_getaddrinfo_socktype(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t handle, int32_t *socktype, int32_t index)
{
return OMRPORT_ERROR_NOT_SUPPORTED_ON_THIS_PLATFORM;
omr_os_addrinfo *info = handle->addrInfo;
int32_t i = 0;

for(i = 0; i < index; i++) {
info = info->ai_next;
}

*socktype = info->ai_socktype;
return 0;
}

int32_t
omrsock_getaddrinfo_protocol(struct OMRPortLibrary *portLibrary, omrsock_addrinfo_t handle, int32_t *protocol, int32_t index)
{
return OMRPORT_ERROR_NOT_SUPPORTED_ON_THIS_PLATFORM;
omr_os_addrinfo *info = handle->addrInfo;
int32_t i = 0;

for(i = 0; i < index; i++) {
info = info->ai_next;
}

*protocol = info->ai_protocol;
return 0;
}

int32_t
Expand Down

0 comments on commit ea48852

Please sign in to comment.