Path: blob/master/src/java.base/share/native/libnio/ch/NativeSocketAddress.c
41153 views
/*1* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include "jni.h"26#include "net_util.h"2728#include "sun_nio_ch_NativeSocketAddress.h"2930JNIEXPORT jint JNICALL31Java_sun_nio_ch_NativeSocketAddress_AFINET(JNIEnv* env, jclass clazz)32{33return AF_INET;34}3536JNIEXPORT jint JNICALL37Java_sun_nio_ch_NativeSocketAddress_AFINET6(JNIEnv* env, jclass clazz)38{39return AF_INET6;40}4142JNIEXPORT jint JNICALL43Java_sun_nio_ch_NativeSocketAddress_sizeofSockAddr4(JNIEnv* env, jclass clazz)44{45return sizeof(struct sockaddr_in);46}4748JNIEXPORT jint JNICALL49Java_sun_nio_ch_NativeSocketAddress_sizeofSockAddr6(JNIEnv* env, jclass clazz)50{51return sizeof(struct sockaddr_in6);52}5354JNIEXPORT jint JNICALL55Java_sun_nio_ch_NativeSocketAddress_sizeofFamily(JNIEnv* env, jclass clazz)56{57// sizeof(struct sockaddr, sa_family)58return sizeof(((struct sockaddr *)0)->sa_family);59}6061JNIEXPORT jint JNICALL62Java_sun_nio_ch_NativeSocketAddress_offsetFamily(JNIEnv* env, jclass clazz)63{64return offsetof(struct sockaddr, sa_family);65}6667JNIEXPORT jint JNICALL68Java_sun_nio_ch_NativeSocketAddress_offsetSin4Port(JNIEnv* env, jclass clazz)69{70return offsetof(struct sockaddr_in, sin_port);71}7273JNIEXPORT jint JNICALL74Java_sun_nio_ch_NativeSocketAddress_offsetSin4Addr(JNIEnv* env, jclass clazz)75{76return offsetof(struct sockaddr_in, sin_addr);77}7879JNIEXPORT jint JNICALL80Java_sun_nio_ch_NativeSocketAddress_offsetSin6Port(JNIEnv* env, jclass clazz)81{82return offsetof(struct sockaddr_in6, sin6_port);83}8485JNIEXPORT jint JNICALL86Java_sun_nio_ch_NativeSocketAddress_offsetSin6Addr(JNIEnv* env, jclass clazz)87{88return offsetof(struct sockaddr_in6, sin6_addr);89}9091JNIEXPORT jint JNICALL92Java_sun_nio_ch_NativeSocketAddress_offsetSin6ScopeId(JNIEnv* env, jclass clazz)93{94return offsetof(struct sockaddr_in6, sin6_scope_id);95}9697JNIEXPORT jint JNICALL98Java_sun_nio_ch_NativeSocketAddress_offsetSin6FlowInfo(JNIEnv* env, jclass clazz)99{100return offsetof(struct sockaddr_in6, sin6_flowinfo);101}102103104