178 # endif |
189 # endif |
179 #else |
190 #else |
180 # undef AF_APPLETALK |
191 # undef AF_APPLETALK |
181 #endif |
192 #endif |
182 |
193 |
183 #ifdef WANT__AF_X25 |
194 #ifdef WANT__AF_X25 /* X.25 */ |
184 # ifdef AF_X25 |
195 # ifdef AF_X25 |
185 # ifndef PF_X25 |
196 # ifndef PF_X25 |
186 # define PF_X25 AF_X25 |
197 # define PF_X25 AF_X25 |
187 # endif |
198 # endif |
188 # endif |
199 # endif |
189 #else |
200 #else |
190 # undef AF_X25 |
201 # undef AF_X25 |
191 #endif |
202 #endif |
192 |
203 |
193 #ifdef WANT__AF_NS |
204 #ifdef WANT__AF_NS /* Xerox XNS */ |
194 # ifdef AF_NS |
205 # ifdef AF_NS |
195 # ifndef PF_NS |
206 # ifndef PF_NS |
196 # define PF_NS AF_NS |
207 # define PF_NS AF_NS |
197 # endif |
208 # endif |
198 # endif |
209 # endif |
199 #else |
210 #else |
200 # undef AF_NS |
211 # undef AF_NS |
201 #endif |
212 #endif |
202 |
213 |
203 #ifdef WANT__AF_SNA |
214 #ifdef WANT__AF_SNA /* IBM SNA */ |
204 # ifdef AF_SNA |
215 # ifdef AF_SNA |
205 # ifndef PF_SNA |
216 # ifndef PF_SNA |
206 # define PF_SNA AF_SNA |
217 # define PF_SNA AF_SNA |
207 # endif |
218 # endif |
208 # endif |
219 # endif |
209 #else |
220 #else |
210 # undef AF_SNA |
221 # undef AF_SNA |
211 #endif |
222 #endif |
212 |
223 |
213 #ifdef WANT__AF_RAW |
224 #ifdef WANT__AF_RAW /* RAW packets */ |
214 # ifdef AF_RAW |
225 # ifdef AF_RAW |
215 # ifndef PF_RAW |
226 # ifndef PF_RAW |
216 # define PF_RAW AF_RAW |
227 # define PF_RAW AF_RAW |
217 # endif |
228 # endif |
218 # endif |
229 # endif |
219 #else |
230 #else |
220 # undef AF_RAW |
231 # undef AF_RAW |
221 #endif |
232 #endif |
222 |
233 |
223 #ifdef WANT__AF_ISO |
234 #ifdef WANT__AF_ISO /* ? */ |
224 # ifdef AF_ISO |
235 # ifdef AF_ISO |
225 # ifndef PF_ISO |
236 # ifndef PF_ISO |
226 # define PF_ISO AF_ISO |
237 # define PF_ISO AF_ISO |
227 # endif |
238 # endif |
228 # endif |
239 # endif |
229 #else |
240 #else |
230 # undef AF_ISO |
241 # undef AF_ISO |
231 #endif |
242 #endif |
232 |
243 |
233 #ifdef WANT__AF_NETBIOS |
244 #ifdef WANT__AF_NETBIOS /* ? */ |
234 # ifdef AF_NETBIOS |
245 # ifdef AF_NETBIOS |
235 # ifndef PF_NETBIOS |
246 # ifndef PF_NETBIOS |
236 # define PF_NETBIOS AF_NETBIOS |
247 # define PF_NETBIOS AF_NETBIOS |
237 # endif |
248 # endif |
238 # endif |
249 # endif |
239 #else |
250 #else |
240 # undef WANT_AF_NETBIOS |
251 # undef WANT_AF_NETBIOS |
241 #endif |
252 #endif |
242 |
253 |
243 #ifdef WANT__AF_CCITT |
254 #ifdef WANT__AF_CCITT /* ? */ |
244 # if defined(AF_CCITT) && (AF_CCITT != AF_X25) |
255 # if defined(AF_CCITT) && (AF_CCITT != AF_X25) |
245 # ifndef PF_CCITT |
256 # ifndef PF_CCITT |
246 # define PF_CCITT AF_CCITT |
257 # define PF_CCITT AF_CCITT |
247 # endif |
258 # endif |
248 # endif |
259 # endif |
249 #else |
260 #else |
250 # undef AF_CCITT |
261 # undef AF_CCITT |
251 #endif |
262 #endif |
252 |
263 |
|
264 #ifdef WANT__AF_IPX /* Novell IPX */ |
|
265 # ifdef AF_IPX |
|
266 # ifndef PF_IPX |
|
267 # define PF_IPX AF_IPX |
|
268 # endif |
|
269 # endif |
|
270 #else |
|
271 # undef WANT_AF_IPX |
|
272 #endif |
|
273 |
|
274 #ifdef WANT__AF_AX25 /* Amateur radio ax25 */ |
|
275 # ifdef AF_AX25 |
|
276 # ifndef PF_AX25 |
|
277 # define PF_AX25 AF_AX25 |
|
278 # endif |
|
279 # endif |
|
280 #else |
|
281 # undef WANT_AF_AX25 |
|
282 #endif |
|
283 |
|
284 #ifdef WANT__AF_NETROM /* Amateur radio NETROM */ |
|
285 # ifdef AF_NETROM |
|
286 # ifndef PF_NETROM |
|
287 # define PF_NETROM AF_NETROM |
|
288 # endif |
|
289 # endif |
|
290 #else |
|
291 # undef WANT_AF_NETROM |
|
292 #endif |
|
293 |
|
294 #ifdef WANT__AF_BRIDGE /* multiprotocol bridge */ |
|
295 # ifdef AF_BRIDGE |
|
296 # ifndef PF_BRIDGE |
|
297 # define PF_BRIDGE AF_BRIDGE |
|
298 # endif |
|
299 # endif |
|
300 #else |
|
301 # undef WANT_AF_BRIDGE |
|
302 #endif |
|
303 |
253 /* |
304 /* |
254 * now, include what we have to ... |
305 * now, include what we have to ... |
255 */ |
306 */ |
256 #ifndef WIN32 |
307 #ifndef WIN32 /* win32 has all in winsock.h */ |
|
308 |
257 # ifdef AF_INET |
309 # ifdef AF_INET |
258 # include <netdb.h> |
310 # include <netdb.h> |
259 # include <netinet/in.h> |
311 # include <netinet/in.h> |
260 # if ! (defined(SYSV3) && defined(mc88k)) |
312 # if ! (defined(SYSV3) && defined(mc88k)) |
261 # include <netinet/tcp.h> |
313 # include <netinet/tcp.h> |
1452 OBJ fp = __INST(filePointer); |
1505 OBJ fp = __INST(filePointer); |
1453 int nInstVars, nInstBytes, objSize; |
1506 int nInstVars, nInstBytes, objSize; |
1454 int sock; |
1507 int sock; |
1455 union { |
1508 union { |
1456 # ifdef AF_INET |
1509 # ifdef AF_INET |
1457 struct sockaddr_in in ; |
1510 struct sockaddr_in in; |
|
1511 # endif |
|
1512 # ifdef AF_INET6 |
|
1513 struct sockaddr_in6 in6; |
1458 # endif |
1514 # endif |
1459 # ifdef AF_UNIX |
1515 # ifdef AF_UNIX |
1460 struct sockaddr_un un; |
1516 struct sockaddr_un un; |
1461 # endif |
1517 # endif |
1462 # ifdef AF_APPLETALK |
1518 # ifdef AF_APPLETALK |
1523 |
1579 |
1524 /* |
1580 /* |
1525 * extract the datagrams address |
1581 * extract the datagrams address |
1526 */ |
1582 */ |
1527 # ifdef AF_UNIX |
1583 # ifdef AF_UNIX |
1528 if (myDomain == @symbol(unix)) { |
1584 if (myDomain == @symbol(unix)) { |
1529 cp[0] = (sa.in.sin_addr.s_addr >> 24) & 0xFF; |
1585 cp[0] = (sa.in.sin_addr.s_addr >> 24) & 0xFF; |
1530 cp[2] = (sa.in.sin_addr.s_addr >> 16) & 0xFF; |
1586 cp[2] = (sa.in.sin_addr.s_addr >> 16) & 0xFF; |
1531 cp[3] = (sa.in.sin_addr.s_addr >> 8) & 0xFF; |
1587 cp[3] = (sa.in.sin_addr.s_addr >> 8) & 0xFF; |
1532 cp[4] = (sa.in.sin_addr.s_addr >> 0) & 0xFF; |
1588 cp[4] = (sa.in.sin_addr.s_addr >> 0) & 0xFF; |
1533 alen = 4; |
1589 alen = 4; |
1534 } |
1590 } |
1535 # endif /* AF_UNIX */ |
1591 # endif /* AF_UNIX */ |
1536 |
1592 |
1537 /* |
1593 /* |
1538 * XXXX add addressing stuff for other domains here ... |
1594 * XXXX add addressing stuff for other domains here ... |
1539 */ |
1595 */ |
1568 # ifdef AF_DECnet |
1624 # ifdef AF_DECnet |
1569 if (myDomain == @symbol(decnet)) { |
1625 if (myDomain == @symbol(decnet)) { |
1570 } |
1626 } |
1571 # endif |
1627 # endif |
1572 # ifdef AF_NETBIOS |
1628 # ifdef AF_NETBIOS |
1573 if (myDomain == @symbol(decnet)) { |
1629 if (myDomain == @symbol(netbios)) { |
|
1630 } |
|
1631 # endif |
|
1632 # if defined(AF_IPX) |
|
1633 if (myDomain == @symbol(ipx)) { |
|
1634 } |
|
1635 # endif |
|
1636 # if defined(AF_BRIDGE) |
|
1637 if (myDomain == @symbol(bridge)) { |
1574 } |
1638 } |
1575 # endif |
1639 # endif |
1576 # if defined(AF_CCITT) && (AF_CCITT != AF_X25) |
1640 # if defined(AF_CCITT) && (AF_CCITT != AF_X25) |
1577 if (myDomain == @symbol(ccitt)) { |
1641 if (myDomain == @symbol(ccitt)) { |
1578 } |
1642 } |
1655 OBJ fp = __INST(filePointer); |
1719 OBJ fp = __INST(filePointer); |
1656 int nInstVars, nInstBytes, objSize; |
1720 int nInstVars, nInstBytes, objSize; |
1657 int sock; |
1721 int sock; |
1658 union { |
1722 union { |
1659 # ifdef AF_INET |
1723 # ifdef AF_INET |
1660 struct sockaddr_in in ; |
1724 struct sockaddr_in in; |
|
1725 # endif |
|
1726 # ifdef AF_INET6 |
|
1727 struct sockaddr_in6 in6; |
1661 # endif |
1728 # endif |
1662 # ifdef AF_UNIX |
1729 # ifdef AF_UNIX |
1663 struct sockaddr_un un; |
1730 struct sockaddr_un un; |
1664 # endif |
1731 # endif |
1665 # ifdef AF_APPLETALK |
1732 # ifdef AF_APPLETALK |
1697 #ifdef AF_INET |
1764 #ifdef AF_INET |
1698 if (__INST(domain) == @symbol(inet)) { |
1765 if (__INST(domain) == @symbol(inet)) { |
1699 sa.in.sin_family = AF_INET; |
1766 sa.in.sin_family = AF_INET; |
1700 sa.in.sin_port = htons((u_short) __intVal(portNo)); |
1767 sa.in.sin_port = htons((u_short) __intVal(portNo)); |
1701 } |
1768 } |
|
1769 #endif |
|
1770 #ifdef AF_INET6 |
|
1771 if (__INST(domain) == @symbol(inet6)) { |
|
1772 sa.in6.sin6_family = AF_INET; |
|
1773 sa.in6.sin6_port = htons((u_short) __intVal(portNo)); |
|
1774 } |
1702 #endif |
1775 #endif |
1703 #ifdef AF_APPLETALK |
1776 #ifdef AF_APPLETALK |
1704 if (__INST(domain) == @symbol(appletalk)) { |
1777 if (__INST(domain) == @symbol(appletalk)) { |
1705 sa.at.sat_family = AF_INET; |
1778 sa.at.sat_family = AF_INET; |
1706 sa.at.sat_port = __intVal(portNo); |
1779 sa.at.sat_port = __intVal(portNo); |
1966 } |
2042 } |
1967 DBGPRINTF(("SOCKET: bind addr: %x port: %x\n", sa.in.sin_addr.s_addr, sa.in.sin_port)); |
2043 DBGPRINTF(("SOCKET: bind addr: %x port: %x\n", sa.in.sin_addr.s_addr, sa.in.sin_port)); |
1968 sockaddr_size = sizeof(struct sockaddr_in); |
2044 sockaddr_size = sizeof(struct sockaddr_in); |
1969 ok = 1; |
2045 ok = 1; |
1970 } |
2046 } |
1971 # endif |
2047 # endif /* AF_INET */ |
|
2048 |
|
2049 # ifdef AF_INET6 |
|
2050 if (myDomain == @symbol(inet6)) { |
|
2051 /* |
|
2052 * INET6 addresses - port must be a smallinteger or nil |
|
2053 */ |
|
2054 sa.in6.sin6_family = AF_INET6; |
|
2055 |
|
2056 if (portNrOrName == nil) { |
|
2057 sa.in6.sin6_port = 0; |
|
2058 } else { |
|
2059 if (! __isSmallInteger(portNrOrName)) { |
|
2060 DBGPRINTF(("SOCKET: invalid port arg\n")); |
|
2061 RETURN (false); |
|
2062 } |
|
2063 sa.in6.sin6_port = htons((u_short) _intVal(portNrOrName)); |
|
2064 } |
|
2065 |
|
2066 /* |
|
2067 * INET6 addresses - addr must be nil or byteArray or string |
|
2068 */ |
|
2069 if (address == nil) { |
|
2070 sa.in6.sin6_addr.s6_addr[0] = 0; |
|
2071 sa.in6.sin6_addr.s6_addr[1] = 0; |
|
2072 sa.in6.sin6_addr.s6_addr[2] = 0; |
|
2073 sa.in6.sin6_addr.s6_addr[3] = 0; |
|
2074 sa.in6.sin6_addr.s6_addr[4] = 0; |
|
2075 sa.in6.sin6_addr.s6_addr[5] = 0; |
|
2076 } else { |
|
2077 if (__isByteArray(address)) { |
|
2078 unsigned char *cp; |
|
2079 int n; |
|
2080 |
|
2081 cp = __ByteArrayInstPtr(address)->ba_element; |
|
2082 n = __byteArraySize(address); |
|
2083 if (n > 6) n = 6; |
|
2084 bcopy(cp, &sa.in6.sin6_addr.s6_addr, n); |
|
2085 } else { |
|
2086 char *hostName; |
|
2087 unsigned addr; |
|
2088 struct hostent *hp ; |
|
2089 |
|
2090 if (! __isString(address)) { |
|
2091 DBGPRINTF(("SOCKET: invalid address arg in bind\n")); |
|
2092 RETURN (false); |
|
2093 } |
|
2094 |
|
2095 hostName = (char *) __stringVal(address); |
|
2096 |
|
2097 /* |
|
2098 * do we know the host's address? |
|
2099 */ |
|
2100 if ((hp = gethostbyname(hostName)) == NULL) { |
|
2101 DBGPRINTF(("SOCKET: unknown host:%s\n", hostName)); |
|
2102 RETURN (false); |
|
2103 } |
|
2104 bcopy(hp->h_addr, (char *) &sa.in6.sin6_addr, hp->h_length) ; |
|
2105 sa.in.sin_family = hp->h_addrtype; |
|
2106 } |
|
2107 } |
|
2108 |
|
2109 DBGPRINTF(("SOCKET: bind addr: %x.%x.%x.%x.%x.%x port: %x\n", |
|
2110 sa.in6.sin6_addr.s6_addr[0], |
|
2111 sa.in6.sin6_addr.s6_addr[1], |
|
2112 sa.in6.sin6_addr.s6_addr[2], |
|
2113 sa.in6.sin6_addr.s6_addr[3], |
|
2114 sa.in6.sin6_addr.s6_addr[4], |
|
2115 sa.in6.sin6_addr.s6_addr[5], |
|
2116 sa.in6.sin6_port)); |
|
2117 sockaddr_size = sizeof(struct sockaddr_in6); |
|
2118 ok = 1; |
|
2119 } |
|
2120 # endif /* AF_INET6 */ |
1972 |
2121 |
1973 # ifdef AF_UNIX |
2122 # ifdef AF_UNIX |
1974 /* |
2123 /* |
1975 * UNIX domain - port is ignored; address must be a string (path) |
2124 * UNIX domain - port is ignored; address must be a string (path) |
1976 */ |
2125 */ |
1992 strcpy(sa.un.sun_path, pathName); |
2141 strcpy(sa.un.sun_path, pathName); |
1993 sa.un.sun_family = AF_UNIX; |
2142 sa.un.sun_family = AF_UNIX; |
1994 sockaddr_size = l + sizeof ( sa.un.sun_family ); |
2143 sockaddr_size = l + sizeof ( sa.un.sun_family ); |
1995 ok = 1; |
2144 ok = 1; |
1996 } |
2145 } |
1997 # endif |
2146 # endif /* AF_UNIX */ |
1998 |
2147 |
1999 # ifdef AF_APPLETALK |
2148 # ifdef AF_APPLETALK |
2000 /* |
2149 /* |
2001 * this has never been tested .... |
2150 * this has never been tested .... |
2002 */ |
2151 */ |
2159 __INST(port) = __MKSMALLINT(p); |
2315 __INST(port) = __MKSMALLINT(p); |
2160 } |
2316 } |
2161 } |
2317 } |
2162 } |
2318 } |
2163 # endif |
2319 # endif |
|
2320 # ifdef AF_INET6 |
|
2321 if (myDomain == @symbol(inet6)) { |
|
2322 if (! __isSmallInteger(portNrOrName) |
|
2323 || (portNrOrName == __MKSMALLINT(0))) { |
|
2324 int p; |
|
2325 |
|
2326 /* |
|
2327 * INET6 anonymous port - get the actual portNr |
|
2328 */ |
|
2329 if (getsockname(sock, (struct sockaddr *)&sa, &sockaddr_size) < 0) { |
|
2330 DBGPRINTF(("SOCKET: cannot get peername\n")); |
|
2331 } else { |
|
2332 DBGPRINTF(("SOCKET: anon port=%x\n", sa.in.sin_port)); |
|
2333 p = ntohs(sa.in6.sin6_port); |
|
2334 __INST(port) = __MKSMALLINT(p); |
|
2335 } |
|
2336 } |
|
2337 } |
|
2338 # endif |
|
2339 # ifdef AF_APPLETALK |
|
2340 if (myDomain == @symbol(appletalk)) { |
|
2341 if (! __isSmallInteger(portNrOrName) |
|
2342 || (portNrOrName == __MKSMALLINT(0))) { |
|
2343 int p; |
|
2344 |
|
2345 /* |
|
2346 * APPLETALK anonymous port - get the actual portNr |
|
2347 */ |
|
2348 if (getsockname(sock, (struct sockaddr *)&sa, &sockaddr_size) < 0) { |
|
2349 DBGPRINTF(("SOCKET: cannot get peername\n")); |
|
2350 } else { |
|
2351 DBGPRINTF(("SOCKET: anon port=%x\n", sa.in.sin_port)); |
|
2352 p = sa.at.sat_port; |
|
2353 __INST(port) = __MKSMALLINT(p); |
|
2354 } |
|
2355 } |
|
2356 } |
|
2357 # endif |
|
2358 |
2164 #else /* NO_SOCKET */ |
2359 #else /* NO_SOCKET */ |
2165 RETURN (false); |
2360 RETURN (false); |
2166 #endif /* NO_SOCKET */ |
2361 #endif /* NO_SOCKET */ |
2167 %}. |
2362 %}. |
2168 ^ true |
2363 ^ true |
2227 #ifdef AF_INET |
2425 #ifdef AF_INET |
2228 if (__INST(domain) == @symbol(inet)) { |
2426 if (__INST(domain) == @symbol(inet)) { |
2229 alen0 = sizeof(sa.in); |
2427 alen0 = sizeof(sa.in); |
2230 } |
2428 } |
2231 #endif |
2429 #endif |
|
2430 #ifdef AF_INET6 |
|
2431 if (__INST(domain) == @symbol(inet6)) { |
|
2432 alen0 = sizeof(sa.in6); |
|
2433 } |
|
2434 #endif |
2232 #ifdef AF_UNIX |
2435 #ifdef AF_UNIX |
2233 if (__INST(domain) == @symbol(unix)) { |
2436 if (__INST(domain) == @symbol(unix)) { |
2234 alen0 = sizeof(sa.un); |
2437 alen0 = sizeof(sa.un); |
2235 } |
2438 } |
2236 #endif |
2439 #endif |
|
2440 # ifdef AF_APPLETALK |
|
2441 if (__INST(domain) == @symbol(appletalk)) { |
|
2442 alen0 = sizeof(sa.at); |
|
2443 } |
|
2444 # endif |
|
2445 |
2237 /* |
2446 /* |
2238 * XXXX add addressing stuff for other domains here ... |
2447 * XXXX add addressing stuff for other domains here ... |
2239 */ |
2448 */ |
2240 # ifdef AF_X25 |
2449 # ifdef AF_X25 |
2241 if (__INST(domain) == @symbol(x25)) { |
2450 if (__INST(domain) == @symbol(x25)) { |
2315 DBGPRINTF(("SOCKET: accepted connection from host %s\n", (he ? he->h_name : dotted))) ; |
2527 DBGPRINTF(("SOCKET: accepted connection from host %s\n", (he ? he->h_name : dotted))) ; |
2316 __INST(peerName) = __MKSTRING((he ? he->h_name : dotted)); |
2528 __INST(peerName) = __MKSTRING((he ? he->h_name : dotted)); |
2317 __STORESELF(peerName); |
2529 __STORESELF(peerName); |
2318 } |
2530 } |
2319 #endif |
2531 #endif |
|
2532 |
|
2533 #ifdef AF_INET6 |
|
2534 if (__INST(domain) == @symbol(inet6)) { |
|
2535 he = gethostbyaddr((char *) &sa.in6.sin6_addr.s6_addr, alen, AF_INET6) ; |
|
2536 if (! he) { |
|
2537 unsigned long norder; |
|
2538 |
|
2539 /* |
|
2540 * XXX: what is inet6's naming convention ? |
|
2541 */ |
|
2542 norder = htonl(sa.in.sin_addr.s_addr) ; |
|
2543 sprintf(dotted, "%d.%d.%d.%d", |
|
2544 sa.in6.sin6_addr.s6_addr[0], |
|
2545 sa.in6.sin6_addr.s6_addr[1], |
|
2546 sa.in6.sin6_addr.s6_addr[2], |
|
2547 sa.in6.sin6_addr.s6_addr[3], |
|
2548 sa.in6.sin6_addr.s6_addr[4], |
|
2549 sa.in6.sin6_addr.s6_addr[5]); |
|
2550 } |
|
2551 DBGPRINTF(("SOCKET: accepted connection from host %s\n", (he ? he->h_name : dotted))) ; |
|
2552 __INST(peerName) = __MKSTRING((he ? he->h_name : dotted)); |
|
2553 __STORESELF(peerName); |
|
2554 } |
|
2555 #endif |
|
2556 |
2320 #ifdef AF_UNIX |
2557 #ifdef AF_UNIX |
2321 if (__INST(domain) == @symbol(unix)) { |
2558 if (__INST(domain) == @symbol(unix)) { |
2322 DBGPRINTF(("SOCKET: accepted connection on unix socket\n")) ; |
2559 DBGPRINTF(("SOCKET: accepted connection on unix socket\n")) ; |
2323 /* nothing to be done here */ |
2560 /* nothing to be done here */ |
2324 } |
2561 } |
2325 #endif |
2562 #endif |
|
2563 |
|
2564 #ifdef AF_APPLETALK |
|
2565 if (__INST(domain) == @symbol(appletalk)) { |
|
2566 he = gethostbyaddr((char *) &sa.at.sat_addr, alen, AF_APPLETALK) ; |
|
2567 if (! he) { |
|
2568 unsigned net; |
|
2569 |
|
2570 /* |
|
2571 * XXX: what is apples naming convention ? |
|
2572 */ |
|
2573 net = htons(sa.at.sat_addr.s_net) ; |
|
2574 sprintf(dotted, "%d.%d", |
|
2575 net, |
|
2576 sa.at.sat_addr.s_node); |
|
2577 } |
|
2578 DBGPRINTF(("SOCKET: accepted connection from host %s\n", (he ? he->h_name : dotted))) ; |
|
2579 __INST(peerName) = __MKSTRING((he ? he->h_name : dotted)); |
|
2580 __STORESELF(peerName); |
|
2581 } |
|
2582 # endif |
|
2583 |
2326 /* |
2584 /* |
2327 * XXXX add addressing stuff for other domains here ... |
2585 * XXXX add addressing stuff for other domains here ... |
2328 */ |
2586 */ |
2329 # ifdef AF_X25 |
2587 # ifdef AF_X25 |
2330 if (__INST(domain) == @symbol(x25)) { |
2588 if (__INST(domain) == @symbol(x25)) { |
2519 sockaddr_size = sizeof(struct sockaddr_in); |
2784 sockaddr_size = sizeof(struct sockaddr_in); |
2520 ok = 1; |
2785 ok = 1; |
2521 } |
2786 } |
2522 #endif /* AF_INET */ |
2787 #endif /* AF_INET */ |
2523 |
2788 |
|
2789 #ifdef AF_INET6 |
|
2790 if (myDomain == @symbol(inet6)) { |
|
2791 char *hostName; |
|
2792 |
|
2793 /* |
|
2794 * INET6 addressing: port must be a smallInteger; |
|
2795 * hostOrPathName the name of the host |
|
2796 * or a byteArray containing the 6 address bytes. |
|
2797 */ |
|
2798 if (! __isSmallInteger(portNrOrName)) { |
|
2799 DBGPRINTF(("SOCKET: invalid port arg\n")); |
|
2800 RETURN (false); |
|
2801 } |
|
2802 |
|
2803 sa.in6.sin6_family = AF_INET6; |
|
2804 sa.in6.sin6_port = htons((u_short) _intVal(portNrOrName)) ; |
|
2805 |
|
2806 if (__isByteArray(hostOrPathName)) { |
|
2807 unsigned char *cp; |
|
2808 int n; |
|
2809 |
|
2810 cp = __ByteArrayInstPtr(hostOrPathName)->ba_element; |
|
2811 n = __byteArraySize(hostOrPathName); |
|
2812 if (n > 6) n = 6; |
|
2813 bcopy(cp, &sa.in6.sin6_addr.s6_addr, n); |
|
2814 } else { |
|
2815 if (! __isString(hostOrPathName)) { |
|
2816 DBGPRINTF(("SOCKET: invalid hostname arg\n")); |
|
2817 RETURN (false); |
|
2818 } |
|
2819 |
|
2820 hostName = (char *) __stringVal(hostOrPathName); |
|
2821 |
|
2822 /* |
|
2823 * do we know the host's address? |
|
2824 */ |
|
2825 if ((hp = gethostbyname(hostName)) == NULL) { |
|
2826 DBGPRINTF(("SOCKET: unknown host:%s\n", hostName)); |
|
2827 RETURN (false); |
|
2828 } |
|
2829 bcopy(hp->h_addr, (char *) &sa.in.sin_addr, hp->h_length) ; |
|
2830 sa.in.sin_family = hp->h_addrtype; |
|
2831 } |
|
2832 |
|
2833 DBGPRINTF(("SOCKET: connect addr: %x.%x.%x.%x.%x.%x port: %d\n", |
|
2834 sa.in6.sin6_addr.s6_addr[0], |
|
2835 sa.in6.sin6_addr.s6_addr[1], |
|
2836 sa.in6.sin6_addr.s6_addr[2], |
|
2837 sa.in6.sin6_addr.s6_addr[3], |
|
2838 sa.in6.sin6_addr.s6_addr[4], |
|
2839 sa.in6.sin6_addr.s6_addr[5], |
|
2840 sa.in6.sin6_port)); |
|
2841 |
|
2842 sockaddr_size = sizeof(struct sockaddr_in6); |
|
2843 ok = 1; |
|
2844 } |
|
2845 #endif /* AF_INET6 */ |
|
2846 |
2524 #ifdef AF_UNIX |
2847 #ifdef AF_UNIX |
2525 if (myDomain == @symbol(unix)) { |
2848 if (myDomain == @symbol(unix)) { |
2526 char *pathName; |
2849 char *pathName; |
2527 int l; |
2850 int l; |
2528 |
2851 |