Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HD prefix from network calls #3142

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/H5FDmirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ H5FD__mirror_xmit_decode_uint16(uint16_t *out, const unsigned char *_buf)
HDassert(_buf && out);

H5MM_memcpy(&n, _buf, sizeof(n));
*out = (uint16_t)HDntohs(n);
*out = (uint16_t)ntohs(n);

return 2; /* number of bytes eaten */
} /* end H5FD__mirror_xmit_decode_uint16() */
Expand Down Expand Up @@ -313,7 +313,7 @@ H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *_buf)
HDassert(_buf && out);

H5MM_memcpy(&n, _buf, sizeof(n));
*out = (uint32_t)HDntohl(n);
*out = (uint32_t)ntohl(n);

return 4; /* number of bytes eaten */
} /* end H5FD__mirror_xmit_decode_uint32() */
Expand Down Expand Up @@ -424,7 +424,7 @@ H5FD__mirror_xmit_encode_uint16(unsigned char *_dest, uint16_t v)

HDassert(_dest);

n = (uint16_t)HDhtons(v);
n = (uint16_t)htons(v);
H5MM_memcpy(_dest, &n, sizeof(n));

return 2;
Expand All @@ -451,7 +451,7 @@ H5FD__mirror_xmit_encode_uint32(unsigned char *_dest, uint32_t v)

HDassert(_dest);

n = (uint32_t)HDhtonl(v);
n = (uint32_t)htonl(v);
H5MM_memcpy(_dest, &n, sizeof(n));

return 4;
Expand Down Expand Up @@ -1380,17 +1380,17 @@ H5FD__mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad
/* Handshake with remote */
/* --------------------- */

live_socket = HDsocket(AF_INET, SOCK_STREAM, 0);
live_socket = socket(AF_INET, SOCK_STREAM, 0);
if (live_socket < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't create socket");

target_addr.sin_family = AF_INET;
target_addr.sin_port = HDhtons((uint16_t)fa.handshake_port);
target_addr.sin_addr.s_addr = HDinet_addr(fa.remote_ip);
target_addr.sin_port = htons((uint16_t)fa.handshake_port);
target_addr.sin_addr.s_addr = inet_addr(fa.remote_ip);
HDmemset(target_addr.sin_zero, '\0', sizeof target_addr.sin_zero);

addr_size = sizeof(target_addr);
if (HDconnect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0)
if (connect(live_socket, (struct sockaddr *)&target_addr, addr_size) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "can't connect to remote server");

/* ------------- */
Expand Down
42 changes: 0 additions & 42 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,6 @@ typedef off_t h5_stat_size_t;
#ifndef HDabort
#define HDabort() abort()
#endif
#ifndef HDaccept
#define HDaccept(A, B, C) accept((A), (B), (C))
#endif
#ifndef HDaccess
#define HDaccess(F, M) access(F, M)
#endif
Expand Down Expand Up @@ -644,9 +641,6 @@ typedef off_t h5_stat_size_t;
#ifndef HDatoll
#define HDatoll(S) atoll(S)
#endif
#ifndef HDbind
#define HDbind(A, B, C) bind((A), (B), (C))
#endif
#ifndef HDcalloc
#define HDcalloc(N, Z) calloc(N, Z)
#endif
Expand All @@ -668,9 +662,6 @@ typedef off_t h5_stat_size_t;
#ifndef HDclosedir
#define HDclosedir(D) closedir(D)
#endif
#ifndef HDconnect
#define HDconnect(A, B, C) connect((A), (B), (C))
#endif
#ifndef HDcreat
#define HDcreat(S, M) creat(S, M)
#endif
Expand Down Expand Up @@ -826,9 +817,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDgetenv
#define HDgetenv(S) getenv(S)
#endif
#ifndef HDgethostbyaddr
#define HDgethostbyaddr(A, B, C) gethostbyaddr((A), (B), (C))
#endif
#ifndef HDgethostname
#define HDgethostname(N, L) gethostname(N, L)
#endif
Expand All @@ -850,18 +838,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDgmtime
#define HDgmtime(T) gmtime(T)
#endif
#ifndef HDhtonl
#define HDhtonl(X) htonl((X))
#endif
#ifndef HDhtons
#define HDhtons(X) htons((X))
#endif
#ifndef HDinet_addr
#define HDinet_addr(C) inet_addr((C))
#endif
#ifndef HDinet_ntoa
#define HDinet_ntoa(C) inet_ntoa((C))
#endif
#ifndef HDisalnum
#define HDisalnum(C) isalnum((int)(C)) /* Cast for Solaris warning */
#endif
Expand Down Expand Up @@ -907,9 +883,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDldexp
#define HDldexp(X, N) ldexp(X, N)
#endif
#ifndef HDlisten
#define HDlisten(A, B) listen((A), (B))
#endif
#ifndef HDllround
#define HDllround(V) llround(V)
#endif
Expand Down Expand Up @@ -973,12 +946,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDnanosleep
#define HDnanosleep(N, O) nanosleep(N, O)
#endif
#ifndef HDntohl
#define HDntohl(A) ntohl((A))
#endif
#ifndef HDntohs
#define HDntohs(A) ntohs((A))
#endif
#ifndef HDopen
#define HDopen(F, ...) open(F, __VA_ARGS__)
#endif
Expand Down Expand Up @@ -1100,9 +1067,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDsetenv
#define HDsetenv(N, V, O) setenv(N, V, O)
#endif
#ifndef HDsetsockopt
#define HDsetsockopt(A, B, C, D, E) setsockopt((A), (B), (C), (D), (E))
#endif
#ifndef HDsetvbuf
#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, Z)
#endif
Expand All @@ -1124,9 +1088,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDsnprintf
#define HDsnprintf snprintf /*varargs*/
#endif
#ifndef HDsocket
#define HDsocket(A, B, C) socket((A), (B), (C))
#endif
#ifndef HDsprintf
#define HDsprintf sprintf /*varargs*/
#endif
Expand Down Expand Up @@ -1191,9 +1152,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDstrndup
#define HDstrndup(S, N) strndup(S, N)
#endif
#ifndef HDstrpbrk
#define HDstrpbrk(X, Y) strpbrk(X, Y)
#endif
#ifndef HDstrrchr
#define HDstrrchr(S, C) strrchr(S, C)
#endif
Expand Down
10 changes: 5 additions & 5 deletions test/mirror_vfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2332,19 +2332,19 @@ confirm_server(struct mt_opts *opts)
struct sockaddr_in target_addr;
unsigned attempt = 0;

live_socket = HDsocket(AF_INET, SOCK_STREAM, 0);
live_socket = socket(AF_INET, SOCK_STREAM, 0);
if (live_socket < 0) {
HDprintf("ERROR socket()\n");
return -1;
}

target_addr.sin_family = AF_INET;
target_addr.sin_port = HDhtons((uint16_t)opts->portno);
target_addr.sin_addr.s_addr = HDinet_addr(opts->ip);
target_addr.sin_port = htons((uint16_t)opts->portno);
target_addr.sin_addr.s_addr = inet_addr(opts->ip);
HDmemset(target_addr.sin_zero, '\0', sizeof(target_addr.sin_zero));

while (1) {
if (HDconnect(live_socket, (struct sockaddr *)&target_addr, (socklen_t)sizeof(target_addr)) < 0) {
if (connect(live_socket, (struct sockaddr *)&target_addr, (socklen_t)sizeof(target_addr)) < 0) {
if (attempt > 10) {
HDprintf("ERROR connect() (%d)\n%s\n", errno, HDstrerror(errno));
return -1;
Expand All @@ -2362,7 +2362,7 @@ confirm_server(struct mt_opts *opts)
HDprintf("attempt #%u: ERROR connect() (%d)\n%s\n", attempt, errno, HDstrerror(errno));

/* Re-open socket for retry */
live_socket = HDsocket(AF_INET, SOCK_STREAM, 0);
live_socket = socket(AF_INET, SOCK_STREAM, 0);
if (live_socket < 0) {
HDprintf("ERROR socket()\n");
return -1;
Expand Down
20 changes: 10 additions & 10 deletions utils/mirror_vfd/mirror_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,28 +241,28 @@ prepare_listening_socket(struct server_run *run)
mirror_log(run->loginfo, V_INFO, "preparing socket");

server_addr.sin_family = AF_INET;
server_addr.sin_addr.s_addr = HDhtonl(INADDR_ANY);
server_addr.sin_port = HDhtons((uint16_t)run->opts.main_port);
server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
server_addr.sin_port = htons((uint16_t)run->opts.main_port);

mirror_log(run->loginfo, V_INFO, "socket()");
ret_value = HDsocket(AF_INET, SOCK_STREAM, 0);
ret_value = socket(AF_INET, SOCK_STREAM, 0);
if (ret_value < 0) {
mirror_log(run->loginfo, V_ERR, "listening socket:%d", ret_value);
goto error;
}

mirror_log(run->loginfo, V_ALL, "setsockopt()");
HDsetsockopt(ret_value, SOL_SOCKET, SO_REUSEADDR, &_true, sizeof(int));
setsockopt(ret_value, SOL_SOCKET, SO_REUSEADDR, &_true, sizeof(int));

mirror_log(run->loginfo, V_INFO, "bind()");
ret = HDbind(ret_value, (struct sockaddr *)&server_addr, sizeof(server_addr));
ret = bind(ret_value, (struct sockaddr *)&server_addr, sizeof(server_addr));
if (ret < 0) {
mirror_log(run->loginfo, V_ERR, "bind() %s", HDstrerror(errno));
goto error;
}

mirror_log(run->loginfo, V_INFO, "listen()");
ret = HDlisten(ret_value, LISTENQ);
ret = listen(ret_value, LISTENQ);
if (ret < 0) {
mirror_log(run->loginfo, V_ERR, "H5FD server listen:%d", ret);
goto error;
Expand Down Expand Up @@ -392,7 +392,7 @@ accept_connection(struct server_run *run)
/*------------------------------*/
/* accept a connection on a socket */
clilen = sizeof(client_addr);
connfd = HDaccept(run->listenfd, (struct sockaddr *)&client_addr, &clilen);
connfd = accept(run->listenfd, (struct sockaddr *)&client_addr, &clilen);
if (connfd < 0) {
mirror_log(run->loginfo, V_ERR, "accept:%d", connfd);
goto error;
Expand All @@ -401,15 +401,15 @@ accept_connection(struct server_run *run)

/*------------------------------*/
/* get client address information */
host_port = HDgethostbyaddr((const char *)&client_addr.sin_addr.s_addr,
sizeof(client_addr.sin_addr.s_addr), AF_INET);
host_port = gethostbyaddr((const char *)&client_addr.sin_addr.s_addr, sizeof(client_addr.sin_addr.s_addr),
AF_INET);
if (host_port == NULL) {
mirror_log(run->loginfo, V_ERR, "gethostbyaddr()");
goto error;
}

/* function has the string space statically scoped -- OK until next call */
hostaddrp = HDinet_ntoa(client_addr.sin_addr);
hostaddrp = inet_ntoa(client_addr.sin_addr);
/* TODO? proper error-checking */

mirror_log(run->loginfo, V_INFO, "server connected with %s (%s)", host_port->h_name, hostaddrp);
Expand Down
8 changes: 4 additions & 4 deletions utils/mirror_vfd/mirror_server_stop.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,18 @@ send_shutdown(struct mshs_opts *opts)
return -1;
}

live_socket = HDsocket(AF_INET, SOCK_STREAM, 0);
live_socket = socket(AF_INET, SOCK_STREAM, 0);
if (live_socket < 0) {
HDprintf("ERROR socket()\n");
return -1;
}

target_addr.sin_family = AF_INET;
target_addr.sin_port = HDhtons((uint16_t)opts->portno);
target_addr.sin_addr.s_addr = HDinet_addr(opts->ip);
target_addr.sin_port = htons((uint16_t)opts->portno);
target_addr.sin_addr.s_addr = inet_addr(opts->ip);
HDmemset(target_addr.sin_zero, 0, sizeof(target_addr.sin_zero));

if (HDconnect(live_socket, (struct sockaddr *)&target_addr, (socklen_t)sizeof(target_addr)) < 0) {
if (connect(live_socket, (struct sockaddr *)&target_addr, (socklen_t)sizeof(target_addr)) < 0) {
HDprintf("ERROR connect() (%d)\n%s\n", errno, HDstrerror(errno));
return -1;
}
Expand Down