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

Improve hostname utilities #871

Closed
matthiasblaesing opened this issue Nov 8, 2017 · 0 comments · Fixed by #872
Closed

Improve hostname utilities #871

matthiasblaesing opened this issue Nov 8, 2017 · 0 comments · Fixed by #872

Comments

@matthiasblaesing
Copy link
Member

  • the libc implementations of gethostname, sethostname, getdomainname and setdomainname are expect char[], this maps to byte[] on the java side, not char[]
  • winsock defines a gethostname function, that should also be bound
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Nov 8, 2017
Fix wrong mapping of libc function gethostname, sethostname, 
getdomainname  and setdomainname. The functions are defined as:

       int getdomainname(char *name, size_t len);
       int setdomainname(const char *name, size_t len);

       int gethostname(char *name, size_t len);
       int sethostname(const char *name, size_t len);

and a C char[] maps by default to a byte[] in java.


In addition bind the winsock gethostname function:

com.sun.jna.platform.win32.Winsock2.gethostname(byte[], int)

This closes java-native-access#871
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Nov 8, 2017
Fix wrong mapping of libc function gethostname, sethostname, 
getdomainname  and setdomainname. The functions are defined as:

       int getdomainname(char *name, size_t len);
       int setdomainname(const char *name, size_t len);

       int gethostname(char *name, size_t len);
       int sethostname(const char *name, size_t len);

and a C char[] maps by default to a byte[] in java.


In addition bind the winsock gethostname function:

com.sun.jna.platform.win32.Winsock2.gethostname(byte[], int)

This closes java-native-access#871
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Nov 9, 2017
Fix wrong mapping of libc function gethostname, sethostname, 
getdomainname  and setdomainname. The functions are defined as:

       int getdomainname(char *name, size_t len);
       int setdomainname(const char *name, size_t len);

       int gethostname(char *name, size_t len);
       int sethostname(const char *name, size_t len);

and a C char[] maps by default to a byte[] in java if the parameter
needs to be writeable from the C side and String if the parameter is
a constant passed into the function.

In addition bind the winsock gethostname function:

com.sun.jna.platform.win32.Winsock2.gethostname(byte[], int)

The 

This closes java-native-access#871
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Nov 9, 2017
Fix wrong mapping of libc function gethostname, sethostname,
getdomainname  and setdomainname. The functions are defined as:

       int getdomainname(char *name, size_t len);
       int setdomainname(const char *name, size_t len);

       int gethostname(char *name, size_t len);
       int sethostname(const char *name, size_t len);

and a C char[] maps by default to a byte[] in java.

In addition bind the winsock gethostname function:

com.sun.jna.platform.win32.Winsock2.gethostname(byte[], int)

The sethostname and setdomainname were tested manually,
as changing the hostname is a privileged operation and
is not regularly possible in unittests.

This closes java-native-access#871
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Nov 9, 2017
Fix wrong mapping of libc function gethostname, sethostname,
getdomainname  and setdomainname. The functions are defined as:

       int getdomainname(char *name, size_t len);
       int setdomainname(const char *name, size_t len);

       int gethostname(char *name, size_t len);
       int sethostname(const char *name, size_t len);

and a C char[] maps by default to a byte[] in java.

In addition bind the winsock gethostname function:

com.sun.jna.platform.win32.Winsock2.gethostname(byte[], int)

The sethostname and setdomainname were tested manually,
as changing the hostname is a privileged operation and
is not regularly possible in unittests.

This closes java-native-access#871
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Nov 9, 2017
Fix wrong mapping of libc function gethostname, sethostname,
getdomainname  and setdomainname. The functions are defined as:

       int getdomainname(char *name, size_t len);
       int setdomainname(const char *name, size_t len);

       int gethostname(char *name, size_t len);
       int sethostname(const char *name, size_t len);

and a C char[] maps by default to a byte[] in java.

In addition bind the winsock gethostname function:

com.sun.jna.platform.win32.Winsock2.gethostname(byte[], int)

The sethostname and setdomainname were tested manually,
as changing the hostname is a privileged operation and
is not regularly possible in unittests.

This closes java-native-access#871
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant