1 /* 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #include <sys/socket.h> 27 #include <poll.h> 28 #include "jni.h" 29 30 /* Function types to support dynamic linking of socket API extension functions 31 * for RDMA. This is so that there is no linkage depandancy during build or 32 * runtime for librdmacm.*/ 33 typedef int rs_rsocket_func(int domain, int type, int protocol); 34 typedef int rs_rfcntl_func(int fd, int cmd, ... /* arg */ ); 35 typedef int rs_rlisten_func(int sockfd, int backlog); 36 typedef int rs_rbind_func(int sockfd, const struct sockaddr *addr, 37 socklen_t addrlen); 38 typedef int rs_rconnect_func(int sockfd, const struct sockaddr *addr, 39 socklen_t addlen); 40 typedef int rs_rgetsockname_func(int sockfd, struct sockaddr *addr, 41 socklen_t *addrlen); 42 typedef int rs_rgetsockopt_func(int sockfd, int level, int optname, 43 void *optval, socklen_t *optlen); 44 typedef int rs_rsetsockopt_func(int sockfd, int level, int optname, 45 const void *optval, socklen_t optlen); 46 typedef int rs_rshutdown_func(int sockfd, int how); 47 typedef int rs_rpoll_func(struct pollfd *fds, nfds_t nfds, int timeout); 48 typedef size_t rs_rsend_func(int sockfd, const void *buf, size_t len, 49 int flags); 50 typedef int rs_raccept_func(int sockfd, struct sockaddr *addr, 51 socklen_t *addrlen); 52 typedef int rs_rclose_func(int sockfd); 53 typedef ssize_t rs_rread_func(int sockfd, void *buf, size_t count); 54 typedef ssize_t rs_rreadv_func(int sockfd, const struct iovec *iov, 55 int iovcnt); 56 typedef ssize_t rs_rwrite_func(int sockfd, const void *buf, size_t count); 57 typedef ssize_t rs_rwritev_func(int sockfd, const struct iovec *iov, 58 int iovcnt); 59 typedef ssize_t rs_rrecv_func(int sockfd, void *buf, size_t len, int flags); 60 typedef ssize_t rs_rrecvfrom_func(int sockfd, void *buf, size_t len, int flags, 61 struct sockaddr *src_addr, socklen_t *addrlen); 62 typedef ssize_t rs_rsendto_func(int sockfd, const void *buf, size_t len, 63 int flags, const struct sockaddr *dest_addr, socklen_t addrlen); 64 65 rs_rsocket_func* rs_socket; 66 rs_rfcntl_func* rs_fcntl; 67 rs_rlisten_func* rs_listen; 68 rs_rbind_func* rs_bind; 69 rs_rconnect_func* rs_connect; 70 rs_rgetsockname_func* rs_getsockname; 71 rs_rgetsockopt_func* rs_getsockopt; 72 rs_rsetsockopt_func* rs_setsockopt; 73 rs_rshutdown_func* rs_shutdown; 74 rs_rpoll_func* rs_poll; 75 rs_rsend_func* rs_send; 76 rs_raccept_func* rs_accept; 77 rs_rclose_func* rs_close; 78 rs_rread_func* rs_read; 79 rs_rreadv_func* rs_readv; 80 rs_rwrite_func* rs_write; 81 rs_rwritev_func* rs_writev; 82 rs_rrecv_func* rs_recv; 83 rs_rrecvfrom_func* rs_recvfrom; 84 rs_rsendto_func* rs_sendto; 85 86 jboolean loadRdmaFuncs(JNIEnv* env); 87 88 /* Definitions taken from librdmacm/include/rdma/rsocket.h */ 89 #ifndef SOL_RDMA 90 #define SOL_RDMA 0x10000 91 #endif 92 enum { 93 RDMA_SQSIZE, 94 RDMA_RQSIZE, 95 RDMA_INLINE, 96 };