1 /* |
1 /* |
2 * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
367 /* |
367 /* |
368 * Class: java_net_DualStackPlainSocketImpl |
368 * Class: java_net_DualStackPlainSocketImpl |
369 * Method: setIntOption |
369 * Method: setIntOption |
370 * Signature: (III)V |
370 * Signature: (III)V |
371 */ |
371 */ |
372 JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_setIntOption |
372 JNIEXPORT void JNICALL |
373 (JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value) { |
373 Java_java_net_DualStackPlainSocketImpl_setIntOption |
374 |
374 (JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value) |
|
375 { |
375 int level = 0, opt = 0; |
376 int level = 0, opt = 0; |
376 struct linger linger = {0, 0}; |
377 struct linger linger = {0, 0}; |
377 char *parg; |
378 char *parg; |
378 int arglen; |
379 int arglen; |
379 |
380 |
380 if (NET_MapSocketOption(cmd, &level, &opt) < 0) { |
381 if (NET_MapSocketOption(cmd, &level, &opt) < 0) { |
381 JNU_ThrowByNameWithLastError(env, |
382 JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); |
382 JNU_JAVANETPKG "SocketException", |
|
383 "Invalid option"); |
|
384 return; |
383 return; |
385 } |
384 } |
386 |
385 |
387 if (opt == java_net_SocketOptions_SO_LINGER) { |
386 if (opt == java_net_SocketOptions_SO_LINGER) { |
388 parg = (char *)&linger; |
387 parg = (char *)&linger; |
408 * Class: java_net_DualStackPlainSocketImpl |
407 * Class: java_net_DualStackPlainSocketImpl |
409 * Method: getIntOption |
408 * Method: getIntOption |
410 * Signature: (II)I |
409 * Signature: (II)I |
411 */ |
410 */ |
412 JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_getIntOption |
411 JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_getIntOption |
413 (JNIEnv *env, jclass clazz, jint fd, jint cmd) { |
412 (JNIEnv *env, jclass clazz, jint fd, jint cmd) |
414 |
413 { |
415 int level = 0, opt = 0; |
414 int level = 0, opt = 0; |
416 int result=0; |
415 int result=0; |
417 struct linger linger = {0, 0}; |
416 struct linger linger = {0, 0}; |
418 char *arg; |
417 char *arg; |
419 int arglen; |
418 int arglen; |
420 |
419 |
421 if (NET_MapSocketOption(cmd, &level, &opt) < 0) { |
420 if (NET_MapSocketOption(cmd, &level, &opt) < 0) { |
422 JNU_ThrowByNameWithLastError(env, |
421 JNU_ThrowByName(env, "java/net/SocketException", "Invalid option"); |
423 JNU_JAVANETPKG "SocketException", |
|
424 "Unsupported socket option"); |
|
425 return -1; |
422 return -1; |
426 } |
423 } |
427 |
424 |
428 if (opt == java_net_SocketOptions_SO_LINGER) { |
425 if (opt == java_net_SocketOptions_SO_LINGER) { |
429 arg = (char *)&linger; |
426 arg = (char *)&linger; |