sgx_socket.c 20 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include "platform_api_vmcore.h"
  6. #include "platform_api_extension.h"
  7. #ifndef SGX_DISABLE_WASI
  8. #define TRACE_OCALL_FAIL() os_printf("ocall %s failed!\n", __FUNCTION__)
  9. /** OCALLs prototypes **/
  10. int
  11. ocall_accept(int *p_ret, int sockfd, void *addr, uint32_t *addrlen,
  12. uint32_t addr_size);
  13. int
  14. ocall_bind(int *p_ret, int sockfd, const void *addr, uint32_t addrlen);
  15. int
  16. ocall_close(int *p_ret, int fd);
  17. int
  18. ocall_connect(int *p_ret, int sockfd, void *addr, uint32_t addrlen);
  19. int
  20. ocall_fcntl_long(int *p_ret, int fd, int cmd, long arg);
  21. int
  22. ocall_getsockname(int *p_ret, int sockfd, void *addr, uint32_t *addrlen,
  23. uint32_t addr_size);
  24. int
  25. ocall_getsockopt(int *p_ret, int sockfd, int level, int optname, void *val_buf,
  26. unsigned int val_buf_size, void *len_buf);
  27. int
  28. ocall_listen(int *p_ret, int sockfd, int backlog);
  29. int
  30. ocall_recv(int *p_ret, int sockfd, void *buf, size_t len, int flags);
  31. int
  32. ocall_recvmsg(ssize_t *p_ret, int sockfd, void *msg_buf,
  33. unsigned int msg_buf_size, int flags);
  34. int
  35. ocall_send(int *p_ret, int sockfd, const void *buf, size_t len, int flags);
  36. int
  37. ocall_sendmsg(ssize_t *p_ret, int sockfd, void *msg_buf,
  38. unsigned int msg_buf_size, int flags);
  39. int
  40. ocall_setsockopt(int *p_ret, int sockfd, int level, int optname, void *optval,
  41. unsigned int optlen);
  42. int
  43. ocall_shutdown(int *p_ret, int sockfd, int how);
  44. int
  45. ocall_socket(int *p_ret, int domain, int type, int protocol);
  46. /** OCALLs prototypes end **/
  47. /** In-enclave implementation of POSIX functions **/
  48. static bool
  49. is_little_endian()
  50. {
  51. long i = 0x01020304;
  52. unsigned char *c = (unsigned char *)&i;
  53. return (*c == 0x04) ? true : false;
  54. }
  55. static void
  56. swap32(uint8 *pData)
  57. {
  58. uint8 value = *pData;
  59. *pData = *(pData + 3);
  60. *(pData + 3) = value;
  61. value = *(pData + 1);
  62. *(pData + 1) = *(pData + 2);
  63. *(pData + 2) = value;
  64. }
  65. static void
  66. swap16(uint8 *pData)
  67. {
  68. uint8 value = *pData;
  69. *(pData) = *(pData + 1);
  70. *(pData + 1) = value;
  71. }
  72. uint32
  73. htonl(uint32 value)
  74. {
  75. uint32 ret;
  76. if (is_little_endian()) {
  77. ret = value;
  78. swap32((uint8 *)&ret);
  79. return ret;
  80. }
  81. return value;
  82. }
  83. uint32
  84. ntohl(uint32 value)
  85. {
  86. return htonl(value);
  87. }
  88. uint16
  89. htons(uint16 value)
  90. {
  91. uint16 ret;
  92. if (is_little_endian()) {
  93. ret = value;
  94. swap16((uint8 *)&ret);
  95. return ret;
  96. }
  97. return value;
  98. }
  99. static uint16
  100. ntohs(uint16 value)
  101. {
  102. return htons(value);
  103. }
  104. /* Coming from musl, under MIT license */
  105. static int
  106. hexval(unsigned c)
  107. {
  108. if (c - '0' < 10)
  109. return c - '0';
  110. c |= 32;
  111. if (c - 'a' < 6)
  112. return c - 'a' + 10;
  113. return -1;
  114. }
  115. /* Coming from musl, under MIT license */
  116. static int
  117. inet_pton(int af, const char *restrict s, void *restrict a0)
  118. {
  119. uint16_t ip[8];
  120. unsigned char *a = a0;
  121. int i, j, v, d, brk = -1, need_v4 = 0;
  122. if (af == AF_INET) {
  123. for (i = 0; i < 4; i++) {
  124. for (v = j = 0; j < 3 && isdigit(s[j]); j++)
  125. v = 10 * v + s[j] - '0';
  126. if (j == 0 || (j > 1 && s[0] == '0') || v > 255)
  127. return 0;
  128. a[i] = v;
  129. if (s[j] == 0 && i == 3)
  130. return 1;
  131. if (s[j] != '.')
  132. return 0;
  133. s += j + 1;
  134. }
  135. return 0;
  136. }
  137. else if (af != AF_INET6) {
  138. errno = EAFNOSUPPORT;
  139. return -1;
  140. }
  141. if (*s == ':' && *++s != ':')
  142. return 0;
  143. for (i = 0;; i++) {
  144. if (s[0] == ':' && brk < 0) {
  145. brk = i;
  146. ip[i & 7] = 0;
  147. if (!*++s)
  148. break;
  149. if (i == 7)
  150. return 0;
  151. continue;
  152. }
  153. for (v = j = 0; j < 4 && (d = hexval(s[j])) >= 0; j++)
  154. v = 16 * v + d;
  155. if (j == 0)
  156. return 0;
  157. ip[i & 7] = v;
  158. if (!s[j] && (brk >= 0 || i == 7))
  159. break;
  160. if (i == 7)
  161. return 0;
  162. if (s[j] != ':') {
  163. if (s[j] != '.' || (i < 6 && brk < 0))
  164. return 0;
  165. need_v4 = 1;
  166. i++;
  167. break;
  168. }
  169. s += j + 1;
  170. }
  171. if (brk >= 0) {
  172. memmove(ip + brk + 7 - i, ip + brk, 2 * (i + 1 - brk));
  173. for (j = 0; j < 7 - i; j++)
  174. ip[brk + j] = 0;
  175. }
  176. for (j = 0; j < 8; j++) {
  177. *a++ = ip[j] >> 8;
  178. *a++ = ip[j];
  179. }
  180. if (need_v4 && inet_pton(AF_INET, (void *)s, a - 4) <= 0)
  181. return 0;
  182. return 1;
  183. }
  184. static int
  185. inet_addr(const char *p)
  186. {
  187. struct in_addr a;
  188. if (!inet_pton(AF_INET, p, &a))
  189. return -1;
  190. return a.s_addr;
  191. }
  192. /** In-enclave implementation of POSIX functions end **/
  193. static int
  194. textual_addr_to_sockaddr(const char *textual, int port, struct sockaddr_in *out)
  195. {
  196. assert(textual);
  197. out->sin_family = AF_INET;
  198. out->sin_port = htons(port);
  199. out->sin_addr.s_addr = inet_addr(textual);
  200. return BHT_OK;
  201. }
  202. int
  203. socket(int domain, int type, int protocol)
  204. {
  205. int ret;
  206. if (ocall_socket(&ret, domain, type, protocol) != SGX_SUCCESS) {
  207. TRACE_OCALL_FAIL();
  208. return -1;
  209. }
  210. if (ret == -1)
  211. errno = get_errno();
  212. return ret;
  213. }
  214. int
  215. getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen)
  216. {
  217. int ret;
  218. unsigned int val_buf_size = *optlen;
  219. if (ocall_getsockopt(&ret, sockfd, level, optname, optval, val_buf_size,
  220. (void *)optlen)
  221. != SGX_SUCCESS) {
  222. TRACE_OCALL_FAIL();
  223. return -1;
  224. }
  225. if (ret == -1)
  226. errno = get_errno();
  227. return ret;
  228. }
  229. ssize_t
  230. sendmsg(int sockfd, const struct msghdr *msg, int flags)
  231. {
  232. ssize_t ret;
  233. int i;
  234. char *p;
  235. struct msghdr *msg1;
  236. uint64 total_size = sizeof(struct msghdr) + (uint64)msg->msg_namelen
  237. + (uint64)msg->msg_controllen;
  238. total_size += sizeof(struct iovec) * (msg->msg_iovlen);
  239. for (i = 0; i < msg->msg_iovlen; i++) {
  240. total_size += msg->msg_iov[i].iov_len;
  241. }
  242. if (total_size >= UINT32_MAX)
  243. return -1;
  244. msg1 = BH_MALLOC((uint32)total_size);
  245. if (msg1 == NULL)
  246. return -1;
  247. p = (char *)(uintptr_t)sizeof(struct msghdr);
  248. if (msg->msg_name != NULL) {
  249. msg1->msg_name = p;
  250. memcpy((uintptr_t)p + (char *)msg1, msg->msg_name,
  251. (size_t)msg->msg_namelen);
  252. p += msg->msg_namelen;
  253. }
  254. if (msg->msg_control != NULL) {
  255. msg1->msg_control = p;
  256. memcpy((uintptr_t)p + (char *)msg1, msg->msg_control,
  257. (size_t)msg->msg_control);
  258. p += msg->msg_controllen;
  259. }
  260. if (msg->msg_iov != NULL) {
  261. msg1->msg_iov = (struct iovec *)p;
  262. p += (uintptr_t)(sizeof(struct iovec) * (msg->msg_iovlen));
  263. for (i = 0; i < msg->msg_iovlen; i++) {
  264. msg1->msg_iov[i].iov_base = p;
  265. msg1->msg_iov[i].iov_len = msg->msg_iov[i].iov_len;
  266. memcpy((uintptr_t)p + (char *)msg1, msg->msg_iov[i].iov_base,
  267. (size_t)(msg->msg_iov[i].iov_len));
  268. p += msg->msg_iov[i].iov_len;
  269. }
  270. }
  271. if (ocall_sendmsg(&ret, sockfd, (void *)msg1, (uint32)total_size, flags)
  272. != SGX_SUCCESS) {
  273. TRACE_OCALL_FAIL();
  274. return -1;
  275. }
  276. if (ret == -1)
  277. errno = get_errno();
  278. return ret;
  279. }
  280. ssize_t
  281. recvmsg(int sockfd, struct msghdr *msg, int flags)
  282. {
  283. ssize_t ret;
  284. int i;
  285. char *p;
  286. struct msghdr *msg1;
  287. uint64 total_size = sizeof(struct msghdr) + (uint64)msg->msg_namelen
  288. + (uint64)msg->msg_controllen;
  289. total_size += sizeof(struct iovec) * (msg->msg_iovlen);
  290. for (i = 0; i < msg->msg_iovlen; i++) {
  291. total_size += msg->msg_iov[i].iov_len;
  292. }
  293. if (total_size >= UINT32_MAX)
  294. return -1;
  295. msg1 = BH_MALLOC((uint32)total_size);
  296. if (msg1 == NULL)
  297. return -1;
  298. memset(msg1, 0, total_size);
  299. p = (char *)(uintptr_t)sizeof(struct msghdr);
  300. if (msg->msg_name != NULL) {
  301. msg1->msg_name = p;
  302. p += msg->msg_namelen;
  303. }
  304. if (msg->msg_control != NULL) {
  305. msg1->msg_control = p;
  306. p += msg->msg_controllen;
  307. }
  308. if (msg->msg_iov != NULL) {
  309. msg1->msg_iov = (struct iovec *)p;
  310. p += (uintptr_t)(sizeof(struct iovec) * (msg->msg_iovlen));
  311. for (i = 0; i < msg->msg_iovlen; i++) {
  312. msg1->msg_iov[i].iov_base = p;
  313. msg1->msg_iov[i].iov_len = msg->msg_iov[i].iov_len;
  314. p += msg->msg_iov[i].iov_len;
  315. }
  316. }
  317. if (ocall_recvmsg(&ret, sockfd, (void *)msg1, (uint32)total_size, flags)
  318. != SGX_SUCCESS) {
  319. TRACE_OCALL_FAIL();
  320. return -1;
  321. }
  322. p = (char *)(uintptr_t)(sizeof(struct msghdr));
  323. if (msg1->msg_name != NULL) {
  324. memcpy(msg->msg_name, (uintptr_t)p + (char *)msg1,
  325. (size_t)msg1->msg_namelen);
  326. p += msg1->msg_namelen;
  327. }
  328. if (msg1->msg_control != NULL) {
  329. memcpy(msg->msg_control, (uintptr_t)p + (char *)msg1,
  330. (size_t)msg1->msg_control);
  331. p += msg->msg_controllen;
  332. }
  333. if (msg1->msg_iov != NULL) {
  334. p += (uintptr_t)(sizeof(struct iovec) * (msg1->msg_iovlen));
  335. for (i = 0; i < msg1->msg_iovlen; i++) {
  336. memcpy(msg->msg_iov[i].iov_base, (uintptr_t)p + (char *)msg1,
  337. (size_t)(msg1->msg_iov[i].iov_len));
  338. p += msg1->msg_iov[i].iov_len;
  339. }
  340. }
  341. if (ret == -1)
  342. errno = get_errno();
  343. return ret;
  344. }
  345. int
  346. shutdown(int sockfd, int how)
  347. {
  348. int ret;
  349. if (ocall_shutdown(&ret, sockfd, how) != SGX_SUCCESS) {
  350. TRACE_OCALL_FAIL();
  351. return -1;
  352. }
  353. if (ret == -1)
  354. errno = get_errno();
  355. return ret;
  356. }
  357. int
  358. os_socket_accept(bh_socket_t server_sock, bh_socket_t *sock, void *addr,
  359. unsigned int *addrlen)
  360. {
  361. struct sockaddr addr_tmp;
  362. unsigned int len = sizeof(struct sockaddr);
  363. if (ocall_accept(sock, server_sock, &addr_tmp, &len, len) != SGX_SUCCESS) {
  364. TRACE_OCALL_FAIL();
  365. return -1;
  366. }
  367. if (*sock < 0) {
  368. errno = get_errno();
  369. return BHT_ERROR;
  370. }
  371. return BHT_OK;
  372. }
  373. int
  374. os_socket_bind(bh_socket_t socket, const char *host, int *port)
  375. {
  376. struct sockaddr_in addr;
  377. struct linger ling;
  378. unsigned int socklen;
  379. int ret;
  380. assert(host);
  381. assert(port);
  382. ling.l_onoff = 1;
  383. ling.l_linger = 0;
  384. if (ocall_fcntl_long(&ret, socket, F_SETFD, FD_CLOEXEC) != SGX_SUCCESS) {
  385. TRACE_OCALL_FAIL();
  386. return -1;
  387. }
  388. if (ret < 0) {
  389. goto fail;
  390. }
  391. if (ocall_setsockopt(&ret, socket, SOL_SOCKET, SO_LINGER, &ling,
  392. sizeof(ling))
  393. != SGX_SUCCESS) {
  394. TRACE_OCALL_FAIL();
  395. return -1;
  396. }
  397. if (ret < 0) {
  398. goto fail;
  399. }
  400. addr.sin_addr.s_addr = inet_addr(host);
  401. addr.sin_port = htons(*port);
  402. addr.sin_family = AF_INET;
  403. if (ocall_bind(&ret, socket, &addr, sizeof(addr)) != SGX_SUCCESS) {
  404. TRACE_OCALL_FAIL();
  405. return -1;
  406. }
  407. if (ret < 0) {
  408. goto fail;
  409. }
  410. socklen = sizeof(addr);
  411. if (ocall_getsockname(&ret, socket, (void *)&addr, &socklen, socklen)
  412. != SGX_SUCCESS) {
  413. TRACE_OCALL_FAIL();
  414. return -1;
  415. }
  416. if (ret == -1) {
  417. goto fail;
  418. }
  419. *port = ntohs(addr.sin_port);
  420. return BHT_OK;
  421. fail:
  422. errno = get_errno();
  423. return BHT_ERROR;
  424. }
  425. int
  426. os_socket_close(bh_socket_t socket)
  427. {
  428. int ret;
  429. if (ocall_close(&ret, socket) != SGX_SUCCESS) {
  430. TRACE_OCALL_FAIL();
  431. return -1;
  432. }
  433. if (ret == -1)
  434. errno = get_errno();
  435. return ret;
  436. }
  437. int
  438. os_socket_connect(bh_socket_t socket, const char *addr, int port)
  439. {
  440. struct sockaddr_in addr_in = { 0 };
  441. socklen_t addr_len = sizeof(struct sockaddr_in);
  442. int ret = 0;
  443. if ((ret = textual_addr_to_sockaddr(addr, port, &addr_in)) < 0) {
  444. return ret;
  445. }
  446. if (ocall_connect(&ret, socket, &addr_in, addr_len) != SGX_SUCCESS) {
  447. TRACE_OCALL_FAIL();
  448. return -1;
  449. }
  450. if (ret == -1)
  451. errno = get_errno();
  452. return ret;
  453. }
  454. int
  455. os_socket_create(bh_socket_t *sock, bool is_ipv4, bool is_tcp)
  456. {
  457. int af;
  458. if (!sock) {
  459. return BHT_ERROR;
  460. }
  461. if (is_ipv4) {
  462. af = AF_INET;
  463. }
  464. else {
  465. errno = ENOSYS;
  466. return BHT_ERROR;
  467. }
  468. if (is_tcp) {
  469. if (ocall_socket(sock, af, SOCK_STREAM, IPPROTO_TCP) != SGX_SUCCESS) {
  470. TRACE_OCALL_FAIL();
  471. return -1;
  472. }
  473. }
  474. else {
  475. if (ocall_socket(sock, af, SOCK_DGRAM, 0) != SGX_SUCCESS) {
  476. TRACE_OCALL_FAIL();
  477. return -1;
  478. }
  479. }
  480. if (*sock == -1) {
  481. errno = get_errno();
  482. return BHT_ERROR;
  483. }
  484. return BHT_OK;
  485. }
  486. int
  487. os_socket_inet_network(bool is_ipv4, const char *cp, bh_ip_addr_buffer_t *out)
  488. {
  489. if (!cp)
  490. return BHT_ERROR;
  491. if (is_ipv4) {
  492. if (inet_pton(AF_INET, cp, &out->ipv4) != 1) {
  493. return BHT_ERROR;
  494. }
  495. /* Note: ntohl(INADDR_NONE) == INADDR_NONE */
  496. out->ipv4 = ntohl(out->ipv4);
  497. }
  498. else {
  499. if (inet_pton(AF_INET6, cp, out->ipv6) != 1) {
  500. return BHT_ERROR;
  501. }
  502. for (int i = 0; i < 8; i++) {
  503. out->ipv6[i] = ntohs(out->ipv6[i]);
  504. }
  505. }
  506. return BHT_OK;
  507. }
  508. int
  509. os_socket_listen(bh_socket_t socket, int max_client)
  510. {
  511. int ret;
  512. if (ocall_listen(&ret, socket, max_client) != SGX_SUCCESS) {
  513. TRACE_OCALL_FAIL();
  514. return -1;
  515. }
  516. if (ret == -1)
  517. errno = get_errno();
  518. return ret;
  519. }
  520. int
  521. os_socket_recv(bh_socket_t socket, void *buf, unsigned int len)
  522. {
  523. int ret;
  524. if (ocall_recv(&ret, socket, buf, len, 0) != SGX_SUCCESS) {
  525. errno = ENOSYS;
  526. return -1;
  527. }
  528. if (ret == -1)
  529. errno = get_errno();
  530. return ret;
  531. }
  532. int
  533. os_socket_recv_from(bh_socket_t socket, void *buf, unsigned int len, int flags,
  534. bh_sockaddr_t *src_addr)
  535. {
  536. errno = ENOSYS;
  537. return BHT_ERROR;
  538. }
  539. int
  540. os_socket_send(bh_socket_t socket, const void *buf, unsigned int len)
  541. {
  542. int ret;
  543. if (ocall_send(&ret, socket, buf, len, 0) != SGX_SUCCESS) {
  544. errno = ENOSYS;
  545. return -1;
  546. }
  547. if (ret == -1)
  548. errno = get_errno();
  549. return ret;
  550. }
  551. int
  552. os_socket_send_to(bh_socket_t socket, const void *buf, unsigned int len,
  553. int flags, const bh_sockaddr_t *dest_addr)
  554. {
  555. errno = ENOSYS;
  556. return BHT_ERROR;
  557. }
  558. int
  559. os_socket_shutdown(bh_socket_t socket)
  560. {
  561. return shutdown(socket, O_RDWR);
  562. }
  563. int
  564. os_socket_addr_resolve(const char *host, const char *service,
  565. uint8_t *hint_is_tcp, uint8_t *hint_is_ipv4,
  566. bh_addr_info_t *addr_info, size_t addr_info_size,
  567. size_t *max_info_size)
  568. {
  569. errno = ENOSYS;
  570. return BHT_ERROR;
  571. }
  572. int
  573. os_socket_addr_local(bh_socket_t socket, bh_sockaddr_t *sockaddr)
  574. {
  575. errno = ENOSYS;
  576. return BHT_ERROR;
  577. }
  578. int
  579. os_socket_addr_remote(bh_socket_t socket, bh_sockaddr_t *sockaddr)
  580. {
  581. errno = ENOSYS;
  582. return BHT_ERROR;
  583. }
  584. int
  585. os_socket_set_send_timeout(bh_socket_t socket, uint64 timeout_us)
  586. {
  587. errno = ENOSYS;
  588. return BHT_ERROR;
  589. }
  590. int
  591. os_socket_get_send_timeout(bh_socket_t socket, uint64 *timeout_us)
  592. {
  593. errno = ENOSYS;
  594. return BHT_ERROR;
  595. }
  596. int
  597. os_socket_set_recv_timeout(bh_socket_t socket, uint64 timeout_us)
  598. {
  599. errno = ENOSYS;
  600. return BHT_ERROR;
  601. }
  602. int
  603. os_socket_get_recv_timeout(bh_socket_t socket, uint64 *timeout_us)
  604. {
  605. errno = ENOSYS;
  606. return BHT_ERROR;
  607. }
  608. int
  609. os_socket_set_send_buf_size(bh_socket_t socket, size_t bufsiz)
  610. {
  611. errno = ENOSYS;
  612. return BHT_ERROR;
  613. }
  614. int
  615. os_socket_get_send_buf_size(bh_socket_t socket, size_t *bufsiz)
  616. {
  617. errno = ENOSYS;
  618. return BHT_ERROR;
  619. }
  620. int
  621. os_socket_set_recv_buf_size(bh_socket_t socket, size_t bufsiz)
  622. {
  623. errno = ENOSYS;
  624. return BHT_ERROR;
  625. }
  626. int
  627. os_socket_get_recv_buf_size(bh_socket_t socket, size_t *bufsiz)
  628. {
  629. errno = ENOSYS;
  630. return BHT_ERROR;
  631. }
  632. int
  633. os_socket_set_keep_alive(bh_socket_t socket, bool is_enabled)
  634. {
  635. errno = ENOSYS;
  636. return BHT_ERROR;
  637. }
  638. int
  639. os_socket_get_keep_alive(bh_socket_t socket, bool *is_enabled)
  640. {
  641. errno = ENOSYS;
  642. return BHT_ERROR;
  643. }
  644. int
  645. os_socket_set_reuse_addr(bh_socket_t socket, bool is_enabled)
  646. {
  647. errno = ENOSYS;
  648. return BHT_ERROR;
  649. }
  650. int
  651. os_socket_get_reuse_addr(bh_socket_t socket, bool *is_enabled)
  652. {
  653. errno = ENOSYS;
  654. return BHT_ERROR;
  655. }
  656. int
  657. os_socket_set_reuse_port(bh_socket_t socket, bool is_enabled)
  658. {
  659. errno = ENOSYS;
  660. return BHT_ERROR;
  661. }
  662. int
  663. os_socket_get_reuse_port(bh_socket_t socket, bool *is_enabled)
  664. {
  665. errno = ENOSYS;
  666. return BHT_ERROR;
  667. }
  668. int
  669. os_socket_set_linger(bh_socket_t socket, bool is_enabled, int linger_s)
  670. {
  671. errno = ENOSYS;
  672. return BHT_ERROR;
  673. }
  674. int
  675. os_socket_get_linger(bh_socket_t socket, bool *is_enabled, int *linger_s)
  676. {
  677. errno = ENOSYS;
  678. return BHT_ERROR;
  679. }
  680. int
  681. os_socket_set_tcp_no_delay(bh_socket_t socket, bool is_enabled)
  682. {
  683. errno = ENOSYS;
  684. return BHT_ERROR;
  685. }
  686. int
  687. os_socket_get_tcp_no_delay(bh_socket_t socket, bool *is_enabled)
  688. {
  689. errno = ENOSYS;
  690. return BHT_ERROR;
  691. }
  692. int
  693. os_socket_set_tcp_quick_ack(bh_socket_t socket, bool is_enabled)
  694. {
  695. errno = ENOSYS;
  696. return BHT_ERROR;
  697. }
  698. int
  699. os_socket_get_tcp_quick_ack(bh_socket_t socket, bool *is_enabled)
  700. {
  701. errno = ENOSYS;
  702. return BHT_ERROR;
  703. }
  704. int
  705. os_socket_set_tcp_keep_idle(bh_socket_t socket, uint32 time_s)
  706. {
  707. errno = ENOSYS;
  708. return BHT_ERROR;
  709. }
  710. int
  711. os_socket_get_tcp_keep_idle(bh_socket_t socket, uint32 *time_s)
  712. {
  713. errno = ENOSYS;
  714. return BHT_ERROR;
  715. }
  716. int
  717. os_socket_set_tcp_keep_intvl(bh_socket_t socket, uint32 time_s)
  718. {
  719. errno = ENOSYS;
  720. return BHT_ERROR;
  721. }
  722. int
  723. os_socket_get_tcp_keep_intvl(bh_socket_t socket, uint32 *time_s)
  724. {
  725. errno = ENOSYS;
  726. return BHT_ERROR;
  727. }
  728. int
  729. os_socket_set_tcp_fastopen_connect(bh_socket_t socket, bool is_enabled)
  730. {
  731. errno = ENOSYS;
  732. return BHT_ERROR;
  733. }
  734. int
  735. os_socket_get_tcp_fastopen_connect(bh_socket_t socket, bool *is_enabled)
  736. {
  737. errno = ENOSYS;
  738. return BHT_ERROR;
  739. }
  740. int
  741. os_socket_set_ip_multicast_loop(bh_socket_t socket, bool ipv6, bool is_enabled)
  742. {
  743. errno = ENOSYS;
  744. return BHT_ERROR;
  745. }
  746. int
  747. os_socket_get_ip_multicast_loop(bh_socket_t socket, bool ipv6, bool *is_enabled)
  748. {
  749. errno = ENOSYS;
  750. return BHT_ERROR;
  751. }
  752. int
  753. os_socket_set_ip_add_membership(bh_socket_t socket,
  754. bh_ip_addr_buffer_t *imr_multiaddr,
  755. uint32_t imr_interface, bool is_ipv6)
  756. {
  757. errno = ENOSYS;
  758. return BHT_ERROR;
  759. }
  760. int
  761. os_socket_set_ip_drop_membership(bh_socket_t socket,
  762. bh_ip_addr_buffer_t *imr_multiaddr,
  763. uint32_t imr_interface, bool is_ipv6)
  764. {
  765. errno = ENOSYS;
  766. return BHT_ERROR;
  767. }
  768. int
  769. os_socket_set_ip_ttl(bh_socket_t socket, uint8_t ttl_s)
  770. {
  771. errno = ENOSYS;
  772. return BHT_ERROR;
  773. }
  774. int
  775. os_socket_get_ip_ttl(bh_socket_t socket, uint8_t *ttl_s)
  776. {
  777. errno = ENOSYS;
  778. return BHT_ERROR;
  779. }
  780. int
  781. os_socket_set_ip_multicast_ttl(bh_socket_t socket, uint8_t ttl_s)
  782. {
  783. errno = ENOSYS;
  784. return BHT_ERROR;
  785. }
  786. int
  787. os_socket_get_ip_multicast_ttl(bh_socket_t socket, uint8_t *ttl_s)
  788. {
  789. errno = ENOSYS;
  790. return BHT_ERROR;
  791. }
  792. int
  793. os_socket_set_ipv6_only(bh_socket_t socket, bool option)
  794. {
  795. errno = ENOSYS;
  796. return BHT_ERROR;
  797. }
  798. int
  799. os_socket_get_ipv6_only(bh_socket_t socket, bool *option)
  800. {
  801. errno = ENOSYS;
  802. return BHT_ERROR;
  803. }
  804. int
  805. os_socket_set_broadcast(bh_socket_t socket, bool is_enabled)
  806. {
  807. errno = ENOSYS;
  808. return BHT_ERROR;
  809. }
  810. int
  811. os_socket_get_broadcast(bh_socket_t socket, bool *is_enabled)
  812. {
  813. errno = ENOSYS;
  814. return BHT_ERROR;
  815. }
  816. #endif