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