Lines Matching refs:sock

131 static netif  *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs);
134 static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs);
137 static netif *addif(JNIEnv *env, int sock, const char * if_name, netif *ifs, struct sockaddr* ifr_addrP, int family, short prefix);
144 static struct sockaddr *getBroadcast(JNIEnv *env, int sock, const char *name, struct sockaddr *brdcast_store);
145 static short getSubnet(JNIEnv *env, int sock, const char *ifname);
146 static int getIndex(int sock, const char *ifname);
148 static int getFlags(int sock, const char *ifname, int *flags);
149 static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf);
150 static int getMTU(JNIEnv *env, int sock, const char *ifname);
155 static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family);
488 int sock;
494 if ((sock =openSocketWithFallback(env, name_utf)) < 0) {
507 len = getMacAddress(env, sock, name_utf, &iaddr, mac);
509 len = getMacAddress(env, sock, name_utf,NULL, mac);
523 close(sock);
536 int sock;
541 if ((sock =openSocketWithFallback(env, name_utf)) < 0) {
546 ret = getMTU(env, sock, name_utf);
550 close(sock);
558 int ret, sock;
564 if ((sock = openSocketWithFallback(env, name_utf)) < 0) {
571 ret = getFlags(sock, name_utf, &flags);
573 close(sock);
749 int sock;
755 sock = openSocket(env, AF_INET);
756 if (sock < 0 && (*env)->ExceptionOccurred(env)) {
760 ifs = enumIPv4Interfaces(env, sock, NULL);
761 close(sock);
779 sock = openSocket(env, AF_INET6);
780 if (sock < 0 && (*env)->ExceptionOccurred(env)) {
785 ifs = enumIPv6Interfaces(env, sock, ifs);
786 close(sock);
837 netif *addif(JNIEnv *env, int sock, const char * if_name,
894 addrP->brdcast = getBroadcast(env, sock, name, brdcast_to );
896 if (addrP->brdcast && (mask = getSubnet(env, sock, name)) != -1) {
912 if (getFlags(sock, name, &flags) < 0 || flags < 0) {
947 currif->index = getIndex(sock, name);
983 currif->index = getIndex(sock, vname);
1015 int sock;
1017 if ((sock = JVM_Socket(proto, SOCK_DGRAM, 0)) < 0) {
1028 return sock;
1040 int sock;
1043 if ((sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
1045 if ( (sock = JVM_Socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
1059 return sock;
1068 static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
1080 if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
1088 if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
1102 ifs = addif(env, sock, ifreqP->ifr_name, ifs, (struct sockaddr *) & (ifreqP->ifr_addr), AF_INET, 0);
1127 static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
1152 ifs = addif(env, sock, devname, ifs, (struct sockaddr *)&addr, AF_INET6, plen);
1170 static int getIndex(int sock, const char *name){
1178 if (ioctl(sock, SIOCGIFINDEX, (char *)&if2) < 0) {
1189 static struct sockaddr *getBroadcast(JNIEnv *env, int sock, const char *ifname, struct sockaddr *brdcast_store) {
1197 if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
1204 if (ioctl(sock, SIOCGIFBRDADDR, (char *)&if2) < 0) {
1220 static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
1228 if (ioctl(sock, SIOCGIFNETMASK, (char *)&if2) < 0) {
1248 static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf) {
1253 if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) {
1272 static int getMTU(JNIEnv *env, int sock, const char *ifname) {
1278 if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
1286 static int getFlags(int sock, const char *ifname, int *flags) {
1292 if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0){
1314 int sock, alreadyV6 = 0;
1317 if ((sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
1319 if ( (sock = JVM_Socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
1345 if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
1346 close(sock);
1347 if ( (sock = JVM_Socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
1354 return sock;
1368 static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
1369 return enumIPvXInterfaces(env,sock, ifs, AF_INET);
1373 static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
1374 return enumIPvXInterfaces(env,sock, ifs, AF_INET6);
1382 static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family) {
1395 if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) {
1410 if (ioctl(sock, SIOCGLIFCONF, (char *)&ifc) < 0) {
1434 s6->sin6_scope_id = getIndex(sock, ifr->lifr_name);
1439 ifs = addif(env, sock,ifr->lifr_name, ifs, (struct sockaddr *)&(ifr->lifr_addr),family, (short) ifr->lifr_addrlen);
1455 static int getIndex(int sock, const char *name){
1463 if (ioctl(sock, SIOCGLIFINDEX, (char *)&if2) < 0) {
1474 static struct sockaddr *getBroadcast(JNIEnv *env, int sock, const char *ifname, struct sockaddr *brdcast_store) {
1482 if (ioctl(sock, SIOCGLIFFLAGS, (char *)&if2) < 0) {
1489 if (ioctl(sock, SIOCGLIFBRDADDR, (char *)&if2) < 0) {
1505 static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
1513 if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
1596 static int getMacAddress(JNIEnv *env, int sock, const char *ifname, const struct in_addr* addr, unsigned char *buf) {
1609 if (ioctl(sock, SIOCGLIFHWADDR, &lif) != -1) {
1641 if (ioctl(sock, SIOCGARP, &arpreq) < 0) {
1660 static int getMTU(JNIEnv *env, int sock, const char *ifname) {
1666 if (ioctl(sock, SIOCGLIFMTU, (char *)&if2) < 0) {
1675 static int getFlags(int sock, const char *ifname, int *flags) {
1680 if (ioctl(sock, SIOCGLIFFLAGS, (char *)&lifr) < 0) {
1700 int sock;
1703 if ((sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
1705 if ( (sock = JVM_Socket(AF_INET6, SOCK_DGRAM, 0)) < 0 ){
1716 return sock;
1728 static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
1748 ifs = addif(env, sock, ifa->ifa_name, ifs, ifa->ifa_addr, AF_INET, 0);
1802 static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
1825 if (ioctl(sock, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) < 0) {
1835 ifs = addif(env, sock, ifa->ifa_name, ifs, ifa->ifa_addr, AF_INET6,
1854 static int getIndex(int sock, const char *name){
1863 if (ioctl(sock, SIOCGIFINDEX, (char *)&if2) < 0) {
1881 static struct sockaddr *getBroadcast(JNIEnv *env, int sock, const char *ifname, struct sockaddr *brdcast_store) {
1889 if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
1896 if (ioctl(sock, SIOCGIFBRDADDR, (char *)&if2) < 0) {
1912 static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
1920 if (ioctl(sock, SIOCGIFNETMASK, (char *)&if2) < 0) {
1940 static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf) {
1967 static int getMTU(JNIEnv *env, int sock, const char *ifname) {
1973 if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
1981 static int getFlags(int sock, const char *ifname, int *flags) {
1988 if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0){