1 #include "private-libwebsockets.h"
4 * included from libwebsockets.c for MBED3 builds
5 * MBED3 is an "OS" for very small embedded systems.
6 * He doesn't have Posix semantics or apis.
7 * But he has things like TCP sockets.
10 unsigned long long time_in_microseconds(void)
15 LWS_VISIBLE int lws_get_random(struct lws_context *context, void *buf, int len)
18 unsigned char *b = (unsigned char *)buf;
28 * MBED3 does not have a 'kernel' which takes copies of what userland wants
29 * to send. The user application must hold the tx buffer until it is informed
30 * that send of the user buffer was complete.
32 * So as soon as you send something the pipe is globally choked.
34 * There is no concept of additional sent things being maybe acceptable.
35 * You can send one thing up to 64KB at a time and may not try to send
36 * anything else until that is completed.
38 * You can send things on other sockets, but they cannot complete until they
39 * get their turn at the network device.
42 LWS_VISIBLE int lws_send_pipe_choked(struct lws *wsi)
45 struct lws_pollfd fds;
47 /* treat the fact we got a truncated send pending as if we're choked */
55 if (poll(&fds, 1, 0) != 1)
58 if ((fds.revents & POLLOUT) == 0)
61 /* okay to send another packet without blocking */
68 lws_poll_listen_fd(struct lws_pollfd *fd)
75 * lws_cancel_service() - Cancel servicing of pending websocket activity
76 * @context: Websocket context
78 * This function let a call to lws_service() waiting for a timeout
81 * There is no poll() in MBED3, he will fire callbacks when he feels like
85 lws_cancel_service(struct lws_context *context)
91 lws_cancel_service_pt(struct lws *wsi)
96 LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
98 printf("%d: %s", level, line);
102 lws_plat_set_socket_options(struct lws_context *context, lws_sockfd_type fd)
110 lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
116 lws_plat_context_early_init(void)
122 lws_plat_context_early_destroy(struct lws_context *context)
128 lws_plat_context_late_destroy(struct lws_context *context)
135 lws_plat_service_periodic(struct lws_context *context)
140 LWS_VISIBLE const char *
141 lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt)
147 return "unsupported";
151 insert_wsi(struct lws_context *context, struct lws *wsi)
160 delete_from_fd(struct lws_context *context, lws_sockfd_type fd)
168 static lws_filefd_type
169 _lws_plat_file_open(struct lws *wsi, const char *filename,
170 unsigned long *filelen, int flags)
180 _lws_plat_file_close(struct lws *wsi, lws_filefd_type fd)
188 _lws_plat_file_seek_cur(struct lws *wsi, lws_filefd_type fd, long offset)
198 _lws_plat_file_read(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
199 unsigned char *buf, unsigned long len)
211 _lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
212 unsigned char *buf, unsigned long len)
224 lws_plat_init(struct lws_context *context,
225 struct lws_context_creation_info *info)
229 context->fops.open = _lws_plat_file_open;
230 context->fops.close = _lws_plat_file_close;
231 context->fops.seek_cur = _lws_plat_file_seek_cur;
232 context->fops.read = _lws_plat_file_read;
233 context->fops.write = _lws_plat_file_write;