From f4f9abd17d2c0abc34ac3fd3c50c3c1ce35945c8 Mon Sep 17 00:00:00 2001 From: com Date: Sun, 7 Jul 2024 12:14:00 +0800 Subject: [PATCH 01/34] up --- crt/crt_assert.hpp | 30 +++++++ crt/crt_error.h | 24 ----- crt/crt_event.h | 50 ++++++----- stdcrt/event/compat_event.c | 43 ++++----- stdcrt/event/compat_event_epoll.c | 23 +++-- stdcrt/event/compat_event_iocp.c | 30 +++---- stdcrt/event/compat_event_util.c | 64 ++++++++++--- stdcrt/event/compat_event_util.h | 143 ++++++++++++++++++++---------- stdcrt_test/main.c | 4 +- stdcrt_test/test_oper.c | 28 ++---- stdcrt_test/test_timer.c | 2 +- 11 files changed, 265 insertions(+), 176 deletions(-) diff --git a/crt/crt_assert.hpp b/crt/crt_assert.hpp index db6652b6..51af1abe 100644 --- a/crt/crt_assert.hpp +++ b/crt/crt_assert.hpp @@ -2,6 +2,36 @@ #define _CRT_ASSERT_HPP_ #include +#include +// this linux kernel if +// #define likely(x) __builtin_expect(!!(x), 1) +// #define unlikely(x) __builtin_expect(!!(x), 0) + +#define rs_error(p, v) \ + do { \ + if ((int)(p)) \ + return v; \ + } while (0); + +#define rc_error(p, v) \ + do { \ + if (!(int)(p)) \ + return v; \ + } while (0); + +#define rc_return(p) \ + do { \ + if (!(int)(p)) \ + return; \ + } while (0); + +#define rc_error_continue(p) \ + if (!(int)(p)) \ + continue; + +#define rc_error_break(p) \ + if (!(int)(p)) \ + break; #endif diff --git a/crt/crt_error.h b/crt/crt_error.h index 6bb72f18..359444fe 100644 --- a/crt/crt_error.h +++ b/crt/crt_error.h @@ -9,30 +9,6 @@ extern "C" { #include -// this linux kernel if -// #define likely(x) __builtin_expect(!!(x), 1) -// #define unlikely(x) __builtin_expect(!!(x), 0) - -#define rc_error(p, v) \ - do { \ - if (!(int)(p)) \ - return v; \ - } while (0); - -#define rc_return(p) \ - do { \ - if (!(int)(p)) \ - return; \ - } while (0); - -#define rc_error_continue(p) \ - if (!(int)(p)) \ - continue; - -#define rc_error_break(p) \ - if (!(int)(p)) \ - break; - #if (TARGET_OS == OS_WIN) typedef DWORD crterr; #elif (TARGET_OS == OS_POSIX) diff --git a/crt/crt_event.h b/crt/crt_event.h index e203a5d0..c10e3470 100644 --- a/crt/crt_event.h +++ b/crt/crt_event.h @@ -17,6 +17,8 @@ typedef struct evoper_s evoper_t; typedef struct evsysop_s evsysop_t; typedef struct evloop_s evloop_t; typedef struct evaddr_s evaddr_t; +typedef unsigned char evevent; +typedef unsigned char evtype; typedef void* (*evmem_malloc)(evloop_t* loop, size_t count, size_t size); typedef int (*evmem_free)(evloop_t* loop, void* ptr); @@ -33,22 +35,21 @@ struct evaddr_s { }; #endif // !_evaddrptr_ -#define ev_type 0 +#define ev_none_type 0x00 // write,read,send,recv -#define ev_sock ev_type + 10 // tcp_sock_c -#define ev_sockpoll ev_type + 20 // tcp_sock_s +#define ev_sock 0xE1 // tcp_sock_c +#define ev_sockpoll 0xE2 // tcp_sock_s // recvfrom,sendto -#define ev_rsock ev_type + 11 // raw_sock_c -#define ev_rsockpoll ev_type + 21 // raw_sock_s +#define ev_rsock 0xE3 // raw_sock_c +#define ev_rsockpoll 0xE4 // raw_sock_s // recvfrom,sendto -#define ev_usock ev_type + 12 // udp_sock_c -#define ev_usockpoll ev_type + 22 // udp_sock_s +#define ev_usock 0xE5 // udp_sock_c +#define ev_usockpoll 0xE6 // udp_sock_s //system -#define ev_system 2000 -#define ev_thread ev_system + 11 -#define ev_signal ev_system + 21 -#define ev_child ev_system + 31 -#define ev_time ev_system + 41 +#define ev_thread 0xA1 +#define ev_signal 0xA2 +#define ev_child 0xA3 +#define ev_time 0xA4 #ifndef op_ev_none #define op_ev_none 0x00 @@ -62,26 +63,27 @@ struct evaddr_s { #define op_ev_write 0x20 #endif // !op_ev_write +#ifndef op_ev_timer +#define op_ev_timer 0x30 +#endif // !op_ev_timer + #ifndef op_ev_open #define op_ev_open 0x40 #endif // !op_ev_open #ifndef op_ev_connect -#define op_ev_connect 0x80 +#define op_ev_connect 0x50 #endif // !op_ev_connect -#ifndef op_ev_timeout -#define op_ev_timeout 0x10 -#endif // !op_ev_timeout - -#ifndef op_ev_closed -#define op_ev_closed 0x20 -#endif // !op_ev_closed - #ifndef op_ev_accept -#define op_ev_accept 0x40 +#define op_ev_accept 0x60 #endif // !op_ev_accept +#ifndef op_ev_close +#define op_ev_close 0x70 +#endif // !op_ev_close + + /* When libevent tim&es out, The while loop takes a del timer from the top of the heap once -- @@ -106,8 +108,8 @@ int evoper_bind_sock(evoper_t* oper, _sock_t sock); int evoper_get_sock(evoper_t* oper, _sock_t* sock); int evoper_bind_fd(evoper_t* oper, _fd_t fd); int evoper_get_fd(evoper_t* oper, _fd_t* fd); -int evoper_bind_type(evoper_t* oper, int type); -int evoper_get_type(evoper_t* oper, int* type); +int evoper_bind_type(evoper_t* oper, evtype type); +int evoper_get_type(evoper_t* oper, evtype* type); int evoper_bind_evloop(evoper_t* oper, evloop_t* loop); int evoper_get_evloop(evoper_t* oper, evloop_t** evloop); int evoper_sock(evoper_t* oper); diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index 14723ac6..e7b60b07 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -1,5 +1,6 @@ #include #include "compat_event_util.h" + #if (TARGET_OS == OS_WIN) #include "compat_event_iocp.h" #elif (TARGET_OS == OS_POSIX) @@ -8,19 +9,19 @@ #include "compat_event_kqueue.h" #endif -static int evloop_sysop_handler(int err, crterr code, evoper_t* oper, evoper_t* oper_s, short event) +static int evloop_sysop_handler(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) { int rc = 0; - if (op_ev_accept & event) { - oper->handler(err, oper_s, INVALID_SOCKET, event); - } - if (op_ev_connect & event) { - + if (oper->c == op_ev_opening && (op == op_ev_opening)) { + oper->handler(err, oper_s, INVALID_SOCKET, op_ev_open); + } else if (oper->c == op_ev_closeing && (op == op_ev_closeing)) { + oper->handler(err, oper_s, INVALID_SOCKET, op_ev_close); + } else if (oper->a == op_ev_accepting && (op == op_ev_accepting)) { + oper->handler(err, oper_s, INVALID_SOCKET, op_ev_accept); + } else if (oper->s == op_ev_connecting && (op == op_ev_connecting)) { // win iocp https://learn.microsoft.com/zh-cn/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex - // int res = err == 0 ? S_SUCCESS : S_ERROR; - if (evoper_sock_connected(oper) == S_SUCCESS) - oper->handler(err, oper, -1, event); + oper->handler(err, oper, -1, op_ev_connect); else { logi("connect error"); } @@ -112,16 +113,16 @@ int evoper_get_fd(evoper_t* oper, _fd_t* fd) *fd = oper->fd; return S_SUCCESS; } -int evoper_bind_type(evoper_t* oper, int type) +int evoper_bind_type(evoper_t* oper, evtype type) { rc_error(oper != NULL, S_ERROR); - oper->type = type; + oper->t = type; return S_SUCCESS; } -int evoper_get_type(evoper_t* oper, int* type) +int evoper_get_type(evoper_t* oper, evtype* type) { rc_error(oper != NULL, S_ERROR); - *type = oper->type; + *type = oper->t; return S_SUCCESS; } int evoper_bind_evloop(evoper_t* oper, evloop_t* loop) @@ -321,7 +322,8 @@ int evloop_poll(evoper_t* oper, int count) rc_error(evsel->op_poll != NULL, S_ERROR); oper->accept_count = count; - oper->accept = 1; + evoper_accept_op(oper, op_ev_accepting); + return evsel->op_poll(loop, oper); } int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) @@ -334,13 +336,14 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_connect != NULL, S_ERROR); + rs_error(oper->c == op_ev_connected, S_COMPLETED) + + evoper_connect_op(oper, op_ev_connecting); - oper->connect = 1; rc = evsel->op_add_connect(loop, oper, addr, tv); - - if (rc == S_PENDING) - return S_SUCCESS; - else if (rc == S_COMPLETED) + rs_error(rc == S_PENDING, S_SUCCESS) + + if (rc == S_COMPLETED) oper->handler(S_SUCCESS, oper, oper->sock, op_ev_connect); return rc; @@ -470,7 +473,7 @@ static int cmd_poll_time(evloop_t* loop, evoper_t* oper) op->op_dispatch(loop, op_cmd_poll, ms); rc_error(oper->handler != NULL, S_ERROR); - oper->handler(ms > 0 ? S_SUCCESS : S_ERROR, oper, oper->sock, oper->mask); + oper->handler(ms > 0 ? S_SUCCESS : S_ERROR, oper, oper->sock, op_ev_timer); return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index a9caee5d..e256d472 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -297,21 +297,20 @@ int epoll_event_complete(evloop_t* loop, crterr err, epoll_op_t* base, evoper_t* int rc = S_ERROR; rc_error(oper != NULL, S_ERROR); - if (oper->accept && (ev & op_ev_read)) - rc = complete_sock_accept(loop, S_SUCCESS, err, 10, oper, NULL, base->ev); + if (oper->a == op_ev_accepting && (ev == op_ev_readed)) + rc = complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); - if (oper->connect && (ev & op_ev_write)) + if (oper->c == op_ev_connecting && (ev == op_ev_writed)) rc = complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); - if (oper->closed && (ev & op_ev_closed)) + if (oper->s == op_ev_closeing || (ev == op_ev_closed)) rc = complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - - if (oper->r.active && (ev & op_ev_read)) { + if (oper->r == op_ev_reading && (ev & op_ev_readed)) { } - if (oper->w.active && (ev & op_ev_read)) { + if (oper->w == op_ev_writeing && (ev & op_ev_writed)) { } @@ -345,16 +344,16 @@ static int epoll_op_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) rc_error_continue(oper->fd != INVALID_SOCKET) if (events & EPOLLERR) { - ev = op_ev_read | op_ev_write; + ev = op_ev_readed | op_ev_writed; } else if ((events & EPOLLHUP) && !(events & EPOLLRDHUP)) { - ev = op_ev_read | op_ev_write; + ev = op_ev_readed | op_ev_writed; } else { if (events & EPOLLIN) - ev |= op_ev_read; + ev = op_ev_readed; if (events & EPOLLOUT) - ev |= op_ev_write; + ev = op_ev_writed; if (events & EPOLLRDHUP) - ev |= op_ev_closed; + ev = op_ev_closed; } rc_error_continue(ev != 0) diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index 56215a96..6e77ca3b 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -36,7 +36,7 @@ static int wsasock_bind_iocp(iocp_op_t* base, wsasock* sk) rc_error(sk != NULL, S_ERROR); rc_error(sk->oper != NULL, S_ERROR); evoper_t* oper = sk->oper; - HANDLE ret = CreateIoCompletionPort((HANDLE)oper->sock, base->hiocp, (ULONG_PTR)&oper->type, 0); + HANDLE ret = CreateIoCompletionPort((HANDLE)oper->sock, base->hiocp, (ULONG_PTR)&oper->t, 0); rc_error(ret != NULL, S_ERROR); return S_SUCCESS; } @@ -50,7 +50,7 @@ static lpwsasock wsasock_create(evloop_t* loop) rc_error(oper != NULL, NULL); oper->sock = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, 0, WSA_FLAG_OVERLAPPED); - oper->type = ev_sock; + evoper_bind_type(oper, ev_sock); lpevoper_ov obj = (lpevoper_ov)loop->mm_malloc(loop, 1, sizeof(evoper_ov)); rc_error(obj != NULL, NULL); @@ -166,7 +166,7 @@ static int poll_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, D rc_error(sock->oper != NULL, S_ERROR); rc_error(base->ev != NULL, S_ERROR); win32_sock_accpet_ctx(sock->accept_oper, sock->oper); - return complete_sock_accept(loop, S_SUCCESS, err, 10, sock->accept_oper, sock->oper, base->ev); + return complete_sock_accept(loop, S_SUCCESS, err, sock->accept_oper, sock->oper, base->ev); } static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, DWORD err, DWORD bytes) { @@ -176,7 +176,7 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, D oper = evoper_ov->ptr; rc_error(oper != NULL, S_ERROR); - if (oper->connect) { + if (oper->c == op_ev_connecting) { int conn_error = S_SUCCESS; @@ -194,10 +194,10 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, D complete_sock_connect(loop, conn_error, err, oper, base->ev); - } else if (oper->w.active) { - base->ev(oper->w.error, err, oper, NULL, op_ev_write); - } else if (oper->r.active) { - base->ev(oper->r.error, err, oper, NULL, op_ev_read); + } else if (oper->w == op_ev_writeing) { + base->ev(0, err, oper, NULL, op_ev_writeing); + } else if (oper->r == op_ev_reading) { + base->ev(0, err, oper, NULL, op_ev_writeing); } return S_SUCCESS; } @@ -268,7 +268,7 @@ static int iocp_op_alloc_evoper(evloop_t* loop, evoper_t* oper) { iocp_op_t* base = (iocp_op_t*)evloop_evbase(loop); - HANDLE hRet = CreateIoCompletionPort(oper->fd, base->hiocp, oper->type, 0); + HANDLE hRet = CreateIoCompletionPort(oper->fd, base->hiocp, oper->t, 0); if (hRet == NULL) { crterr err = crt_geterror(); @@ -296,8 +296,8 @@ int iocp_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; - if (oper->type == ev_sock) { - if (oper->r.active) { + if (oper->t == ev_sock) { + if (oper->r) { // rc = win32_sock_read(oper); } } @@ -306,8 +306,8 @@ int iocp_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) int iocp_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; - if (oper->type == ev_sock) { - if (oper->w.active) { + if (oper->t == ev_sock) { + if (oper->w) { // rc = win32_sock_read(oper); } } @@ -338,7 +338,7 @@ int iocp_op_poll(evloop_t* loop, evoper_t* oper) { iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - rc_error(oper->type == ev_sockpoll, S_ERROR); + rc_error(oper->t == ev_sockpoll, S_ERROR); lpwsasock sk = wsasock_create(loop); rc_error(sk != NULL, S_ERROR); rc_error(wsasock_bind_iocp(base, sk) == S_SUCCESS, S_ERROR) @@ -346,7 +346,7 @@ int iocp_op_poll(evloop_t* loop, evoper_t* oper) } int icop_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { - rc_error(oper->type == ev_sock, S_ERROR); + rc_error(oper->t == ev_sock, S_ERROR); return win32_sock_connect(oper, addr, tv); } int icop_op_del_connect(evloop_t* loop, evoper_t* oper) diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index b2b64a7b..63f365c4 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -121,6 +121,42 @@ void* evoper_private(evoper_t* oper) rc_error(oper != NULL, NULL); return oper->private; } +int evoper_state_op(evoper_t* oper, unsigned char op) +{ + rc_error(oper != NULL, S_ERROR); + oper->s = op; + return S_SUCCESS; +} +int evoper_connect_op(evoper_t* oper, unsigned char op) +{ + rc_error(oper != NULL, S_ERROR); + oper->c = op; + return S_SUCCESS; +} +int evoper_accept_op(evoper_t* oper, unsigned char op) +{ + rc_error(oper != NULL, S_ERROR); + oper->a = op; + return S_SUCCESS; +} +int evoper_accept_size(evoper_t* oper, unsigned int count) +{ + rc_error(oper != NULL, S_ERROR); + oper->accept_count = count; + return S_SUCCESS; +} +int evoper_read_op(evoper_t* oper, unsigned char op) +{ + rc_error(oper != NULL, S_ERROR); + oper->r = op; + return S_SUCCESS; +} +int evoper_write_op(evoper_t* oper, unsigned char op) +{ + rc_error(oper != NULL, S_ERROR); + oper->w = op; + return S_SUCCESS; +} int evoper_bind_private(evoper_t* oper, void* obj) { rc_error(oper != NULL, S_ERROR); @@ -158,18 +194,20 @@ int evoper_sock_connected(evoper_t* oper) #endif return rc; } -int complete_sock_accept(evloop_t* loop, int err, crterr code, int size, evoper_t* oper, evoper_t* oper_t, ev_op func) +int complete_sock_accept(evloop_t* loop, int err, crterr code, evoper_t* oper, evoper_t* oper_t, ev_op func) { - int i = 0; + unsigned int l = 0; rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); #if (TARGET_OS == OS_WIN) - oper->bind = 1; - func(err == 0 ? S_SUCCESS : S_ERROR, err, oper, oper_t, op_ev_accept); + //oper->bind = 1; + func(err == 0 ? S_SUCCESS : S_ERROR, err, oper, oper_t, op_ev_accepting); #else - for (i = 0; i < size; i++) { + unsigned int count = oper->accept_count; + + for (l = 0; l < count; l++) { struct sockaddr_in cliaddr; socklen_t clilen = sizeof(struct sockaddr_in); @@ -182,7 +220,7 @@ int complete_sock_accept(evloop_t* loop, int err, crterr code, int size, evoper_ rc_error_break(oper_s != NULL); evoper_assign_sock(oper_s, accept_sock); - func(S_SUCCESS, err, oper, oper_s, op_ev_accept); + func(S_SUCCESS, err, oper, oper_s, op_ev_accepting); } #endif return S_SUCCESS; @@ -192,9 +230,8 @@ int complete_sock_connect(evloop_t* loop, int err, crterr code, evoper_t* oper, rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - func(err, code, oper, NULL, op_ev_connect); - oper->connect = 0; - oper->connected = 1; + func(err, code, oper, NULL, op_ev_connecting); + evoper_connect_op(oper, op_ev_connected); return S_SUCCESS; } int complete_sock_close(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func) @@ -202,7 +239,8 @@ int complete_sock_close(evloop_t* loop, int err, crterr code, evoper_t* oper, ev rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - func(err, code, oper, NULL, op_ev_closed); + func(err, code, oper, NULL, op_ev_closeing); + evoper_state_op(oper, op_ev_closed); return S_SUCCESS; } int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func) @@ -210,7 +248,8 @@ int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_ rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - func(err, code, oper, NULL, op_ev_read); + func(err, code, oper, NULL, op_ev_reading); + evoper_read_op(oper, op_ev_readed); return S_SUCCESS; } int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func) @@ -218,7 +257,8 @@ int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - func(err, code, oper, NULL, op_ev_write); + func(err, code, oper, NULL, op_ev_writeing); + evoper_write_op(oper, op_ev_writed); return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index b6ef6823..0d845b3d 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -129,74 +129,114 @@ typedef struct evloop_nodes_s evloop_nodes_t; typedef struct evloop_clock_s evloop_clock_t; -typedef struct evop_action_s evop_action_t; -#ifndef ac_on -#define ac_on 1 -#endif // !ac_on +/* + * An active default event. The event type depends on interface: + * edge-triggered for kqueue, and modern epoll; + * level-triggered for old epoll, devpoll, pollset, poll, and select; + * oneshot for kqueue and eventport. + */ +#define op_ev_default 0x00 -#ifndef ac_off -#define ac_off 0 -#endif // !ac_off +/* A completely inactive event. */ +#define op_ev_inactive 0x02 +/* + * An event presents in the kernel but disabled after oneshot. + * Used by epoll. + */ +#define op_ev_disable 0x03 +/* + * An event is active in the kernel but blocked by application. + * Used by kqueue, epoll, eventport, devpoll, and pollset. + */ +#define op_ev_blocked 0x04 +/* + * An active oneshot event. + * Used by epoll, devpoll, pollset, poll, and select. + */ +#define op_ev_oneshot 0x05 +/* An active level-triggered event. Used by eventport. */ +#define op_ev_level 0x06 -struct evop_action_s { - // max 32 bits - unsigned active : 1; //active - unsigned cancel : 1; //cancel - unsigned disabled : 1; //auto r,w +#define op_ev_active 0xf0 - unsigned eof : 1; // - unsigned pending_eof : 1; // - - unsigned post : 1; //post event - unsigned ready : 1; //iocp epoll kqueue - unsigned timedout : 1; - unsigned timer_set : 1; - unsigned complete : 1; - unsigned error : 1; //error +#define op_ev_reading 0x01 +#define op_ev_readed 0x02 -#if (TARGET_OS == OS_MACH) - unsigned kq_vnode : 1; - unsigned kq_errno : 1; -#endif +#define op_ev_writeing 0x03 +#define op_ev_writed 0x04 -}; +#define op_ev_timering 0x05 +#define op_ev_timered 0x06 + +#define op_ev_opening 0x07 +#define op_ev_opened 0x08 + +#define op_ev_connecting 0x09 +#define op_ev_connected 0x0A + +#define op_ev_accepting 0x0B +#define op_ev_accepted 0x0C + +#define op_ev_closeing 0x0D +#define op_ev_closed 0x0E + +#ifndef ev_on +#define ev_on 0x01 +#endif // !ev_on + +#ifndef ev_off +#define ev_off 0x00 +#endif // !ev_off + +#ifndef ev_none +#define ev_none 0x00 +#endif // !ev_on + +#ifndef ev_bind +#define ev_bind 0x10 +#endif // !ev_bind + +#ifndef ev_eof +#define ev_eof 0x20 +#endif // !ev_eof + +#ifndef ev_pendingeof +#define ev_pendingeof 0x30 +#endif // !ev_pendingeof struct evoper_s { void* ctx; void* private; - evop_action_t r; - evop_action_t w; - - unsigned connect : 1; // connect - unsigned open : 1; // open - unsigned accept : 1; // accept - unsigned accept_alway; // accept_alway; - unsigned closed : 1; // oper_close - unsigned bind : 1; // bind evloop - unsigned connected : 1; - - ev_handler handler; - evloop_t* loop; - crt_msec msec; - unsigned int type; - unsigned int mask; - _heap_node_t node; + evtype t; + evevent o; + evevent r; + evevent w; + evevent c; + evevent a; + evevent s; // 1=bind evloop, 2=eof, 2=pending_eof, 3=close - int accept_count; - +#if (TARGET_OS == OS_MACH) + unsigned kq_vnode : 1; + unsigned kq_errno : 1; +#endif + unsigned int accept_count; union { _fd_t fd; _sock_t sock; }; -}; + _heap_node_t node; + ev_handler handler; + evloop_t* loop; + crt_msec msec; +}; -typedef int (*ev_op)(int err, crterr code, evoper_t* oper, evoper_t* accepet_oper, short event); +typedef int (*ev_op)(int err, crterr code, evoper_t* oper, evoper_t* accepet_oper, evevent op); struct evsysop_s { void* (*op_alloc)(evloop_t* loop, int size); @@ -262,12 +302,19 @@ void* evloop_sysop(evloop_t* loop); void* evoper_evbase(evoper_t* oper); void* evoper_private(evoper_t* oper); +int evoper_state_op(evoper_t* oper, unsigned char op); +int evoper_connect_op(evoper_t* oper, unsigned char op); +int evoper_accept_op(evoper_t* oper, unsigned char op); +int evoper_accept_size(evoper_t* oper, unsigned int count); +int evoper_read_op(evoper_t* oper, unsigned char op); +int evoper_write_op(evoper_t* oper, unsigned char op); + int evoper_bind_private(evoper_t* oper, void* obj); int evoper_assign_sock(evoper_t* oper, _sock_t sock); int evoper_sock_connect(evoper_t* oper, const evaddr_t* addr); int evoper_sock_connected(evoper_t* oper); -int complete_sock_accept(evloop_t* loop, int err, crterr code, int size, evoper_t* oper, evoper_t* oper_t, ev_op func); +int complete_sock_accept(evloop_t* loop, int err, crterr code, evoper_t* oper, evoper_t* oper_t, ev_op func); int complete_sock_connect(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func); int complete_sock_close(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func); int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func); diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index bb00c3ec..8f42249a 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -9,10 +9,12 @@ evloop_t* loop; void thread_proc2(void* ctx) { + sleep_time(7); + test_conn_oper(loop); while (1) { sleep_time(7); - test_conn_oper(loop); + } } diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index e18c4dab..ff698aa4 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -13,43 +13,33 @@ void test_init_evaddr() addr.len = s_strlen("127.0.0.1"); addr.port = 9000; } -int open_proc(int err, evoper_t* oper, _sock_t s, short event) +int evop_proc(int err, evoper_t* oper, _sock_t s, short event) { if (event == op_ev_connect) { - logi("open_connect %ld", err); - evloop_t* loop; - evoper_get_evloop(oper, &loop); - evloop_dealloc_evoper(loop, oper); + logi("open_connect %d", err); + }else if (event == op_ev_accept) { + logi("accept_connect %d", err); + } else if (event == op_ev_close) { + logi("clse_connect %d", err); } return S_SUCCESS; } -int accept_proc(int err, evoper_t* oper, _sock_t s, short event) -{ - logi("accept_connect %ld", err); - // new_oper.sock = s; - // new_oper.handler = open_proc; - //evloop_alloc_evoper(loop, new_oper); - return S_SUCCESS; -} - void test_accept_oper(evloop_t* loop) { evoper_alloc(&accept_oper, NULL, oper_alloc); evoper_pollsock(accept_oper, &addr, 1); evloop_alloc_evoper(loop, accept_oper); - evoper_bind_handler(accept_oper, accept_proc); - evloop_poll(accept_oper, 10); + evoper_bind_handler(accept_oper, evop_proc); + evloop_poll(accept_oper, 1); } void test_conn_oper(evloop_t* loop) { evoper_alloc(&oper, NULL, oper_alloc); evoper_sock(oper); - evoper_bind_handler(oper, open_proc); + evoper_bind_handler(oper, evop_proc); evloop_alloc_evoper(loop, oper); int rc = evloop_add_connect(oper, &addr, NULL); - - //printf("%d\n", rc); } \ No newline at end of file diff --git a/stdcrt_test/test_timer.c b/stdcrt_test/test_timer.c index 00c9f26b..fb01ff7a 100644 --- a/stdcrt_test/test_timer.c +++ b/stdcrt_test/test_timer.c @@ -16,7 +16,7 @@ int time_handler(int err, evoper_t* oper, _sock_t s, short event) ms = clockmsec - opermsec; - if (event == op_ev_timeout) { + if (event == op_ev_timer) { if (err == S_SUCCESS) { int* id = NULL; evoper_get_ctx(oper, (void**)&id); -- Gitee From 7288a635c9216d7b878ce511b769e5229e958359 Mon Sep 17 00:00:00 2001 From: com Date: Sun, 7 Jul 2024 13:11:46 +0800 Subject: [PATCH 02/34] up --- crt/crt_event.h | 2 +- stdcrt/compat_log.c | 20 ++++++++++++-- stdcrt/event/compat_event.c | 46 ++++++++++++++++++++++---------- stdcrt/event/compat_event_util.c | 12 +++++---- stdcrt/event/compat_event_util.h | 10 +++---- stdcrt_test/main.c | 11 ++++++-- stdcrt_test/test_oper.c | 2 +- stdcrt_test/test_timer.c | 11 +++----- 8 files changed, 77 insertions(+), 37 deletions(-) diff --git a/crt/crt_event.h b/crt/crt_event.h index c10e3470..cde11703 100644 --- a/crt/crt_event.h +++ b/crt/crt_event.h @@ -23,7 +23,7 @@ typedef unsigned char evtype; typedef void* (*evmem_malloc)(evloop_t* loop, size_t count, size_t size); typedef int (*evmem_free)(evloop_t* loop, void* ptr); typedef int (*evloop_handler)(evloop_t* loop, short event, void* ctx); -typedef int (*ev_handler)(int err, evoper_t* oper, _sock_t s, short event); +typedef int (*ev_handler)(int err, evoper_t* oper, evoper_t* oper_s, evevent event); #ifndef _evaddrptr_ diff --git a/stdcrt/compat_log.c b/stdcrt/compat_log.c index 79141617..625b3b7b 100644 --- a/stdcrt/compat_log.c +++ b/stdcrt/compat_log.c @@ -1,6 +1,6 @@ #include -#define LOG_FORMAT "[%s][%s][%d]==>" +#define LOG_FORMAT "[%s][%s][%s][%d]==>" #define LOG_PAGE_SIZE 1024 #ifdef __ANDROID__ @@ -18,9 +18,20 @@ static int _log_print(int proi, const char* tag, int line, const char* func, con int hmsglen = 0; int msglen = 0; + char tm[81] = {0x00}; + int rc; + rc = get_time_t(tm, 80); + rc_error(rc != S_ERROR, E_FAIL); + msg = (char*)heap_calloc(LOG_PAGE_SIZE, sizeof(char)); rc_error(msg != NULL, S_ERROR); - hmsglen = snprintf(msg, LOG_PAGE_SIZE, LOG_FORMAT, tag, func, line); + +#if (TARGET_OS == OS_WIN) + hmsglen = sprintf_s(msg, LOG_PAGE_SIZE, LOG_FORMAT, tag, tm, func, line); +#else + hmsglen = snprintf(msg, LOG_PAGE_SIZE, LOG_FORMAT, tag, tm, func, line); +#endif + if (hmsglen > 0 && hmsglen < LOG_PAGE_SIZE) { msglen = LOG_PAGE_SIZE - hmsglen; @@ -28,7 +39,12 @@ static int _log_print(int proi, const char* tag, int line, const char* func, con msglen = LOG_PAGE_SIZE; hmsglen = 0; } +#if (TARGET_OS == OS_WIN) + vsnprintf_s(msg + hmsglen, msglen, msglen, fmt, ap); +#else vsnprintf(msg + hmsglen, msglen, fmt, ap); +#endif + #ifdef __ANDROID__ __android_log_write(proi, "", msg); diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index e7b60b07..49d20ba9 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -12,20 +12,35 @@ static int evloop_sysop_handler(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) { int rc = 0; - if (oper->c == op_ev_opening && (op == op_ev_opening)) { - oper->handler(err, oper_s, INVALID_SOCKET, op_ev_open); - } else if (oper->c == op_ev_closeing && (op == op_ev_closeing)) { - oper->handler(err, oper_s, INVALID_SOCKET, op_ev_close); - } else if (oper->a == op_ev_accepting && (op == op_ev_accepting)) { - oper->handler(err, oper_s, INVALID_SOCKET, op_ev_accept); - } else if (oper->s == op_ev_connecting && (op == op_ev_connecting)) { - // win iocp https://learn.microsoft.com/zh-cn/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex + if (oper->o == op_ev_opening && (op == op_ev_opening)) { + oper->handler(err, oper, oper, op_ev_open); + } else if (oper->s == op_ev_closeing && (op == op_ev_closeing)) { + oper->handler(err, oper, oper, op_ev_close); + } else if (oper->c == op_ev_connecting && (op == op_ev_connecting)) { + if (evoper_sock_connected(oper) == S_SUCCESS) - oper->handler(err, oper, -1, op_ev_connect); + oper->handler(err, oper, oper, op_ev_connect); else { logi("connect error"); } + + } else if (oper->a == op_ev_accepting && (op == op_ev_accepting)) { + oper->handler(err, oper, oper_s, op_ev_accept); + } + + if (oper->o == op_ev_reading && (op == op_ev_reading)) { + oper->handler(err, oper, oper_s, op_ev_read); + } + + if (oper->o == op_ev_writeing && (op == op_ev_opening)) { + oper->handler(err, oper, oper_s, op_ev_write); } + + if (oper->t == ev_time && (op == op_ev_timering)) + { + oper->handler(err, oper, oper, op_ev_timer); + } + return S_SUCCESS; } static void* evmem_heap_malloc(evloop_t* loop, size_t count, size_t size) @@ -343,9 +358,11 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) rc = evsel->op_add_connect(loop, oper, addr, tv); rs_error(rc == S_PENDING, S_SUCCESS) - if (rc == S_COMPLETED) - oper->handler(S_SUCCESS, oper, oper->sock, op_ev_connect); - + if (rc == S_COMPLETED) { + evloop_sysop_handler(S_SUCCESS, 0, oper, oper, op_ev_connect); + //op_ev_connecting ==> op_ev_connected + evoper_connect_op(oper, op_ev_connected); + } return rc; } int evloop_del_connect(evoper_t* oper) @@ -472,8 +489,9 @@ static int cmd_poll_time(evloop_t* loop, evoper_t* oper) if (ms > 0) op->op_dispatch(loop, op_cmd_poll, ms); - rc_error(oper->handler != NULL, S_ERROR); - oper->handler(ms > 0 ? S_SUCCESS : S_ERROR, oper, oper->sock, op_ev_timer); + evloop_sysop_handler(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timering); + + return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index 63f365c4..ec1ad122 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -121,19 +121,19 @@ void* evoper_private(evoper_t* oper) rc_error(oper != NULL, NULL); return oper->private; } -int evoper_state_op(evoper_t* oper, unsigned char op) +int evoper_state_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); oper->s = op; return S_SUCCESS; } -int evoper_connect_op(evoper_t* oper, unsigned char op) +int evoper_connect_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); oper->c = op; return S_SUCCESS; } -int evoper_accept_op(evoper_t* oper, unsigned char op) +int evoper_accept_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); oper->a = op; @@ -145,13 +145,13 @@ int evoper_accept_size(evoper_t* oper, unsigned int count) oper->accept_count = count; return S_SUCCESS; } -int evoper_read_op(evoper_t* oper, unsigned char op) +int evoper_read_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); oper->r = op; return S_SUCCESS; } -int evoper_write_op(evoper_t* oper, unsigned char op) +int evoper_write_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); oper->w = op; @@ -185,6 +185,8 @@ int evoper_sock_connect(evoper_t* oper, const evaddr_t* addr) } int evoper_sock_connected(evoper_t* oper) { +//win iocp https://learn.microsoft.com/zh-cn/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex + int rc = S_ERROR; rc_error(oper != NULL, S_ERROR); #if (TARGET_OS == OS_WIN) diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 0d845b3d..34f7cfbc 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -302,12 +302,12 @@ void* evloop_sysop(evloop_t* loop); void* evoper_evbase(evoper_t* oper); void* evoper_private(evoper_t* oper); -int evoper_state_op(evoper_t* oper, unsigned char op); -int evoper_connect_op(evoper_t* oper, unsigned char op); -int evoper_accept_op(evoper_t* oper, unsigned char op); +int evoper_state_op(evoper_t* oper, evevent op); +int evoper_connect_op(evoper_t* oper, evevent op); +int evoper_accept_op(evoper_t* oper, evevent op); int evoper_accept_size(evoper_t* oper, unsigned int count); -int evoper_read_op(evoper_t* oper, unsigned char op); -int evoper_write_op(evoper_t* oper, unsigned char op); +int evoper_read_op(evoper_t* oper, evevent op); +int evoper_write_op(evoper_t* oper, evevent op); int evoper_bind_private(evoper_t* oper, void* obj); int evoper_assign_sock(evoper_t* oper, _sock_t sock); diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index 8f42249a..759e3a92 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -9,13 +9,16 @@ evloop_t* loop; void thread_proc2(void* ctx) { - sleep_time(7); + /* sleep_time(7); test_conn_oper(loop); while (1) { sleep_time(7); - } + }*/ + + + } int main(int argc, char* argv[]) @@ -38,6 +41,10 @@ int main(int argc, char* argv[]) rc = _thread_create(&thread2, thread_proc2, NULL); rc_error(rc == S_SUCCESS, S_ERROR); + + + test_timer(loop); + evloop_run(loop, 50000); uninit_sockenv(2, 2); diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index ff698aa4..fa732b65 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -13,7 +13,7 @@ void test_init_evaddr() addr.len = s_strlen("127.0.0.1"); addr.port = 9000; } -int evop_proc(int err, evoper_t* oper, _sock_t s, short event) +int evop_proc(int err, evoper_t* oper, evoper_t* oper_s, evevent event) { if (event == op_ev_connect) { logi("open_connect %d", err); diff --git a/stdcrt_test/test_timer.c b/stdcrt_test/test_timer.c index fb01ff7a..f4f68d49 100644 --- a/stdcrt_test/test_timer.c +++ b/stdcrt_test/test_timer.c @@ -1,27 +1,24 @@ #include #include "test.h" -int time_handler(int err, evoper_t* oper, _sock_t s, short event) +int time_handler(int err, evoper_t* oper, evoper_t* oper_s, evevent event) { evloop_t* evloop; - crt_msec ms = 0; crt_msec opermsec = 0; evoper_get_msec(oper, &opermsec); crt_msec clockmsec = 0; evoper_get_evloop(oper, &evloop); - evloop_get_clock(evloop, &clockmsec); - ms = clockmsec - opermsec; - - if (event == op_ev_timer) { if (err == S_SUCCESS) { + logi("timer %ld==%ld", clockmsec, opermsec); int* id = NULL; evoper_get_ctx(oper, (void**)&id); - // sleep_time(4); + sleep_time(4); } else { + logi("timer out %ld==%ld", clockmsec, opermsec); int* id = NULL; evoper_get_ctx(oper, (void**)&id); } -- Gitee From 5468348e5b871b2adb4e5eb6a0bfec17e1ad72c0 Mon Sep 17 00:00:00 2001 From: com Date: Wed, 10 Jul 2024 18:36:10 +0800 Subject: [PATCH 03/34] up --- crt/crt_common.hpp | 1 + crt/crt_sjson.h | 13 +++--- stdcrt/code/compat_sjson.c | 93 ++++++++++++++++++++++++++++++++++++- stdcrt/event/compat_event.c | 18 ++++--- stdcrt_test/main.c | 3 ++ stdcrt_test/test_timer.c | 2 +- uibase/uicontrolimpl.cpp | 12 ++--- 7 files changed, 121 insertions(+), 21 deletions(-) diff --git a/crt/crt_common.hpp b/crt/crt_common.hpp index ae631132..3aec6e44 100644 --- a/crt/crt_common.hpp +++ b/crt/crt_common.hpp @@ -145,6 +145,7 @@ typedef uint64_t uint64; // #define uint64 unsigned long long int #define fmt_i64d "%lld" +//"%" PRId64 #if defined(ANDROID) #define fmt_i64u "%lu" diff --git a/crt/crt_sjson.h b/crt/crt_sjson.h index c179e383..b8418c46 100644 --- a/crt/crt_sjson.h +++ b/crt/crt_sjson.h @@ -11,12 +11,13 @@ extern "C" { #define sjson_true S_SUCCESS #define sjson_invalid (0) -#define sjson_raw (1 << 0) -#define sjson_int (1 << 1) -#define sjson_double (1 << 2) -#define sjson_string (1 << 3) -#define sjson_array (1 << 4) -#define sjson_obj (1 << 5) +#define sjson_raw (1 << 0) +#define sjson_int64 (1 << 1) +#define sjson_int (1 << 2) +#define sjson_double (1 << 3) +#define sjson_string (1 << 4) +#define sjson_array (1 << 5) +#define sjson_obj (1 << 6) #define sjson_is_invalid(m) \ ((m->type & 0xFF) == sjson_invalid ? sjson_true : sjson_false) diff --git a/stdcrt/code/compat_sjson.c b/stdcrt/code/compat_sjson.c index a552bc59..ff9c7fe7 100644 --- a/stdcrt/code/compat_sjson.c +++ b/stdcrt/code/compat_sjson.c @@ -1,5 +1,5 @@ #include - +#include #define decimal_point_char '.' @@ -132,7 +132,10 @@ loop_end: if (number >= INT_MIN && number <= INT_MAX) { item->valueint = (int)number; item->type = sjson_int; - } + } else { + item->valueint64 = (int64)number; + item->type = sjson_int64; + } } @@ -198,6 +201,47 @@ static void update_offset(sjsonprintvptr buffer) buffer->offset += strlen((const char*)buffer_pointer); } +static int print_int64(sjsoncvptr item, sjsonprintvptr output_buffer) +{ + unsigned char* output_pointer = NULL; + int64 d = item->valueint64; + int length = 0; + size_t i = 0; + unsigned char number_buffer[41] = {0x00}; + if (output_buffer == NULL) { + return sjson_false; + } + + +#if (TARGET_OS == OS_WIN) + length = sprintf((char*)number_buffer, fmt_i64d, d); +#else + length = sprintf((char*)number_buffer, "%" PRId64, d); +#endif + + if (length < 0) { + return sjson_false; + } + + if (length > (int)(sizeof(number_buffer) - 1)) { + return sjson_false; + } + + output_pointer = ensure(output_buffer, (size_t)length); + if (output_pointer == NULL) { + return sjson_false; + } + + for (i = 0; i < ((size_t)length); i++) { + output_pointer[i] = number_buffer[i]; + } + + output_pointer[i] = '\0'; + + output_buffer->offset += (size_t)length; + + return sjson_true; +} static int print_int(sjsoncvptr item, sjsonprintvptr output_buffer) { unsigned char* output_pointer = NULL; @@ -784,6 +828,8 @@ static int print_value(sjsoncvptr item, sjsonprintvptr output_buffer) rc_error(item != NULL, sjson_false) switch ((item->type) & 0xFF) { + case sjson_int64: + return print_int64(item, output_buffer); case sjson_int: return print_int(item, output_buffer); case sjson_double: @@ -1312,6 +1358,7 @@ int sjson_compare(sjsoncvptr a, sjsoncvptr b) rc_error((a->type & 0xFF) == (b->type & 0xFF), sjson_false) switch (a->type & 0xFF) { + case sjson_int64: case sjson_int: case sjson_double: case sjson_string: @@ -1327,6 +1374,11 @@ int sjson_compare(sjsoncvptr a, sjsoncvptr b) } switch (a->type & 0xFF) { + case sjson_int64: + if (a->valueint64 == b->valueint64) { + return sjson_true; + } + return sjson_false; case sjson_int: if (a->valueint == b->valueint) { return sjson_true; @@ -1506,6 +1558,15 @@ sjsonptr sjson_create_obj(void) } return item; } +sjsonptr sjson_create_int64(int64 value) +{ + sjsonptr item = sjson_new_Item(); + if (item) { + item->type = sjson_int64; + item->valueint64 = value; + } + return item; +} sjsonptr sjson_create_int(int value) { sjsonptr item = sjson_new_Item(); @@ -1540,6 +1601,34 @@ sjsonptr sjson_create_string(const char* value) return item; } +sjsonptr sjson_create_int64_array(const int64* values, unsigned int count) +{ + size_t i = 0; + sjsonptr n = NULL; + sjsonptr p = NULL; + sjsonptr a = NULL; + + rc_error(count > 0, NULL); + rc_error(values != NULL, NULL); + + a = sjson_create_array(); + for (i = 0; a && (i < count); i++) { + n = sjson_create_int64(values[i]); + if (!n) { + sjson_delete(a); + return NULL; + } + if (!i) { + a->child = n; + } else { + append_object(p, n); + } + p = n; + } + + return a; +} + sjsonptr sjson_create_int_array(const int* values, unsigned int count) { size_t i = 0; diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index 49d20ba9..dc5a41d0 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -472,27 +472,33 @@ static int cmd_poll_time(evloop_t* loop, evoper_t* oper) rc_error(op != NULL, S_ERROR); crt_msec ms = 0; - crt_msec clock_msec = 0; + crt_msec msec = 0; crt_msec oper_msec = 0; uint64_t node_count = 0; rc = evloop_nodes_count(loop->nodes, &node_count); + rc_error(rc != S_ERROR, S_ERROR) + rc_error(node_count != 0, S_ERROR); rc = evloop_deltime(loop->nodes, oper); + rc_error(rc != S_ERROR, S_ERROR) + rc_error(oper != NULL, S_ERROR); rc = evoper_get_msec(oper, &oper_msec); + rc_error(rc != S_ERROR, S_ERROR) + rc_error(oper_msec != 0, S_ERROR); - rc = evloop_clock_getmsec(loop->clock, &clock_msec); + rc = evloop_clock_getmsec(loop->clock, &msec); + rc_error(rc != S_ERROR, S_ERROR) + rc_error(msec != 0, S_ERROR); - ms = oper_msec - clock_msec; + ms = oper_msec - msec; if (ms > 0) op->op_dispatch(loop, op_cmd_poll, ms); evloop_sysop_handler(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timering); - - - + return S_SUCCESS; } static int cmd_poll(evloop_t* loop, crt_msec msec) diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index 759e3a92..6b2f5050 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -23,6 +23,9 @@ void thread_proc2(void* ctx) int main(int argc, char* argv[]) { + + test_cjson(); + init_sockenv(2, 2); int rc = 0; diff --git a/stdcrt_test/test_timer.c b/stdcrt_test/test_timer.c index f4f68d49..5a37dee5 100644 --- a/stdcrt_test/test_timer.c +++ b/stdcrt_test/test_timer.c @@ -16,7 +16,7 @@ int time_handler(int err, evoper_t* oper, evoper_t* oper_s, evevent event) logi("timer %ld==%ld", clockmsec, opermsec); int* id = NULL; evoper_get_ctx(oper, (void**)&id); - sleep_time(4); + //sleep_time(4); } else { logi("timer out %ld==%ld", clockmsec, opermsec); int* id = NULL; diff --git a/uibase/uicontrolimpl.cpp b/uibase/uicontrolimpl.cpp index e188f801..d608472b 100644 --- a/uibase/uicontrolimpl.cpp +++ b/uibase/uicontrolimpl.cpp @@ -130,7 +130,7 @@ int CUiControlImpl::GetY() } SIZE CUiControlImpl::GetFixed() { - SIZE rc; + SIZE rc = {0,0}; return rc; } HRESULT CUiControlImpl::SetFixed(SIZE rc) @@ -139,7 +139,7 @@ HRESULT CUiControlImpl::SetFixed(SIZE rc) } RECT CUiControlImpl::GetPos() { - RECT rc; + RECT rc = {0,0,0,0}; return rc; } HRESULT CUiControlImpl::SetPos(RECT rc) @@ -148,7 +148,7 @@ HRESULT CUiControlImpl::SetPos(RECT rc) } RECT CUiControlImpl::GetRelativePos() { - RECT rc; + RECT rc = {0, 0, 0, 0}; return rc; } HRESULT CUiControlImpl::SetRelativePos(RECT rc) @@ -166,7 +166,7 @@ HRESULT CUiControlImpl::SetBorderStyle(UINT nStyle) } RECT CUiControlImpl::GetPadding() { - RECT rc; + RECT rc = {0, 0, 0, 0}; return rc; } HRESULT CUiControlImpl::SetPadding(RECT rc) @@ -226,7 +226,7 @@ HRESULT CUiControlImpl::SetFocusBorderColor(DWORD dwBorderColor) } SIZE CUiControlImpl::GetBorderRound() { - SIZE rc; + SIZE rc = {0,0}; return rc; } HRESULT CUiControlImpl::SetBorderRound(SIZE cxyRound) @@ -235,7 +235,7 @@ HRESULT CUiControlImpl::SetBorderRound(SIZE cxyRound) } SIZE CUiControlImpl::GetBorderSize() { - SIZE rc; + SIZE rc = {0, 0}; return rc; } HRESULT CUiControlImpl::SetBorderSize(SIZE rc) -- Gitee From 817b036ac5cf7cd5a846b2cf64e9090963dffd2b Mon Sep 17 00:00:00 2001 From: com Date: Thu, 11 Jul 2024 21:15:47 +0800 Subject: [PATCH 04/34] up --- crt/crt_clock.h | 16 +++--- crt/crt_msgq.h | 29 +++++++++++ crt/crt_mutex.h | 18 +++---- crt/crt_qqueue.h | 88 -------------------------------- crt/crt_queue.h | 1 - crt/crt_rwlock.h | 18 +++---- crt/crt_util.h | 2 + stdcrt/event/compat_event_util.c | 6 +-- stdcrt/event/compat_event_util.h | 2 +- stdcrt/stdlib/compat_clock.c | 14 ++--- stdcrt/thread/compat_msgq.c | 41 +++++++++++++++ stdcrt_test/main.c | 3 +- stdcrt_test/test.h | 1 + stdcrt_test/test_stdlib.c | 40 +++++++++++++++ 14 files changed, 146 insertions(+), 133 deletions(-) create mode 100644 crt/crt_msgq.h delete mode 100644 crt/crt_qqueue.h create mode 100644 stdcrt/thread/compat_msgq.c diff --git a/crt/crt_clock.h b/crt/crt_clock.h index be043014..39f8efee 100644 --- a/crt/crt_clock.h +++ b/crt/crt_clock.h @@ -7,9 +7,9 @@ extern "C" { #endif -typedef struct evclock_s evclock_t; +typedef struct _clock_s _clock_t; -struct evclock_s { +struct _clock_s { #if (TARGET_OS == OS_WIN) LARGE_INTEGER freq; #elif (TARGET_OS == OS_POSIX) @@ -27,12 +27,12 @@ struct evclock_s { struct timeval last_clock; }; -int evclock_init(evclock_t* clock); -long get_evclock_sec(evclock_t* clock); -long get_evclock_usec(evclock_t* clock); -int get_evclock(evclock_t* clock, struct timeval* tv); -int evclock_adjust(evclock_t* clock, struct timeval* tv); -int evclock_outputlog(evclock_t* clock); +int _clock_init(_clock_t* clock); +long get_clock_sec(_clock_t* clock); +long get_clock_usec(_clock_t* clock); +int get_clock(_clock_t* clock, struct timeval* tv); +int clock_adjust(_clock_t* clock, struct timeval* tv); +int clock_outputlog(_clock_t* clock); #ifdef __cplusplus } diff --git a/crt/crt_msgq.h b/crt/crt_msgq.h new file mode 100644 index 00000000..29e67181 --- /dev/null +++ b/crt/crt_msgq.h @@ -0,0 +1,29 @@ +#ifndef _CRT_MSGQ_H_ +#define _CRT_MSGQ_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _msgq_s _msgq_t; + +//typedef _QUEUE msg_q; +typedef _queue_t msg_q; + +struct _msgq_s { + _mutex_t lock; + _cond_t cond; + msg_q queue; + int exit; +}; + +int _msgq_init(_msgq_t* msgq); +int _msgq_destroy(_msgq_t* msgq); +int _msgq_produce(_msgq_t* msgq, msg_q* queue); +int _msgq_consume(_msgq_t* msgq, msg_q* queue); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/crt/crt_mutex.h b/crt/crt_mutex.h index a9a70b67..11c8c274 100644 --- a/crt/crt_mutex.h +++ b/crt/crt_mutex.h @@ -9,34 +9,28 @@ extern "C" { #if (TARGET_OS == OS_WIN) -typedef struct _mutex_s _mutex_t; - -struct _mutex_s { +typedef struct { int setrobus; int process_shared; CRITICAL_SECTION cs; DWORD owner; -}; +} _mutex_t; #elif (TARGET_OS == OS_POSIX) -typedef struct _mutex_s _mutex_t; - -struct _mutex_s { +typedef struct { int setrobus; int process_shared; pthread_mutex_t mutex; -}; +} _mutex_t; #elif (TARGET_OS == OS_MACH) -typedef struct _mutex_s _mutex_t; - -struct _mutex_s { +typedef struct { int setrobus; int process_shared; pthread_mutex_t mutex; -}; +} _mutex_t; #endif diff --git a/crt/crt_qqueue.h b/crt/crt_qqueue.h deleted file mode 100644 index 2575dfc3..00000000 --- a/crt/crt_qqueue.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef _CRT_QQUEUE_H_ -#define _CRT_QQUEUE_H_ - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void* _QUEUE[2]; - -#define _QUEUE_NEXT(q) (*(_QUEUE**)&((*(q))[0])) -#define _QUEUE_PREV(q) (*(_QUEUE**)&((*(q))[1])) -#define _QUEUE_PREV_NEXT(q) (_QUEUE_NEXT(_QUEUE_PREV(q))) -#define _QUEUE_NEXT_PREV(q) (_QUEUE_PREV(_QUEUE_NEXT(q))) - -#define _QUEUE_DATA(ptr, type, field) ((type*)((char*)(ptr)-offsetof(type, field))) - -#define _QUEUE_FOREACH(q, h) for ((q) = _QUEUE_NEXT(h); (q) != (h); (q) = _QUEUE_NEXT(q)) - -#define _QUEUE_EMPTY(q) ((const _QUEUE*)(q) == (const _QUEUE*)_QUEUE_NEXT(q)) - -#define _QUEUE_HEAD(q) (_QUEUE_NEXT(q)) - -#define _QUEUE_INIT(q) \ - do { \ - _QUEUE_NEXT(q) = (q); \ - _QUEUE_PREV(q) = (q); \ - } while (0) - -#define _QUEUE_ADD(h, n) \ - do { \ - _QUEUE_PREV_NEXT(h) = _QUEUE_NEXT(n); \ - _QUEUE_NEXT_PREV(n) = _QUEUE_PREV(h); \ - _QUEUE_PREV(h) = _QUEUE_PREV(n); \ - _QUEUE_PREV_NEXT(h) = (h); \ - } while (0) - -#define _QUEUE_SPLIT(h, q, n) \ - do { \ - _QUEUE_PREV(n) = _QUEUE_PREV(h); \ - _QUEUE_PREV_NEXT(n) = (n); \ - _QUEUE_NEXT(n) = (q); \ - _QUEUE_PREV(h) = _QUEUE_PREV(q); \ - _QUEUE_PREV_NEXT(h) = (h); \ - _QUEUE_PREV(q) = (n); \ - } while (0) - -#define _QUEUE_MOVE(h, n) \ - do { \ - if (_QUEUE_EMPTY(h)) \ - _QUEUE_INIT(n); \ - else { \ - _QUEUE* q = _QUEUE_HEAD(h); \ - _QUEUE_SPLIT(h, q, n); \ - } \ - } while (0) - -#define _QUEUE_INSERT_HEAD(h, q) \ - do { \ - _QUEUE_NEXT(q) = _QUEUE_NEXT(h); \ - _QUEUE_PREV(q) = (h); \ - _QUEUE_NEXT_PREV(q) = (q); \ - _QUEUE_NEXT(h) = (q); \ - } while (0) - -#define _QUEUE_INSERT_TAIL(h, q) \ - do { \ - _QUEUE_NEXT(q) = (h); \ - _QUEUE_PREV(q) = _QUEUE_PREV(h); \ - _QUEUE_PREV_NEXT(q) = (q); \ - _QUEUE_PREV(h) = (q); \ - } while (0) - -#define _QUEUE_REMOVE(q) \ - do { \ - _QUEUE_PREV_NEXT(q) = _QUEUE_NEXT(q); \ - _QUEUE_NEXT_PREV(q) = _QUEUE_PREV(q); \ - } while (0) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/crt/crt_queue.h b/crt/crt_queue.h index 383e3be2..8a3d7038 100644 --- a/crt/crt_queue.h +++ b/crt/crt_queue.h @@ -65,7 +65,6 @@ struct _queue_s { #define _queue_data(q, type, link) (type*)((u_char*)q - offsetof(type, link)) /* - typedef struct { int x; diff --git a/crt/crt_rwlock.h b/crt/crt_rwlock.h index c4aa56bd..f7fe7760 100644 --- a/crt/crt_rwlock.h +++ b/crt/crt_rwlock.h @@ -9,32 +9,26 @@ extern "C" { #if (TARGET_OS == OS_WIN) -typedef struct _rwlock_s _rwlock_t; - -struct _rwlock_s { +typedef struct { int process_shared; unsigned int num_readers_; CRITICAL_SECTION num_readers_lock_; HANDLE write_semaphore_; -}; +} _rwlock_t; #elif (TARGET_OS == OS_POSIX) -typedef struct _rwlock_s _rwlock_t; - -struct _rwlock_s { +typedef struct { int process_shared; pthread_rwlock_t rwlock; -}; +} _rwlock_t; #elif (TARGET_OS == OS_MACH) -typedef struct _rwlock_s _rwlock_t; - -struct _rwlock_s { +typedef struct { int process_shared; pthread_rwlock_t rwlock; -}; +} _rwlock_t; #endif diff --git a/crt/crt_util.h b/crt/crt_util.h index 6cccef4e..61015ba0 100644 --- a/crt/crt_util.h +++ b/crt/crt_util.h @@ -126,4 +126,6 @@ of a structure or union are aligned according to the widest member. #include #include +#include + #endif // _CRT_UTIL_H_ diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index ec1ad122..0334eeeb 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -70,7 +70,7 @@ int evloop_nodes_count(evloop_nodes_t* nodes, uint64_t* count) int evloop_clock_init(evloop_clock_t* clock) { rc_error(clock != NULL, S_ERROR); - evclock_init(&clock->clock); + _clock_init(&clock->clock); return S_SUCCESS; } int evloop_clock_uninit(evloop_clock_t* clock) @@ -82,8 +82,8 @@ int evloop_clock_update(evloop_clock_t* clock) { rc_error(clock != NULL, S_ERROR); struct timeval tv; - get_evclock(&clock->clock, &tv); - evclock_adjust(&clock->clock, &tv); + get_clock(&clock->clock, &tv); + clock_adjust(&clock->clock, &tv); clock->msec = tv_to_msec(&clock->clock.monotonic_clock); return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 34f7cfbc..47cddcf4 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -263,7 +263,7 @@ struct evloop_nodes_s { struct evloop_clock_s { _mutex_t lock; - evclock_t clock; + _clock_t clock; crt_msec msec; }; diff --git a/stdcrt/stdlib/compat_clock.c b/stdcrt/stdlib/compat_clock.c index e2f9f234..29b9fb13 100644 --- a/stdcrt/stdlib/compat_clock.c +++ b/stdcrt/stdlib/compat_clock.c @@ -1,6 +1,6 @@ #include -int evclock_init(evclock_t* clock) +int _clock_init(_clock_t* clock) { rc_error(clock != NULL, S_ERROR); @@ -47,22 +47,22 @@ int evclock_init(evclock_t* clock) #endif struct timeval tv; - get_evclock(clock, &tv); + get_clock(clock, &tv); clock->last_clock = tv; return S_SUCCESS; } -long get_evclock_sec(evclock_t* clock) +long get_clock_sec(_clock_t* clock) { rc_error(clock != NULL, 0); return clock->monotonic_clock.tv_sec; } -long get_evclock_usec(evclock_t* clock) +long get_clock_usec(_clock_t* clock) { rc_error(clock != NULL, 0); return clock->monotonic_clock.tv_usec; } -int get_evclock(evclock_t* clock, struct timeval* tv) +int get_clock(_clock_t* clock, struct timeval* tv) { rc_error(clock != NULL, S_ERROR); @@ -110,7 +110,7 @@ int get_evclock(evclock_t* clock, struct timeval* tv) return S_SUCCESS; } -int evclock_adjust(evclock_t* clock, struct timeval* tv) +int clock_adjust(_clock_t* clock, struct timeval* tv) { rc_error(clock != NULL, S_ERROR); @@ -140,7 +140,7 @@ clearclock: return S_SUCCESS; } -int evclock_outputlog(evclock_t* clock) +int clock_outputlog(_clock_t* clock) { rc_error(clock != NULL, S_ERROR); diff --git a/stdcrt/thread/compat_msgq.c b/stdcrt/thread/compat_msgq.c new file mode 100644 index 00000000..7dc5a70a --- /dev/null +++ b/stdcrt/thread/compat_msgq.c @@ -0,0 +1,41 @@ +#include + +int _msgq_init(_msgq_t* msgq) +{ + rc_error(msgq != NULL, S_ERROR); + + _queue_init(&msgq->queue); + + //_QUEUE_INIT(&msgq->queue); + + return S_SUCCESS; +} +int _msgq_destroy(_msgq_t* msgq) +{ + rc_error(msgq != NULL, S_ERROR); + + return S_SUCCESS; +} +int _msgq_produce(_msgq_t* msgq, msg_q* queue) +{ + rc_error(msgq != NULL, S_ERROR); + + _queue_insert_tail(&msgq->queue, queue); + //_QUEUE_INSERT_TAIL(&msgq->queue, queue); + + return S_SUCCESS; +} +int _msgq_consume(_msgq_t* msgq, msg_q* queue) +{ + rc_error(msgq != NULL, S_ERROR); + + // _QUEUE* q = _QUEUE_HEAD(&msgq->queue); + //_QUEUE_SPLIT(&msgq->queue, q, queue); + + _queue_t* q = _queue_head(&msgq->queue); + _queue_split(&msgq->queue, q, queue); + + + return S_SUCCESS; +} + diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index 6b2f5050..33608f18 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -24,7 +24,8 @@ void thread_proc2(void* ctx) int main(int argc, char* argv[]) { - test_cjson(); + + test_msgq(); init_sockenv(2, 2); diff --git a/stdcrt_test/test.h b/stdcrt_test/test.h index bc176095..e34c1c66 100644 --- a/stdcrt_test/test.h +++ b/stdcrt_test/test.h @@ -11,6 +11,7 @@ struct pipe_s { size_t len; }; +void test_msgq(void); void test_cjson(); int mini_heap(void); diff --git a/stdcrt_test/test_stdlib.c b/stdcrt_test/test_stdlib.c index 304348d5..112dd8cc 100644 --- a/stdcrt_test/test_stdlib.c +++ b/stdcrt_test/test_stdlib.c @@ -8,6 +8,46 @@ #include #include +typedef struct myNode_s { + msg_q queue; + int val; +} myNode_t; + + +void travel_queue(msg_q* queue) +{ + myNode_t* reqnode; + msg_q* q = _queue_head(queue); + for (; q != _queue_sentinel(queue); q = _queue_next(q)) + { + reqnode = _queue_data(q, myNode_t, queue); + printf("val:%d\n", reqnode->val); + } +} + +void test_msgq(void) +{ + _msgq_t msg; + _msgq_init(&msg); + + _msgq_t msg1; + _msgq_init(&msg1); + + int i = 0; + for (int i = 0; i < 10; i++) { + myNode_t* regnode = malloc(sizeof(myNode_t)); + regnode->val = i; + _msgq_produce(&msg, ®node->queue); + } + + //copy to msg1.queue + _msgq_consume(&msg, &msg1.queue); + + //output + travel_queue(&msg1.queue); + travel_queue(&msg.queue); +} + void test_cjson(void) { -- Gitee From 194dca5c49bf728a46a3080de757908a1822bbb2 Mon Sep 17 00:00:00 2001 From: com Date: Thu, 11 Jul 2024 21:18:08 +0800 Subject: [PATCH 05/34] up --- crt/crt_util.h | 1 - stdcrt/stdcrt.vcxproj | 1 + stdcrt/stdcrt.vcxproj.filters | 3 +++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crt/crt_util.h b/crt/crt_util.h index 61015ba0..7945cf89 100644 --- a/crt/crt_util.h +++ b/crt/crt_util.h @@ -83,7 +83,6 @@ of a structure or union are aligned according to the widest member. #include #include #include -#include #include #include diff --git a/stdcrt/stdcrt.vcxproj b/stdcrt/stdcrt.vcxproj index 4f9a794e..3c8076ba 100644 --- a/stdcrt/stdcrt.vcxproj +++ b/stdcrt/stdcrt.vcxproj @@ -124,6 +124,7 @@ + diff --git a/stdcrt/stdcrt.vcxproj.filters b/stdcrt/stdcrt.vcxproj.filters index f9848bb9..1a60c56a 100644 --- a/stdcrt/stdcrt.vcxproj.filters +++ b/stdcrt/stdcrt.vcxproj.filters @@ -144,6 +144,9 @@ event + + thread + -- Gitee From b35a512f59a7fe9aed4533d8ad60a49ed66bb934 Mon Sep 17 00:00:00 2001 From: com Date: Mon, 15 Jul 2024 21:17:30 +0800 Subject: [PATCH 06/34] up --- crt/crt_def.h | 18 +- crt/crt_error.h | 1 - crt/crt_event.h | 29 ++- crt/crt_init.h | 8 +- crt/crt_msgq.h | 10 +- stdcrt/compat_error.c | 8 +- stdcrt/event/compat_event.c | 64 ++++--- stdcrt/event/compat_event_epoll.c | 19 +- stdcrt/event/compat_event_iocp.c | 24 +-- stdcrt/event/compat_event_kqueue.c | 297 ++++++++++------------------- stdcrt/event/compat_event_kqueue.h | 8 +- stdcrt/event/compat_event_posix.c | 30 +++ stdcrt/event/compat_event_util.c | 37 ++++ stdcrt/event/compat_event_util.h | 39 ++-- stdcrt/event/epoll3.png | Bin 0 -> 28033 bytes stdcrt/init/compat_init.c | 10 +- stdcrt/thread/compat_msgq.c | 19 +- stdcrt_test/main.c | 16 +- stdcrt_test/test.h | 4 + stdcrt_test/test_oper.c | 31 ++- stdcrt_test/test_stdlib.c | 30 +-- stdcrt_test/test_timer.c | 4 +- 22 files changed, 354 insertions(+), 352 deletions(-) create mode 100644 stdcrt/event/epoll3.png diff --git a/crt/crt_def.h b/crt/crt_def.h index f9a071b1..0dca830e 100644 --- a/crt/crt_def.h +++ b/crt/crt_def.h @@ -75,9 +75,9 @@ extern "C" { #define S_NOFOUND 302 #endif // !S_FOUND -#ifndef S_AGEIN -#define S_AGEIN 303 -#endif // !S_AGEIN +#ifndef S_AGAIN +#define S_AGAIN 303 +#endif // !S_AGAIN #pragma pack(push, 1) @@ -122,19 +122,11 @@ typedef const SafeMemoryPtr* SafeMemoryConstPtr; #endif #ifndef BUF_PTR -typedef unsigned char* BUF_PTR; +typedef unsigned char* buf_ptr; #endif #ifndef BUF_SIZE -typedef unsigned long BUF_SIZE; -#endif - -#ifndef BUF_T -typedef struct _buffer_s _buffer_t; -struct _buffer_s { - BUF_PTR ptr; - BUF_SIZE len; -}; +typedef size_t buf_len; #endif #pragma pack(pop) diff --git a/crt/crt_error.h b/crt/crt_error.h index 359444fe..9237d391 100644 --- a/crt/crt_error.h +++ b/crt/crt_error.h @@ -19,7 +19,6 @@ typedef int crterr; void crt_setfatalerror(const crterr errorno); crterr crt_geterror(void); -crterr crt_wsageterror(void); #ifdef __cplusplus } diff --git a/crt/crt_event.h b/crt/crt_event.h index cde11703..aa61b0db 100644 --- a/crt/crt_event.h +++ b/crt/crt_event.h @@ -23,7 +23,7 @@ typedef unsigned char evtype; typedef void* (*evmem_malloc)(evloop_t* loop, size_t count, size_t size); typedef int (*evmem_free)(evloop_t* loop, void* ptr); typedef int (*evloop_handler)(evloop_t* loop, short event, void* ctx); -typedef int (*ev_handler)(int err, evoper_t* oper, evoper_t* oper_s, evevent event); +typedef int (*ev_handler)(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event); #ifndef _evaddrptr_ @@ -84,21 +84,18 @@ struct evaddr_s { #endif // !op_ev_close -/* - When libevent tim&es out, -The while loop takes a del timer from the top of the heap once -- -until the newly adjusted minimum top of the heap is not a timeout event (actually a del event), -but later places the timeout event in the active task list. -The event is marked as timeout, -and the application layer callback determines how to handle the event marked as timeout when the -ActVIE queue is processed. - -When nginx handles a timeout, -it removes the RB node member from the red-black tree (event structure) -and calls the timeout handler function already registered in the application layer through the Add -Timer. The reason I didn't use the heap, Because each time the node is removed directly from the -inside, not the top of the heap -*/ +/////////////////////////////////// +#ifndef op_ev_success +#define op_ev_success 0x00 +#endif // !op_ev_success + +#ifndef op_ev_faild +#define op_ev_faild 0x01 +#endif // !op_ev_faild +/////////////////////////////////// + +int evoper_read(evoper_t* oper, buf_ptr buf, buf_len len); +int evoper_write(evoper_t* oper, buf_ptr buf, buf_len len); int evoper_set_msec(evoper_t* oper, crt_msec msec); int evoper_get_msec(evoper_t* oper, crt_msec* msec); diff --git a/crt/crt_init.h b/crt/crt_init.h index 0b31c07d..c5dc8ef6 100644 --- a/crt/crt_init.h +++ b/crt/crt_init.h @@ -11,10 +11,10 @@ int init_sockenv(int low, int high); int uninit_sockenv(int low, int high); int init_rpcenv(LPCSTR guid); int uninit_rpcenv(LPCSTR guid); -int get_target_bits(); -int get_target_os(); -int get_target_type(); -int get_os_compiler(); +int get_target_bits(void); +int get_target_os(void); +int get_target_type(void); +int get_os_compiler(void); #ifdef __cplusplus } diff --git a/crt/crt_msgq.h b/crt/crt_msgq.h index 29e67181..258bc989 100644 --- a/crt/crt_msgq.h +++ b/crt/crt_msgq.h @@ -6,21 +6,19 @@ extern "C" { #endif typedef struct _msgq_s _msgq_t; - -//typedef _QUEUE msg_q; -typedef _queue_t msg_q; +typedef _queue_t _msg_q; struct _msgq_s { _mutex_t lock; _cond_t cond; - msg_q queue; + _msg_q queue; int exit; }; int _msgq_init(_msgq_t* msgq); int _msgq_destroy(_msgq_t* msgq); -int _msgq_produce(_msgq_t* msgq, msg_q* queue); -int _msgq_consume(_msgq_t* msgq, msg_q* queue); +int _msgq_produce(_msgq_t* msgq, _msg_q* queue); +int _msgq_consume(_msgq_t* msgq, _msg_q* queue); #ifdef __cplusplus } diff --git a/stdcrt/compat_error.c b/stdcrt/compat_error.c index ad25c37a..dea56d85 100644 --- a/stdcrt/compat_error.c +++ b/stdcrt/compat_error.c @@ -33,10 +33,4 @@ crterr crt_geterror(void) return error; } -crterr crt_wsageterror(void) -{ - crterr error; - error = WSAERRNO; - crt_setfatalerror(error); - return error; -} + diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index dc5a41d0..32c5afec 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -9,31 +9,29 @@ #include "compat_event_kqueue.h" #endif -static int evloop_sysop_handler(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) +static int complete_handler(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) { - int rc = 0; - if (oper->o == op_ev_opening && (op == op_ev_opening)) { - oper->handler(err, oper, oper, op_ev_open); - } else if (oper->s == op_ev_closeing && (op == op_ev_closeing)) { - oper->handler(err, oper, oper, op_ev_close); - } else if (oper->c == op_ev_connecting && (op == op_ev_connecting)) { - + if (oper->c == op_ev_connecting && (op == op_ev_connecting)) { + if (evoper_sock_connected(oper) == S_SUCCESS) - oper->handler(err, oper, oper, op_ev_connect); - else { - logi("connect error"); - } + oper->handler(op_ev_success, oper, oper, op_ev_connect); + else + oper->handler(op_ev_faild, oper, oper, op_ev_connect); - } else if (oper->a == op_ev_accepting && (op == op_ev_accepting)) { - oper->handler(err, oper, oper_s, op_ev_accept); + } else if(oper->o == op_ev_opening && (op == op_ev_opening)) { + oper->handler(op_ev_success, oper, oper, op_ev_open); + } else if (oper->s == op_ev_closeing && (op == op_ev_closeing)) { + oper->handler(op_ev_success, oper, oper, op_ev_close); + } else if (oper->a == op_ev_accepting && (op == op_ev_accepting)) { + oper->handler(op_ev_success, oper, oper_s, op_ev_accept); } if (oper->o == op_ev_reading && (op == op_ev_reading)) { - oper->handler(err, oper, oper_s, op_ev_read); + oper->handler(op_ev_success, oper, oper, op_ev_read); } if (oper->o == op_ev_writeing && (op == op_ev_opening)) { - oper->handler(err, oper, oper_s, op_ev_write); + oper->handler(op_ev_success, oper, oper, op_ev_write); } if (oper->t == ev_time && (op == op_ev_timering)) @@ -78,7 +76,21 @@ static int evsysop_init(evsysop_t* op, int flag) } static int evsysop_bind_handler(evloop_t* loop, evsysop_t* op) { - return op->op_handler(loop, evloop_sysop_handler); + return op->op_handler(loop, complete_handler); +} +int evoper_read(evoper_t* oper, buf_ptr buf, buf_len len) +{ + rc_error(oper != NULL, S_ERROR); + oper->rbuf = buf; + oper->rlen = len; + return S_SUCCESS; +} +int evoper_write(evoper_t* oper, buf_ptr buf, buf_len len) +{ + rc_error(oper != NULL, S_ERROR); + oper->wbuf = buf; + oper->wlen = len; + return S_SUCCESS; } int evoper_set_msec(evoper_t* oper, crt_msec msec) { @@ -359,7 +371,7 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) rs_error(rc == S_PENDING, S_SUCCESS) if (rc == S_COMPLETED) { - evloop_sysop_handler(S_SUCCESS, 0, oper, oper, op_ev_connect); + complete_handler(S_SUCCESS, 0, oper, oper, op_ev_connect); //op_ev_connecting ==> op_ev_connected evoper_connect_op(oper, op_ev_connected); } @@ -401,6 +413,7 @@ int evloop_dealloc_evoper(evloop_t* loop, evoper_t* oper) } int evloop_init(evloop_t* loop, int size, int flag) { + int rc = S_ERROR; rc_error(loop != NULL, S_ERROR); loop->status = evloop_null; @@ -421,7 +434,8 @@ int evloop_init(evloop_t* loop, int size, int flag) rc_error(loop->sysop != NULL, S_MEMERROR); evsysop_init(loop->sysop, flag); - loop->evbase = loop->sysop->op_alloc(loop, size); + rc = loop->sysop->op_alloc(loop, size); + rc_error(rc != S_ERROR, S_SUPORTERROR); rc_error(loop->evbase != NULL, S_SUPORTERROR); evsysop_bind_handler(loop, loop->sysop); @@ -429,6 +443,10 @@ int evloop_init(evloop_t* loop, int size, int flag) rc_error(loop->nodes != NULL, S_MEMERROR); evloop_nodes_init(loop->nodes); + loop->queue = loop->mm_malloc(loop, 1, sizeof(evloop_queue_t)); + rc_error(loop->queue != NULL, S_MEMERROR); + evloop_queue_init(loop->queue); + loop->clock = loop->mm_malloc(loop, 1, sizeof(evloop_clock_t)); rc_error(loop->clock != NULL, S_MEMERROR); evloop_clock_init(loop->clock); @@ -497,7 +515,7 @@ static int cmd_poll_time(evloop_t* loop, evoper_t* oper) if (ms > 0) op->op_dispatch(loop, op_cmd_poll, ms); - evloop_sysop_handler(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timering); + complete_handler(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timering); return S_SUCCESS; } @@ -511,6 +529,7 @@ static int cmd_poll(evloop_t* loop, crt_msec msec) op->op_dispatch(loop, op_cmd_poll, msec); return S_SUCCESS; } +/* static int cmd_exit(evloop_t* loop, crt_msec msec) { rc_error(loop != NULL, S_ERROR); @@ -541,6 +560,7 @@ static int cmd_load(evloop_t* loop, crt_msec msec) op->op_dispatch(loop, op_cmd_load, msec); return S_SUCCESS; } +*/ int evloop_run(evloop_t* loop, crt_msec msec) { @@ -557,10 +577,10 @@ int evloop_run(evloop_t* loop, crt_msec msec) { evoper_t* oper = NULL; int ret = S_NOFOUND; - rc = evloop_gettime(loop->nodes, &oper); + ret = evloop_gettime(loop->nodes, &oper); evloop_update_time(loop); - rc = (rc == S_FOUND ? cmd_poll_time(loop, oper) : cmd_poll(loop, msec)); + rc = (ret == S_FOUND ? cmd_poll_time(loop, oper) : cmd_poll(loop, msec)); evloop_update_time(loop); } return S_SUCCESS; diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index e256d472..c716e65e 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -113,14 +113,14 @@ static int epoll_op(epoll_op_t* base, void* ptr, uint32_t events, int op, int fd return S_ERROR; } -void* epoll_op_alloc(evloop_t* loop, int size) +int epoll_op_alloc(evloop_t* loop, int size) { int rc = S_ERROR; - epoll_op_t* base = (epoll_op_t*)evloop_evbase(loop); + epoll_op_t* base = NULL; base = (epoll_op_t*)calloc(1, sizeof(epoll_op_t)); - rc_error(base != NULL, NULL); + rc_error(base != NULL, S_ERROR); base->size = size; base->notify_fd = INVALID_SOCKET; @@ -135,7 +135,6 @@ void* epoll_op_alloc(evloop_t* loop, int size) //base->sys_timerfd_create = NULL; //base->sys_timerfd_settime = NULL; - rc = sys_hook_api(base); if (rc != S_SUCCESS) goto err; @@ -176,18 +175,19 @@ void* epoll_op_alloc(evloop_t* loop, int size) if (base->poll == NULL) goto err; - return base; + return evloop_bind_evbase(loop, base); err: if (base != NULL) free(base); - return NULL; + return S_ERROR; } -void* epoll_op_dealloc(evloop_t* loop) +int epoll_op_dealloc(evloop_t* loop) { + rc_error(loop != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evloop_evbase(loop); loop->mm_free(loop, base->poll); - return NULL; + return S_SUCCESS; } int epoll_op_handler(evloop_t* loop, ev_op ev) { @@ -238,6 +238,9 @@ int epoll_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); + + posix_tcpsock_send(oper); + return epoll_op(base, oper, ev_write_event, EPOLL_CTL_MOD, oper->fd); } int epoll_op_del_read(evloop_t* loop, evoper_t* oper, short event) diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index 6e77ca3b..122f9d95 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -213,12 +213,12 @@ static int iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULON } return S_SUCCESS; } -static void* iocp_op_alloc(evloop_t* loop, int size) +int iocp_op_alloc(evloop_t* loop, int size) { int rc = 0; iocp_op_t* base = NULL; base = (iocp_op_t*)loop->mm_malloc(loop, 1, sizeof(iocp_op_t)); - rc_error(base != NULL, NULL); + rc_error(base != NULL, S_ERROR); base->size = size; base->hiocp = INVALID_HANDLE_VALUE; @@ -239,7 +239,7 @@ static void* iocp_op_alloc(evloop_t* loop, int size) if (rc != S_SUCCESS) goto err; - return base; + return evloop_bind_evbase(loop, base); err: @@ -249,13 +249,13 @@ err: if (base != NULL) heap_free(base); - return NULL; + return S_ERROR; } -static void* iocp_op_dealloc(evloop_t* loop) +int iocp_op_dealloc(evloop_t* loop) { - return NULL; + return S_SUCCESS; } -static int iocp_op_handler(evloop_t* loop, ev_op ev) +int iocp_op_handler(evloop_t* loop, ev_op ev) { int rc = S_ERROR; rc_error(loop != NULL, S_ERROR); @@ -264,7 +264,7 @@ static int iocp_op_handler(evloop_t* loop, ev_op ev) base->ev = ev; return S_SUCCESS; } -static int iocp_op_alloc_evoper(evloop_t* loop, evoper_t* oper) +int iocp_op_alloc_evoper(evloop_t* loop, evoper_t* oper) { iocp_op_t* base = (iocp_op_t*)evloop_evbase(loop); @@ -283,7 +283,7 @@ static int iocp_op_alloc_evoper(evloop_t* loop, evoper_t* oper) return S_SUCCESS; } -static int iocp_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) +int iocp_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) { lpevoper_ov obj = (lpevoper_ov)evoper_private(oper); if (HasOverlappedIoCompleted(&obj->overlapped)) { @@ -308,7 +308,7 @@ int iocp_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) int rc = S_ERROR; if (oper->t == ev_sock) { if (oper->w) { - // rc = win32_sock_read(oper); + rc = win32_sock_write_op(oper); } } return rc; @@ -384,7 +384,7 @@ int iocp_op_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) } if (ovlp == NULL) - return S_AGEIN; + return S_AGAIN; if (err == ERROR_NETNAME_DELETED || /* the socket was closed */ @@ -394,7 +394,7 @@ int iocp_op_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) * the WSA_OPERATION_ABORTED completion notification * for a file descriptor that was closed */ - return S_AGEIN; + return S_AGAIN; } diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index d5be9576..9cea86a3 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -3,29 +3,30 @@ #if (TARGET_OS == OS_MACH) - - -static int kqueue_hook_api(evop_t* op) +static int kqueue_hook_api(kqueue_op_t* base) { - op->sys_kqueue = (kqueue_fn)dlsym(RTLD_NEXT, "kqueue"); - rc_error(op->sys_kqueue != NULL, S_ERROR); - - op->sys_kevent = (kevent_fn)dlsym(RTLD_NEXT, "kevent"); - rc_error(op->sys_kevent != NULL, S_ERROR); + base->sys_kqueue = (kqueue_fn)dlsym(RTLD_NEXT, "kqueue"); + rc_error(base->sys_kqueue != NULL, S_ERROR); + base->sys_kevent = (kevent_fn)dlsym(RTLD_NEXT, "kevent"); + rc_error(base->sys_kevent != NULL, S_ERROR); + return S_SUCCESS; } -static void* kqueue_op_alloc(evloop_t* loop, int size) +static int kqueue_op(kqueue_op_t* base, void* ptr, uint32_t events, int op, int fd) +{ + return S_SUCCESS; +} +int kqueue_op_alloc(evloop_t* loop, int size) { int rc = S_ERROR; - evop_t* base = (evop_t*)evloop_evbase(loop); - - base = (evop_t*)calloc(1, sizeof(evop_t)); - rc_error(base != NULL, NULL); + kqueue_op_t* base = NULL; + base = (kqueue_op_t*)calloc(1, sizeof(kqueue_op_t)); + rc_error(base != NULL, S_ERROR); - base->size = 1024; + base->size = size; rc = kqueue_hook_api(base); if (rc != S_SUCCESS) @@ -37,35 +38,41 @@ static void* kqueue_op_alloc(evloop_t* loop, int size) base->poll = NULL; base->poll = loop->mm_malloc(loop, base->size, sizeof(struct kevent)); - rc_error(base->poll != NULL, NULL); - - return base; + if(base->poll == NULL) + goto err; + + return evloop_bind_evbase(loop, base); err: if (base != NULL) free(base); - return NULL; + return S_ERROR; } -static void* kqueue_op_dealloc(evloop_t* loop) +int kqueue_op_dealloc(evloop_t* loop) { - evop_t* base = (evop_t*)evloop_evbase(loop); - + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); loop->mm_free(loop, base->poll); + return S_SUCCESS; +} - return NULL; +int kqueue_op_handler(evloop_t* loop, ev_op ev) +{ + rc_error(loop != NULL, S_ERROR); + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); + base->ev = ev; + return S_SUCCESS; } -static int kqueue_op_alloc_evoper(evloop_t* loop, evoper_t* oper) + +int kqueue_op_alloc_evoper(evloop_t* loop, evoper_t* oper) { rc_error(oper != NULL, S_ERROR); - evevent_t* obj = (evevent_t*)heap_calloc(1, sizeof(evevent_t)); + kqueue_event_t* obj = (kqueue_event_t*)heap_calloc(1, sizeof(kqueue_event_t)); rc_error(obj != NULL, S_ERROR); - evoper_bind_private(oper, obj); - return S_SUCCESS; } -static int kqueue_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) +int kqueue_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) { rc_error(oper != NULL, S_ERROR); @@ -74,195 +81,48 @@ static int kqueue_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) return S_SUCCESS; } -int kqueue_op_add(evoper_t* oper, short event, ev_time_t tv) +int kqueue_op_add(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { - evop_t* base = (evop_t*)evoper_evbase(oper); + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - evevent_t* ptr = (evevent_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - rc_error(ptr->reg == 0, S_SUCCESS); - - int rc = 0; - struct kevent ev; - int16_t filter = 0; - uint32_t fflags = 0; - - if (is_maskwrite(oper)) - filter |= EVFILT_WRITE; - if (is_maskread(oper)) - filter |= EVFILT_READ; - - fflags = EV_ADD | EV_ENABLE | EV_ERROR | EV_ONESHOT; - - if (is_maskedge(oper)) - fflags &= ~EV_ONESHOT; - - if (is_maskoneshot(oper)) - fflags &= ~EV_ONESHOT; - - EV_SET(&ev, oper->sock, filter, fflags, 0, 0, oper); - - rc = base->sys_kevent(base->kqfd, &ev, 1, NULL, 0, NULL); - - if (rc == -1 || !(ev.flags & EV_ERROR)) { - return S_ERROR; - } - - ptr->filter = filter; - ptr->fflags = fflags; - return S_SUCCESS; } -int kqueue_op_del(evoper_t* oper, short event) +int kqueue_op_del(evloop_t* loop, evoper_t* oper, short event) { - evop_t* base = (evop_t*)evoper_evbase(oper); + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - evevent_t* ptr = (evevent_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - rc_error(ptr->reg == 0, S_SUCCESS); - - int rc = 0; - struct kevent ev; - int16_t filter = ptr->filter; - uint32_t fflags = ptr->fflags; - - if (is_maskwrite(oper)) - filter &= ~EVFILT_READ; - - if (is_maskread(oper)) - filter &= ~EVFILT_WRITE; - - fflags = EV_DELETE | EV_DISABLE | EV_ERROR; - - EV_SET(&ev, oper->fd, filter, fflags, 0, 0, oper); - - rc = base->sys_kevent(base->kqfd, &ev, 1, NULL, 0, NULL); - - if (rc == -1 || !(ev.flags & EV_ERROR)) { - return S_ERROR; - } - - ptr->filter = filter; - ptr->fflags = fflags; - return S_SUCCESS; } -int kqueue_op_cancel(evoper_t* oper) +int kqueue_op_cancel(evloop_t* loop, evoper_t* oper) { return S_SUCCESS; } -int kqueue_op_open(evoper_t* oper, const evaddr_t* addr, short event) +int kqueue_op_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) { return S_SUCCESS; } -int kqueue_op_poll(evoper_t* oper) +int kqueue_op_poll(evloop_t* loop, evoper_t* oper) { - evop_t* base = (evop_t*)evoper_evbase(oper); + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - evevent_t* ptr = (evevent_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - rc_error(ptr->reg == 0, S_SUCCESS); - - int rc = 0; - struct kevent ev; - - int16_t filter = 0; - uint32_t fflags = 0; - - fflags = EV_ADD | EV_ENABLE | EV_ERROR; //|EV_ONESHOT - filter = EVFILT_READ; - - EV_SET(&ev, oper->fd, filter, fflags, 0, 0, oper); - - rc = base->sys_kevent(base->kqfd, &ev, 1, NULL, 0, NULL); - - if (rc == -1 || !(ev.flags & EV_ERROR)) { - return S_ERROR; - } - - ptr->filter = filter; - ptr->fflags = fflags; - return S_SUCCESS; } -int kqueue_op_add_connect(evoper_t* oper, const evaddr_t* addr, short event, ev_time_t tv) +int kqueue_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { - - int rc = S_ERROR; - evop_t* base = (evop_t*)evoper_evbase(oper); + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - rc = kqueue_op_add(oper, op_ev_write | op_ev_onshot, tv); - rc_error(rc == S_SUCCESS, S_ERROR) - - rc = evoper_sock_connect(oper, addr); - //waiting for response - if (rc == S_PENDING) { - return S_SUCCESS; - } else if (rc == S_COMPLETED) { - return S_COMPLETED; - } - - return S_SUCCESS; } -int kqueue_op_del_connect(evoper_t* oper, short event) -{ - return S_SUCCESS; -} -static int kevent_close_handler(struct kevent* kev) -{ - return S_SUCCESS; -} -static int kevent_error_handler(struct kevent* kev) -{ - switch (kev->data) { - case ENOENT: - case EINVAL: - break; - case EBADF: - break; - case EPERM: - case EPIPE: - break; - default: - break; - } - return S_SUCCESS; -} -static int kevent_read_handler(struct kevent* kev) -{ - evoper_t* oper = NULL; - rc_error(kev != NULL, S_ERROR); - oper = kev->udata; - rc_error(oper != NULL, S_ERROR); - - int rc = 0; - - if (oper->type == ev_sockpoll) - rc = mach_sock_accept(oper); - - return S_SUCCESS; -} -static int kevent_write_handler(struct kevent* kev) -{ - evoper_t* oper = NULL; - rc_error(kev != NULL, S_ERROR); - oper = kev->udata; - rc_error(oper != NULL, S_ERROR) - - return S_SUCCESS; -} -static int kevent_signal_handler(struct kevent* kev) +int kqueue_op_del_connect(evloop_t* loop, evoper_t* oper) { return S_SUCCESS; } -static int kevent_time_handler(struct kevent* kev) +int kqueue_event_complete(evloop_t* loop, crterr err, kqueue_op_t* base, evoper_t* oper, short ev) { - return S_SUCCESS; + return S_SUCCESS; } - -static int kqueue_op_cmd_poll(evop_t* base, evloop_t* loop, crt_msec timer) +static int kqueue_op_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) { struct timespec timeout; timeout.tv_sec = timer / 1000; @@ -274,32 +134,71 @@ static int kqueue_op_cmd_poll(evop_t* base, evloop_t* loop, crt_msec timer) int i = 0; for (i = 0; i < nfds; i++) { + + evoper_t* oper = NULL; + struct kevent* ev = NULL; + ev = &base->poll[i]; + oper = ev->udata; + + + oper->eof = ((ev->flags & EV_EOF)!= 0)? ev_on : ev_off; + oper->err = ev->flags & EV_ERROR; + + if(ev->filter == EVFILT_PROC) { + + } + + if(ev->filter == EVFILT_VNODE) { + + } + + if (ev->filter == EV_OOBAND) { + + } + + if (ev->filter == EVFILT_WRITE) { + + } + + if (ev->filter == EVFILT_SIGNAL) { + + } + + if (ev->filter == EVFILT_USER) { + + } + + + + /* int close = (base->poll[i].filter == EVFILT_READ || base->poll[i].filter == EVFILT_WRITE); if ((base->poll[i].flags & EV_EOF) && close) - kevent_close_handler(&base->poll[i]); + //kevent_close_handler(&base->poll[i]); else if (base->poll[i].flags & EV_ERROR) - kevent_error_handler(&base->poll[i]); + //kevent_error_handler(&base->poll[i]); else if (base->poll[i].filter == EVFILT_READ) - kevent_read_handler(&base->poll[i]); + //kevent_read_handler(&base->poll[i]); else if (base->poll[i].filter == EVFILT_WRITE) - kevent_write_handler(&base->poll[i]); + //kevent_write_handler(&base->poll[i]); else if (base->poll[i].filter == EVFILT_SIGNAL) - kevent_signal_handler(&base->poll[i]); + //kevent_signal_handler(&base->poll[i]); else if (base->poll[i].filter == EVFILT_TIMER) - kevent_time_handler(&base->poll[i]); + //kevent_time_handler(&base->poll[i]); + */ + } return S_SUCCESS; } -static int kqueue_op_cmd_exit(const evop_t* base, evloop_t* loop) +static int kqueue_op_cmd_exit(const kqueue_op_t* base, evloop_t* loop) { return S_SUCCESS; } -static int kqueue_op_cmd_once(const evop_t* base, evloop_t* loop) +static int kqueue_op_cmd_once(const kqueue_op_t* base, evloop_t* loop) { return S_SUCCESS; } -static int kqueue_op_cmd_load(const evop_t* base, evloop_t* loop) +static int kqueue_op_cmd_load(const kqueue_op_t* base, evloop_t* loop) { return S_SUCCESS; } @@ -307,7 +206,7 @@ static int kqueue_op_dispatch(evloop_t* loop, short event, crt_msec time) { int rc = S_SUCCESS; - evop_t* base = (evop_t*)evloop_evbase(loop); + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); switch (event) { case op_cmd_poll: @@ -333,6 +232,8 @@ int kqueue_evop_t(evsysop_t* op) op->op_alloc = kqueue_op_alloc; op->op_dealloc = kqueue_op_dealloc; + op->op_handler = kqueue_op_handler; + op->op_alloc_evoper = kqueue_op_alloc_evoper; op->op_dealloc_evoper = kqueue_op_dealloc_evoper; diff --git a/stdcrt/event/compat_event_kqueue.h b/stdcrt/event/compat_event_kqueue.h index 5a3c3e09..1a654c41 100644 --- a/stdcrt/event/compat_event_kqueue.h +++ b/stdcrt/event/compat_event_kqueue.h @@ -10,8 +10,9 @@ extern "C" { #if (TARGET_OS == OS_MACH) -typedef struct kevent_s evevent_t; -typedef struct kqueue_op_s evop_t; + +typedef struct kqueue_op_s kqueue_op_t; +typedef struct kevent_s kqueue_event_t; struct kevent_s { int reg; @@ -28,8 +29,11 @@ struct kqueue_op_s { kqueue_fn sys_kqueue; kevent_fn sys_kevent; struct kevent* poll; + ev_op ev; + _mutex_t lock; }; + int kqueue_evop_t(evsysop_t* op); #endif diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index b7fdbfe9..cc3c901a 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -11,6 +11,36 @@ int posix_tcpsock_send(evoper_t* oper) int rc = S_ERROR; rc_error(oper != NULL, rc); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); + ssize_t n; + oper->sent = 0; + for (;;) { + n = send(oper->fd, oper->wbuf, oper->wlen, 0); + + crterr err = crt_geterror(); + + if (n > 0) { + if (n < (ssize_t)oper->wlen) { + //wev->ready = 0; + } + oper->sent += n; + return S_SUCCESS; + } + + if (n == 0) { + //wev->ready = 0; + return S_SUCCESS; + } + + if (err == EAGAIN || err == EINTR) { + //wev->ready = 0; + if (err == EAGAIN) { + return S_AGAIN; + } + + } else { + return S_ERROR; + } + } return S_SUCCESS; } int posix_tcpsock_recv(evoper_t* oper) diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index 0334eeeb..a858d45c 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -41,6 +41,7 @@ int evloop_nodes_deltime(evloop_nodes_t* nodes, evoper_t* del) heap_remove((_heap_t*)&nodes->heap, (_heap_node_t*)&del->node, oper_msec_less_than); return S_SUCCESS; } + int evloop_nodes_gettime(evloop_nodes_t* nodes, evoper_t** get) { rc_error(nodes->heap.count != 0, S_NOFOUND); @@ -67,6 +68,30 @@ int evloop_nodes_count(evloop_nodes_t* nodes, uint64_t* count) *count =nodes->heap.count; return S_SUCCESS; } +int evloop_queue_init(evloop_queue_t* queue) +{ + rc_error(queue != NULL, S_ERROR); + _queue_init(queue); + return S_SUCCESS; +} +int evloop_queue_uninit(evloop_queue_t* queue) +{ + rc_error(queue != NULL, S_ERROR); + + return S_SUCCESS; +} +int evloop_add_ev(evloop_queue_t* queue, evoper_queue* ev) +{ + rc_error(queue != NULL, S_ERROR); + _queue_insert_tail(queue, ev); + return S_SUCCESS; +} +int evloop_del_ev(evloop_queue_t* queue, evoper_queue* ev) +{ + rc_error(queue != NULL, S_ERROR); + _queue_remove(ev); + return S_SUCCESS; +} int evloop_clock_init(evloop_clock_t* clock) { rc_error(clock != NULL, S_ERROR); @@ -99,6 +124,12 @@ int evloop_clock_getmsec(evloop_clock_t* clock, crt_msec* msec) *msec = clock->msec; return S_SUCCESS; } +int evloop_bind_evbase(evloop_t* loop, void* evbase) +{ + rc_error(loop != NULL, S_ERROR); + loop->evbase = evbase; + return S_SUCCESS; +} void* evloop_evbase(evloop_t* loop) { rc_error(loop != NULL, NULL); @@ -157,6 +188,12 @@ int evoper_write_op(evoper_t* oper, evevent op) oper->w = op; return S_SUCCESS; } +int evoper_post_op(evoper_t* oper, evevent op) +{ + rc_error(oper != NULL, S_ERROR); + oper->post = op; + return S_SUCCESS; +} int evoper_bind_private(evoper_t* oper, void* obj) { rc_error(oper != NULL, S_ERROR); diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 47cddcf4..9b52020d 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -129,6 +129,8 @@ typedef struct evloop_nodes_s evloop_nodes_t; typedef struct evloop_clock_s evloop_clock_t; +typedef _queue_t evloop_queue_t; +typedef _queue_t evoper_queue; /* * An active default event. The event type depends on interface: @@ -158,7 +160,6 @@ typedef struct evloop_clock_s evloop_clock_t; /* An active level-triggered event. Used by eventport. */ #define op_ev_level 0x06 - #define op_ev_active 0xf0 #define op_ev_reading 0x01 @@ -208,21 +209,27 @@ typedef struct evloop_clock_s evloop_clock_t; struct evoper_s { + evtype t; void* ctx; void* private; - - evtype t; + evevent o; evevent r; evevent w; evevent c; evevent a; - evevent s; // 1=bind evloop, 2=eof, 2=pending_eof, 3=close + evevent s; + evevent eof; + evevent post; + evevent err; + evevent vnode; //kqueue_vnode; + + buf_ptr rbuf; + buf_len rlen; + buf_ptr wbuf; + buf_len wlen; + buf_len sent; -#if (TARGET_OS == OS_MACH) - unsigned kq_vnode : 1; - unsigned kq_errno : 1; -#endif unsigned int accept_count; union { @@ -234,13 +241,16 @@ struct evoper_s { ev_handler handler; evloop_t* loop; crt_msec msec; + + crterr code; + evoper_queue queue; }; typedef int (*ev_op)(int err, crterr code, evoper_t* oper, evoper_t* accepet_oper, evevent op); struct evsysop_s { - void* (*op_alloc)(evloop_t* loop, int size); - void* (*op_dealloc)(evloop_t* loop); + int (*op_alloc)(evloop_t* loop, int size); + int (*op_dealloc)(evloop_t* loop); int (*op_handler)(evloop_t* loop, ev_op handler); int (*op_alloc_evoper)(evloop_t* loop, evoper_t* oper); int (*op_dealloc_evoper)(evloop_t* loop, evoper_t* oper); @@ -276,7 +286,7 @@ struct evloop_s { evloop_clock_t* clock; evloop_nodes_t* nodes; - evloop_nodes_t* complate_nodes; + evloop_queue_t* queue; evmem_malloc mm_malloc; evmem_free mm_free; @@ -291,12 +301,18 @@ int evloop_nodes_init(evloop_nodes_t* nodes); int evloop_nodes_uninit(evloop_nodes_t* nodes); int evloop_nodes_count(evloop_nodes_t* nodes, uint64_t* count); +int evloop_queue_init(evloop_queue_t* queue); +int evloop_queue_uninit(evloop_queue_t* queue); +int evloop_add_ev(evloop_queue_t* queue, evoper_queue* ev); +int evloop_del_ev(evloop_queue_t* queue, evoper_queue* ev); + int evloop_clock_init(evloop_clock_t* clock); int evloop_clock_uninit(evloop_clock_t* clock); int evloop_clock_update(evloop_clock_t* clock); int evloop_clock_setmsec(evloop_clock_t* clock, crt_msec msec); int evloop_clock_getmsec(evloop_clock_t* clock, crt_msec* msec); +int evloop_bind_evbase(evloop_t* loop, void* evbase); void* evloop_evbase(evloop_t* loop); void* evloop_sysop(evloop_t* loop); void* evoper_evbase(evoper_t* oper); @@ -308,6 +324,7 @@ int evoper_accept_op(evoper_t* oper, evevent op); int evoper_accept_size(evoper_t* oper, unsigned int count); int evoper_read_op(evoper_t* oper, evevent op); int evoper_write_op(evoper_t* oper, evevent op); +int evoper_post_op(evoper_t* oper, evevent op); int evoper_bind_private(evoper_t* oper, void* obj); int evoper_assign_sock(evoper_t* oper, _sock_t sock); diff --git a/stdcrt/event/epoll3.png b/stdcrt/event/epoll3.png new file mode 100644 index 0000000000000000000000000000000000000000..7d109b4f12d16812ab3fdb7e495afc18e463f271 GIT binary patch literal 28033 zcmc$_XHZl@*Dg9lC8^{Lk~2sa5D-Cfh8YHioMFgG0RaKYNkDSWX@)#Q&N)jMhKwWy z1|%bb$niZ@r_Oipk8^I-_v1dhYS&)ftDo*4y}PQ{v)04X!#BV)b!9bW02USifc5VI zJgfo~|5^V%{Dl!^PJFo& zZ}aa(vy=F8_~lOG{~ryn|9FnjjFlQ4+k}KZy}kK8^8@g|zjtW0x?)V~F3ls|-p&A- ze!}g60rTEHg^fN`k2gI84x_oWgwppJb3J|g^S+Ts(dmF6y-g;oT#N2VRr*5iuhkAZA5ul3ME za~@9^R64&``I>{y4spI;Ml#umHGmVyn7Ag#z=sI;!}FBN79QuTvO``)GbiV%*I8-O zjZtRj$z=UYMjWZWp>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3|MP&j4fFP%-w&s z99CgQvCtsI+<#v!Xcwh!UaB+L)dEi<@~fi&3%w2l+eWu)J152_-H5*--uh_w)#Vf4 ze^~J4ICd;@O)lj@(9wYP@I3m(+i?k@dlJqw1UC)a54>LYosI?eovxV^{We|OX(H@* zu0H5}+MN&ypNn`@X>=wDksC5y(&uU{i@^INSB**gwm<$~3_{?4@26J?-=Nx!UGLGk zb&Er0PY0xT0)JngPF@j>H?#Lb*Lmxt((Gp@y_}VsH(P=+Y;va8OA@oc{dwx{u&UXz zk@*xsO-MeoC8_?kU~8FN{pGN;KGKn%QN-}(wjzKuqat8Y2!&y+XKTPc@tLEs6X78s z4!7_mhPO?Obw>4)_wDscY7K7(YWNizw$!QWEVKF$o=}q3xMOC-OI&YJl{NY%R>_%n z6xcJ@!q-kB7KA>)G7Aknom<{CX_ncwU#Z%fU^pg)AR z=4689#vcXrp0;VtzhA>RRaMd9kI&;GPdA_xBd7G`(^uz#MTPhX*BYo5XiX!?U<2+Z zdQ>p|su21AkEfzUxp{RqWJ$GbPyB}}b9rqueue); - - //_QUEUE_INIT(&msgq->queue); - return S_SUCCESS; } int _msgq_destroy(_msgq_t* msgq) @@ -16,26 +12,17 @@ int _msgq_destroy(_msgq_t* msgq) return S_SUCCESS; } -int _msgq_produce(_msgq_t* msgq, msg_q* queue) +int _msgq_produce(_msgq_t* msgq, _msg_q* queue) { rc_error(msgq != NULL, S_ERROR); - _queue_insert_tail(&msgq->queue, queue); - //_QUEUE_INSERT_TAIL(&msgq->queue, queue); - return S_SUCCESS; } -int _msgq_consume(_msgq_t* msgq, msg_q* queue) +int _msgq_consume(_msgq_t* msgq, _msg_q* queue) { rc_error(msgq != NULL, S_ERROR); - - // _QUEUE* q = _QUEUE_HEAD(&msgq->queue); - //_QUEUE_SPLIT(&msgq->queue, q, queue); - - _queue_t* q = _queue_head(&msgq->queue); + _msg_q* q = _queue_head(&msgq->queue); _queue_split(&msgq->queue, q, queue); - - return S_SUCCESS; } diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index 33608f18..85f70656 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -7,25 +7,25 @@ // #pragma comment(linker, "/ENTRY:main") evloop_t* loop; + + void thread_proc2(void* ctx) { - /* sleep_time(7); + sleep_time(7); test_conn_oper(loop); while (1) { sleep_time(7); - - }*/ + test_write_oper(loop); - + } } int main(int argc, char* argv[]) { - - test_msgq(); + //test_msgq(); init_sockenv(2, 2); @@ -45,9 +45,7 @@ int main(int argc, char* argv[]) rc = _thread_create(&thread2, thread_proc2, NULL); rc_error(rc == S_SUCCESS, S_ERROR); - - - test_timer(loop); + //test_timer(loop); evloop_run(loop, 50000); diff --git a/stdcrt_test/test.h b/stdcrt_test/test.h index e34c1c66..730575ba 100644 --- a/stdcrt_test/test.h +++ b/stdcrt_test/test.h @@ -35,4 +35,8 @@ void test_conn_oper(evloop_t* loop); void test_accept_oper(evloop_t* loop); void thread_proc2(void* ctx); + +void test_write_oper(evloop_t* loop); +void test_read_oper(evloop_t* loop); + #endif diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index fa732b65..f65cb25a 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -6,21 +6,26 @@ evoper_t* accept_oper; evoper_t* new_oper; evaddr_t addr; +char* send_data; +char* recv_data; + void test_init_evaddr() { const char* ip = "127.0.0.1"; addr.ptr = ip; addr.len = s_strlen("127.0.0.1"); addr.port = 9000; + send_data = heap_malloc(4096); + recv_data = heap_malloc(4096); } -int evop_proc(int err, evoper_t* oper, evoper_t* oper_s, evevent event) +int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) { - if (event == op_ev_connect) { - logi("open_connect %d", err); - }else if (event == op_ev_accept) { - logi("accept_connect %d", err); - } else if (event == op_ev_close) { - logi("clse_connect %d", err); + if (event == op_ev_connect && res == op_ev_success) { + logi("open_connect"); + } else if (event == op_ev_accept && res == op_ev_success) { + logi("accept_connect"); + } else if (event == op_ev_close && res == op_ev_success) { + logi("clse_connect"); } return S_SUCCESS; } @@ -42,4 +47,16 @@ void test_conn_oper(evloop_t* loop) evloop_alloc_evoper(loop, oper); int rc = evloop_add_connect(oper, &addr, NULL); //printf("%d\n", rc); +} + +void test_write_oper(evloop_t* loop) +{ + s_strncpy(send_data, "hello", 5); + size_t len = s_strlen(send_data); + evoper_write(oper, (buf_ptr)send_data, len); + evloop_add_write(loop, oper, NULL); +} +void test_read_oper(evloop_t* loop) +{ + } \ No newline at end of file diff --git a/stdcrt_test/test_stdlib.c b/stdcrt_test/test_stdlib.c index 112dd8cc..71fcd251 100644 --- a/stdcrt_test/test_stdlib.c +++ b/stdcrt_test/test_stdlib.c @@ -9,17 +9,17 @@ #include typedef struct myNode_s { - msg_q queue; + _msg_q queue; int val; } myNode_t; -void travel_queue(msg_q* queue) +void travel_queue(_msg_q* queue) { - myNode_t* reqnode; - msg_q* q = _queue_head(queue); - for (; q != _queue_sentinel(queue); q = _queue_next(q)) + _msg_q* q = NULL; + for (q = _queue_head(queue); q != _queue_sentinel(queue); q = _queue_next(q)) { + myNode_t* reqnode; reqnode = _queue_data(q, myNode_t, queue); printf("val:%d\n", reqnode->val); } @@ -33,12 +33,16 @@ void test_msgq(void) _msgq_t msg1; _msgq_init(&msg1); - int i = 0; - for (int i = 0; i < 10; i++) { - myNode_t* regnode = malloc(sizeof(myNode_t)); - regnode->val = i; - _msgq_produce(&msg, ®node->queue); - } + + myNode_t* regnode = malloc(sizeof(myNode_t)); + regnode->val = 1; + + myNode_t* regnode1 = malloc(sizeof(myNode_t)); + regnode1->val = 2; + + _msgq_produce(&msg, ®node->queue); + _msgq_produce(&msg, ®node1->queue); + //copy to msg1.queue _msgq_consume(&msg, &msg1.queue); @@ -306,10 +310,10 @@ int stdtest_func(void) unsigned char* str2hex(char* str) { unsigned char* ret = NULL; - int str_len = strlen(str); + size_t str_len = s_strlen(str); int i = 0; assert((str_len % 2) == 0); - ret = (char*)malloc(str_len / 2); + ret = (unsigned char*)malloc(str_len / 2); for (i = 0; i < str_len; i = i + 2) { sscanf(str + i, "%2hhx", &ret[i / 2]); } diff --git a/stdcrt_test/test_timer.c b/stdcrt_test/test_timer.c index 5a37dee5..fc44842a 100644 --- a/stdcrt_test/test_timer.c +++ b/stdcrt_test/test_timer.c @@ -1,7 +1,7 @@ #include #include "test.h" -int time_handler(int err, evoper_t* oper, evoper_t* oper_s, evevent event) +int time_handler(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) { evloop_t* evloop; crt_msec opermsec = 0; @@ -12,7 +12,7 @@ int time_handler(int err, evoper_t* oper, evoper_t* oper_s, evevent event) evloop_get_clock(evloop, &clockmsec); if (event == op_ev_timer) { - if (err == S_SUCCESS) { + if (res == op_ev_success) { logi("timer %ld==%ld", clockmsec, opermsec); int* id = NULL; evoper_get_ctx(oper, (void**)&id); -- Gitee From edbd1b34adbac32cf214951b48b3ddb60223150d Mon Sep 17 00:00:00 2001 From: com Date: Fri, 19 Jul 2024 20:09:17 +0800 Subject: [PATCH 07/34] up --- crt/crt_assert.hpp | 4 + crt/crt_def.h | 2 +- crt/crt_event.h | 2 +- stdcrt/compat_error.c | 2 +- stdcrt/event/compat_event.c | 29 ++-- stdcrt/event/compat_event_epoll.c | 249 +++++++++++++++++++++++++---- stdcrt/event/compat_event_epoll.h | 4 + stdcrt/event/compat_event_iocp.c | 12 +- stdcrt/event/compat_event_kqueue.c | 15 ++ stdcrt/event/compat_event_kqueue.h | 1 + stdcrt/event/compat_event_posix.c | 98 +++++++++--- stdcrt/event/compat_event_posix.h | 4 +- stdcrt/event/compat_event_util.c | 106 ++++++++++-- stdcrt/event/compat_event_util.h | 87 +++++----- stdcrt/event/compat_event_win32.c | 158 ++++++++++-------- stdcrt_test/main.c | 11 +- stdcrt_test/test_oper.c | 34 +++- 17 files changed, 607 insertions(+), 211 deletions(-) diff --git a/crt/crt_assert.hpp b/crt/crt_assert.hpp index 51af1abe..7c36f00f 100644 --- a/crt/crt_assert.hpp +++ b/crt/crt_assert.hpp @@ -26,6 +26,10 @@ return; \ } while (0); +#define rs_error_continue(p) \ + if ((int)(p)) \ + continue; + #define rc_error_continue(p) \ if (!(int)(p)) \ continue; diff --git a/crt/crt_def.h b/crt/crt_def.h index 0dca830e..6a57018e 100644 --- a/crt/crt_def.h +++ b/crt/crt_def.h @@ -122,7 +122,7 @@ typedef const SafeMemoryPtr* SafeMemoryConstPtr; #endif #ifndef BUF_PTR -typedef unsigned char* buf_ptr; +typedef unsigned char* buf_ptr; #endif #ifndef BUF_SIZE diff --git a/crt/crt_event.h b/crt/crt_event.h index aa61b0db..dff6b044 100644 --- a/crt/crt_event.h +++ b/crt/crt_event.h @@ -132,7 +132,7 @@ int evloop_del_read(evloop_t* loop, evoper_t* oper); int evloop_del_write(evloop_t* loop, evoper_t* oper); int evloop_canncel(evloop_t* loop, evoper_t* oper); int evloop_open(evoper_t* oper, const evaddr_t* addr, ev_time_t tv); -int evloop_poll(evoper_t* oper, int count); +int evloop_poll(evoper_t* oper, unsigned int ls); int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv); int evloop_del_connect(evoper_t* oper); int evloop_alloc_evoper(evloop_t* loop, evoper_t* oper); diff --git a/stdcrt/compat_error.c b/stdcrt/compat_error.c index dea56d85..4f1e1a2c 100644 --- a/stdcrt/compat_error.c +++ b/stdcrt/compat_error.c @@ -29,7 +29,7 @@ crterr crt_geterror(void) { int error; error = ERRNO; - crt_setfatalerror(error); + //crt_setfatalerror(error); return error; } diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index 32c5afec..dc6761d0 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -11,26 +11,26 @@ static int complete_handler(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) { - if (oper->c == op_ev_connecting && (op == op_ev_connecting)) { + if (oper->conn == op_ev_connecting && (op == op_ev_connecting)) { if (evoper_sock_connected(oper) == S_SUCCESS) oper->handler(op_ev_success, oper, oper, op_ev_connect); else oper->handler(op_ev_faild, oper, oper, op_ev_connect); - } else if(oper->o == op_ev_opening && (op == op_ev_opening)) { + } else if(oper->open == op_ev_opening && (op == op_ev_opening)) { oper->handler(op_ev_success, oper, oper, op_ev_open); } else if (oper->s == op_ev_closeing && (op == op_ev_closeing)) { oper->handler(op_ev_success, oper, oper, op_ev_close); - } else if (oper->a == op_ev_accepting && (op == op_ev_accepting)) { + } else if (oper->accept == op_ev_accepting && (op == op_ev_accepting)) { oper->handler(op_ev_success, oper, oper_s, op_ev_accept); } - if (oper->o == op_ev_reading && (op == op_ev_reading)) { + if (oper->read == op_ev_reading && (op == op_ev_reading)) { oper->handler(op_ev_success, oper, oper, op_ev_read); } - if (oper->o == op_ev_writeing && (op == op_ev_opening)) { + if (oper->write == op_ev_writeing && (op == op_ev_writeing)) { oper->handler(op_ev_success, oper, oper, op_ev_write); } @@ -81,16 +81,12 @@ static int evsysop_bind_handler(evloop_t* loop, evsysop_t* op) int evoper_read(evoper_t* oper, buf_ptr buf, buf_len len) { rc_error(oper != NULL, S_ERROR); - oper->rbuf = buf; - oper->rlen = len; - return S_SUCCESS; + return evbuf_bind(&oper->rbuf, buf, len, len); } int evoper_write(evoper_t* oper, buf_ptr buf, buf_len len) { rc_error(oper != NULL, S_ERROR); - oper->wbuf = buf; - oper->wlen = len; - return S_SUCCESS; + return evbuf_bind(&oper->wbuf, buf, len, 0); } int evoper_set_msec(evoper_t* oper, crt_msec msec) { @@ -288,6 +284,7 @@ int evloop_add_read(evloop_t* loop, evoper_t* oper, ev_time_t tv) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_read != NULL, S_ERROR); + evoper_read_op(oper, op_ev_reading); return evsel->op_add_read(loop, oper, op_ev_read, tv); } int evloop_add_write(evloop_t* loop, evoper_t* oper, ev_time_t tv) @@ -297,6 +294,7 @@ int evloop_add_write(evloop_t* loop, evoper_t* oper, ev_time_t tv) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_write != NULL, S_ERROR); + evoper_write_op(oper, op_ev_writeing); return evsel->op_add_write(loop, oper, op_ev_write, tv); } int evloop_del_read(evloop_t* loop, evoper_t* oper) @@ -339,7 +337,7 @@ int evloop_open(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) return evsel->op_open(loop, oper, addr); } -int evloop_poll(evoper_t* oper, int count) +int evloop_poll(evoper_t* oper, unsigned int ls) { rc_error(oper != NULL, S_ERROR); evloop_t* loop = oper->loop; @@ -348,7 +346,8 @@ int evloop_poll(evoper_t* oper, int count) rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_poll != NULL, S_ERROR); - oper->accept_count = count; + evoper_listen_size(oper, ls); + evoper_accept_op(oper, op_ev_accepting); return evsel->op_poll(loop, oper); @@ -363,7 +362,7 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_connect != NULL, S_ERROR); - rs_error(oper->c == op_ev_connected, S_COMPLETED) + rs_error(oper->conn == op_ev_connected, S_COMPLETED) evoper_connect_op(oper, op_ev_connecting); @@ -436,7 +435,7 @@ int evloop_init(evloop_t* loop, int size, int flag) evsysop_init(loop->sysop, flag); rc = loop->sysop->op_alloc(loop, size); rc_error(rc != S_ERROR, S_SUPORTERROR); - rc_error(loop->evbase != NULL, S_SUPORTERROR); + rc_error(loop->evbase != NULL, S_MEMERROR); evsysop_bind_handler(loop, loop->sysop); loop->nodes = loop->mm_malloc(loop, 1, sizeof(evloop_nodes_t)); diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index c716e65e..05358560 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -3,6 +3,30 @@ #if (TARGET_OS == OS_POSIX) + +/* + * The first epoll version has been introduced in Linux 2.5.44. The + * interface was changed several times since then and the final version + * of epoll_create(), epoll_ctl(), epoll_wait(), and EPOLLET mode has + * been introduced in Linux 2.6.0 and is supported since glibc 2.3.2. + * + * EPOLLET mode did not work reliable in early implementaions and in + * Linux 2.4 backport. + * + * EPOLLONESHOT Linux 2.6.2, glibc 2.3. + * EPOLLRDHUP Linux 2.6.17, glibc 2.8. + * epoll_pwait() Linux 2.6.19, glibc 2.6. + * signalfd() Linux 2.6.22, glibc 2.7. + * eventfd() Linux 2.6.22, glibc 2.7. + * timerfd_create() Linux 2.6.25, glibc 2.8. + * epoll_create1() Linux 2.6.27, glibc 2.9. + * signalfd4() Linux 2.6.27, glibc 2.9. + * eventfd2() Linux 2.6.27, glibc 2.9. + * accept4() Linux 2.6.28, glibc 2.10. + * eventfd2(EFD_SEMAPHORE) Linux 2.6.30, glibc 2.10. + * EPOLLEXCLUSIVE Linux 4.5, glibc 2.24. + */ + #include #ifndef __USE_GNU @@ -14,9 +38,29 @@ #endif // !EPOLLRDHUP #ifndef is_epoll_err -#define is_epoll_err(ev) ((ev & EPOLLERR) || (ev & EPOLLHUP) || (!(ev & EPOLLIN))) +#define is_epoll_err(ev) ((ev & EPOLLERR) || (ev & EPOLLHUP) || (!(ev & EPOLLIN))) +#endif + +//EPOLLRDHUP + +#define ev_base_event (EPOLLET | EPOLLERR) + +#ifdef EPOLLEXCLUSIVE +#define ev_poll_event (EPOLLIN | EPOLLEXCLUSIVE) +#else +#define ev_poll_event (EPOLLIN) #endif +#define ev_conn_event (EPOLLOUT) + +#define ev_read_event (EPOLLIN | EPOLLRDHUP) +#define ev_write_event (EPOLLOUT) + +#define ev_clear_event (EPOLLET) + +#define ev_oneshot_write_event (EPOLLOUT | EPOLLONESHOT) +#define ev_oneshot_read_event (EPOLLIN | EPOLLONESHOT) + static int is_use_epoll_rdhup(epoll_op_t* base, int ep) { int use_epoll_rdhup; @@ -97,19 +141,71 @@ static int sys_hook_api(epoll_op_t* base) return S_SUCCESS; } -static int epoll_op(epoll_op_t* base, void* ptr, uint32_t events, int op, int fd) +static uint32_t epoll_event_add(epoll_event_t* ptr, uint32_t op) +{ + uint32_t event = 0; + + if (ptr->op == ev_base_event) { + event = ptr->op; + event |= op; + } else if (ptr->op == ev_clear_event) { + event |= ev_base_event; + event |= op; + } + return event; +} +static uint32_t epoll_event_del(epoll_event_t* ptr, uint32_t op) +{ + uint32_t event = 0; + + if (ptr->op == ev_base_event) { + event = ptr->op; + event &= ~op; + } else if (ptr->op == ev_clear_event) { + event |= ev_base_event; + event &= ~op; + } + return event; +} +static uint32_t get_epoll_op(epoll_event_t* ptr) +{ + rc_error(ptr != NULL, S_ERROR); + return ptr->op; +} +static int get_epoll_ctl(epoll_event_t* ptr) +{ + rc_error(ptr != NULL, S_ERROR); + return ptr->ctl == ev_off ? EPOLL_CTL_ADD : EPOLL_CTL_MOD; +} +static int set_epoll_op(epoll_event_t* ptr, uint32_t op) +{ + rc_error(ptr != NULL, S_ERROR); + ptr->op = op; + return S_SUCCESS; +} +static int set_epoll_ctl(epoll_event_t* ptr, evevent on) +{ + rc_error(ptr != NULL, S_ERROR); + ptr->ctl = on; + return S_SUCCESS; +} + +static int epoll_op(epoll_op_t* base, evoper_t* oper, epoll_event_t* ptr) { struct epoll_event ee; - ee.events = events; + int op = 0; + + op = get_epoll_ctl(ptr); + ee.events = get_epoll_op(ptr); ee.data.u32 = 0; ee.data.u64 = 0; - ee.data.ptr = ptr; + ee.data.ptr = oper; - if (base->sys_epoll_ctl(base->epfd, op, fd, &ee) == 0) + if (base->sys_epoll_ctl(base->epfd, op, oper->fd, &ee) == 0) return S_SUCCESS; if (errno != EPERM) - loge("epoll_ctl error %d, epfd=%d, fd=%d\n", errno, base->epfd, fd); + loge("epoll_ctl error %d, epfd=%d, fd=%d\n", errno, base->epfd, oper->fd); return S_ERROR; } @@ -129,7 +225,7 @@ int epoll_op_alloc(evloop_t* loop, int size) base->sys_epoll_wait = NULL; base->sys_epoll_ctl = NULL; base->sys_eventfd = NULL; - + base->mode = 0; //base->timerfd = -1; //base->sys_timerfd_create = NULL; @@ -149,6 +245,9 @@ int epoll_op_alloc(evloop_t* loop, int size) base->size += 1; } + + base->mode = ev_base_event; + //if (base->sys_timerfd_create != NULL) { // base->timerfd = base->sys_timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC); // if (base->timerfd >= 0) { @@ -202,13 +301,18 @@ int epoll_op_alloc_evoper(evloop_t* loop, evoper_t* oper) { rc_error(loop != NULL, S_ERROR); rc_error(oper != NULL, S_ERROR); - epoll_event_t* obj = (epoll_event_t*)heap_calloc(1, sizeof(epoll_event_t)); - rc_error(obj != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evloop_evbase(loop); rc_error(base != NULL, S_ERROR); - evoper_bind_private(oper, obj); + + epoll_event_t* ptr = (epoll_event_t*)heap_calloc(1, sizeof(epoll_event_t)); + rc_error(ptr != NULL, S_ERROR); + + evoper_bind_private(oper, ptr); + + ptr->ctl = ev_off; + //https://elixir.bootlin.com/linux/v4.19.316/source/fs/eventpoll.c#L2047 - return epoll_op(base, oper, 0, EPOLL_CTL_ADD, oper->fd); + return S_SUCCESS; // epoll_op(base, oper, 0, EPOLL_CTL_ADD, oper->fd); } int epoll_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) { @@ -217,10 +321,14 @@ int epoll_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) rc_error(loop != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evloop_evbase(loop); rc_error(base != NULL, S_ERROR); + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); - rc = epoll_op(base, oper, 0, EPOLL_CTL_DEL, oper->fd); + set_epoll_op(ptr, 0); + set_epoll_ctl(ptr, EPOLL_CTL_DEL); + + rc = epoll_op(base, oper, ptr); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); if (ptr != NULL) heap_free(ptr); @@ -228,40 +336,93 @@ int epoll_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) } int epoll_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { + int rc = S_SUCCESS; rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - return epoll_op(base, oper, ev_read_event, EPOLL_CTL_MOD, oper->fd); + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + rc = posix_tcpsock_recv(oper, 0); + if (rc == S_AGAIN) { + + uint32_t op = epoll_event_add(ptr, ev_read_event); + set_epoll_op(ptr, op); + set_epoll_ctl(ptr, EPOLL_CTL_MOD); + + epoll_op(base, oper, ptr); + } else if (rc == S_SUCCESS){ + + + } + return rc; } int epoll_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { + int rc = S_SUCCESS; rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); - posix_tcpsock_send(oper); + rc = posix_tcpsock_send(oper, 0); + if (rc == S_AGAIN) { + uint32_t op = epoll_event_add(ptr, ev_write_event); + set_epoll_op(ptr, op); + set_epoll_ctl(ptr, EPOLL_CTL_MOD); + epoll_op(base, oper, ptr); + } else if (rc == S_SUCCESS) { + - return epoll_op(base, oper, ev_write_event, EPOLL_CTL_MOD, oper->fd); + } + return rc; // } int epoll_op_del_read(evloop_t* loop, evoper_t* oper, short event) { rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - return epoll_op(base, oper, (EPOLLOUT | EPOLLERR | EPOLLET), EPOLL_CTL_MOD, oper->fd); + + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + uint32_t op = epoll_event_del(ptr, ev_read_event); + set_epoll_op(ptr, op); + set_epoll_ctl(ptr, EPOLL_CTL_MOD); + epoll_op(base, oper, ptr); + + return S_SUCCESS; } int epoll_op_del_write(evloop_t* loop, evoper_t* oper, short event) { rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - return epoll_op(base, oper, (EPOLLOUT | EPOLLERR | EPOLLET), EPOLL_CTL_MOD, oper->fd); + + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + uint32_t op = epoll_event_del(ptr, ev_read_event); + set_epoll_op(ptr, op); + set_epoll_ctl(ptr, EPOLL_CTL_MOD); + + epoll_op(base, oper, ptr); + + return S_SUCCESS; } int epoll_op_cancel(evloop_t* loop, evoper_t* oper) { epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - return epoll_op(base, oper, ev_clear_event, EPOLL_CTL_MOD, oper->fd); + + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + set_epoll_op(ptr, ev_clear_event); + set_epoll_ctl(ptr, EPOLL_CTL_DEL); + + return epoll_op(base, oper, ptr); } int epoll_op_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) { @@ -272,7 +433,15 @@ int epoll_op_poll(evloop_t* loop, evoper_t* oper) rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - return epoll_op(base, oper, ev_poll_event, EPOLL_CTL_MOD, oper->fd); + + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + uint32_t op = ev_poll_event | ev_base_event; + set_epoll_op(ptr, op); + set_epoll_ctl(ptr, EPOLL_CTL_ADD); + + return epoll_op(base, oper, ptr); } int epoll_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { @@ -281,41 +450,55 @@ int epoll_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, e epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - if (epoll_op(base, oper, ev_conn_event, EPOLL_CTL_MOD, oper->fd) == S_SUCCESS) - rc = evoper_sock_connect(oper, addr); + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + rc = evoper_sock_connect(oper, addr); + + if (rc == S_PENDING) { + uint32_t op = ev_conn_event | ev_base_event; + set_epoll_op(ptr, op); + set_epoll_ctl(ptr, EPOLL_CTL_ADD); + rc = epoll_op(base, oper, ptr); + } return rc; } int epoll_op_del_connect(evloop_t* loop, evoper_t* oper) { - int rc = S_ERROR; rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - return rc; + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + uint32_t op = epoll_event_del(ptr, ev_conn_event); + set_epoll_op(ptr, op); + set_epoll_ctl(ptr, EPOLL_CTL_DEL); + epoll_op(base, oper, ptr); + + return S_SUCCESS; } int epoll_event_complete(evloop_t* loop, crterr err, epoll_op_t* base, evoper_t* oper, short ev) { int rc = S_ERROR; rc_error(oper != NULL, S_ERROR); - if (oper->a == op_ev_accepting && (ev == op_ev_readed)) + if (oper->accept == op_ev_accepting && (ev == op_ev_readed)) rc = complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); - if (oper->c == op_ev_connecting && (ev == op_ev_writed)) + if (oper->conn == op_ev_connecting && (ev == op_ev_writed)) rc = complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); if (oper->s == op_ev_closeing || (ev == op_ev_closed)) rc = complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - if (oper->r == op_ev_reading && (ev & op_ev_readed)) { - - } - - if (oper->w == op_ev_writeing && (ev & op_ev_writed)) { - - } + if (oper->read == op_ev_reading && (ev & op_ev_readed)) + rc = complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); + + if (oper->write == op_ev_writeing && (ev & op_ev_writed)) + rc = complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); return rc; } diff --git a/stdcrt/event/compat_event_epoll.h b/stdcrt/event/compat_event_epoll.h index 84f3b3c5..fb2fbba6 100644 --- a/stdcrt/event/compat_event_epoll.h +++ b/stdcrt/event/compat_event_epoll.h @@ -14,6 +14,7 @@ typedef struct epoll_event_s epoll_event_t; typedef struct epoll_op_s epoll_op_t; struct epoll_event_s { + evevent ctl; uint32_t op; }; @@ -63,6 +64,9 @@ struct epoll_op_s { //op ev_op ev; + + //mode + uint32_t mode; }; int epoll_evop_t(evsysop_t* op); diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index 122f9d95..87638008 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -176,7 +176,7 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, D oper = evoper_ov->ptr; rc_error(oper != NULL, S_ERROR); - if (oper->c == op_ev_connecting) { + if (oper->conn == op_ev_connecting) { int conn_error = S_SUCCESS; @@ -194,9 +194,9 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, D complete_sock_connect(loop, conn_error, err, oper, base->ev); - } else if (oper->w == op_ev_writeing) { + } else if (oper->write == op_ev_writeing) { base->ev(0, err, oper, NULL, op_ev_writeing); - } else if (oper->r == op_ev_reading) { + } else if (oper->read == op_ev_reading) { base->ev(0, err, oper, NULL, op_ev_writeing); } return S_SUCCESS; @@ -297,8 +297,8 @@ int iocp_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) int rc = S_ERROR; if (oper->t == ev_sock) { - if (oper->r) { - // rc = win32_sock_read(oper); + if (oper->read == op_ev_reading) { + rc = win32_sock_read_op(oper); } } return rc; @@ -307,7 +307,7 @@ int iocp_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; if (oper->t == ev_sock) { - if (oper->w) { + if (oper->write == op_ev_writeing) { rc = win32_sock_write_op(oper); } } diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 9cea86a3..aaf4112b 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -3,6 +3,21 @@ #if (TARGET_OS == OS_MACH) +static int kqueue_notify_init(kqueue_op_t* base) +{ + base->notify_kev.ident = 0; + base->notify_kev.filter = EVFILT_USER; + base->notify_kev.data = 0; + base->notify_kev.flags = EV_ADD | EV_CLEAR; + base->notify_kev.fflags = 0; + base->notify_kev.udata = 0; + + if (kevent(base->kqfd, &base->notify_kev, 1, NULL, 0, NULL) == -1) { + return S_ERROR; + } + return S_SUCCESS; +} + static int kqueue_hook_api(kqueue_op_t* base) { base->sys_kqueue = (kqueue_fn)dlsym(RTLD_NEXT, "kqueue"); diff --git a/stdcrt/event/compat_event_kqueue.h b/stdcrt/event/compat_event_kqueue.h index 1a654c41..ca429024 100644 --- a/stdcrt/event/compat_event_kqueue.h +++ b/stdcrt/event/compat_event_kqueue.h @@ -29,6 +29,7 @@ struct kqueue_op_s { kqueue_fn sys_kqueue; kevent_fn sys_kevent; struct kevent* poll; + struct kevent notify_kev; ev_op ev; _mutex_t lock; }; diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index cc3c901a..72ef7407 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -6,49 +6,99 @@ #include "compat_event_epoll.h" #include "compat_event_posix.h" -int posix_tcpsock_send(evoper_t* oper) +int posix_tcpsock_send(evoper_t* oper, int flags) { - int rc = S_ERROR; + int rc = S_SUCCESS; rc_error(oper != NULL, rc); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); ssize_t n; - oper->sent = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->wbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->wbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + for (;;) { - n = send(oper->fd, oper->wbuf, oper->wlen, 0); - crterr err = crt_geterror(); + int err = 0; + + n = send(oper->fd, ptr, len, flags); + + err = (n == -1) ? errno : 0; if (n > 0) { - if (n < (ssize_t)oper->wlen) { - //wev->ready = 0; - } - oper->sent += n; + evoper_ready_op(oper, ev_on); + evbuf_off_sum(&oper->wbuf, n); return S_SUCCESS; } - if (n == 0) { - //wev->ready = 0; + switch (err) { + case EAGAIN: + return S_AGAIN; + case EINTR: + continue; + default: + return S_ERROR; + } + } + return rc; +} +int posix_tcpsock_recv(evoper_t* oper, int flags) +{ + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); + ssize_t n; + buf_ptr ptr = NULL; + buf_len len = 0; + crterr err; + + rc = evbuf_get_buf(&oper->rbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->rbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + + for (;;) { + + int err = 0; + n = recv(oper->fd, ptr, len, flags); + err = (n == -1) ? errno : 0; + + if (n > 0) { + + if (n < len) { + evoper_ready_op(oper, ev_on); + } + evbuf_off_sub(&oper->rbuf, n); return S_SUCCESS; } - if (err == EAGAIN || err == EINTR) { - //wev->ready = 0; - if (err == EAGAIN) { - return S_AGAIN; + if (n == 0) { + evoper_close_op(oper, ev_on); + + if ((flags & MSG_PEEK) == 0) { + evoper_ready_op(oper, ev_on); } + return S_SUCCESS; + } - } else { + switch (err) { + case EAGAIN: + evoper_ready_op(oper, ev_on); + return S_AGAIN; + case EINTR: + continue; + default: return S_ERROR; } + } - return S_SUCCESS; -} -int posix_tcpsock_recv(evoper_t* oper) -{ - int rc = S_ERROR; - rc_error(oper != NULL, rc); - epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); - return S_SUCCESS; + return rc; } #endif diff --git a/stdcrt/event/compat_event_posix.h b/stdcrt/event/compat_event_posix.h index e237df3a..64a12e88 100644 --- a/stdcrt/event/compat_event_posix.h +++ b/stdcrt/event/compat_event_posix.h @@ -9,8 +9,8 @@ extern "C" { #if (TARGET_OS == OS_POSIX) -int posix_tcpsock_send(evoper_t* oper); -int posix_tcpsock_recv(evoper_t* oper); +int posix_tcpsock_send(evoper_t* oper, int flags); +int posix_tcpsock_recv(evoper_t* oper, int flags); #endif diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index a858d45c..3cd0b86d 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -152,6 +152,12 @@ void* evoper_private(evoper_t* oper) rc_error(oper != NULL, NULL); return oper->private; } +int evoper_bind_private(evoper_t* oper, void* obj) +{ + rc_error(oper != NULL, S_ERROR); + oper->private = obj; + return S_SUCCESS; +} int evoper_state_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); @@ -161,31 +167,31 @@ int evoper_state_op(evoper_t* oper, evevent op) int evoper_connect_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); - oper->c = op; + oper->conn = op; return S_SUCCESS; } int evoper_accept_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); - oper->a = op; + oper->accept = op; return S_SUCCESS; } -int evoper_accept_size(evoper_t* oper, unsigned int count) +int evoper_listen_size(evoper_t* oper, evoper_ls ls) { rc_error(oper != NULL, S_ERROR); - oper->accept_count = count; + oper->ls = ls; return S_SUCCESS; } int evoper_read_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); - oper->r = op; + oper->read = op; return S_SUCCESS; } int evoper_write_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); - oper->w = op; + oper->write = op; return S_SUCCESS; } int evoper_post_op(evoper_t* oper, evevent op) @@ -194,10 +200,22 @@ int evoper_post_op(evoper_t* oper, evevent op) oper->post = op; return S_SUCCESS; } -int evoper_bind_private(evoper_t* oper, void* obj) +int evoper_ready_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); - oper->private = obj; + oper->ready = op; + return S_SUCCESS; +} +int evoper_eof_op(evoper_t* oper, evevent op) +{ + rc_error(oper != NULL, S_ERROR); + oper->eof = op; + return S_SUCCESS; +} +int evoper_close_op(evoper_t* oper, evevent op) +{ + rc_error(oper != NULL, S_ERROR); + oper->close = op; return S_SUCCESS; } int evoper_assign_sock(evoper_t* oper, _sock_t sock) @@ -235,7 +253,7 @@ int evoper_sock_connected(evoper_t* oper) } int complete_sock_accept(evloop_t* loop, int err, crterr code, evoper_t* oper, evoper_t* oper_t, ev_op func) { - unsigned int l = 0; + evoper_ls l = 0; rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); @@ -244,9 +262,9 @@ int complete_sock_accept(evloop_t* loop, int err, crterr code, evoper_t* oper, e //oper->bind = 1; func(err == 0 ? S_SUCCESS : S_ERROR, err, oper, oper_t, op_ev_accepting); #else - unsigned int count = oper->accept_count; + evoper_ls ls = oper->ls; - for (l = 0; l < count; l++) { + for (l = 0; l < ls; l++) { struct sockaddr_in cliaddr; socklen_t clilen = sizeof(struct sockaddr_in); @@ -254,7 +272,7 @@ int complete_sock_accept(evloop_t* loop, int err, crterr code, evoper_t* oper, e accept_sock = accept(oper->sock, (struct sockaddr*)&cliaddr, &clilen); rc_error_break(accept_sock != -1); - + evoper_t* oper_s = (evoper_t*)loop->mm_malloc(loop, 1, sizeof(evoper_t)); rc_error_break(oper_s != NULL); @@ -287,6 +305,13 @@ int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_ rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); + +#if (TARGET_OS == OS_WIN) + +#else + posix_tcpsock_recv(oper, 0); +#endif + func(err, code, oper, NULL, op_ev_reading); evoper_read_op(oper, op_ev_readed); return S_SUCCESS; @@ -300,4 +325,61 @@ int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev evoper_write_op(oper, op_ev_writed); return S_SUCCESS; } +int evbuf_is_eof(evbuf_t* buf) +{ + rc_error(buf != NULL, S_ERROR); + return buf->len == buf->off ? S_SUCCESS : S_ERROR; +} +int evbuf_bind(evbuf_t* buf, buf_ptr ptr, buf_len len, buf_len off) +{ + rc_error(buf != NULL, S_ERROR); + rc_error(ptr != NULL, S_ERROR); + rc_error(len != 0, S_ERROR); + + buf->ptr = ptr; + buf->len = len; + buf->off = off; + return S_SUCCESS; +} +int evbuf_get_buf(evbuf_t* buf, buf_ptr* ptr) +{ + rc_error(buf != NULL, S_ERROR); + *ptr = buf->ptr; + return S_SUCCESS; +} +int evbuf_get_len(evbuf_t* buf, buf_len* len) +{ + rc_error(buf != NULL, S_ERROR); + *len = buf->len; + return S_SUCCESS; +} +int evbuf_get_off(evbuf_t* buf, buf_len* off) +{ + rc_error(buf != NULL, S_ERROR); + *off = buf->off; + return S_SUCCESS; +} +int evbuf_set_off(evbuf_t* buf, buf_len off) +{ + rc_error(buf != NULL, S_ERROR); + buf->off = off; + return S_SUCCESS; +} +int evbuf_off_sum(evbuf_t* buf, buf_len off) +{ + rc_error(buf != NULL, S_ERROR); + buf->off +=off; + return S_SUCCESS; +} +int evbuf_off_sub(evbuf_t* buf, buf_len off) +{ + rc_error(buf != NULL, S_ERROR); + buf->off -= off; + return S_SUCCESS; +} +int is_evbuf_compelete(evbuf_t* buf) +{ + rc_error(buf != NULL, S_ERROR); + return buf->off == buf->len ? S_SUCCESS : S_ERROR; +} \ No newline at end of file diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 9b52020d..cdf78128 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -68,23 +68,10 @@ #elif (TARGET_OS == OS_POSIX) //linux 2.6.17 -#define ev_base_event (EPOLLERR | EPOLLET) - -#define ev_poll_event (EPOLLIN | ev_base_event) -#define ev_conn_event (EPOLLOUT | ev_base_event) - -#define ev_read_event (EPOLLIN | ev_base_event) -#define ev_write_event (EPOLLOUT | ev_base_event) - -#define ev_clear_event ev_base_event -#define ev_level_event 0 - -#define ev_oneshot_event EPOLLONESHOT -#define ev_exclusive_event EPOLLEXCLUSIVE #elif (TARGET_OS == OS_WIN) -#define ev_conn_event 0 +#define ev_conn_event 0 #define ev_read_event 0 #define ev_write_event 1 #define ev_level_event 0 @@ -105,11 +92,6 @@ #endif -#ifndef ev_clear_event -#define ev_clear_event 0 -#endif - - #ifndef op_cmd_poll #define op_cmd_poll 0x01 #endif // !op_cmd_poll @@ -129,8 +111,11 @@ typedef struct evloop_nodes_s evloop_nodes_t; typedef struct evloop_clock_s evloop_clock_t; +typedef struct evbuf_s evbuf_t; typedef _queue_t evloop_queue_t; typedef _queue_t evoper_queue; +typedef unsigned int evoper_ls; + /* * An active default event. The event type depends on interface: @@ -184,11 +169,11 @@ typedef _queue_t evoper_queue; #define op_ev_closed 0x0E #ifndef ev_on -#define ev_on 0x01 +#define ev_on 0x00 #endif // !ev_on #ifndef ev_off -#define ev_off 0x00 +#define ev_off 0x01 #endif // !ev_off #ifndef ev_none @@ -203,9 +188,11 @@ typedef _queue_t evoper_queue; #define ev_eof 0x20 #endif // !ev_eof -#ifndef ev_pendingeof -#define ev_pendingeof 0x30 -#endif // !ev_pendingeof +struct evbuf_s { + buf_ptr ptr; + buf_len len; + buf_len off; +}; struct evoper_s { @@ -213,24 +200,30 @@ struct evoper_s { void* ctx; void* private; - evevent o; - evevent r; - evevent w; - evevent c; - evevent a; - evevent s; + evevent open; + + evevent read; + evbuf_t rbuf; + + evevent write; + evbuf_t wbuf; + + evevent conn; + + evevent accept; + evoper_ls ls; + + evevent oneshot; evevent eof; evevent post; - evevent err; - evevent vnode; //kqueue_vnode; + evevent close; + evevent err; - buf_ptr rbuf; - buf_len rlen; - buf_ptr wbuf; - buf_len wlen; - buf_len sent; + evevent vnode; // kqueue_vnode; + evevent pending_eof; // kqueue_vnode; - unsigned int accept_count; + evevent ready; // eventing + evevent s; // enable,disable,close union { _fd_t fd; @@ -317,16 +310,20 @@ void* evloop_evbase(evloop_t* loop); void* evloop_sysop(evloop_t* loop); void* evoper_evbase(evoper_t* oper); void* evoper_private(evoper_t* oper); +int evoper_bind_private(evoper_t* oper, void* obj); int evoper_state_op(evoper_t* oper, evevent op); int evoper_connect_op(evoper_t* oper, evevent op); int evoper_accept_op(evoper_t* oper, evevent op); -int evoper_accept_size(evoper_t* oper, unsigned int count); +int evoper_listen_size(evoper_t* oper, evoper_ls ls); int evoper_read_op(evoper_t* oper, evevent op); int evoper_write_op(evoper_t* oper, evevent op); int evoper_post_op(evoper_t* oper, evevent op); +int evoper_ready_op(evoper_t* oper, evevent op); +int evoper_eof_op(evoper_t* oper, evevent op); +int evoper_close_op(evoper_t* oper, evevent op); + -int evoper_bind_private(evoper_t* oper, void* obj); int evoper_assign_sock(evoper_t* oper, _sock_t sock); int evoper_sock_connect(evoper_t* oper, const evaddr_t* addr); int evoper_sock_connected(evoper_t* oper); @@ -337,5 +334,15 @@ int complete_sock_close(evloop_t* loop, int err, crterr code, evoper_t* oper, ev int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func); int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func); +int evbuf_is_eof(evbuf_t* buf); +int evbuf_bind(evbuf_t* buf, buf_ptr ptr, buf_len len, buf_len off); +int evbuf_get_buf(evbuf_t* buf, buf_ptr* ptr); +int evbuf_get_len(evbuf_t* buf, buf_len* len); +int evbuf_get_off(evbuf_t* buf, buf_len* off); + +int evbuf_set_off(evbuf_t* buf, buf_len off); +int evbuf_off_sum(evbuf_t* buf, buf_len off); +int evbuf_off_sub(evbuf_t* buf, buf_len off); +int is_evbuf_compelete(evbuf_t* buf); #endif diff --git a/stdcrt/event/compat_event_win32.c b/stdcrt/event/compat_event_win32.c index 16ba156a..8b36b87c 100644 --- a/stdcrt/event/compat_event_win32.c +++ b/stdcrt/event/compat_event_win32.c @@ -168,53 +168,75 @@ int win32_sock_accept(evoper_t* accept_oper, wsasock* sk) return rc; } -static int wsa_sock_recv(evoper_t* oper, crterr* err, sock_size* bytes, int op) +static int wsa_sock_recv(evoper_t* oper, int* ret, sock_size* bytes, evevent op) { int rc = S_ERROR; + DWORD bytes_transferred = 0; DWORD flags = 0; WSABUF wsabuf; - int ret = 0; lpevoper_ov ov = (lpevoper_ov)evoper_private(oper); rc_error(ov != NULL, S_ERROR); rc = oper_overlapped_memset(oper); rc_error(rc != S_ERROR, S_ERROR); - //wsabuf.buf = oper->r.ptr; - //wsabuf.len = oper->r.len & 0xFFFFFFFF; - if (op) - ret = WSARecv(oper->sock, &wsabuf, 1, bytes, &flags, &ov->overlapped, NULL); + + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->rbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->rbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + wsabuf.buf = ptr; + wsabuf.len = len & 0xFFFFFFFF; + + if (op == ev_on) + *ret = WSARecv(oper->sock, &wsabuf, 1, &bytes_transferred, &flags, &ov->overlapped, NULL); else - ret = WSARecv(oper->sock, &wsabuf, 1, bytes, &flags, NULL, NULL); + *ret = WSARecv(oper->sock, &wsabuf, 1, &bytes_transferred, &flags, NULL, NULL); + + *bytes = bytes_transferred; - *err = crt_geterror(); return rc; } -static int wsa_sock_send(evoper_t* oper, crterr* err, sock_size* size, int op) +static int wsa_sock_send(evoper_t* oper, int* ret, sock_size* bytes, evevent op) { int rc = S_ERROR; - DWORD bytes = 0; + DWORD bytes_transferred = 0; DWORD flags = 0; WSABUF wsabuf; - int ret = 0; - rc_error(oper != NULL, 0); + rc_error(oper != NULL, S_ERROR); lpevoper_ov ov = (lpevoper_ov)evoper_private(oper); - rc_error(ov != NULL, 0); + rc_error(ov != NULL, S_ERROR); rc = oper_overlapped_memset(oper); - rc_error(rc != S_ERROR, 0); + rc_error(rc != S_ERROR, S_ERROR); + + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->wbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); - //wsabuf.buf = oper->w.ptr; - //wsabuf.len = oper->w.len & 0xFFFFFFFF; + rc = evbuf_get_len(&oper->wbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); - if (op) - ret = WSASend(oper->sock, &wsabuf, 1, &bytes, flags, &ov->overlapped, NULL); + wsabuf.buf = ptr; + wsabuf.len = len & 0xFFFFFFFF; + + if (op == ev_on) + *ret = WSASend(oper->sock, &wsabuf, 1, &bytes_transferred, flags, &ov->overlapped, NULL); else - ret = WSASend(oper->sock, &wsabuf, 1, &bytes, flags, NULL, NULL); + *ret = WSASend(oper->sock, &wsabuf, 1, &bytes_transferred, flags, NULL, NULL); + + + *bytes = bytes_transferred; - *err = crt_geterror(); - return ret; + return rc; } sock_size win32_sock_read(evoper_t* oper, sock_size size) @@ -224,7 +246,9 @@ sock_size win32_sock_read(evoper_t* oper, sock_size size) sock_size byte = 0; crterr err = 0; rc_error(oper != NULL, S_ERROR); - ret = wsa_sock_recv(oper, &err, &byte, 0); + + rc = wsa_sock_recv(oper, &ret, &byte, ev_off); + err = crt_geterror(); if (err == ERROR_NETNAME_DELETED) byte = 0; @@ -245,7 +269,8 @@ sock_size win32_sock_write(evoper_t* oper, sock_size size) sock_size byte = 0; crterr err = 0; rc_error(oper != NULL, S_ERROR); - ret = wsa_sock_send(oper, &err, &byte, 0); + rc = wsa_sock_send(oper, &ret, &byte, ev_off); + err = crt_geterror(); if (err == ERROR_NETNAME_DELETED) byte = 0; @@ -258,26 +283,6 @@ sock_size win32_sock_write(evoper_t* oper, sock_size size) return byte; } -//void complete_iocp_recv(state_type state, const weak_cancel_token_type& cancel_token, bool all_empty, asio::error_code& ec, size_t bytes_transferred) -//{ -// // Map non-portable errors to their portable counterparts. -// if (ec.value() == ERROR_NETNAME_DELETED) { -// if (cancel_token.expired()) -// ec = asio::error::operation_aborted; -// else -// ec = asio::error::connection_reset; -// } else if (ec.value() == ERROR_PORT_UNREACHABLE) { -// ec = asio::error::connection_refused; -// } else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA) { -// asio::error::clear(ec); -// } -// -// // Check for connection closed. -// else if (!ec && bytes_transferred == 0 && (state & stream_oriented) != 0 && !all_empty) { -// ec = asio::error::eof; -// } -//} - int win32_sock_read_op(evoper_t* oper) { int ret = 0; @@ -285,34 +290,38 @@ int win32_sock_read_op(evoper_t* oper) sock_size byte = 0; crterr err = 0; rc_error(oper != NULL, S_ERROR); - ret = wsa_sock_recv(oper, &err, &byte, 1); - + rc = wsa_sock_recv(oper, &ret, &byte, ev_on); + err = crt_geterror(); + if (err == ERROR_NETNAME_DELETED) rc = S_ERROR; else if (err == ERROR_PORT_UNREACHABLE) rc = S_ERROR; - if (ret != 0 && err != WSA_IO_PENDING) - rc = S_COMPLETED; - else + if (ret == 0) { + evbuf_off_sub(&oper->rbuf, byte); + if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { + rc = S_COMPLETED; + goto end; + } + } + + if (err == WSA_IO_PENDING) { rc = S_PENDING; + goto end; + } + + if (byte == 0) { + evoper_eof_op(oper, ev_on); + rc = S_ERROR; + goto end; + } + return S_ERROR; +end: return rc; } - -//void complete_iocp_send(const weak_cancel_token_type& cancel_token, asio::error_code& ec) -//{ -// // Map non-portable errors to their portable counterparts. -// if (ec.value() == ERROR_NETNAME_DELETED) { -// if (cancel_token.expired()) -// ec = asio::error::operation_aborted; -// else -// ec = asio::error::connection_reset; -// } else if (ec.value() == ERROR_PORT_UNREACHABLE) { -// ec = asio::error::connection_refused; -// } -//} int win32_sock_write_op(evoper_t* oper) { int ret = 0; @@ -321,17 +330,34 @@ int win32_sock_write_op(evoper_t* oper) crterr err = 0; rc_error(oper != NULL, S_ERROR); - ret = wsa_sock_send(oper, &err, &byte, 1); + rc = wsa_sock_send(oper, &ret, &byte, ev_on); err = crt_geterror(); if (err == ERROR_PORT_UNREACHABLE) rc = S_ERROR; - if (ret != 0 && err != WSA_IO_PENDING) - rc = S_COMPLETED; - else - rc = S_PENDING; + if (ret == 0) { + + if (err == WSA_IO_PENDING) { + rc = S_PENDING; + goto end; + } + evbuf_off_sum(&oper->wbuf, byte); + if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { + rc = WSA_IO_PENDING; + goto end; + } + } + + if (err == WSA_IO_PENDING) { + rc = S_PENDING; + goto end; + } + + + return S_ERROR; +end: return rc; } #endif diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index 85f70656..27edfb87 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -13,11 +13,16 @@ void thread_proc2(void* ctx) { sleep_time(7); test_conn_oper(loop); - + + sleep_time(5); + test_write_oper(loop); + while (1) { - sleep_time(7); - test_write_oper(loop); + //sleep_time(5); + //test_conn_oper(loop); + sleep_time(5); + test_read_oper(loop); } } diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index f65cb25a..97307f3e 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -5,6 +5,7 @@ evoper_t* oper; evoper_t* accept_oper; evoper_t* new_oper; evaddr_t addr; +evloop_t* loop_ex; char* send_data; char* recv_data; @@ -17,6 +18,9 @@ void test_init_evaddr() addr.port = 9000; send_data = heap_malloc(4096); recv_data = heap_malloc(4096); + + s_memset(send_data, 0x00, 4096); + s_memset(recv_data, 0x00, 4096); } int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) { @@ -24,18 +28,32 @@ int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) logi("open_connect"); } else if (event == op_ev_accept && res == op_ev_success) { logi("accept_connect"); + new_oper = oper_s; } else if (event == op_ev_close && res == op_ev_success) { - logi("clse_connect"); + logi("close_connect"); + } else if (event == op_ev_write && res == op_ev_success) { + logi("write"); } return S_SUCCESS; } +void bind_loop(evloop_t* loop, evoper_t* oper_oper) +{ + evloop_alloc_evoper(loop, oper_oper); + evoper_bind_handler(oper_oper, evop_proc); +} + void test_accept_oper(evloop_t* loop) { + int rc; evoper_alloc(&accept_oper, NULL, oper_alloc); - evoper_pollsock(accept_oper, &addr, 1); - evloop_alloc_evoper(loop, accept_oper); - evoper_bind_handler(accept_oper, evop_proc); + + + rc = evoper_pollsock(accept_oper, &addr, 1); + if (rc != S_SUCCESS) + logi("evoper_pollsock error"); + + bind_loop(loop, accept_oper); evloop_poll(accept_oper, 1); } @@ -43,8 +61,7 @@ void test_conn_oper(evloop_t* loop) { evoper_alloc(&oper, NULL, oper_alloc); evoper_sock(oper); - evoper_bind_handler(oper, evop_proc); - evloop_alloc_evoper(loop, oper); + bind_loop(loop, oper); int rc = evloop_add_connect(oper, &addr, NULL); //printf("%d\n", rc); } @@ -58,5 +75,8 @@ void test_write_oper(evloop_t* loop) } void test_read_oper(evloop_t* loop) { - + evloop_alloc_evoper(loop, new_oper); + evoper_read(new_oper, (buf_ptr)recv_data, 5); + evoper_bind_handler(new_oper, evop_proc); + evloop_add_read(loop, new_oper, NULL); } \ No newline at end of file -- Gitee From 69f814b72fe478a0fb642a9b452078ca5007583b Mon Sep 17 00:00:00 2001 From: com Date: Fri, 19 Jul 2024 21:29:43 +0800 Subject: [PATCH 08/34] up --- stdcrt/event/compat_event.c | 34 ++++++++++------ stdcrt/event/compat_event_epoll.c | 15 ++------ stdcrt/event/compat_event_posix.c | 64 ++++++++++++++++--------------- stdcrt/event/compat_event_util.c | 10 +---- stdcrt/event/compat_event_util.h | 3 +- stdcrt/event/compat_event_win32.c | 4 +- stdcrt_test/test_oper.c | 5 ++- 7 files changed, 68 insertions(+), 67 deletions(-) diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index dc6761d0..54d80baa 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -9,7 +9,7 @@ #include "compat_event_kqueue.h" #endif -static int complete_handler(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) +static int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) { if (oper->conn == op_ev_connecting && (op == op_ev_connecting)) { @@ -41,6 +41,7 @@ static int complete_handler(int err, crterr code, evoper_t* oper, evoper_t* oper return S_SUCCESS; } + static void* evmem_heap_malloc(evloop_t* loop, size_t count, size_t size) { return heap_calloc(count, size); @@ -76,12 +77,12 @@ static int evsysop_init(evsysop_t* op, int flag) } static int evsysop_bind_handler(evloop_t* loop, evsysop_t* op) { - return op->op_handler(loop, complete_handler); + return op->op_handler(loop, complete_op); } int evoper_read(evoper_t* oper, buf_ptr buf, buf_len len) { rc_error(oper != NULL, S_ERROR); - return evbuf_bind(&oper->rbuf, buf, len, len); + return evbuf_bind(&oper->rbuf, buf, len, 0); } int evoper_write(evoper_t* oper, buf_ptr buf, buf_len len) { @@ -279,23 +280,35 @@ int evloop_add_timer(evloop_t* loop, evoper_t* oper, ev_time_t tv) } int evloop_add_read(evloop_t* loop, evoper_t* oper, ev_time_t tv) { + int rc = S_ERROR; rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_read != NULL, S_ERROR); evoper_read_op(oper, op_ev_reading); - return evsel->op_add_read(loop, oper, op_ev_read, tv); + rc = evsel->op_add_read(loop, oper, op_ev_read, tv); + if (rc == S_COMPLETED) { + complete_op(S_SUCCESS, 0, oper, oper, op_ev_reading); + evoper_read_op(oper, op_ev_readed); + } + return rc; } int evloop_add_write(evloop_t* loop, evoper_t* oper, ev_time_t tv) { + int rc = S_ERROR; rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_write != NULL, S_ERROR); evoper_write_op(oper, op_ev_writeing); - return evsel->op_add_write(loop, oper, op_ev_write, tv); + rc = evsel->op_add_write(loop, oper, op_ev_write, tv); + if (rc == S_COMPLETED) { + complete_op(S_SUCCESS, 0, oper, oper, op_ev_writeing); + evoper_write_op(oper, op_ev_writed); + } + return rc; } int evloop_del_read(evloop_t* loop, evoper_t* oper) { @@ -345,11 +358,8 @@ int evloop_poll(evoper_t* oper, unsigned int ls) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_poll != NULL, S_ERROR); - evoper_listen_size(oper, ls); - evoper_accept_op(oper, op_ev_accepting); - return evsel->op_poll(loop, oper); } int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) @@ -370,10 +380,10 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) rs_error(rc == S_PENDING, S_SUCCESS) if (rc == S_COMPLETED) { - complete_handler(S_SUCCESS, 0, oper, oper, op_ev_connect); - //op_ev_connecting ==> op_ev_connected + complete_op(S_SUCCESS, 0, oper, oper, op_ev_connecting); evoper_connect_op(oper, op_ev_connected); } + return rc; } int evloop_del_connect(evoper_t* oper) @@ -514,8 +524,8 @@ static int cmd_poll_time(evloop_t* loop, evoper_t* oper) if (ms > 0) op->op_dispatch(loop, op_cmd_poll, ms); - complete_handler(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timering); - + complete_op(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timering); + return S_SUCCESS; } static int cmd_poll(evloop_t* loop, crt_msec msec) diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index 05358560..baf9fce6 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -344,17 +344,13 @@ int epoll_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) rc_error(ptr != NULL, S_ERROR); rc = posix_tcpsock_recv(oper, 0); - if (rc == S_AGAIN) { + if (rc == S_PENDING) { uint32_t op = epoll_event_add(ptr, ev_read_event); set_epoll_op(ptr, op); set_epoll_ctl(ptr, EPOLL_CTL_MOD); - epoll_op(base, oper, ptr); - } else if (rc == S_SUCCESS){ - - - } + } return rc; } int epoll_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) @@ -367,15 +363,12 @@ int epoll_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv rc_error(ptr != NULL, S_ERROR); rc = posix_tcpsock_send(oper, 0); - if (rc == S_AGAIN) { + if (rc == S_PENDING) { uint32_t op = epoll_event_add(ptr, ev_write_event); set_epoll_op(ptr, op); set_epoll_ctl(ptr, EPOLL_CTL_MOD); epoll_op(base, oper, ptr); - } else if (rc == S_SUCCESS) { - - - } + } return rc; // } int epoll_op_del_read(evloop_t* loop, evoper_t* oper, short event) diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index 72ef7407..b61add6f 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -24,27 +24,30 @@ int posix_tcpsock_send(evoper_t* oper, int flags) for (;;) { int err = 0; - n = send(oper->fd, ptr, len, flags); - err = (n == -1) ? errno : 0; if (n > 0) { - evoper_ready_op(oper, ev_on); - evbuf_off_sum(&oper->wbuf, n); - return S_SUCCESS; + evbuf_op_off(&oper->wbuf, n); + if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { + return S_COMPLETED; + } + return S_PENDING; } - switch (err) { - case EAGAIN: - return S_AGAIN; - case EINTR: - continue; - default: - return S_ERROR; + if (err == EAGAIN) { + rc = S_PENDING; + goto end; + } else if (err == EINTR) { + // sync + } else { + rc = S_ERROR; + goto end; } } return rc; +end: + return rc; } int posix_tcpsock_recv(evoper_t* oper, int flags) { @@ -70,35 +73,34 @@ int posix_tcpsock_recv(evoper_t* oper, int flags) err = (n == -1) ? errno : 0; if (n > 0) { - - if (n < len) { - evoper_ready_op(oper, ev_on); + evbuf_op_off(&oper->rbuf, n); + if (is_evbuf_compelete(&oper->rbuf) == S_SUCCESS) { + rc = S_COMPLETED; + goto end; } - evbuf_off_sub(&oper->rbuf, n); - return S_SUCCESS; + rc = S_PENDING; + goto end; } if (n == 0) { evoper_close_op(oper, ev_on); - - if ((flags & MSG_PEEK) == 0) { - evoper_ready_op(oper, ev_on); - } - return S_SUCCESS; + rc = S_ERROR; + goto end; } - switch (err) { - case EAGAIN: - evoper_ready_op(oper, ev_on); - return S_AGAIN; - case EINTR: - continue; - default: - return S_ERROR; + if (err == EAGAIN) { + rc = S_PENDING; + goto end; + } else if (err == EINTR) { + //sync + } else { + rc = S_ERROR; + goto end; } - } return rc; +end: + return rc; } #endif diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index 3cd0b86d..4aca9f68 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -366,16 +366,10 @@ int evbuf_set_off(evbuf_t* buf, buf_len off) buf->off = off; return S_SUCCESS; } -int evbuf_off_sum(evbuf_t* buf, buf_len off) +int evbuf_op_off(evbuf_t* buf, buf_len off) { rc_error(buf != NULL, S_ERROR); - buf->off +=off; - return S_SUCCESS; -} -int evbuf_off_sub(evbuf_t* buf, buf_len off) -{ - rc_error(buf != NULL, S_ERROR); - buf->off -= off; + buf->off += off; return S_SUCCESS; } int is_evbuf_compelete(evbuf_t* buf) diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index cdf78128..3427229c 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -341,8 +341,7 @@ int evbuf_get_len(evbuf_t* buf, buf_len* len); int evbuf_get_off(evbuf_t* buf, buf_len* off); int evbuf_set_off(evbuf_t* buf, buf_len off); -int evbuf_off_sum(evbuf_t* buf, buf_len off); -int evbuf_off_sub(evbuf_t* buf, buf_len off); +int evbuf_op_off(evbuf_t* buf, buf_len off); int is_evbuf_compelete(evbuf_t* buf); #endif diff --git a/stdcrt/event/compat_event_win32.c b/stdcrt/event/compat_event_win32.c index 8b36b87c..def98434 100644 --- a/stdcrt/event/compat_event_win32.c +++ b/stdcrt/event/compat_event_win32.c @@ -299,7 +299,7 @@ int win32_sock_read_op(evoper_t* oper) rc = S_ERROR; if (ret == 0) { - evbuf_off_sub(&oper->rbuf, byte); + evbuf_op_off(&oper->rbuf, byte); if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { rc = S_COMPLETED; goto end; @@ -343,7 +343,7 @@ int win32_sock_write_op(evoper_t* oper) goto end; } - evbuf_off_sum(&oper->wbuf, byte); + evbuf_op_off(&oper->wbuf, byte); if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { rc = WSA_IO_PENDING; goto end; diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index 97307f3e..ad91f2b7 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -33,6 +33,8 @@ int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) logi("close_connect"); } else if (event == op_ev_write && res == op_ev_success) { logi("write"); + } else if (event == op_ev_read && res == op_ev_success) { + logi("read"); } return S_SUCCESS; } @@ -76,7 +78,8 @@ void test_write_oper(evloop_t* loop) void test_read_oper(evloop_t* loop) { evloop_alloc_evoper(loop, new_oper); - evoper_read(new_oper, (buf_ptr)recv_data, 5); + size_t len = s_strlen(send_data); + evoper_read(new_oper, (buf_ptr)recv_data, len); evoper_bind_handler(new_oper, evop_proc); evloop_add_read(loop, new_oper, NULL); } \ No newline at end of file -- Gitee From 955bf0c0048724c26c31ec8d7c77ebbdabab9a76 Mon Sep 17 00:00:00 2001 From: com Date: Tue, 23 Jul 2024 21:55:44 +0800 Subject: [PATCH 09/34] up --- crt/crt_sock.h | 8 +- stdcrt/event/compat_event.c | 40 ---------- stdcrt/event/compat_event_epoll.c | 14 ---- stdcrt/event/compat_event_iocp.c | 17 ----- stdcrt/event/compat_event_kqueue.c | 119 ++++++++++++++++++----------- stdcrt/event/compat_event_kqueue.h | 4 +- stdcrt/event/compat_event_mach.c | 98 ++++++++++++++++++++++-- stdcrt/event/compat_event_mach.h | 4 +- stdcrt/event/compat_event_posix.c | 5 +- stdcrt/event/compat_event_util.c | 8 +- stdcrt/event/compat_event_util.h | 10 --- stdcrt/net/compat_sock.c | 36 +++++---- stdcrt_test/main.c | 49 ++++++------ stdcrt_test/test_oper.c | 24 ++++-- 14 files changed, 243 insertions(+), 193 deletions(-) diff --git a/crt/crt_sock.h b/crt/crt_sock.h index ed5b6068..12c1eb02 100644 --- a/crt/crt_sock.h +++ b/crt/crt_sock.h @@ -231,10 +231,10 @@ int set_linger(_sock_t s, int sec); int set_sendtime(_sock_t s, int sec); int set_recvtime(_sock_t s, int sec); int set_connectime(_sock_t s, int sec); -int set_sendbuflen(_sock_t s, int size); -int set_recvbuflen(_sock_t s, int size); -int set_sendlowat(_sock_t s, int size); -int set_recvlowat(_sock_t s, int size); +int set_sendbuflen(_sock_t s, socklen_t size); +int set_recvbuflen(_sock_t s, socklen_t size); +int set_sendlowat(_sock_t s, socklen_t size); +int set_recvlowat(_sock_t s, socklen_t size); #if (TARGET_OS == OS_WIN) int socketpair(int d, int type, int protocol, _sock_t sv[2]); diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index 54d80baa..fb2861bf 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -373,9 +373,7 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_connect != NULL, S_ERROR); rs_error(oper->conn == op_ev_connected, S_COMPLETED) - evoper_connect_op(oper, op_ev_connecting); - rc = evsel->op_add_connect(loop, oper, addr, tv); rs_error(rc == S_PENDING, S_SUCCESS) @@ -538,56 +536,18 @@ static int cmd_poll(evloop_t* loop, crt_msec msec) op->op_dispatch(loop, op_cmd_poll, msec); return S_SUCCESS; } -/* -static int cmd_exit(evloop_t* loop, crt_msec msec) -{ - rc_error(loop != NULL, S_ERROR); - rc_error(loop != NULL, S_ERROR); - const evsysop_t* op = evloop_sysop(loop); - rc_error(op != NULL, S_ERROR); - rc_error(op->op_dispatch != NULL, S_ERROR); - op->op_dispatch(loop, op_cmd_exit, msec); - return S_SUCCESS; -} -static int cmd_once(evloop_t* loop, crt_msec msec) -{ - rc_error(loop != NULL, S_ERROR); - rc_error(loop != NULL, S_ERROR); - const evsysop_t* op = evloop_sysop(loop); - rc_error(op != NULL, S_ERROR); - rc_error(op->op_dispatch != NULL, S_ERROR); - op->op_dispatch(loop, op_cmd_once, msec); - return S_SUCCESS; -} -static int cmd_load(evloop_t* loop, crt_msec msec) -{ - rc_error(loop != NULL, S_ERROR); - rc_error(loop != NULL, S_ERROR); - const evsysop_t* op = evloop_sysop(loop); - rc_error(op != NULL, S_ERROR); - rc_error(op->op_dispatch != NULL, S_ERROR); - op->op_dispatch(loop, op_cmd_load, msec); - return S_SUCCESS; -} -*/ - int evloop_run(evloop_t* loop, crt_msec msec) { rc_error(loop != NULL, S_ERROR); const evsysop_t* op = evloop_sysop(loop); rc_error(op != NULL, S_ERROR); - int rc = S_ERROR; - loop->status = evloop_running; - - while (loop->status != evloop_close) { evoper_t* oper = NULL; int ret = S_NOFOUND; ret = evloop_gettime(loop->nodes, &oper); - evloop_update_time(loop); rc = (ret == S_FOUND ? cmd_poll_time(loop, oper) : cmd_poll(loop, msec)); evloop_update_time(loop); diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index baf9fce6..d91b73e5 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -546,14 +546,6 @@ static int epoll_op_cmd_exit(const epoll_op_t* base, evloop_t* loop) { return S_SUCCESS; } -static int epoll_op_cmd_once(const epoll_op_t* base, evloop_t* loop) -{ - return S_SUCCESS; -} -static int epoll_op_cmd_load(const epoll_op_t* base, evloop_t* loop) -{ - return S_SUCCESS; -} static int epoll_op_dispatch(evloop_t* loop, short event, crt_msec time) { int rc = S_SUCCESS; @@ -567,12 +559,6 @@ static int epoll_op_dispatch(evloop_t* loop, short event, crt_msec time) case op_cmd_exit: rc = epoll_op_cmd_exit(base, loop); break; - case op_cmd_once: - rc = epoll_op_cmd_once(base, loop); - break; - case op_cmd_load: - rc = epoll_op_cmd_load(base, loop); - break; default: break; } diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index 87638008..fa4a2959 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -3,7 +3,6 @@ #if (TARGET_OS == OS_WIN) - void _waitsem_threadProc(void* obj) { iocp_op_t* base = NULL; @@ -444,16 +443,6 @@ static int iocp_op_cmd_exit(iocp_op_t* base, evloop_t* loop) ret = PostQueuedCompletionStatus(base->hiocp, 0, iocp_exit, NULL); return ret > 0 ? S_SUCCESS : S_ERROR; } -static int iocp_op_cmd_once(iocp_op_t* base, evloop_t* loop) -{ - return S_SUCCESS; -} - -static int iocp_op_cmd_load(iocp_op_t* base, evloop_t* loop) -{ - return S_SUCCESS; -} - int iocp_op_dispatch(evloop_t* loop, short event, crt_msec time) { int rc = S_ERROR; @@ -467,12 +456,6 @@ int iocp_op_dispatch(evloop_t* loop, short event, crt_msec time) case op_cmd_exit: rc = iocp_op_cmd_exit(base, loop); break; - case op_cmd_once: - rc = iocp_op_cmd_once(base, loop); - break; - case op_cmd_load: - rc = iocp_op_cmd_load(base, loop); - break; default: break; } diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index aaf4112b..614148fd 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -3,34 +3,45 @@ #if (TARGET_OS == OS_MACH) +static int set_kevent_op(kqueue_event_t* ptr, uint32_t op) +{ + rc_error(ptr != NULL, S_ERROR); + ptr->op = op; + return S_SUCCESS; +} +static int set_kevent_ctl(kqueue_event_t* ptr, evevent on) +{ + rc_error(ptr != NULL, S_ERROR); + ptr->ctl = on; + return S_SUCCESS; +} +static int kqueue_op(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr) +{ + return S_SUCCESS; +} static int kqueue_notify_init(kqueue_op_t* base) { - base->notify_kev.ident = 0; - base->notify_kev.filter = EVFILT_USER; - base->notify_kev.data = 0; - base->notify_kev.flags = EV_ADD | EV_CLEAR; - base->notify_kev.fflags = 0; - base->notify_kev.udata = 0; - - if (kevent(base->kqfd, &base->notify_kev, 1, NULL, 0, NULL) == -1) { - return S_ERROR; - } - return S_SUCCESS; + base->notify_kev.ident = 0; + base->notify_kev.filter = EVFILT_USER; + base->notify_kev.data = 0; + base->notify_kev.flags = EV_ADD | EV_CLEAR; + base->notify_kev.fflags = 0; + base->notify_kev.udata = 0; + + if (base->sys_kevent(base->kqfd, &base->notify_kev, 1, NULL, 0, NULL) == -1) { + return S_ERROR; + } + return S_SUCCESS; } static int kqueue_hook_api(kqueue_op_t* base) { base->sys_kqueue = (kqueue_fn)dlsym(RTLD_NEXT, "kqueue"); - rc_error(base->sys_kqueue != NULL, S_ERROR); + rc_error(base->sys_kqueue != NULL, S_ERROR); base->sys_kevent = (kevent_fn)dlsym(RTLD_NEXT, "kevent"); - rc_error(base->sys_kevent != NULL, S_ERROR); + rc_error(base->sys_kevent != NULL, S_ERROR); - return S_SUCCESS; -} - -static int kqueue_op(kqueue_op_t* base, void* ptr, uint32_t events, int op, int fd) -{ return S_SUCCESS; } int kqueue_op_alloc(evloop_t* loop, int size) @@ -46,16 +57,25 @@ int kqueue_op_alloc(evloop_t* loop, int size) rc = kqueue_hook_api(base); if (rc != S_SUCCESS) goto err; - - base->kqfd = base->sys_kqueue(); - if (base->kqfd == 0) - goto err; - + + base->kqfd = base->sys_kqueue(); + if (base->kqfd == 0) + goto err; + + rc = kqueue_notify_init(base); + if(rc != S_SUCCESS) + goto err; + base->poll = NULL; base->poll = loop->mm_malloc(loop, base->size, sizeof(struct kevent)); if(base->poll == NULL) goto err; + base->change = NULL; + base->change = loop->mm_malloc(loop, base->size, sizeof(struct kevent)); + if(base->poll == NULL) + goto err; + return evloop_bind_evbase(loop, base); err: @@ -67,7 +87,13 @@ err: int kqueue_op_dealloc(evloop_t* loop) { kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); - loop->mm_free(loop, base->poll); + + if(base->poll) + loop->mm_free(loop, base->poll); + + if(base->change) + loop->mm_free(loop, base->change); + return S_SUCCESS; } @@ -96,24 +122,40 @@ int kqueue_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) return S_SUCCESS; } -int kqueue_op_add(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int kqueue_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); return S_SUCCESS; } -int kqueue_op_del(evloop_t* loop, evoper_t* oper, short event) +int kqueue_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +{ + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); + return S_SUCCESS; +} +int kqueue_op_del_read(evloop_t* loop, evoper_t* oper, short event) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); return S_SUCCESS; } +int kqueue_op_del_write(evloop_t* loop, evoper_t* oper, short event) +{ + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); + return S_SUCCESS; +} int kqueue_op_cancel(evloop_t* loop, evoper_t* oper) { + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); return S_SUCCESS; } int kqueue_op_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) { + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); return S_SUCCESS; } int kqueue_op_poll(evloop_t* loop, evoper_t* oper) @@ -126,11 +168,12 @@ int kqueue_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - return S_SUCCESS; } int kqueue_op_del_connect(evloop_t* loop, evoper_t* oper) { + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); return S_SUCCESS; } int kqueue_event_complete(evloop_t* loop, crterr err, kqueue_op_t* base, evoper_t* oper, short ev) @@ -209,14 +252,6 @@ static int kqueue_op_cmd_exit(const kqueue_op_t* base, evloop_t* loop) { return S_SUCCESS; } -static int kqueue_op_cmd_once(const kqueue_op_t* base, evloop_t* loop) -{ - return S_SUCCESS; -} -static int kqueue_op_cmd_load(const kqueue_op_t* base, evloop_t* loop) -{ - return S_SUCCESS; -} static int kqueue_op_dispatch(evloop_t* loop, short event, crt_msec time) { int rc = S_SUCCESS; @@ -230,12 +265,6 @@ static int kqueue_op_dispatch(evloop_t* loop, short event, crt_msec time) case op_cmd_exit: rc = kqueue_op_cmd_exit(base, loop); break; - case op_cmd_once: - rc = kqueue_op_cmd_once(base, loop); - break; - case op_cmd_load: - rc = kqueue_op_cmd_load(base, loop); - break; default: break; } @@ -252,10 +281,10 @@ int kqueue_evop_t(evsysop_t* op) op->op_alloc_evoper = kqueue_op_alloc_evoper; op->op_dealloc_evoper = kqueue_op_dealloc_evoper; - op->op_add_read = kqueue_op_add; - op->op_add_write = kqueue_op_add; - op->op_del_read = kqueue_op_del; - op->op_del_write = kqueue_op_del; + op->op_add_read = kqueue_op_add_read; + op->op_add_write = kqueue_op_add_write; + op->op_del_read = kqueue_op_del_read; + op->op_del_write = kqueue_op_del_write; op->op_cancel = kqueue_op_cancel; op->op_open = kqueue_op_open; diff --git a/stdcrt/event/compat_event_kqueue.h b/stdcrt/event/compat_event_kqueue.h index ca429024..074e1646 100644 --- a/stdcrt/event/compat_event_kqueue.h +++ b/stdcrt/event/compat_event_kqueue.h @@ -17,7 +17,8 @@ typedef struct kevent_s kqueue_event_t; struct kevent_s { int reg; int16_t filter; - uint32_t fflags; + evevent ctl; + uint32_t op; }; typedef int (*kqueue_fn)(void); @@ -29,6 +30,7 @@ struct kqueue_op_s { kqueue_fn sys_kqueue; kevent_fn sys_kevent; struct kevent* poll; + struct kevent* change; struct kevent notify_kev; ev_op ev; _mutex_t lock; diff --git a/stdcrt/event/compat_event_mach.c b/stdcrt/event/compat_event_mach.c index eebb804c..89f095cc 100644 --- a/stdcrt/event/compat_event_mach.c +++ b/stdcrt/event/compat_event_mach.c @@ -6,17 +6,99 @@ #include "compat_event_kqueue.h" #include "compat_event_mach.h" -int mach_tcpsock_send(evoper_t* oper) +int mach_tcpsock_send(evoper_t* oper, int flags) { - int rc = S_ERROR; - rc_error(oper != NULL, rc); - return S_SUCCESS; + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->wbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->wbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + for (;;) { + + int err = 0; + n = send(oper->fd, ptr, len, flags); + err = (n == -1) ? errno : 0; + + if (n > 0) { + evbuf_op_off(&oper->wbuf, n); + if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { + return S_COMPLETED; + } + return S_PENDING; + } + + if (err == EAGAIN) { + rc = S_PENDING; + goto end; + } else if (err == EINTR) { + // sync + } else { + rc = S_ERROR; + goto end; + } + } + return rc; +end: + return rc; } -int mach_tcpsock_recv(evoper_t* oper) +int mach_tcpsock_recv(evoper_t* oper, int flags) { - int rc = S_ERROR; - rc_error(oper != NULL, rc); - return S_SUCCESS; + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->rbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->rbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + + for (;;) { + + int err = 0; + n = recv(oper->fd, ptr, len, flags); + err = (n == -1) ? errno : 0; + + if (n > 0) { + evbuf_op_off(&oper->rbuf, n); + if (is_evbuf_compelete(&oper->rbuf) == S_SUCCESS) { + rc = S_COMPLETED; + goto end; + } + rc = S_PENDING; + goto end; + } + + if (n == 0) { + evoper_close_op(oper, ev_on); + rc = S_ERROR; + goto end; + } + + if (err == EAGAIN) { + rc = S_PENDING; + goto end; + } else if (err == EINTR) { + //sync + } else { + rc = S_ERROR; + goto end; + } + } + return rc; +end: + return rc; } + #endif diff --git a/stdcrt/event/compat_event_mach.h b/stdcrt/event/compat_event_mach.h index 38e17aa1..664e3794 100644 --- a/stdcrt/event/compat_event_mach.h +++ b/stdcrt/event/compat_event_mach.h @@ -9,8 +9,8 @@ extern "C" { #if (TARGET_OS == OS_MACH) -int mach_tcpsock_send(evoper_t* oper); -int mach_tcpsock_recv(evoper_t* oper); +int mach_tcpsock_send(evoper_t* oper, int flags); +int mach_tcpsock_recv(evoper_t* oper, int flags); #endif diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index b61add6f..b8f65c14 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -10,7 +10,6 @@ int posix_tcpsock_send(evoper_t* oper, int flags) { int rc = S_SUCCESS; rc_error(oper != NULL, rc); - epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); ssize_t n; buf_ptr ptr = NULL; buf_len len = 0; @@ -53,12 +52,10 @@ int posix_tcpsock_recv(evoper_t* oper, int flags) { int rc = S_SUCCESS; rc_error(oper != NULL, rc); - epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); ssize_t n; buf_ptr ptr = NULL; buf_len len = 0; - crterr err; - + rc = evbuf_get_buf(&oper->rbuf, &ptr); rc_error(rc != S_ERROR, S_ERROR); diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index 4aca9f68..da1024c0 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -308,8 +308,12 @@ int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_ #if (TARGET_OS == OS_WIN) +#elif (TARGET_OS == OS_POSIX) + posix_tcpsock_recv(oper, 0); +#elif (TARGET_OS == OS_MACH) + mach_tcpsock_recv(oper, 0); #else - posix_tcpsock_recv(oper, 0); + #endif func(err, code, oper, NULL, op_ev_reading); @@ -376,4 +380,4 @@ int is_evbuf_compelete(evbuf_t* buf) { rc_error(buf != NULL, S_ERROR); return buf->off == buf->len ? S_SUCCESS : S_ERROR; -} \ No newline at end of file +} diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 3427229c..3a7882de 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -100,15 +100,6 @@ #define op_cmd_exit 0x02 #endif // !op_cmd_exit -#ifndef op_cmd_once -#define op_cmd_once 0x04 -#endif // !op_cmd_once - -#ifndef op_cmd_load -#define op_cmd_load 0x08 -#endif // !op_cmd_load - - typedef struct evloop_nodes_s evloop_nodes_t; typedef struct evloop_clock_s evloop_clock_t; typedef struct evbuf_s evbuf_t; @@ -323,7 +314,6 @@ int evoper_ready_op(evoper_t* oper, evevent op); int evoper_eof_op(evoper_t* oper, evevent op); int evoper_close_op(evoper_t* oper, evevent op); - int evoper_assign_sock(evoper_t* oper, _sock_t sock); int evoper_sock_connect(evoper_t* oper, const evaddr_t* addr); int evoper_sock_connected(evoper_t* oper); diff --git a/stdcrt/net/compat_sock.c b/stdcrt/net/compat_sock.c index 64e48771..f5519156 100644 --- a/stdcrt/net/compat_sock.c +++ b/stdcrt/net/compat_sock.c @@ -462,29 +462,33 @@ int set_connectime(_sock_t s, int sec) { return S_SUCCESS; } -int set_sendbuflen(_sock_t s, int size) +int set_sendbuflen(_sock_t s, socklen_t size) { - long len = size * 1024; - setsockopt(s, SOL_SOCKET, SO_RCVBUF, (const char*)&len, sizeof(long)); - return S_SUCCESS; + int rc = 0; + socklen_t len = size; + rc = setsockopt(s, SOL_SOCKET, SO_SNDBUF, (const char*)&len, sizeof(len)); + return rc == 0 ? S_SUCCESS : S_ERROR; } -int set_recvbuflen(_sock_t s, int size) +int set_recvbuflen(_sock_t s, socklen_t size) { - long len = size * 1024; - setsockopt(s, SOL_SOCKET, SO_RCVBUF, (const char*)&len, sizeof(long)); - return S_SUCCESS; + int rc = 0; + socklen_t len = size; + rc = setsockopt(s, SOL_SOCKET, SO_RCVBUF, (const char*)&len, sizeof(len)); + return rc == 0 ? S_SUCCESS : S_ERROR; } -int set_sendlowat(_sock_t s, int size) +int set_sendlowat(_sock_t s, socklen_t size) { - int value = size; - setsockopt(s, SOL_SOCKET, SO_SNDLOWAT, (void*)&value, sizeof(value)); - return S_SUCCESS; + int rc = 0; + socklen_t value = size; + rc = setsockopt(s, SOL_SOCKET, SO_SNDLOWAT, (void*)&value, sizeof(value)); + return rc == 0 ? S_SUCCESS : S_ERROR; } -int set_recvlowat(_sock_t s, int size) +int set_recvlowat(_sock_t s, socklen_t size) { - int value = size; - setsockopt(s, SOL_SOCKET, SO_RCVLOWAT, (void*)&value, sizeof(value)); - return S_SUCCESS; + int rc = 0; + socklen_t value = size; + rc = setsockopt(s, SOL_SOCKET, SO_RCVLOWAT, (void*)&value, sizeof(value)); + return rc == 0 ? S_SUCCESS : S_ERROR; } #if (TARGET_OS == OS_WIN) diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index 27edfb87..e75cf67e 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -1,60 +1,59 @@ #include #include "test.h" - // #pragma comment(lib, "kernel32.lib") // #pragma comment(lib, "shell32.lib") // #pragma comment(linker, "/ENTRY:main") -evloop_t* loop; - +evloop_t* loop; +_cond_t cond; +_mutex_t mutex; -void thread_proc2(void* ctx) +void thread_proc1(void* ctx) { sleep_time(7); test_conn_oper(loop); - - sleep_time(5); + _cond_broadcast(&cond); + sleep_time(1); + while (1) { + test_write_oper(loop); + } +} +void thread_proc2(void* ctx) +{ + _cond_wait(&cond, &mutex); test_write_oper(loop); while (1) { - //sleep_time(5); - //test_conn_oper(loop); - - sleep_time(5); + //sleep_time(1); test_read_oper(loop); } - } - int main(int argc, char* argv[]) { + init_sockenv(2, 2); + int rc = 0; - //test_msgq(); - init_sockenv(2, 2); - int rc = 0; + _cond_init(&cond); + _mutex_init(&mutex); - _thread_t thread2; - evloop_alloc(&loop, NULL, loop_alloc); + evloop_alloc(&loop, NULL, loop_alloc); evloop_init(loop, 1024, 0); - evloop_bind_memory(loop, loop_mem_alloc, loop_mem_free, NULL); - test_init_evaddr(); - test_accept_oper(loop); - rc = _thread_create(&thread2, thread_proc2, NULL); - rc_error(rc == S_SUCCESS, S_ERROR); + _thread_t thread1; + rc = _thread_create(&thread1, thread_proc1, NULL); - //test_timer(loop); + _thread_t thread2; + rc = _thread_create(&thread2, thread_proc2, NULL); + rc_error(rc == S_SUCCESS, S_ERROR); evloop_run(loop, 50000); - uninit_sockenv(2, 2); - return 0; } diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index ad91f2b7..0fc66f79 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -9,6 +9,10 @@ evloop_t* loop_ex; char* send_data; char* recv_data; +#define test_len 1 +int iread = 0; +int iwrite = 0; + void test_init_evaddr() { @@ -26,15 +30,27 @@ int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) { if (event == op_ev_connect && res == op_ev_success) { logi("open_connect"); + + _sock_t s; + evoper_get_sock(oper_s, &s); + set_sendbuflen(s, test_len); + } else if (event == op_ev_accept && res == op_ev_success) { + logi("accept_connect"); new_oper = oper_s; + _sock_t s; + evoper_get_sock(new_oper, &s); + set_recvbuflen(s, test_len); + } else if (event == op_ev_close && res == op_ev_success) { logi("close_connect"); - } else if (event == op_ev_write && res == op_ev_success) { - logi("write"); + } else if (event == op_ev_write && res == op_ev_success) { + iwrite++; + //logi("write %d\n", iwrite); } else if (event == op_ev_read && res == op_ev_success) { - logi("read"); + iread++; + logi("read %d == %d\n", iread, iwrite); } return S_SUCCESS; } @@ -50,7 +66,6 @@ void test_accept_oper(evloop_t* loop) int rc; evoper_alloc(&accept_oper, NULL, oper_alloc); - rc = evoper_pollsock(accept_oper, &addr, 1); if (rc != S_SUCCESS) logi("evoper_pollsock error"); @@ -65,7 +80,6 @@ void test_conn_oper(evloop_t* loop) evoper_sock(oper); bind_loop(loop, oper); int rc = evloop_add_connect(oper, &addr, NULL); - //printf("%d\n", rc); } void test_write_oper(evloop_t* loop) -- Gitee From 84c7493293bec3b72fe265993702b36203e7542e Mon Sep 17 00:00:00 2001 From: com Date: Thu, 25 Jul 2024 16:54:33 +0800 Subject: [PATCH 10/34] up --- asynio/eventwrap.cpp | 4 +- asynio/eventwrap.h | 10 ++--- asynio/iooperationimpl.cpp | 72 +++++++++++++++--------------- asynio/iooperationimpl.h | 38 ++++++++-------- asynio/tcpsocketimpl.cpp | 4 +- asynio/tcpsocketsslimpl.cpp | 8 ++-- asynio/tcpsocketsslimpl.h | 4 +- crt/crt_def.h | 4 +- extensions/include/io/ioperation.h | 32 ++++++------- extensions/include/io/isocket.h | 4 +- extensions/include/net/ihttp.h | 12 ++--- mainui/appviewimpl.cpp | 4 +- mainui/appviewimpl.h | 4 +- msgbus/agent.cpp | 6 +-- msgbus/broker.cpp | 4 +- msgbus/consumer.cpp | 6 +-- msgbus/producer.cpp | 6 +-- net/dnsimpl.cpp | 10 ++--- testmain/appviewimpl.cpp | 12 ++--- testmain/appviewimpl.h | 12 ++--- 20 files changed, 127 insertions(+), 129 deletions(-) diff --git a/asynio/eventwrap.cpp b/asynio/eventwrap.cpp index faa88e60..3f2c84c3 100644 --- a/asynio/eventwrap.cpp +++ b/asynio/eventwrap.cpp @@ -164,7 +164,7 @@ int ioevstream_setwritecb(ioevstream_t* stream, stream_writecb cb) stream->write = cb; return S_SUCCESS; } -int ioevstream_write(ioevstream_t* stream, BUF_PTR ptr, BUF_SIZE len, int sec) +int ioevstream_write(ioevstream_t* stream, buf_ptr ptr, buf_len len, int sec) { struct timeval timeout; @@ -175,7 +175,7 @@ int ioevstream_write(ioevstream_t* stream, BUF_PTR ptr, BUF_SIZE len, int sec) return S_SUCCESS; } -int ioevstream_read(ioevstream_t* stream, BUF_PTR ptr, BUF_SIZE len, int sec) +int ioevstream_read(ioevstream_t* stream, buf_ptr ptr, buf_len len, int sec) { struct timeval tv; diff --git a/asynio/eventwrap.h b/asynio/eventwrap.h index d209b71c..38c3e042 100644 --- a/asynio/eventwrap.h +++ b/asynio/eventwrap.h @@ -55,12 +55,10 @@ int ioevtcp_disable(ioevtcp_t* tcp); typedef struct ioevstream_s ioevstream_t; typedef int (*stream_eventcb)(ioevstream_t* stream, short err, short what, _sock_t fd); -typedef int (*stream_readcb)(ioevstream_t* stream, short err, BUF_PTR ptr, BUF_SIZE len); -typedef int (*stream_writecb)(ioevstream_t* stream, short err, BUF_PTR ptr, BUF_SIZE len); +typedef int (*stream_readcb)(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len); +typedef int (*stream_writecb)(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len); struct ioevstream_s { void* ctx; - _buffer_t in; - _buffer_t out; stream_eventcb event; stream_readcb read; stream_writecb write; @@ -74,8 +72,8 @@ void* ioevstream_getctx(ioevstream_t* stream); int ioevstream_seteventcb(ioevstream_t* stream, stream_eventcb cb); int ioevstream_setreadcb(ioevstream_t* stream, stream_readcb cb); int ioevstream_setwritecb(ioevstream_t* stream, stream_writecb cb); -int ioevstream_write(ioevstream_t* stream, BUF_PTR ptr, BUF_SIZE len, int sec); -int ioevstream_read(ioevstream_t* stream, BUF_PTR ptr, BUF_SIZE len, int sec); +int ioevstream_write(ioevstream_t* stream, buf_ptr ptr, buf_len len, int sec); +int ioevstream_read(ioevstream_t* stream, buf_ptr ptr, buf_len len, int sec); int ioevstream_connectsock(ioevstream_t* stream, NET_ADDR ip, NET_ADDR_PORT port, int sec); int ioevstream_connect6sock(ioevstream_t* stream, NET_ADDR ip, NET_ADDR_PORT port, int sec); diff --git a/asynio/iooperationimpl.cpp b/asynio/iooperationimpl.cpp index d1578519..62052322 100644 --- a/asynio/iooperationimpl.cpp +++ b/asynio/iooperationimpl.cpp @@ -50,94 +50,94 @@ crtid CIoOperationImpl::GetId() { return m_cid; } -HRESULT CIoOperationImpl::SetResult(crterr err, BUF_SIZE uTransferedBytes) +HRESULT CIoOperationImpl::SetResult(crterr err, buf_len len) { m_err = err; - m_pTransferedBytes = uTransferedBytes; + m_pTransferedBytes = len; return S_OK; } -HRESULT CIoOperationImpl::GetResult(crterr* err, BUF_SIZE* pTransferedBytes) +HRESULT CIoOperationImpl::GetResult(crterr* err, buf_len* len) { *err = m_err; - *pTransferedBytes = m_pTransferedBytes; + *len = m_pTransferedBytes; return S_OK; } -HRESULT CIoOperationImpl::SetIoParam(ULONG uStartPos, ULONG uExpectBytes) +HRESULT CIoOperationImpl::SetIoParam(buf_len pos, buf_len len) { - if (uExpectBytes - uStartPos > m_pBufLen) { + if (len - pos > m_pBufLen) { return E_FAIL; } - m_uStartPos = uStartPos; - m_uExpectBytes = uExpectBytes; + m_uStartPos = pos; + m_uExpectBytes = len; return S_OK; } -HRESULT CIoOperationImpl::GetIoParam(ULONG* uStartPos, ULONG* pExpectBytes) +HRESULT CIoOperationImpl::GetIoParam(buf_len* pos, buf_len* len) { - *uStartPos = m_uStartPos; - *pExpectBytes = m_uExpectBytes; + *pos = m_uStartPos; + *len = m_uExpectBytes; return S_OK; } -HRESULT CIoOperationImpl::SetExpect(ULONG uExpectBytes) +HRESULT CIoOperationImpl::SetExpect(buf_len len) { - m_uExpectBytes = uExpectBytes; + m_uExpectBytes = len; return S_OK; } -HRESULT CIoOperationImpl::GetExpect(ULONG* pExpectBytes) +HRESULT CIoOperationImpl::GetExpect(buf_len* len) { - *pExpectBytes = m_uExpectBytes; + *len = m_uExpectBytes; return S_OK; } -HRESULT CIoOperationImpl::SetPos(ULONG uPos) +HRESULT CIoOperationImpl::SetPos(buf_len pos) { - m_uStartPos = uPos; + m_uStartPos = pos; return S_OK; } -HRESULT CIoOperationImpl::GetPos(ULONG* pPos) +HRESULT CIoOperationImpl::GetPos(buf_len* pos) { - *pPos = m_uStartPos; + *pos = m_uStartPos; return S_OK; } -HRESULT CIoOperationImpl::SetTransfered(BUF_SIZE uTransferedBytes) +HRESULT CIoOperationImpl::SetTransfered(buf_len len) { - m_pTransferedBytes = uTransferedBytes; + m_pTransferedBytes = len; return S_OK; } -HRESULT CIoOperationImpl::GetTransfered(BUF_SIZE* pTransferedBytes) +HRESULT CIoOperationImpl::GetTransfered(buf_len* len) { - *pTransferedBytes = m_pTransferedBytes; + *len = m_pTransferedBytes; return S_OK; } -HRESULT CIoOperationImpl::Attach(BUF_PTR Ptr, BUF_SIZE Pos, BUF_SIZE Size) +HRESULT CIoOperationImpl::Attach(buf_ptr ptr, buf_len pos, buf_len size) { - rc_error(Ptr != NULL, E_FAIL); + rc_error(ptr != NULL, E_FAIL); rc_error(m_pBuf.m_p != NULL, E_FAIL); - s_memcpy(m_pBuf.m_p + Pos, Ptr, Size); - return SetIoParam(Pos, Size); + s_memcpy(m_pBuf.m_p + pos, ptr, size); + return SetIoParam(pos, size); } -HRESULT CIoOperationImpl::Alloc(BUF_SIZE Size) +HRESULT CIoOperationImpl::Alloc(buf_len size) { m_pBuf.dispose(); - m_pBufLen = Size; + m_pBufLen = size; m_pBuf = ALLOC_NEW unsigned char[m_pBufLen + 1](); rc_error(m_pBuf.m_p != NULL, E_FAIL); return S_OK; } -HRESULT CIoOperationImpl::GetLen(BUF_SIZE* Len) +HRESULT CIoOperationImpl::GetLen(buf_len* len) { - *Len = m_pBufLen; + *len = m_pBufLen; return S_OK; } -HRESULT CIoOperationImpl::GetPtr(BUF_PTR* Ptr) +HRESULT CIoOperationImpl::GetPtr(buf_ptr* ptr) { rc_error(m_pBuf.m_p != NULL, E_FAIL); - *Ptr = m_pBuf.m_p; + *ptr = m_pBuf.m_p; return S_OK; } -HRESULT CIoOperationImpl::GetOperationPtr(BUF_PTR* Ptr, BUF_SIZE* Len) +HRESULT CIoOperationImpl::GetOperationPtr(buf_ptr* ptr, buf_len* len) { rc_error(m_pBuf.m_p != NULL, E_FAIL); - *Ptr = m_pBuf.m_p; - *Len = m_pBufLen; + *ptr = m_pBuf.m_p; + *len = m_pBufLen; return S_OK; } HRESULT CIoOperationImpl::ReleasePtr() diff --git a/asynio/iooperationimpl.h b/asynio/iooperationimpl.h index 53d6553c..9473f8ec 100644 --- a/asynio/iooperationimpl.h +++ b/asynio/iooperationimpl.h @@ -24,21 +24,21 @@ public: std_method(UnBindEvent)(); std_method(SetId)(crtid id); std_method_(crtid, GetId)(); - std_method(SetResult)(crterr err, BUF_SIZE uTransferedBytes); - std_method(GetResult)(crterr* err, BUF_SIZE* pTransferedBytes); - std_method(SetIoParam)(BUF_SIZE uStartPos, BUF_SIZE uExpectBytes); - std_method(GetIoParam)(BUF_SIZE* uStartPos, BUF_SIZE* pExpectBytes); - std_method(SetExpect)(BUF_SIZE uExpectBytes); - std_method(GetExpect)(BUF_SIZE* pExpectBytes); - std_method(SetPos)(BUF_SIZE uPos); - std_method(GetPos)(BUF_SIZE* pPos); - std_method(SetTransfered)(BUF_SIZE uTransferedBytes); - std_method(GetTransfered)(BUF_SIZE* pTransferedBytes); - std_method(Attach)(BUF_PTR Ptr, BUF_SIZE Pos, BUF_SIZE Size); - std_method(Alloc)(BUF_SIZE Size); - std_method(GetLen)(BUF_SIZE* Len); - std_method(GetPtr)(BUF_PTR* Ptr); - std_method(GetOperationPtr)(BUF_PTR* Ptr, BUF_SIZE* Len); + std_method(SetResult)(crterr err, buf_len len); + std_method(GetResult)(crterr* err, buf_len* len); + std_method(SetIoParam)(buf_len pos, buf_len len); + std_method(GetIoParam)(buf_len* pos, buf_len* len); + std_method(SetExpect)(buf_len len); + std_method(GetExpect)(buf_len* len); + std_method(SetPos)(buf_len pos); + std_method(GetPos)(buf_len* pos); + std_method(SetTransfered)(buf_len len); + std_method(GetTransfered)(buf_len* len); + std_method(Attach)(buf_ptr ptr, buf_len pos, buf_len size); + std_method(Alloc)(buf_len size); + std_method(GetLen)(buf_len* len); + std_method(GetPtr)(buf_ptr* ptr); + std_method(GetOperationPtr)(buf_ptr* ptr, buf_len* len); std_method(ReleasePtr)(); std_method(ClearPtr)(); std_method(Post)(crtid cid, crterr err); @@ -46,10 +46,10 @@ public: private: crterr m_err; crtid m_cid; - BUF_SIZE m_pTransferedBytes; - BUF_SIZE m_uStartPos; - BUF_SIZE m_uExpectBytes; - BUF_SIZE m_pBufLen; + buf_len m_pTransferedBytes; + buf_len m_uStartPos; + buf_len m_uExpectBytes; + buf_len m_pBufLen; UCharArrayPtr m_pBuf; _lComPtr m_pEvent; _lComPtr m_pBase; diff --git a/asynio/tcpsocketimpl.cpp b/asynio/tcpsocketimpl.cpp index 91522961..e50cb946 100644 --- a/asynio/tcpsocketimpl.cpp +++ b/asynio/tcpsocketimpl.cpp @@ -14,14 +14,14 @@ int tcpsocket_opencb(ioevstream_t* stream, short err, _sock_t fd) return S_SUCCESS; } -int tcpsocket_readcb(ioevstream_t* stream, short err, BUF_PTR ptr, BUF_SIZE len) +int tcpsocket_readcb(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len) { rc_error(stream != NULL, S_ERROR); CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); return S_SUCCESS; } -int tcpsocket_writecb(ioevstream_t* stream, short err, BUF_PTR ptr, BUF_SIZE len) +int tcpsocket_writecb(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len) { rc_error(stream != NULL, S_ERROR); CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); diff --git a/asynio/tcpsocketsslimpl.cpp b/asynio/tcpsocketsslimpl.cpp index 6d772a5c..e28ac682 100644 --- a/asynio/tcpsocketsslimpl.cpp +++ b/asynio/tcpsocketsslimpl.cpp @@ -11,14 +11,14 @@ int tcpsocketssl_eventcb(ioevstream_t* stream, short err, short what, _sock_t fd tcpsockssl->OnEventcb(err, what, fd); return S_SUCCESS; } -int tcpsocketssl_readcb(ioevstream_t* stream, short err, BUF_PTR ptr, BUF_SIZE len) +int tcpsocketssl_readcb(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len) { rc_error(stream != NULL, S_ERROR); CTcpSocketSslImpl* tcpsockssl = (CTcpSocketSslImpl*)ioevstream_getctx(stream); tcpsockssl->OnReadcb(err, ptr, len); return S_SUCCESS; } -int tcpsocketssl_writecb(ioevstream_t* stream, short err, BUF_PTR ptr, BUF_SIZE len) +int tcpsocketssl_writecb(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len) { rc_error(stream != NULL, S_ERROR); CTcpSocketSslImpl* tcpsockssl = (CTcpSocketSslImpl*)ioevstream_getctx(stream); @@ -212,7 +212,7 @@ HRESULT CTcpSocketSslImpl::OnEventcb(short err, short what, _sock_t fd) return S_OK; } -HRESULT CTcpSocketSslImpl::OnReadcb(short err, BUF_PTR ptr, BUF_SIZE len) +HRESULT CTcpSocketSslImpl::OnReadcb(short err, buf_ptr ptr, buf_len len) { rc_error(m_pISockProc.m_p != NULL, E_FAIL); @@ -240,7 +240,7 @@ HRESULT CTcpSocketSslImpl::OnReadcb(short err, BUF_PTR ptr, BUF_SIZE len) return S_OK; } -HRESULT CTcpSocketSslImpl::OnWritecb(short err, BUF_PTR ptr, BUF_SIZE len) +HRESULT CTcpSocketSslImpl::OnWritecb(short err, buf_ptr ptr, buf_len len) { rc_error(m_pISockProc.m_p != NULL, E_FAIL); diff --git a/asynio/tcpsocketsslimpl.h b/asynio/tcpsocketsslimpl.h index 3afe67a7..a0067a59 100644 --- a/asynio/tcpsocketsslimpl.h +++ b/asynio/tcpsocketsslimpl.h @@ -58,8 +58,8 @@ public: public: std_method(OnEventcb)(short err, short what, _sock_t fd); - std_method(OnReadcb)(short err, BUF_PTR ptr, BUF_SIZE len); - std_method(OnWritecb)(short err, BUF_PTR ptr, BUF_SIZE len); + std_method(OnReadcb)(short err, buf_ptr ptr, buf_len len); + std_method(OnWritecb)(short err, buf_ptr ptr, buf_len len); private: _sock_t m_sock; diff --git a/crt/crt_def.h b/crt/crt_def.h index 6a57018e..e54a5919 100644 --- a/crt/crt_def.h +++ b/crt/crt_def.h @@ -121,11 +121,11 @@ typedef struct MemoryPtr_s { typedef const SafeMemoryPtr* SafeMemoryConstPtr; #endif -#ifndef BUF_PTR +#ifndef buf_ptr typedef unsigned char* buf_ptr; #endif -#ifndef BUF_SIZE +#ifndef buf_len typedef size_t buf_len; #endif diff --git a/extensions/include/io/ioperation.h b/extensions/include/io/ioperation.h index e146ab67..d6718dc8 100644 --- a/extensions/include/io/ioperation.h +++ b/extensions/include/io/ioperation.h @@ -25,23 +25,23 @@ interface IOperation : public IBase std_method(QueryIBaseIID)(REFIID riid, void** ppv) PURE; std_method(BindEvent)(IBase* pEvents) PURE; std_method(UnBindEvent)() PURE; - std_method(SetId)(crtid uId) PURE; + std_method(SetId)(crtid id) PURE; std_method_(crtid, GetId)() PURE; - std_method(SetResult)(crterr err, BUF_SIZE uTransferedBytes) PURE; - std_method(GetResult)(crterr* err, BUF_SIZE* pTransferedBytes) PURE; - std_method(SetIoParam)(BUF_SIZE uStartPos, BUF_SIZE uExpectBytes) PURE; - std_method(GetIoParam)(BUF_SIZE* uStartPos, BUF_SIZE* pExpectBytes) PURE; - std_method(SetExpect)(BUF_SIZE uExpectBytes) PURE; - std_method(GetExpect)(BUF_SIZE* pExpectBytes) PURE; - std_method(SetPos)(BUF_SIZE uPos) PURE; - std_method(GetPos)(BUF_SIZE* pPos) PURE; - std_method(SetTransfered)(BUF_SIZE uTransferedBytes) PURE; - std_method(GetTransfered)(BUF_SIZE* pTransferedBytes) PURE; - std_method(Attach)(BUF_PTR Ptr, BUF_SIZE Pos, BUF_SIZE Size) PURE; - std_method(Alloc)(BUF_SIZE Size) PURE; - std_method(GetLen)(BUF_SIZE* Len) PURE; - std_method(GetPtr)(BUF_PTR* Ptr) PURE; - std_method(GetOperationPtr)(BUF_PTR* Ptr, BUF_SIZE* Len) PURE; + std_method(SetResult)(crterr err, buf_len len) PURE; + std_method(GetResult)(crterr * err, buf_len * len) PURE; + std_method(SetIoParam)(buf_len pos, buf_len len) PURE; + std_method(GetIoParam)(buf_len * pos, buf_len * len) PURE; + std_method(SetExpect)(buf_len len) PURE; + std_method(GetExpect)(buf_len * len) PURE; + std_method(SetPos)(buf_len pos) PURE; + std_method(GetPos)(buf_len* pos) PURE; + std_method(SetTransfered)(buf_len len) PURE; + std_method(GetTransfered)(buf_len * len) PURE; + std_method(Attach)(buf_ptr ptr, buf_len pos, buf_len size) PURE; + std_method(Alloc)(buf_len size) PURE; + std_method(GetLen)(buf_len* len) PURE; + std_method(GetPtr)(buf_ptr* ptr) PURE; + std_method(GetOperationPtr)(buf_ptr* ptr, buf_len* Len) PURE; std_method(ReleasePtr)() PURE; std_method(ClearPtr)() PURE; std_method(Post)(crtid op, crterr err) PURE; diff --git a/extensions/include/io/isocket.h b/extensions/include/io/isocket.h index ac9c3151..6cd12447 100644 --- a/extensions/include/io/isocket.h +++ b/extensions/include/io/isocket.h @@ -3,8 +3,8 @@ interface ISockProc : public IBase { - std_method(OnSockSend)(crtid cid, crterr err, BUF_PTR buf, BUF_SIZE size) PURE; - std_method(OnSockRecv)(crtid cid, crterr err, BUF_PTR buf, BUF_SIZE size) PURE; + std_method(OnSockSend)(crtid cid, crterr err, buf_ptr buf, buf_len size) PURE; + std_method(OnSockRecv)(crtid cid, crterr err, buf_ptr buf, buf_len size) PURE; std_method(OnSockConnect)(crtid cid, crterr err, _sock_t fd) PURE; std_method(OnSockEvent)(crtid cid, crtop op, crterr err, _sock_t fd) PURE; }; diff --git a/extensions/include/net/ihttp.h b/extensions/include/net/ihttp.h index 0ebd4adf..78246673 100644 --- a/extensions/include/net/ihttp.h +++ b/extensions/include/net/ihttp.h @@ -82,12 +82,12 @@ interface IHttpProc : public IBase { std_method(OnHttpAuth)(ULONG event) PURE; std_method(OnHttpNotify)(crtid event, crterr err) PURE; - std_method(OnHttpSendParam)(UCHAR* key, BUF_SIZE klen, UCHAR* value, BUF_SIZE vlen) PURE; - std_method(OnHttpRecvParam)(UCHAR* key, BUF_SIZE klen, UCHAR* value, BUF_SIZE vlen) PURE; - std_method(OnHttpSendHeaded)(UCHAR* data, BUF_SIZE size) PURE; - std_method(OnHttpRecvHeaded)(UCHAR* data, BUF_SIZE size) PURE; - std_method(OnHttpSendBody)(UCHAR* data, BUF_SIZE size) PURE; - std_method(OnHttpRecvBody)(UCHAR* data, BUF_SIZE size) PURE; + std_method(OnHttpSendParam)(UCHAR* key, buf_len klen, UCHAR* value, buf_len vlen) PURE; + std_method(OnHttpRecvParam)(UCHAR* key, buf_len klen, UCHAR* value, buf_len vlen) PURE; + std_method(OnHttpSendHeaded)(UCHAR* data, buf_len size) PURE; + std_method(OnHttpRecvHeaded)(UCHAR* data, buf_len size) PURE; + std_method(OnHttpSendBody)(UCHAR* data, buf_len size) PURE; + std_method(OnHttpRecvBody)(UCHAR* data, buf_len size) PURE; }; // {8C102441-E383-4B3C-8CC8-7C8E0B0162FE} diff --git a/mainui/appviewimpl.cpp b/mainui/appviewimpl.cpp index 1b9657d2..a247d414 100644 --- a/mainui/appviewimpl.cpp +++ b/mainui/appviewimpl.cpp @@ -43,11 +43,11 @@ HRESULT CAppViewImpl::Stop(unsigned int exit) return hr; } -HRESULT CAppViewImpl::OnSockSend(crtid id, crterr error_code, BUF_PTR buf, BUF_SIZE size) +HRESULT CAppViewImpl::OnSockSend(crtid id, crterr error_code, buf_ptr buf, buf_len size) { return S_OK; } -HRESULT CAppViewImpl::OnSockRecv(crtid id, crterr error_code, BUF_PTR buf, BUF_SIZE size) +HRESULT CAppViewImpl::OnSockRecv(crtid id, crterr error_code, buf_ptr buf, buf_len size) { return S_OK; } diff --git a/mainui/appviewimpl.h b/mainui/appviewimpl.h index 6cff3529..1d1eeaf8 100644 --- a/mainui/appviewimpl.h +++ b/mainui/appviewimpl.h @@ -44,8 +44,8 @@ public: std_method(Stop)(unsigned int exit); // ISockProc - std_method(OnSockSend)(crtid id, crterr error_code, BUF_PTR buf, BUF_SIZE size); - std_method(OnSockRecv)(crtid id, crterr error_code, BUF_PTR buf, BUF_SIZE size); + std_method(OnSockSend)(crtid id, crterr error_code, buf_ptr buf, buf_len size); + std_method(OnSockRecv)(crtid id, crterr error_code, buf_ptr buf, buf_len size); std_method(OnSockConnect)(crtid id, crterr error_code, _sock_t fd); std_method(OnSockEvent)(crtid id, crtid event, crterr error_code, _sock_t fd); diff --git a/msgbus/agent.cpp b/msgbus/agent.cpp index 93a98722..dcf35d56 100644 --- a/msgbus/agent.cpp +++ b/msgbus/agent.cpp @@ -73,7 +73,7 @@ HRESULT CAgentImpl::OnConnected(IBase* pIBase) { HRESULT hr = S_OK; - BUF_PTR ptr = NULL; + buf_ptr ptr = NULL; // hr = this->GetWritePtr(&ptr); rc_error(hr == S_OK, E_FAIL); @@ -103,8 +103,8 @@ HRESULT CAgentImpl::OnRecvSeqAcked(IBase* pIBase) { HRESULT hr = S_OK; - BUF_SIZE TransferedBytes = 0; - BUF_PTR ptr = NULL; + buf_len TransferedBytes = 0; + buf_ptr ptr = NULL; unsigned int s = 0; unsigned int a = 0; diff --git a/msgbus/broker.cpp b/msgbus/broker.cpp index 644ec7a0..7ffb4522 100644 --- a/msgbus/broker.cpp +++ b/msgbus/broker.cpp @@ -199,8 +199,8 @@ HRESULT CBrokerImpl::OnRecvAcked(IBase* pIBase) { HRESULT hr = S_OK; - BUF_SIZE TransferedBytes = 0; - BUF_PTR ptr = NULL; + buf_len TransferedBytes = 0; + buf_ptr ptr = NULL; unsigned int s = 0; unsigned int a = 0; diff --git a/msgbus/consumer.cpp b/msgbus/consumer.cpp index 99a11b8b..dca7a961 100644 --- a/msgbus/consumer.cpp +++ b/msgbus/consumer.cpp @@ -69,7 +69,7 @@ HRESULT CConsumerImpl::OnConnected(IBase* pIBase) { HRESULT hr = S_OK; - BUF_PTR ptr = NULL; + buf_ptr ptr = NULL; // hr = this->GetWritePtr(&ptr); rc_error(hr == S_OK, E_FAIL); @@ -99,8 +99,8 @@ HRESULT CConsumerImpl::OnRecvSeqAcked(IBase* pIBase) { HRESULT hr = S_OK; - BUF_SIZE TransferedBytes = 0; - BUF_PTR ptr = NULL; + buf_len TransferedBytes = 0; + buf_ptr ptr = NULL; unsigned int s = 0; unsigned int a = 0; diff --git a/msgbus/producer.cpp b/msgbus/producer.cpp index b72b2abf..fad45ab3 100644 --- a/msgbus/producer.cpp +++ b/msgbus/producer.cpp @@ -69,7 +69,7 @@ HRESULT CProducerImpl::OnConnected(IBase* pIBase) { HRESULT hr = S_OK; - BUF_PTR ptr = NULL; + buf_ptr ptr = NULL; // hr = this->GetWritePtr(&ptr); rc_error(hr == S_OK, E_FAIL); @@ -99,8 +99,8 @@ HRESULT CProducerImpl::OnRecvSeqAcked(IBase* pIBase) { HRESULT hr = S_OK; - BUF_SIZE TransferedBytes = 0; - BUF_PTR ptr = NULL; + buf_len TransferedBytes = 0; + buf_ptr ptr = NULL; unsigned int s = 0; unsigned int a = 0; diff --git a/net/dnsimpl.cpp b/net/dnsimpl.cpp index d346acbd..64e63251 100644 --- a/net/dnsimpl.cpp +++ b/net/dnsimpl.cpp @@ -51,14 +51,14 @@ HRESULT CDnsImpl::Post(LPCSTR hostname, IBase* pProc) hr = m_pIOperation->BindEvent(pIBase); rc_error(hr == S_OK, E_FAIL); - hr = m_pIOperation->Attach((BUF_PTR)buf, 0, buflen); + hr = m_pIOperation->Attach((buf_ptr)buf, 0, buflen); rc_error(hr == S_OK, E_FAIL); hr = m_pISocket->CreateSock(); rc_error(hr == S_OK, E_FAIL); - BUF_SIZE len = 0; - // len = m_pISocket->SyncSend("114.114.114.114", 53, (BUF_PTR)buf, buflen); + buf_len len = 0; + // len = m_pISocket->SyncSend("114.114.114.114", 53, (buf_ptr)buf, buflen); // rc_error(len != 0, E_FAIL); hr = m_pIOperation->ClearPtr(); @@ -107,10 +107,10 @@ HRESULT CDnsImpl::OnComplete(IBase* pOperation, crtid cid, crterr err) pOperation->QueryInterface(IID_IOperation, (void**)&pOper); crterr error = 0; - BUF_SIZE size = 0; + buf_len size = 0; pOper->GetResult(&error, &size); - BUF_PTR ptr; + buf_ptr ptr; pOper->GetPtr(&ptr); diff --git a/testmain/appviewimpl.cpp b/testmain/appviewimpl.cpp index fd86cfe6..18c59b32 100644 --- a/testmain/appviewimpl.cpp +++ b/testmain/appviewimpl.cpp @@ -88,27 +88,27 @@ HRESULT CAppViewImpl::OnHttpNotify(crtid cid, crterr err) } return S_OK; } -HRESULT CAppViewImpl::OnHttpSendParam(UCHAR* key, BUF_SIZE klen, UCHAR* value, BUF_SIZE vlen) +HRESULT CAppViewImpl::OnHttpSendParam(UCHAR* key, buf_len klen, UCHAR* value, buf_len vlen) { return S_OK; } -HRESULT CAppViewImpl::OnHttpRecvParam(UCHAR* key, BUF_SIZE klen, UCHAR* value, BUF_SIZE vlen) +HRESULT CAppViewImpl::OnHttpRecvParam(UCHAR* key, buf_len klen, UCHAR* value, buf_len vlen) { return S_OK; } -HRESULT CAppViewImpl::OnHttpSendHeaded(UCHAR* data, BUF_SIZE size) +HRESULT CAppViewImpl::OnHttpSendHeaded(UCHAR* data, buf_len size) { return S_OK; } -HRESULT CAppViewImpl::OnHttpRecvHeaded(UCHAR* data, BUF_SIZE size) +HRESULT CAppViewImpl::OnHttpRecvHeaded(UCHAR* data, buf_len size) { return S_OK; } -HRESULT CAppViewImpl::OnHttpSendBody(UCHAR* data, BUF_SIZE size) +HRESULT CAppViewImpl::OnHttpSendBody(UCHAR* data, buf_len size) { return S_OK; } -HRESULT CAppViewImpl::OnHttpRecvBody(UCHAR* data, BUF_SIZE size) +HRESULT CAppViewImpl::OnHttpRecvBody(UCHAR* data, buf_len size) { return S_OK; } diff --git a/testmain/appviewimpl.h b/testmain/appviewimpl.h index c299fa8a..8aa7ff7d 100644 --- a/testmain/appviewimpl.h +++ b/testmain/appviewimpl.h @@ -34,12 +34,12 @@ public: // IHttpProc std_method(OnHttpAuth)(ULONG event); std_method(OnHttpNotify)(crtid cid, crterr err); - std_method(OnHttpSendParam)(UCHAR* key, BUF_SIZE klen, UCHAR* value, BUF_SIZE vlen); - std_method(OnHttpRecvParam)(UCHAR* key, BUF_SIZE klen, UCHAR* value, BUF_SIZE vlen); - std_method(OnHttpSendHeaded)(UCHAR* data, BUF_SIZE size); - std_method(OnHttpRecvHeaded)(UCHAR* data, BUF_SIZE size); - std_method(OnHttpSendBody)(UCHAR* data, BUF_SIZE size); - std_method(OnHttpRecvBody)(UCHAR* data, BUF_SIZE size); + std_method(OnHttpSendParam)(UCHAR* key, buf_len klen, UCHAR* value, buf_len vlen); + std_method(OnHttpRecvParam)(UCHAR* key, buf_len klen, UCHAR* value, buf_len vlen); + std_method(OnHttpSendHeaded)(UCHAR* data, buf_len size); + std_method(OnHttpRecvHeaded)(UCHAR* data, buf_len size); + std_method(OnHttpSendBody)(UCHAR* data, buf_len size); + std_method(OnHttpRecvBody)(UCHAR* data, buf_len size); private: std_method(InitBus)(); -- Gitee From 6405364c79d93464528282cde246ce3f11b7f8be Mon Sep 17 00:00:00 2001 From: com Date: Tue, 6 Aug 2024 20:39:02 +0800 Subject: [PATCH 11/34] up --- crt/crt_def.h | 15 +- crt/crt_endian.h | 6 +- stdcrt/code/compat_endian.c | 10 +- stdcrt/event/compat_event.c | 119 ++++++++------- stdcrt/event/compat_event_epoll.c | 226 +++++++++++++---------------- stdcrt/event/compat_event_epoll.h | 9 +- stdcrt/event/compat_event_iocp.c | 20 ++- stdcrt/event/compat_event_kqueue.c | 205 +++++++++++++++++--------- stdcrt/event/compat_event_kqueue.h | 6 +- stdcrt/event/compat_event_posix.c | 3 +- stdcrt/event/compat_event_util.c | 85 +++++++++-- stdcrt/event/compat_event_util.h | 101 +++---------- stdcrt/event/epoll4.png | Bin 0 -> 226740 bytes stdcrt/stdcrt.vcxproj | 1 + stdcrt_test/main.c | 44 ++---- stdcrt_test/test.h | 5 +- stdcrt_test/test_oper.c | 147 ++++++++++++++----- 17 files changed, 568 insertions(+), 434 deletions(-) create mode 100644 stdcrt/event/epoll4.png diff --git a/crt/crt_def.h b/crt/crt_def.h index e54a5919..e260882b 100644 --- a/crt/crt_def.h +++ b/crt/crt_def.h @@ -37,15 +37,15 @@ extern "C" { #ifndef S_CONNERROR #define S_CONNERROR 7 -#endif // !S_WRITEERROR +#endif // !S_CONNERROR #ifndef S_POLLERROR #define S_POLLERROR 8 -#endif // !S_WRITEERROR +#endif // !S_POLLERROR #ifndef S_SUPORTERROR #define S_SUPORTERROR 9 -#endif // !S_WRITEERROR +#endif // !S_SUPORTERROR #ifndef S_MEMERROR #define S_MEMERROR 80 @@ -79,6 +79,15 @@ extern "C" { #define S_AGAIN 303 #endif // !S_AGAIN +#ifndef S_EXIT +#define S_EXIT 304 +#endif // !S_EXIT + + +#ifndef S_RELOAD +#define S_RELOAD 305 +#endif // !S_RELOAD + #pragma pack(push, 1) #ifndef _SafeStringPtr_ diff --git a/crt/crt_endian.h b/crt/crt_endian.h index 60bd96c8..7569bd36 100644 --- a/crt/crt_endian.h +++ b/crt/crt_endian.h @@ -7,9 +7,9 @@ extern "C" { #endif -#define Null_endian 0 -#define Big_endian 1 -#define Little_endian 2 +#define null_endian 0 +#define big_endian 1 +#define little_endian 2 int is_big_little(void); diff --git a/stdcrt/code/compat_endian.c b/stdcrt/code/compat_endian.c index 16deae50..c9c69304 100644 --- a/stdcrt/code/compat_endian.c +++ b/stdcrt/code/compat_endian.c @@ -6,11 +6,11 @@ int is_big_little(void) char firstByte = *(char*)&val; if (firstByte == 0x01) { - return Little_endian; + return little_endian; } else if (firstByte == 0x04) { - return Big_endian; + return big_endian; } - return Null_endian; + return null_endian; } uint16_t blushort(uint16_t value) @@ -31,7 +31,7 @@ int uint64touint32(uint64_t u64value, uint32* u32value) int rc = 0; - if (is_big_little() == Little_endian) { + if (is_big_little() == little_endian) { rc = u8value[0] == 0x00 && u8value[1] == 0x00 && u8value[2] == 0x00 && u8value[3] == 0x00; rc_error(rc > 0, S_ERROR); @@ -39,7 +39,7 @@ int uint64touint32(uint64_t u64value, uint32* u32value) value = (((uint32_t)u8value[4]) << 24) | (((uint32_t)u8value[5]) << 16) | (((uint32_t)u8value[6]) << 8) | ((uint32_t)u8value[7]); *u32value = value & UINT32_MAX; - } else if (is_big_little() == Big_endian) { + } else if (is_big_little() == big_endian) { rc = u8value[4] == 0x00 && u8value[5] == 0x00 && u8value[6] == 0x00 && u8value[7] == 0x00; rc_error(rc > 0, S_ERROR); diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index fb2861bf..e2e74313 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -11,31 +11,38 @@ static int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) { - if (oper->conn == op_ev_connecting && (op == op_ev_connecting)) { - - if (evoper_sock_connected(oper) == S_SUCCESS) - oper->handler(op_ev_success, oper, oper, op_ev_connect); - else - oper->handler(op_ev_faild, oper, oper, op_ev_connect); - - } else if(oper->open == op_ev_opening && (op == op_ev_opening)) { + if (op == op_ev_connect) { + evevent res = evoper_sock_connected(oper) == S_SUCCESS ? op_ev_success : op_ev_faild; + oper->handler(res, oper, oper, op_ev_connect); + } else if(op == op_ev_open) { oper->handler(op_ev_success, oper, oper, op_ev_open); - } else if (oper->s == op_ev_closeing && (op == op_ev_closeing)) { + } else if (op == op_ev_close) { oper->handler(op_ev_success, oper, oper, op_ev_close); - } else if (oper->accept == op_ev_accepting && (op == op_ev_accepting)) { + } else if (op == op_ev_accept) { oper->handler(op_ev_success, oper, oper_s, op_ev_accept); } - if (oper->read == op_ev_reading && (op == op_ev_reading)) { - oper->handler(op_ev_success, oper, oper, op_ev_read); + if (op == op_ev_read) { + if (oper->bt == ev_io_complete) { + logi("ev_io_complete"); + oper->handler(op_ev_success, oper, oper, op_ev_read); + } else if (oper->bt == ev_func_complete) { + logi("ev_func_complete"); + oper->handler(op_ev_success, oper, oper, op_ev_read); + } } - if (oper->write == op_ev_writeing && (op == op_ev_writeing)) { - oper->handler(op_ev_success, oper, oper, op_ev_write); + if (op == op_ev_write) { + if (oper->bt == ev_io_complete) { + logi("ev_io_complete"); + oper->handler(op_ev_success, oper, oper, op_ev_write); + } else if (oper->bt == ev_func_complete) { + logi("ev_func_complete"); + oper->handler(op_ev_success, oper, oper, op_ev_write); + } } - if (oper->t == ev_time && (op == op_ev_timering)) - { + if (oper->t == ev_time && (op == op_ev_timer)) { oper->handler(err, oper, oper, op_ev_timer); } @@ -258,61 +265,54 @@ int evloop_add_timer(evloop_t* loop, evoper_t* oper, ev_time_t tv) { rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); - const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); evoper_bind_type(oper, ev_time); - evoper_bind_evloop(oper, loop); - evloop_update_time(loop); - crt_msec msec; - evloop_clock_getmsec(loop->clock, &msec); - oper->msec = tv_to_msec(tv) + msec; - evloop_addtime(loop->nodes, oper); - return S_SUCCESS; } int evloop_add_read(evloop_t* loop, evoper_t* oper, ev_time_t tv) { - int rc = S_ERROR; - rc_error(oper != NULL, S_ERROR); - rc_error(loop != NULL, S_ERROR); + rc_error(oper != NULL, S_MEMERROR); + rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); + rs_error(evoper_erring(oper) == S_SUCCESS, S_ERROR); + rs_error(evoper_closeing(oper) == S_SUCCESS, S_CLOSE); + rc_error(loop != NULL, S_MEMERROR); + const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_read != NULL, S_ERROR); - evoper_read_op(oper, op_ev_reading); - rc = evsel->op_add_read(loop, oper, op_ev_read, tv); - if (rc == S_COMPLETED) { - complete_op(S_SUCCESS, 0, oper, oper, op_ev_reading); - evoper_read_op(oper, op_ev_readed); - } - return rc; + + return evsel->op_add_read(loop, oper, op_ev_read, tv); } int evloop_add_write(evloop_t* loop, evoper_t* oper, ev_time_t tv) { - int rc = S_ERROR; - rc_error(oper != NULL, S_ERROR); - rc_error(loop != NULL, S_ERROR); + rc_error(oper != NULL, S_MEMERROR); + rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); + rs_error(evoper_erring(oper) == S_SUCCESS, S_ERROR); + rs_error(evoper_closeing(oper) == S_SUCCESS, S_CLOSE); + rc_error(loop != NULL, S_MEMERROR); + const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_write != NULL, S_ERROR); - evoper_write_op(oper, op_ev_writeing); - rc = evsel->op_add_write(loop, oper, op_ev_write, tv); - if (rc == S_COMPLETED) { - complete_op(S_SUCCESS, 0, oper, oper, op_ev_writeing); - evoper_write_op(oper, op_ev_writed); - } - return rc; + + return evsel->op_add_write(loop, oper, op_ev_write, tv); } int evloop_del_read(evloop_t* loop, evoper_t* oper) { - rc_error(loop != NULL, S_ERROR); + rc_error(oper != NULL, S_MEMERROR); + rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); + rs_error(evoper_erring(oper) == S_SUCCESS, S_ERROR); + rs_error(evoper_closeing(oper) == S_SUCCESS, S_CLOSE); + rc_error(loop != NULL, S_MEMERROR); + const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_del_read != NULL, S_ERROR); @@ -321,17 +321,26 @@ int evloop_del_read(evloop_t* loop, evoper_t* oper) int evloop_del_write(evloop_t* loop, evoper_t* oper) { - rc_error(oper != NULL, S_ERROR); - rc_error(loop != NULL, S_ERROR); + rc_error(oper != NULL, S_MEMERROR); + rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); + rs_error(evoper_erring(oper) == S_SUCCESS, S_ERROR); + rs_error(evoper_closeing(oper) == S_SUCCESS, S_CLOSE); + rc_error(loop != NULL, S_MEMERROR); + const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_del_write != NULL, S_ERROR); + return evsel->op_del_write(loop, oper, op_ev_write); } int evloop_canncel(evloop_t* loop, evoper_t* oper) { - rc_error(oper != NULL, S_ERROR); - rc_error(loop != NULL, S_ERROR); + rc_error(oper != NULL, S_MEMERROR); + rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); + rs_error(evoper_erring(oper) == S_SUCCESS, S_ERROR); + rs_error(evoper_closeing(oper) == S_SUCCESS, S_CLOSE); + rc_error(loop != NULL, S_MEMERROR); + const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_cancel != NULL, S_ERROR); @@ -358,8 +367,12 @@ int evloop_poll(evoper_t* oper, unsigned int ls) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_poll != NULL, S_ERROR); + + rs_error(oper->accept == op_ev_accepting, S_COMPLETED) + rs_error(oper->accept == op_ev_accepted, S_CLOSE) evoper_listen_size(oper, ls); - evoper_accept_op(oper, op_ev_accepting); + evoper_accept_op(oper, op_ev_accepting); + return evsel->op_poll(loop, oper); } int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) @@ -372,13 +385,15 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_connect != NULL, S_ERROR); + rs_error(oper->conn == op_ev_connected, S_COMPLETED) evoper_connect_op(oper, op_ev_connecting); + rc = evsel->op_add_connect(loop, oper, addr, tv); rs_error(rc == S_PENDING, S_SUCCESS) if (rc == S_COMPLETED) { - complete_op(S_SUCCESS, 0, oper, oper, op_ev_connecting); + complete_op(S_SUCCESS, 0, oper, oper, op_ev_connect); evoper_connect_op(oper, op_ev_connected); } @@ -522,7 +537,7 @@ static int cmd_poll_time(evloop_t* loop, evoper_t* oper) if (ms > 0) op->op_dispatch(loop, op_cmd_poll, ms); - complete_op(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timering); + complete_op(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timer); return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index d91b73e5..d1ec0d01 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -44,23 +44,19 @@ //EPOLLRDHUP #define ev_base_event (EPOLLET | EPOLLERR) - #ifdef EPOLLEXCLUSIVE -#define ev_poll_event (EPOLLIN | EPOLLEXCLUSIVE) +#define ev_poll_event (EPOLLIN /*| EPOLLEXCLUSIVE*/) #else #define ev_poll_event (EPOLLIN) #endif - #define ev_conn_event (EPOLLOUT) - #define ev_read_event (EPOLLIN | EPOLLRDHUP) #define ev_write_event (EPOLLOUT) - #define ev_clear_event (EPOLLET) - #define ev_oneshot_write_event (EPOLLOUT | EPOLLONESHOT) #define ev_oneshot_read_event (EPOLLIN | EPOLLONESHOT) + static int is_use_epoll_rdhup(epoll_op_t* base, int ep) { int use_epoll_rdhup; @@ -129,15 +125,6 @@ static int sys_hook_api(epoll_op_t* base) base->sys_eventfd = (sys_eventfd_fn)dlsym(RTLD_NEXT, "eventfd"); rc_error(base->sys_eventfd != NULL, S_ERROR); - //base->sys_timerfd_create = (timerfd_create_fn)dlsym(RTLD_NEXT, "timerfd_create"); - //rc_error(base->sys_timerfd_create != NULL, S_ERROR); - - //base->sys_timerfd_settime = (timerfd_settime_fn)dlsym(RTLD_NEXT, "timerfd_settime"); - //rc_error(base->sys_timerfd_settime != NULL, S_ERROR); - - //base->sys_timerfd_gettime = (timerfd_gettime_fn)dlsym(RTLD_NEXT, " timerfd_gettime"); - //rc_error(base->sys_timerfd_gettime != NULL, S_ERROR); - return S_SUCCESS; } @@ -172,42 +159,38 @@ static uint32_t get_epoll_op(epoll_event_t* ptr) rc_error(ptr != NULL, S_ERROR); return ptr->op; } -static int get_epoll_ctl(epoll_event_t* ptr) -{ - rc_error(ptr != NULL, S_ERROR); - return ptr->ctl == ev_off ? EPOLL_CTL_ADD : EPOLL_CTL_MOD; -} static int set_epoll_op(epoll_event_t* ptr, uint32_t op) { rc_error(ptr != NULL, S_ERROR); ptr->op = op; return S_SUCCESS; } -static int set_epoll_ctl(epoll_event_t* ptr, evevent on) -{ - rc_error(ptr != NULL, S_ERROR); - ptr->ctl = on; - return S_SUCCESS; -} - -static int epoll_op(epoll_op_t* base, evoper_t* oper, epoll_event_t* ptr) +static int epoll_op(epoll_op_t* base, evoper_t* oper, epoll_event_t* ptr, int op) { struct epoll_event ee; - int op = 0; - - op = get_epoll_ctl(ptr); ee.events = get_epoll_op(ptr); ee.data.u32 = 0; ee.data.u64 = 0; ee.data.ptr = oper; - if (base->sys_epoll_ctl(base->epfd, op, oper->fd, &ee) == 0) + //ctl_mod --> EPOLLEXCLUSIVE --> 22 sys_epoll_ctl return EINVAL + if (base->sys_epoll_ctl(base->epfd, op, oper->fd, &ee) == 0) { + ptr->epoll = ev_on; return S_SUCCESS; + } + + ptr->epoll = ev_off; - if (errno != EPERM) + if (errno == ENOENT) { loge("epoll_ctl error %d, epfd=%d, fd=%d\n", errno, base->epfd, oper->fd); + goto end; + } else if (errno != EPERM) { + loge("epoll_ctl error %d, epfd=%d, fd=%d\n", errno, base->epfd, oper->fd); + } return S_ERROR; +end: + return S_NOFOUND; } int epoll_op_alloc(evloop_t* loop, int size) { @@ -215,7 +198,7 @@ int epoll_op_alloc(evloop_t* loop, int size) epoll_op_t* base = NULL; - base = (epoll_op_t*)calloc(1, sizeof(epoll_op_t)); + base = (epoll_op_t*)loop->mm_malloc(loop, 1, sizeof(epoll_op_t)); rc_error(base != NULL, S_ERROR); base->size = size; @@ -227,10 +210,6 @@ int epoll_op_alloc(evloop_t* loop, int size) base->sys_eventfd = NULL; base->mode = 0; - //base->timerfd = -1; - //base->sys_timerfd_create = NULL; - //base->sys_timerfd_settime = NULL; - rc = sys_hook_api(base); if (rc != S_SUCCESS) goto err; @@ -245,22 +224,8 @@ int epoll_op_alloc(evloop_t* loop, int size) base->size += 1; } - base->mode = ev_base_event; - //if (base->sys_timerfd_create != NULL) { - // base->timerfd = base->sys_timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC); - // if (base->timerfd >= 0) { - // struct epoll_event epev; - // s_memset(&epev, 0, sizeof(epev)); - // epev.data.fd = base->timerfd; - // epev.events = ev_read_event; - // if (base->sys_epoll_ctl(base->epfd, EPOLL_CTL_ADD, base->timerfd, &epev) < 0) { - // close(base->timerfd); - // } - // } - //} - rc = is_use_epoll_rdhup(base, base->epfd); if (rc != S_SUCCESS) goto err; @@ -276,14 +241,12 @@ int epoll_op_alloc(evloop_t* loop, int size) return evloop_bind_evbase(loop, base); err: - if (base != NULL) - free(base); - + loop->mm_free(loop, base); return S_ERROR; } int epoll_op_dealloc(evloop_t* loop) { - rc_error(loop != NULL, S_ERROR); + rc_error(loop != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evloop_evbase(loop); loop->mm_free(loop, base->poll); return S_SUCCESS; @@ -309,10 +272,15 @@ int epoll_op_alloc_evoper(evloop_t* loop, evoper_t* oper) evoper_bind_private(oper, ptr); - ptr->ctl = ev_off; + uint32_t op = ev_base_event; + set_epoll_op(ptr, op); + + ptr->epoll = ev_off; + + evoper_op_init(oper); //https://elixir.bootlin.com/linux/v4.19.316/source/fs/eventpoll.c#L2047 - return S_SUCCESS; // epoll_op(base, oper, 0, EPOLL_CTL_ADD, oper->fd); + return epoll_op(base, oper, ptr, EPOLL_CTL_ADD); } int epoll_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) { @@ -324,10 +292,8 @@ int epoll_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - set_epoll_op(ptr, 0); - set_epoll_ctl(ptr, EPOLL_CTL_DEL); - - rc = epoll_op(base, oper, ptr); + set_epoll_op(ptr, ev_clear_event); + rc = epoll_op(base, oper, ptr, EPOLL_CTL_DEL); if (ptr != NULL) heap_free(ptr); @@ -344,13 +310,23 @@ int epoll_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) rc_error(ptr != NULL, S_ERROR); rc = posix_tcpsock_recv(oper, 0); - if (rc == S_PENDING) { + + if (rc == S_COMPLETED) { + + oper->bt = ev_func_complete; + base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); + + } else if (rc == S_PENDING) { uint32_t op = epoll_event_add(ptr, ev_read_event); set_epoll_op(ptr, op); - set_epoll_ctl(ptr, EPOLL_CTL_MOD); - epoll_op(base, oper, ptr); - } + rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); + logi("epoll_read_pending"); + + } else { + logi("epoll_read_error"); + } + return rc; } int epoll_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) @@ -363,12 +339,20 @@ int epoll_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv rc_error(ptr != NULL, S_ERROR); rc = posix_tcpsock_send(oper, 0); - if (rc == S_PENDING) { - uint32_t op = epoll_event_add(ptr, ev_write_event); + + if (rc == S_COMPLETED) { + + oper->bt = ev_func_complete; + base->ev(S_SUCCESS, 0, oper, oper, op_ev_writeing); + + } else if (rc == S_PENDING) { + + uint32_t op = epoll_event_add(ptr, ev_write_event); set_epoll_op(ptr, op); - set_epoll_ctl(ptr, EPOLL_CTL_MOD); - epoll_op(base, oper, ptr); - } + rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); + + } + return rc; // } int epoll_op_del_read(evloop_t* loop, evoper_t* oper, short event) @@ -382,10 +366,8 @@ int epoll_op_del_read(evloop_t* loop, evoper_t* oper, short event) uint32_t op = epoll_event_del(ptr, ev_read_event); set_epoll_op(ptr, op); - set_epoll_ctl(ptr, EPOLL_CTL_MOD); - epoll_op(base, oper, ptr); - return S_SUCCESS; + return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } int epoll_op_del_write(evloop_t* loop, evoper_t* oper, short event) { @@ -398,11 +380,8 @@ int epoll_op_del_write(evloop_t* loop, evoper_t* oper, short event) uint32_t op = epoll_event_del(ptr, ev_read_event); set_epoll_op(ptr, op); - set_epoll_ctl(ptr, EPOLL_CTL_MOD); - - epoll_op(base, oper, ptr); - return S_SUCCESS; + return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } int epoll_op_cancel(evloop_t* loop, evoper_t* oper) { @@ -413,9 +392,8 @@ int epoll_op_cancel(evloop_t* loop, evoper_t* oper) rc_error(ptr != NULL, S_ERROR); set_epoll_op(ptr, ev_clear_event); - set_epoll_ctl(ptr, EPOLL_CTL_DEL); - return epoll_op(base, oper, ptr); + return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } int epoll_op_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) { @@ -430,11 +408,9 @@ int epoll_op_poll(evloop_t* loop, evoper_t* oper) epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - uint32_t op = ev_poll_event | ev_base_event; - set_epoll_op(ptr, op); - set_epoll_ctl(ptr, EPOLL_CTL_ADD); + set_epoll_op(ptr, ev_poll_event| ev_base_event); - return epoll_op(base, oper, ptr); + return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } int epoll_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { @@ -451,8 +427,7 @@ int epoll_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, e if (rc == S_PENDING) { uint32_t op = ev_conn_event | ev_base_event; set_epoll_op(ptr, op); - set_epoll_ctl(ptr, EPOLL_CTL_ADD); - rc = epoll_op(base, oper, ptr); + rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } return rc; @@ -468,33 +443,10 @@ int epoll_op_del_connect(evloop_t* loop, evoper_t* oper) uint32_t op = epoll_event_del(ptr, ev_conn_event); set_epoll_op(ptr, op); - set_epoll_ctl(ptr, EPOLL_CTL_DEL); - epoll_op(base, oper, ptr); + epoll_op(base, oper, ptr, EPOLL_CTL_MOD); return S_SUCCESS; } -int epoll_event_complete(evloop_t* loop, crterr err, epoll_op_t* base, evoper_t* oper, short ev) -{ - int rc = S_ERROR; - rc_error(oper != NULL, S_ERROR); - - if (oper->accept == op_ev_accepting && (ev == op_ev_readed)) - rc = complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); - - if (oper->conn == op_ev_connecting && (ev == op_ev_writed)) - rc = complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); - - if (oper->s == op_ev_closeing || (ev == op_ev_closed)) - rc = complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - - if (oper->read == op_ev_reading && (ev & op_ev_readed)) - rc = complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); - - if (oper->write == op_ev_writeing && (ev & op_ev_writed)) - rc = complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); - - return rc; -} //https://elixir.bootlin.com/linux/v2.6.26/source/fs/eventpoll.c#L99 #define MAX_TIMEOUT_MSEC (35 * 60 * 1000) @@ -510,34 +462,62 @@ static int epoll_op_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) crterr err = crt_geterror(); int n = 0; + for (n = 0; n < fds; n++) { evoper_t* oper = NULL; uint32_t events = 0; - short ev = 0; rc_error_break(base->ev != NULL); oper = base->poll[n].data.ptr; rc_error_continue(oper != NULL); events = base->poll[n].events; rc_error_continue(oper->fd != INVALID_SOCKET) + + if (base->poll[n].data.fd == base->notify_fd) { + if (base->notify_handler(base) == S_EXIT) { + break; + } + } + //error if (events & EPOLLERR) { - ev = op_ev_readed | op_ev_writed; - } else if ((events & EPOLLHUP) && !(events & EPOLLRDHUP)) { - ev = op_ev_readed | op_ev_writed; - } else { - if (events & EPOLLIN) - ev = op_ev_readed; - if (events & EPOLLOUT) - ev = op_ev_writed; - if (events & EPOLLRDHUP) - ev = op_ev_closed; + evoper_err_op(oper, ev_on); + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + continue; + } + + // shutdown + if (events & EPOLLHUP) { + evoper_close_op(oper, ev_on); + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + continue; } - rc_error_continue(ev != 0) + if (events & EPOLLIN) { + + if (events & EPOLLRDHUP) { + evoper_close_op(oper, ev_on); + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + continue; + } - epoll_event_complete(loop, err, base, oper, ev); + if (oper->accept == op_ev_accepting) { + complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); + continue; + } + + oper->bt = ev_io_complete; + complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); + } + + if (events & EPOLLOUT) { + if (oper->conn == op_ev_connecting) { + complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); + continue; + } + complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); + } } return S_SUCCESS; diff --git a/stdcrt/event/compat_event_epoll.h b/stdcrt/event/compat_event_epoll.h index fb2fbba6..cd96e201 100644 --- a/stdcrt/event/compat_event_epoll.h +++ b/stdcrt/event/compat_event_epoll.h @@ -14,8 +14,9 @@ typedef struct epoll_event_s epoll_event_t; typedef struct epoll_op_s epoll_op_t; struct epoll_event_s { - evevent ctl; + int ctl; uint32_t op; + evevent epoll; }; typedef int (*epoll_create_fn)(int); @@ -23,7 +24,6 @@ typedef int (*epoll_wait_fn)(int, struct epoll_event*, int, int); typedef int (*epoll_ctl_fn)(int, int, int, struct epoll_event*); typedef int (*sys_eventfd_fn)(unsigned int, int); - //#ifndef TFD_CLOEXEC //#define TFD_CLOEXEC 02000000 //#endif // !TFD_CLOEXEC @@ -52,11 +52,6 @@ struct epoll_op_s { epoll_ctl_fn sys_epoll_ctl; sys_eventfd_fn sys_eventfd; - //int timerfd; - //timerfd_create_fn sys_timerfd_create; - //timerfd_settime_fn sys_timerfd_settime; - //timerfd_gettime_fn sys_timerfd_gettime; - //notify->epoll 2.6.22 int notify_fd; epoll_event_t notify_event; diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index fa4a2959..21495880 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -57,6 +57,8 @@ static lpwsasock wsasock_create(evloop_t* loop) //oper.private save overlapped ptr evoper_bind_private(oper, obj); + evoper_op_init(oper); + obj->ptr = sk; s_memset(&obj->overlapped, 0, sizeof(OVERLAPPED)); @@ -165,6 +167,7 @@ static int poll_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, D rc_error(sock->oper != NULL, S_ERROR); rc_error(base->ev != NULL, S_ERROR); win32_sock_accpet_ctx(sock->accept_oper, sock->oper); + return complete_sock_accept(loop, S_SUCCESS, err, sock->accept_oper, sock->oper, base->ev); } static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, DWORD err, DWORD bytes) @@ -280,6 +283,8 @@ int iocp_op_alloc_evoper(evloop_t* loop, evoper_t* oper) evoper_bind_private(oper, obj); obj->ptr = oper; + evoper_op_init(oper); + return S_SUCCESS; } int iocp_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) @@ -294,11 +299,9 @@ int iocp_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) int iocp_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; - if (oper->t == ev_sock) { - if (oper->read == op_ev_reading) { - rc = win32_sock_read_op(oper); - } + evoper_read_op(oper, op_ev_reading); + rc = win32_sock_read_op(oper); } return rc; } @@ -306,9 +309,9 @@ int iocp_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; if (oper->t == ev_sock) { - if (oper->write == op_ev_writeing) { - rc = win32_sock_write_op(oper); - } + + evoper_write_op(oper, op_ev_writeing); + rc = win32_sock_write_op(oper); } return rc; } @@ -340,7 +343,9 @@ int iocp_op_poll(evloop_t* loop, evoper_t* oper) rc_error(oper->t == ev_sockpoll, S_ERROR); lpwsasock sk = wsasock_create(loop); rc_error(sk != NULL, S_ERROR); + rc_error(wsasock_bind_iocp(base, sk) == S_SUCCESS, S_ERROR) + return win32_sock_accept(oper, sk); } int icop_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) @@ -371,7 +376,6 @@ int iocp_op_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) crterr err = crt_geterror(); - if (err) { if (ovlp == NULL) { if (err != WAIT_TIMEOUT) { diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 614148fd..c62f6dbf 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -3,22 +3,68 @@ #if (TARGET_OS == OS_MACH) -static int set_kevent_op(kqueue_event_t* ptr, uint32_t op) +#define ev_base_event (EVFILT_READ | EVFILT_WRITE) +#define ev_poll_event EVFILT_READ +#define ev_conn_event EVFILT_WRITE +#define ev_read_event EVFILT_READ +#define ev_write_event EVFILT_WRITE +#define ev_close_event EV_EOF +#define ev_clear_event EV_CLEAR +#define ev_oneshot_read_event EV_ONESHOT | EVFILT_READ +#define ev_oneshot_write_event EV_ONESHOT | EVFILT_WRITE + +#define kevent_add_op (EV_ADD | EV_ERROR) +#define kevent_del_op (EV_DELETE | EV_ERROR) +#define kevent_op_enable (EV_ENABLE | EV_ERROR) +#define kevent_op_disable (EV_DISABLE | EV_ERROR) + +static int set_kevent_op(kqueue_event_t* ptr, int16_t op) { rc_error(ptr != NULL, S_ERROR); ptr->op = op; return S_SUCCESS; } -static int set_kevent_ctl(kqueue_event_t* ptr, evevent on) +static int set_kevent_ctl(kqueue_event_t* ptr, uint32_t ctl) { rc_error(ptr != NULL, S_ERROR); - ptr->ctl = on; + ptr->ctl = ctl; return S_SUCCESS; } -static int kqueue_op(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr) +static int16_t get_kevent_op(kqueue_event_t* ptr) { + return ptr->op; +} +static uint32_t get_kevent_ctl(kqueue_event_t* ptr) +{ + return ptr->ctl; +} +static int kqueue_op_ctl(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr, const struct timespec* tm) +{ + int rc = 0; + struct kevent ev; + int16_t filter = get_kevent_op(ptr); + uint32_t fflags = get_kevent_ctl(ptr); + + EV_SET(&ev, oper->fd, filter, fflags, 0, 0, oper); + rc = base->sys_kevent(base->kqfd, &ev, 1, NULL, 0, tm); + + if (rc == -1) { + crterr err = crt_geterror(); + + if (err == EINVAL) { + loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); + } else if (err == ENOENT) { + loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); + } else if (err != EPERM) { + loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); + } + + return S_ERROR; + } + return S_SUCCESS; } + static int kqueue_notify_init(kqueue_op_t* base) { base->notify_kev.ident = 0; @@ -49,7 +95,7 @@ int kqueue_op_alloc(evloop_t* loop, int size) int rc = S_ERROR; kqueue_op_t* base = NULL; - base = (kqueue_op_t*)calloc(1, sizeof(kqueue_op_t)); + base = (kqueue_op_t*)loop->mm_malloc(loop, 1, sizeof(kqueue_op_t)); rc_error(base != NULL, S_ERROR); base->size = size; @@ -79,24 +125,16 @@ int kqueue_op_alloc(evloop_t* loop, int size) return evloop_bind_evbase(loop, base); err: - if (base != NULL) - free(base); - + loop->mm_free(loop, base); return S_ERROR; } int kqueue_op_dealloc(evloop_t* loop) { kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); - - if(base->poll) - loop->mm_free(loop, base->poll); - - if(base->change) - loop->mm_free(loop, base->change); - + loop->mm_free(loop, base->poll); + loop->mm_free(loop, base->change); return S_SUCCESS; } - int kqueue_op_handler(evloop_t* loop, ev_op ev) { rc_error(loop != NULL, S_ERROR); @@ -104,21 +142,38 @@ int kqueue_op_handler(evloop_t* loop, ev_op ev) base->ev = ev; return S_SUCCESS; } - int kqueue_op_alloc_evoper(evloop_t* loop, evoper_t* oper) { + rc_error(loop != NULL, S_ERROR); + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); rc_error(oper != NULL, S_ERROR); - kqueue_event_t* obj = (kqueue_event_t*)heap_calloc(1, sizeof(kqueue_event_t)); - rc_error(obj != NULL, S_ERROR); - evoper_bind_private(oper, obj); - return S_SUCCESS; + kqueue_event_t* ptr = (kqueue_event_t*)loop->mm_malloc(loop, 1, sizeof(kqueue_event_t)); + rc_error(ptr != NULL, S_ERROR); + evoper_bind_private(oper, ptr); + + evoper_op_init(oper); + + set_kevent_op(ptr, ev_base_event); + set_kevent_ctl(ptr, kevent_add_op); + + return kqueue_op_ctl(base, oper, ptr, NULL); } int kqueue_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) { rc_error(oper != NULL, S_ERROR); - if (evoper_private(oper) != NULL) - heap_free(evoper_private(oper)); + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); + rc_error(oper != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + set_kevent_op(ptr, ev_base_event); + set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); + + kqueue_op_ctl(base, oper, ptr, NULL); + + loop->mm_free(loop, evoper_private(oper)); return S_SUCCESS; } @@ -162,12 +217,31 @@ int kqueue_op_poll(evloop_t* loop, evoper_t* oper) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - return S_SUCCESS; + kqueue_event_t* ptr = (kqueue_event_t*)heap_calloc(1, sizeof(kqueue_event_t)); + rc_error(ptr != NULL, S_ERROR); + + set_kevent_op(ptr, ev_poll_event| ev_base_event); + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + + return kqueue_op_ctl(base, oper, ptr, NULL); } int kqueue_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { + int rc = S_SUCCESS; + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); + kqueue_event_t* ptr = (kqueue_event_t*)heap_calloc(1, sizeof(kqueue_event_t)); + rc_error(ptr != NULL, S_ERROR);; + + rc = evoper_sock_connect(oper, addr); + + if (rc == S_PENDING) { + set_kevent_op(ptr, ev_conn_event | ev_base_event); + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + kqueue_op_ctl(base, oper, ptr, NULL); + } + return S_SUCCESS; } int kqueue_op_del_connect(evloop_t* loop, evoper_t* oper) @@ -176,8 +250,36 @@ int kqueue_op_del_connect(evloop_t* loop, evoper_t* oper) rc_error(base != NULL, S_ERROR); return S_SUCCESS; } + int kqueue_event_complete(evloop_t* loop, crterr err, kqueue_op_t* base, evoper_t* oper, short ev) { + int rc = S_ERROR; + rc_error(oper != NULL, S_ERROR); + + if (oper->accept == op_ev_accepting && (ev == op_ev_readed)) { + rc = complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); + return rc; + } + + if (oper->conn == op_ev_connecting && (ev == op_ev_writed)) { + rc = complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); + return rc; + } + + if (ev & op_ev_closed) { + rc = complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + return rc; + } + + if (ev & op_ev_readed) { + oper->bt = ev_io_complete; + rc = complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); + } + + if (ev & op_ev_writed) { + rc = complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); + } + return S_SUCCESS; } static int kqueue_op_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) @@ -190,60 +292,33 @@ static int kqueue_op_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) nfds = base->sys_kevent(base->kqfd, NULL, 0, base->poll, base->size, &timeout); + crterr err = crt_geterror(); + int i = 0; for (i = 0; i < nfds; i++) { - evoper_t* oper = NULL; - struct kevent* ev = NULL; - ev = &base->poll[i]; - oper = ev->udata; - - - oper->eof = ((ev->flags & EV_EOF)!= 0)? ev_on : ev_off; - oper->err = ev->flags & EV_ERROR; - - if(ev->filter == EVFILT_PROC) { - - } + short ev = 0; - if(ev->filter == EVFILT_VNODE) { - - } + evoper_t* oper =base->poll[i].udata; - if (ev->filter == EV_OOBAND) { - + if ((base->poll[i].flags & EV_EOF)!= 0) { + ev |= op_ev_closed; } - if (ev->filter == EVFILT_WRITE) { - + if ((base->poll[i].flags & EV_ERROR)!= 0) { + ev |= op_ev_closed; } - if (ev->filter == EVFILT_SIGNAL) { + if(base->poll[i].filter == EVFILT_READ) { + ev |= op_ev_readed; + } else if (base->poll[i].filter == EVFILT_WRITE) { + ev |= op_ev_writed; } - if (ev->filter == EVFILT_USER) { - - } + rc_error_continue(ev != 0) - - - /* - int close = (base->poll[i].filter == EVFILT_READ || base->poll[i].filter == EVFILT_WRITE); - - if ((base->poll[i].flags & EV_EOF) && close) - //kevent_close_handler(&base->poll[i]); - else if (base->poll[i].flags & EV_ERROR) - //kevent_error_handler(&base->poll[i]); - else if (base->poll[i].filter == EVFILT_READ) - //kevent_read_handler(&base->poll[i]); - else if (base->poll[i].filter == EVFILT_WRITE) - //kevent_write_handler(&base->poll[i]); - else if (base->poll[i].filter == EVFILT_SIGNAL) - //kevent_signal_handler(&base->poll[i]); - else if (base->poll[i].filter == EVFILT_TIMER) - //kevent_time_handler(&base->poll[i]); - */ + kqueue_event_complete(loop, err, base, oper, ev); } return S_SUCCESS; diff --git a/stdcrt/event/compat_event_kqueue.h b/stdcrt/event/compat_event_kqueue.h index 074e1646..16dece5f 100644 --- a/stdcrt/event/compat_event_kqueue.h +++ b/stdcrt/event/compat_event_kqueue.h @@ -15,10 +15,8 @@ typedef struct kqueue_op_s kqueue_op_t; typedef struct kevent_s kqueue_event_t; struct kevent_s { - int reg; - int16_t filter; - evevent ctl; - uint32_t op; + uint32_t ctl; + int16_t op; }; typedef int (*kqueue_fn)(void); diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index b8f65c14..9562f606 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -68,10 +68,11 @@ int posix_tcpsock_recv(evoper_t* oper, int flags) int err = 0; n = recv(oper->fd, ptr, len, flags); err = (n == -1) ? errno : 0; - if (n > 0) { evbuf_op_off(&oper->rbuf, n); if (is_evbuf_compelete(&oper->rbuf) == S_SUCCESS) { + n = recv(oper->fd, ptr, len, MSG_PEEK); + logi("msg_peek %d\n", n); rc = S_COMPLETED; goto end; } diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index da1024c0..f6351e42 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -158,6 +158,27 @@ int evoper_bind_private(evoper_t* oper, void* obj) oper->private = obj; return S_SUCCESS; } +int evoper_op_init(evoper_t* oper) +{ + rc_error(oper != NULL, S_ERROR); + + oper->read = op_ev_read; + oper->write = op_ev_write; + oper->accept = op_ev_accept; + oper->open = op_ev_open; + oper->conn = op_ev_connect; + oper->close = op_ev_close; + + oper->oneshot = ev_off; + oper->eof = ev_off; + oper->post = ev_off; + oper->err = ev_off; + oper->vnode = ev_off; + oper->pending_eof = ev_off; + oper->s = ev_off; + + return S_SUCCESS; +} int evoper_state_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); @@ -170,6 +191,11 @@ int evoper_connect_op(evoper_t* oper, evevent op) oper->conn = op; return S_SUCCESS; } +int evoper_connected(evoper_t* oper) +{ + rc_error(oper != NULL, S_ERROR); + return oper->conn == op_ev_connected ? S_SUCCESS : S_ERROR; +} int evoper_accept_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); @@ -188,23 +214,47 @@ int evoper_read_op(evoper_t* oper, evevent op) oper->read = op; return S_SUCCESS; } +int evoper_reading(evoper_t* oper) +{ + rc_error(oper != NULL, S_ERROR); + return oper->read == op_ev_reading ? S_SUCCESS : S_ERROR; +} int evoper_write_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); oper->write = op; return S_SUCCESS; } +int evoper_writeing(evoper_t* oper) +{ + rc_error(oper != NULL, S_ERROR); + return oper->write == op_ev_writeing ? S_SUCCESS : S_ERROR; +} +int evoper_closeing(evoper_t* oper) +{ + rc_error(oper != NULL, S_ERROR); + + if (oper->close >= op_ev_closeing && oper->close <= op_ev_closed) + return S_SUCCESS; + + return S_ERROR; +} +int evoper_close_op(evoper_t* oper, evevent op) +{ + rc_error(oper != NULL, S_ERROR); + oper->close = op; + return S_SUCCESS; +} int evoper_post_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); oper->post = op; return S_SUCCESS; } -int evoper_ready_op(evoper_t* oper, evevent op) +int evoper_eofing(evoper_t* oper) { rc_error(oper != NULL, S_ERROR); - oper->ready = op; - return S_SUCCESS; + return oper->eof == ev_on ? S_SUCCESS : S_ERROR; } int evoper_eof_op(evoper_t* oper, evevent op) { @@ -212,10 +262,16 @@ int evoper_eof_op(evoper_t* oper, evevent op) oper->eof = op; return S_SUCCESS; } -int evoper_close_op(evoper_t* oper, evevent op) + +int evoper_erring(evoper_t* oper) { rc_error(oper != NULL, S_ERROR); - oper->close = op; + return oper->err == ev_on ? S_SUCCESS : S_ERROR; +} +int evoper_err_op(evoper_t* oper, evevent op) +{ + rc_error(oper != NULL, S_ERROR); + oper->err = op; return S_SUCCESS; } int evoper_assign_sock(evoper_t* oper, _sock_t sock) @@ -260,7 +316,8 @@ int complete_sock_accept(evloop_t* loop, int err, crterr code, evoper_t* oper, e #if (TARGET_OS == OS_WIN) //oper->bind = 1; - func(err == 0 ? S_SUCCESS : S_ERROR, err, oper, oper_t, op_ev_accepting); + evoper_connect_op(oper_t, op_ev_connected); + func(err == 0 ? S_SUCCESS : S_ERROR, err, oper, oper_t, op_ev_accept); #else evoper_ls ls = oper->ls; @@ -277,7 +334,13 @@ int complete_sock_accept(evloop_t* loop, int err, crterr code, evoper_t* oper, e rc_error_break(oper_s != NULL); evoper_assign_sock(oper_s, accept_sock); - func(S_SUCCESS, err, oper, oper_s, op_ev_accepting); + + evloop_alloc_evoper(loop, oper_s); + + // oper_s connected + evoper_connect_op(oper_s, op_ev_connected); + + func(S_SUCCESS, err, oper, oper_s, op_ev_accept); } #endif return S_SUCCESS; @@ -287,7 +350,7 @@ int complete_sock_connect(evloop_t* loop, int err, crterr code, evoper_t* oper, rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - func(err, code, oper, NULL, op_ev_connecting); + func(err, code, oper, NULL, op_ev_connect); evoper_connect_op(oper, op_ev_connected); return S_SUCCESS; } @@ -296,7 +359,7 @@ int complete_sock_close(evloop_t* loop, int err, crterr code, evoper_t* oper, ev rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - func(err, code, oper, NULL, op_ev_closeing); + func(err, code, oper, NULL, op_ev_close); evoper_state_op(oper, op_ev_closed); return S_SUCCESS; } @@ -316,7 +379,7 @@ int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_ #endif - func(err, code, oper, NULL, op_ev_reading); + func(err, code, oper, NULL, op_ev_read); evoper_read_op(oper, op_ev_readed); return S_SUCCESS; } @@ -325,7 +388,7 @@ int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - func(err, code, oper, NULL, op_ev_writeing); + func(err, code, oper, NULL, op_ev_write); evoper_write_op(oper, op_ev_writed); return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 3a7882de..974384c6 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -24,51 +24,17 @@ #define ev_use_eventport_event 0x00000100 #define ev_use_vnode_event 0x00000200 -#define ev_close_event 1 -#define ev_disable_event 2 #define ev_flush_event 4 #define ev_lowat_event 0 #define ev_vnode_event 0 -#if (TARGET_OS == OS_MACH) - - -#define ev_conn_event 0 -#define ev_read_event EVFILT_READ -#define ev_write_event EVFILT_WRITE - -#undef ev_vnode_event -#define ev_vnode_event EVFILT_VNODE - -/* - * NGX_CLOSE_EVENT, NGX_LOWAT_EVENT, and NGX_FLUSH_EVENT are the module flags - * and they must not go into a kernel so we need to choose the value - * that must not interfere with any existent and future kqueue flags. - * kqueue has such values - EV_FLAG1, EV_EOF, and EV_ERROR: - * they are reserved and cleared on a kernel entrance. - */ - -#undef ev_close_event -#define ev_close_event EV_EOF - -#undef ev_lowat_event -#define ev_lowat_event EV_FLAG1 +#define ev_io_complete 1 +#define ev_func_complete 2 -#undef ev_flush_event -#define ev_flush_event EV_ERROR - -#define ev_level_event 0 - -#define ev_oneshot_event EV_ONESHOT -#define ev_clear_event EV_CLEAR - -#undef ev_disable_event -#define ev_disable_event EV_DISABLE +#if (TARGET_OS == OS_MACH) #elif (TARGET_OS == OS_POSIX) - //linux 2.6.17 - #elif (TARGET_OS == OS_WIN) #define ev_conn_event 0 @@ -107,37 +73,6 @@ typedef _queue_t evloop_queue_t; typedef _queue_t evoper_queue; typedef unsigned int evoper_ls; - -/* - * An active default event. The event type depends on interface: - * edge-triggered for kqueue, and modern epoll; - * level-triggered for old epoll, devpoll, pollset, poll, and select; - * oneshot for kqueue and eventport. - */ -#define op_ev_default 0x00 - -/* A completely inactive event. */ -#define op_ev_inactive 0x02 -/* - * An event presents in the kernel but disabled after oneshot. - * Used by epoll. - */ -#define op_ev_disable 0x03 -/* - * An event is active in the kernel but blocked by application. - * Used by kqueue, epoll, eventport, devpoll, and pollset. - */ -#define op_ev_blocked 0x04 -/* - * An active oneshot event. - * Used by epoll, devpoll, pollset, poll, and select. - */ -#define op_ev_oneshot 0x05 -/* An active level-triggered event. Used by eventport. */ -#define op_ev_level 0x06 - -#define op_ev_active 0xf0 - #define op_ev_reading 0x01 #define op_ev_readed 0x02 @@ -167,18 +102,10 @@ typedef unsigned int evoper_ls; #define ev_off 0x01 #endif // !ev_off -#ifndef ev_none -#define ev_none 0x00 -#endif // !ev_on - #ifndef ev_bind #define ev_bind 0x10 #endif // !ev_bind -#ifndef ev_eof -#define ev_eof 0x20 -#endif // !ev_eof - struct evbuf_s { buf_ptr ptr; buf_len len; @@ -192,6 +119,7 @@ struct evoper_s { void* private; evevent open; + evevent conn; evevent read; evbuf_t rbuf; @@ -199,21 +127,18 @@ struct evoper_s { evevent write; evbuf_t wbuf; - evevent conn; - evevent accept; evoper_ls ls; + evevent close; + evevent oneshot; evevent eof; evevent post; - evevent close; evevent err; evevent vnode; // kqueue_vnode; evevent pending_eof; // kqueue_vnode; - - evevent ready; // eventing evevent s; // enable,disable,close union { @@ -228,6 +153,8 @@ struct evoper_s { crterr code; evoper_queue queue; + + int bt; }; typedef int (*ev_op)(int err, crterr code, evoper_t* oper, evoper_t* accepet_oper, evevent op); @@ -303,16 +230,24 @@ void* evoper_evbase(evoper_t* oper); void* evoper_private(evoper_t* oper); int evoper_bind_private(evoper_t* oper, void* obj); +int evoper_op_init(evoper_t* oper); int evoper_state_op(evoper_t* oper, evevent op); int evoper_connect_op(evoper_t* oper, evevent op); +int evoper_connected(evoper_t* oper); int evoper_accept_op(evoper_t* oper, evevent op); int evoper_listen_size(evoper_t* oper, evoper_ls ls); int evoper_read_op(evoper_t* oper, evevent op); +int evoper_reading(evoper_t* oper); int evoper_write_op(evoper_t* oper, evevent op); +int evoper_writeing(evoper_t* oper); +int evoper_closeing(evoper_t* oper); +int evoper_close_op(evoper_t* oper, evevent op); + int evoper_post_op(evoper_t* oper, evevent op); -int evoper_ready_op(evoper_t* oper, evevent op); +int evoper_eofing(evoper_t* oper); int evoper_eof_op(evoper_t* oper, evevent op); -int evoper_close_op(evoper_t* oper, evevent op); +int evoper_erring(evoper_t* oper); +int evoper_err_op(evoper_t* oper, evevent op); int evoper_assign_sock(evoper_t* oper, _sock_t sock); int evoper_sock_connect(evoper_t* oper, const evaddr_t* addr); diff --git a/stdcrt/event/epoll4.png b/stdcrt/event/epoll4.png new file mode 100644 index 0000000000000000000000000000000000000000..e12984d517dfb77b0d8f85db8df03d8dae617930 GIT binary patch literal 226740 zcmeFYWmH^2v?kiPyIXK~YaD{RL*wqyK!OF=KyY^w+?&Q5ch?ZCaS|*94F*eT{-2S^DF4hw`Dg5Z6AVmrENnDX zWE7nLc)^4afQ*cc0zg7RMnOYC#l|5*Lr29x!2}>7W08`PlTZ*5Q({vA17M6StW3;o zV(fyV;u7*8v!G6D4iN>DcY!(i1sz@RwRIt3Bh$PMeFH-~dxxoiis}Ay(Eps)e~pZc zf{KKOfsTpw@39ime~kN2kWf$os3@ptc>l~q1)vcTqmz&_GLbP0Vz3CwlM5^8V=CHF zh#0(O6}9(?%1|;ia`cUkDJx&zyZ*Zg!2LHZWFizIfE?g_G*$e7@*q`wLgH}pFMxve zFQ6z-Zng9Vew;=BWSRHkW%(BXikT3)dOJz$K>KzE*7HdFPG8jhXv68jZs0FqL95;| zh~Jcn0u}FLYrI>FaBl&>fI7MC{DA12S(zQ)KD z$|p+Tj4#rhl(=aB3ut$!Pnf^$x6U%|rf-8(a&2@ONp;%)M$t6bRNsaHxWl^$?&vzV zv5S|JrOJ|rM@_3uINzxw_H>(uS;1pX$YoS_yWuXcC{o;nd_46lIwblBO|~cufIY|4 zI`)!5`jAumZ^!HkRX{fjovptBmb6%3!DQadXSfG)2GyE+V!l?FE?xWmBDZa;(QDf& za@r(xlOe88&=?)ZZ>r@d25qhj#gRF~*<*rMCnO|j0@%2;LLTY)vWp{u2~ppbQmtD| zNwL}=q4v(z@!kumzWxEBR}w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MCMd6;pa}3cPlO&Sv)g3VIP?zXz1IcVMqoU?<_Bf;Z3g z9Uk)#ifnpf!4NnkD78YLSCNP`^mJrcGI^|GXe;i`2$O;u*fP-VG`MR=SC{-vN=lT` zM=~CRb(a;v^OTf}y#5a++im#LnVU~%A^<>cj)?LTfEmcMMq0GUBoCwUu4KQ+RUPoS zemg(ep}Dw5W!l9Rbm1=9MnI_4xZLa+K6Tr1WskcH_Qh7ay{%E@ZBkdt!bUtsHey*m z=32ydp&kg6QU)FnqXtSB>$WrP1wF-X0eB1}^JJ_D{X4SfNYHbl6Hqi6PgHRsN8ZeP z5|2k70RBCSS^&WCjV|C3G^dD&F0~v)q6StaticLibrary Unicode true + v141_xp StaticLibrary diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index e75cf67e..e30ff8f0 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -5,55 +5,33 @@ // #pragma comment(lib, "shell32.lib") // #pragma comment(linker, "/ENTRY:main") -evloop_t* loop; -_cond_t cond; -_mutex_t mutex; -void thread_proc1(void* ctx) -{ - sleep_time(7); - test_conn_oper(loop); - _cond_broadcast(&cond); - sleep_time(1); - while (1) { - test_write_oper(loop); - } -} -void thread_proc2(void* ctx) -{ - _cond_wait(&cond, &mutex); - test_write_oper(loop); - while (1) { - //sleep_time(1); - test_read_oper(loop); - } -} int main(int argc, char* argv[]) { init_sockenv(2, 2); int rc = 0; + logi("test_main"); - _cond_init(&cond); - _mutex_init(&mutex); - - - evloop_alloc(&loop, NULL, loop_alloc); - evloop_init(loop, 1024, 0); - evloop_bind_memory(loop, loop_mem_alloc, loop_mem_free, NULL); - test_init_evaddr(); - test_accept_oper(loop); - + test_init_evaddr(); + _thread_t thread1; rc = _thread_create(&thread1, thread_proc1, NULL); + rc_error(rc == S_SUCCESS, S_ERROR); _thread_t thread2; rc = _thread_create(&thread2, thread_proc2, NULL); + rc_error(rc == S_SUCCESS, S_ERROR); + _thread_t thread3; + rc = _thread_create(&thread3, thread_proc3, NULL); rc_error(rc == S_SUCCESS, S_ERROR); - evloop_run(loop, 50000); + + + test_oper_run(); + uninit_sockenv(2, 2); return 0; } diff --git a/stdcrt_test/test.h b/stdcrt_test/test.h index 730575ba..a0fd630c 100644 --- a/stdcrt_test/test.h +++ b/stdcrt_test/test.h @@ -28,12 +28,15 @@ int loop_free(void* ctx, void* ptr); void* oper_alloc(void* ctx, size_t size); int oper_free(void* ctx, void* ptr); +void test_oper_run(); +void thread_proc1(void* ctx); +void thread_proc2(void* ctx); +void thread_proc3(void* ctx); void test_init_evaddr(); void test_timer(evloop_t* loop); void test_conn_oper(evloop_t* loop); void test_accept_oper(evloop_t* loop); -void thread_proc2(void* ctx); void test_write_oper(evloop_t* loop); diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index 0fc66f79..106b7bc9 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -1,53 +1,109 @@ #include #include "test.h" -evoper_t* oper; -evoper_t* accept_oper; -evoper_t* new_oper; +evloop_t* loop; evaddr_t addr; -evloop_t* loop_ex; +evoper_t* w_oper; +evoper_t* r_oper; +evoper_t* accept_oper; + +#define buf_len 5 + +unsigned char* send_data; +unsigned char* recv_data; -char* send_data; -char* recv_data; -#define test_len 1 int iread = 0; int iwrite = 0; +_cond_t w_cond; +_mutex_t w_mutex; + +_cond_t r_cond; +_mutex_t r_mutex; + +void thread_proc1(void* ctx) +{ + sleep_time(7); + + test_conn_oper(loop); + + while (1) { + sleep_time(1000); + } +} +void thread_proc2(void* ctx) +{ + _cond_wait(&r_cond, &r_mutex); + test_read_oper(loop); + while (1) { + sleep_time(10); + } + +} + +void thread_proc3(void* ctx) +{ + _cond_wait(&w_cond, &w_mutex); + while (1) { + logi("write_oper"); + sleep_time(15); + test_write_oper(loop); + } +} + void test_init_evaddr() { + _cond_init(&r_cond); + _mutex_init(&r_mutex); + + _cond_init(&w_cond); + _mutex_init(&w_mutex); + + evloop_alloc(&loop, NULL, loop_alloc); + evloop_init(loop, 1024, 0); + evloop_bind_memory(loop, loop_mem_alloc, loop_mem_free, NULL); + const char* ip = "127.0.0.1"; addr.ptr = ip; addr.len = s_strlen("127.0.0.1"); - addr.port = 9000; + _pid_t aa = get_processid(); + aa += 1000; + addr.port = aa % SHRT_MAX; + send_data = heap_malloc(4096); recv_data = heap_malloc(4096); s_memset(send_data, 0x00, 4096); s_memset(recv_data, 0x00, 4096); + + evoper_alloc(&w_oper, NULL, oper_alloc); + evoper_alloc(&accept_oper, NULL, oper_alloc); + + + test_accept_oper(loop); +} + +void test_oper_run() +{ + int rc = S_SUCCESS; + rc = evloop_run(loop, -1); } + int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) { if (event == op_ev_connect && res == op_ev_success) { - logi("open_connect"); - - _sock_t s; - evoper_get_sock(oper_s, &s); - set_sendbuflen(s, test_len); - + logi("open_connect"); + _cond_broadcast(&w_cond); } else if (event == op_ev_accept && res == op_ev_success) { - logi("accept_connect"); - new_oper = oper_s; - _sock_t s; - evoper_get_sock(new_oper, &s); - set_recvbuflen(s, test_len); - + r_oper = oper_s; + _cond_broadcast(&r_cond); } else if (event == op_ev_close && res == op_ev_success) { logi("close_connect"); } else if (event == op_ev_write && res == op_ev_success) { iwrite++; - //logi("write %d\n", iwrite); + logi("write %d\n", iwrite); } else if (event == op_ev_read && res == op_ev_success) { iread++; logi("read %d == %d\n", iread, iwrite); @@ -64,7 +120,6 @@ void bind_loop(evloop_t* loop, evoper_t* oper_oper) void test_accept_oper(evloop_t* loop) { int rc; - evoper_alloc(&accept_oper, NULL, oper_alloc); rc = evoper_pollsock(accept_oper, &addr, 1); if (rc != S_SUCCESS) @@ -76,24 +131,46 @@ void test_accept_oper(evloop_t* loop) void test_conn_oper(evloop_t* loop) { - evoper_alloc(&oper, NULL, oper_alloc); - evoper_sock(oper); - bind_loop(loop, oper); - int rc = evloop_add_connect(oper, &addr, NULL); + evoper_sock(w_oper); + bind_loop(loop, w_oper); + int rc = evloop_add_connect(w_oper, &addr, NULL); } void test_write_oper(evloop_t* loop) { + int rc = 0; s_strncpy(send_data, "hello", 5); - size_t len = s_strlen(send_data); - evoper_write(oper, (buf_ptr)send_data, len); - evloop_add_write(loop, oper, NULL); + + rc = evoper_write(w_oper, (buf_ptr)send_data, buf_len); + if (rc != S_SUCCESS) { + logi("evoper_write"); + } + + rc = evloop_add_write(loop, w_oper, NULL); + + if (rc != S_SUCCESS) { + if (rc != S_PENDING) { + logi("evloop_add_write"); + } + } } void test_read_oper(evloop_t* loop) { - evloop_alloc_evoper(loop, new_oper); - size_t len = s_strlen(send_data); - evoper_read(new_oper, (buf_ptr)recv_data, len); - evoper_bind_handler(new_oper, evop_proc); - evloop_add_read(loop, new_oper, NULL); -} \ No newline at end of file + int rc = 0; + rc = evoper_read(r_oper, (buf_ptr)recv_data, buf_len); + if (rc != S_SUCCESS) { + logi("evoper_read"); + } + + rc = evoper_bind_handler(r_oper, evop_proc); + if (rc != S_SUCCESS) { + logi("evoper_bind_handler"); + } + + rc = evloop_add_read(loop, r_oper, NULL); + if (rc != S_SUCCESS) { + if (rc != S_PENDING) { + logi("evloop_add_read"); + } + } +} -- Gitee From 0f0c186babdd0284bdaa2961cc931c8534b3cc87 Mon Sep 17 00:00:00 2001 From: com Date: Wed, 7 Aug 2024 18:47:37 +0800 Subject: [PATCH 12/34] up --- crt/crt_event.h | 12 +- stdcrt/event/compat_event.c | 8 +- stdcrt/event/compat_event_iocp.c | 362 ++++++++++++++++------------- stdcrt/event/compat_event_iocp.h | 2 + stdcrt/event/compat_event_kqueue.c | 94 ++++---- stdcrt/event/compat_event_util.c | 24 ++ stdcrt/event/compat_event_util.h | 52 +---- stdcrt/event/compat_event_win32.c | 8 +- stdcrt/stdcrt.vcxproj | 2 + stdcrt/stdcrt.vcxproj.filters | 6 + stdcrt_test/test_oper.c | 20 +- 11 files changed, 311 insertions(+), 279 deletions(-) diff --git a/crt/crt_event.h b/crt/crt_event.h index dff6b044..a0323a6d 100644 --- a/crt/crt_event.h +++ b/crt/crt_event.h @@ -84,6 +84,14 @@ struct evaddr_s { #endif // !op_ev_close +#ifndef op_ev_active +#define op_ev_active 0x10 +#endif // !op_ev_active + +#ifndef op_ev_oneshot +#define op_ev_oneshot 0x20 +#endif // !op_ev_oneshot + /////////////////////////////////// #ifndef op_ev_success #define op_ev_success 0x00 @@ -126,8 +134,8 @@ int evloop_bind_mmctx(evloop_t* loop, void* mmctx); int evloop_get_mmctx(evloop_t* loop, void** mmctx); int evloop_add_timer(evloop_t* loop, evoper_t* oper, ev_time_t tv); -int evloop_add_read(evloop_t* loop, evoper_t* oper, ev_time_t tv); -int evloop_add_write(evloop_t* loop, evoper_t* oper, ev_time_t tv); +int evloop_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); +int evloop_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); int evloop_del_read(evloop_t* loop, evoper_t* oper); int evloop_del_write(evloop_t* loop, evoper_t* oper); int evloop_canncel(evloop_t* loop, evoper_t* oper); diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index e2e74313..a014bfa0 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -277,7 +277,7 @@ int evloop_add_timer(evloop_t* loop, evoper_t* oper, ev_time_t tv) evloop_addtime(loop->nodes, oper); return S_SUCCESS; } -int evloop_add_read(evloop_t* loop, evoper_t* oper, ev_time_t tv) +int evloop_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { rc_error(oper != NULL, S_MEMERROR); rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); @@ -289,9 +289,9 @@ int evloop_add_read(evloop_t* loop, evoper_t* oper, ev_time_t tv) rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_read != NULL, S_ERROR); - return evsel->op_add_read(loop, oper, op_ev_read, tv); + return evsel->op_add_read(loop, oper, event, tv); } -int evloop_add_write(evloop_t* loop, evoper_t* oper, ev_time_t tv) +int evloop_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { rc_error(oper != NULL, S_MEMERROR); rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); @@ -303,7 +303,7 @@ int evloop_add_write(evloop_t* loop, evoper_t* oper, ev_time_t tv) rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_write != NULL, S_ERROR); - return evsel->op_add_write(loop, oper, op_ev_write, tv); + return evsel->op_add_write(loop, oper, event, tv); } int evloop_del_read(evloop_t* loop, evoper_t* oper) { diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index 21495880..a29f7941 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -3,6 +3,11 @@ #if (TARGET_OS == OS_WIN) + +int sock_iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err, DWORD bytes); +int sock_iocp_err_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err); + + void _waitsem_threadProc(void* obj) { iocp_op_t* base = NULL; @@ -29,47 +34,6 @@ static void load_library(HMODULE hMod) { FreeLibrary(hMod); } - -static int wsasock_bind_iocp(iocp_op_t* base, wsasock* sk) -{ - rc_error(sk != NULL, S_ERROR); - rc_error(sk->oper != NULL, S_ERROR); - evoper_t* oper = sk->oper; - HANDLE ret = CreateIoCompletionPort((HANDLE)oper->sock, base->hiocp, (ULONG_PTR)&oper->t, 0); - rc_error(ret != NULL, S_ERROR); - return S_SUCCESS; -} - -static lpwsasock wsasock_create(evloop_t* loop) -{ - lpwsasock sk = (lpwsasock)heap_calloc(1, sizeof(wsasock)); - rc_error(sk != NULL, NULL); - - evoper_t* oper = (evoper_t*)loop->mm_malloc(loop, 1, sizeof(evoper_t)); - rc_error(oper != NULL, NULL); - - oper->sock = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, 0, WSA_FLAG_OVERLAPPED); - evoper_bind_type(oper, ev_sock); - - lpevoper_ov obj = (lpevoper_ov)loop->mm_malloc(loop, 1, sizeof(evoper_ov)); - rc_error(obj != NULL, NULL); - - //oper.private save overlapped ptr - evoper_bind_private(oper, obj); - - evoper_op_init(oper); - - obj->ptr = sk; - - s_memset(&obj->overlapped, 0, sizeof(OVERLAPPED)); - set_blocking(oper->sock, 1); - - - sk->oper = oper; - - return sk; -} - static void* get_mswsock_extfunc(SOCKET s, const GUID* which_fn) { void* ptr = NULL; @@ -158,63 +122,6 @@ err: } -static int poll_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, DWORD err, DWORD bytes) -{ - lpwsasock sock = NULL; - int rc = 0; - rc_error(evoper_ov != NULL, S_ERROR); - sock = evoper_ov->ptr; - rc_error(sock->oper != NULL, S_ERROR); - rc_error(base->ev != NULL, S_ERROR); - win32_sock_accpet_ctx(sock->accept_oper, sock->oper); - - return complete_sock_accept(loop, S_SUCCESS, err, sock->accept_oper, sock->oper, base->ev); -} -static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov evoper_ov, DWORD err, DWORD bytes) -{ - evoper_t* oper = NULL; - int rc = 0; - rc_error(evoper_ov != NULL, S_ERROR); - oper = evoper_ov->ptr; - rc_error(oper != NULL, S_ERROR); - - if (oper->conn == op_ev_connecting) { - - int conn_error = S_SUCCESS; - - - //ERROR_INVALID_NETNAME - if (err == ERROR_CONNECTION_REFUSED || - err == ERROR_NETWORK_UNREACHABLE || - err == ERROR_HOST_UNREACHABLE || - err == ERROR_SEM_TIMEOUT) { - conn_error = S_ERROR; - } else { - //https://learn.microsoft.com/zh-cn/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex - win32_sock_connect_ctx(oper); - } - - complete_sock_connect(loop, conn_error, err, oper, base->ev); - - } else if (oper->write == op_ev_writeing) { - base->ev(0, err, oper, NULL, op_ev_writeing); - } else if (oper->read == op_ev_reading) { - base->ev(0, err, oper, NULL, op_ev_writeing); - } - return S_SUCCESS; -} - -static int iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err, DWORD bytes) -{ - rc_error(oper_ov != NULL, S_ERROR) - - if (key == ev_sockpoll) { - poll_handle(loop, base, oper_ov, err, bytes); - } else if (key == ev_sock) { - oper_handle(loop, base, oper_ov, err, bytes); - } - return S_SUCCESS; -} int iocp_op_alloc(evloop_t* loop, int size) { int rc = 0; @@ -244,12 +151,10 @@ int iocp_op_alloc(evloop_t* loop, int size) return evloop_bind_evbase(loop, base); err: - if (base->hiocp != INVALID_HANDLE_VALUE) CloseHandle(base->hiocp); - if (base != NULL) - heap_free(base); + heap_free(base); return S_ERROR; } @@ -269,24 +174,24 @@ int iocp_op_handler(evloop_t* loop, ev_op ev) int iocp_op_alloc_evoper(evloop_t* loop, evoper_t* oper) { iocp_op_t* base = (iocp_op_t*)evloop_evbase(loop); + rc_error(base != NULL, S_ERROR); + HANDLE handle = CreateIoCompletionPort(oper->fd, base->hiocp, oper->t, 0); + rc_error(handle != NULL, S_ERROR); - HANDLE hRet = CreateIoCompletionPort(oper->fd, base->hiocp, oper->t, 0); + evoper_op_init(oper); - if (hRet == NULL) { - crterr err = crt_geterror(); - } - rc_error(hRet != NULL, S_ERROR); - lpevoper_ov obj = (lpevoper_ov)loop->mm_malloc(loop, 1, sizeof(evoper_ov)); rc_error(obj != NULL, S_ERROR); evoper_bind_private(oper, obj); + obj->ptr = oper; - evoper_op_init(oper); + s_memset(&obj->overlapped, 0, sizeof(OVERLAPPED)); return S_SUCCESS; } + int iocp_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) { lpevoper_ov obj = (lpevoper_ov)evoper_private(oper); @@ -299,9 +204,26 @@ int iocp_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) int iocp_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; + + rc_error(oper != NULL, S_ERROR); + iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); + if (oper->t == ev_sock) { - evoper_read_op(oper, op_ev_reading); - rc = win32_sock_read_op(oper); + if (evoper_reading(oper) != S_SUCCESS) { + + if (event == op_ev_active) { + evoper_read_active(oper, ev_on); + } + evoper_read_op(oper, op_ev_reading); + rc = win32_sock_read_op(oper); + if (rc == S_COMPLETED) { + oper->bt = ev_func_complete; + base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); + evoper_read_op(oper, op_ev_readed); + } + } else { + rc = S_PENDING; + } } return rc; } @@ -309,9 +231,15 @@ int iocp_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; if (oper->t == ev_sock) { + if (evoper_writeing(oper) != S_SUCCESS) { - evoper_write_op(oper, op_ev_writeing); - rc = win32_sock_write_op(oper); + if (event == op_ev_active) { + evoper_write_active(oper, ev_on); + } + + evoper_write_op(oper, op_ev_writeing); + rc = win32_sock_write_op(oper); + } } return rc; } @@ -338,13 +266,13 @@ int iocp_op_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) } int iocp_op_poll(evloop_t* loop, evoper_t* oper) { + int rc = S_ERROR; iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); rc_error(oper->t == ev_sockpoll, S_ERROR); - lpwsasock sk = wsasock_create(loop); - rc_error(sk != NULL, S_ERROR); - - rc_error(wsasock_bind_iocp(base, sk) == S_SUCCESS, S_ERROR) + wsasock* sk = NULL; + rc = wsasock_create(loop, base, oper, &sk); + rc_error(rc == S_SUCCESS, S_ERROR); return win32_sock_accept(oper, sk); } @@ -383,59 +311,26 @@ int iocp_op_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) } return S_SUCCESS; } - ovlp->error = err; } if (ovlp == NULL) return S_AGAIN; - - if (err == ERROR_NETNAME_DELETED || /* the socket was closed */ - err == ERROR_OPERATION_ABORTED || /* the operation was canceled */ - err == ERROR_ABANDONED_WAIT_0) { - /* - * the WSA_OPERATION_ABORTED completion notification - * for a file descriptor that was closed - */ - return S_AGAIN; - } - - - // if (HasOverlappedIoCompleted(&ovlp->overlapped) == 0) return S_SUCCESS; - if (SUCCESS == TRUE) { - if (bytes == 0) { - iocp_handle(loop, base, ovlp, key, err, bytes); - } else { - iocp_handle(loop, base, ovlp, key, err, bytes); - } - } else { - - if (ev_sock == key) { - + if (key == ev_sock || key == ev_sockpoll) { if (err == ERROR_NETNAME_DELETED) { - //Operation cancelled. - iocp_handle(loop, base, ovlp, key, err, bytes); - } else if (err == ERROR_PORT_UNREACHABLE) { - //Connection refused - iocp_handle(loop, base, ovlp, key, err, bytes); - } else if (err == WSAEMSGSIZE) { - //Changed the Windows HANDLE - //backend to treat ERROR_MORE_DATA - //as a non-fatal error when returned by GetOverlappedResult - //for a synchronous read. - iocp_handle(loop, base, ovlp, key, err, bytes); - } else if (err == ERROR_OPERATION_ABORTED) { - // cancel; + sock_iocp_err_handle(loop, base, ovlp, key, err); } else { - iocp_handle(loop, base, ovlp, key, err, bytes); - + sock_iocp_handle(loop, base, ovlp, key, err, bytes); } } - + } else { + if (key == ev_sock || key == ev_sockpoll) { + sock_iocp_err_handle(loop, base, ovlp, key, err); + } } return S_SUCCESS; @@ -470,7 +365,6 @@ int iocp_evop_t(evsysop_t* op) { op->op_alloc = iocp_op_alloc; op->op_dealloc = iocp_op_dealloc; - op->op_handler = iocp_op_handler; op->op_alloc_evoper = iocp_op_alloc_evoper; @@ -491,5 +385,159 @@ int iocp_evop_t(evsysop_t* op) return S_SUCCESS; } +int evoper_ov_bind_ptr(evoper_ov* ov, void* ptr) +{ + rc_error(ov != NULL, S_ERROR); + ov->ptr = ptr; + return S_SUCCESS; +} + +int wsasock_create(evloop_t* loop, iocp_op_t* base, evoper_t* oper_s, wsasock** sock) +{ + int rc = S_ERROR; + lpwsasock sk = (lpwsasock)heap_calloc(1, sizeof(wsasock)); + rc_error(sk != NULL, S_ERROR); + + evoper_t* oper = (evoper_t*)loop->mm_malloc(loop, 1, sizeof(evoper_t)); + rc_error(oper != NULL, S_ERROR); + + oper->sock = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, 0, WSA_FLAG_OVERLAPPED); + set_blocking(oper->sock, 1); + + evoper_bind_type(oper, ev_sock); + + rc = evloop_alloc_evoper(loop, oper); + rc_error(rc == S_SUCCESS, S_ERROR); + + sk->oper = oper; + sk->accept_oper = oper_s; + + /* + The current "oper" private stores the evoper_ov pointer + However, currently it is a server OV operation + so changing the private pointer is necessary + */ + lpevoper_ov obj = (lpevoper_ov)evoper_private(oper); + evoper_ov_bind_ptr(obj, sk); + + *sock = sk; + + return S_SUCCESS; +} +static int poll_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) +{ + lpwsasock sock = NULL; + int rc = 0; + rc_error(oper_ov != NULL, S_ERROR); + sock = oper_ov->ptr; + rc_error(sock->oper != NULL, S_ERROR); + rc_error(base->ev != NULL, S_ERROR); + win32_sock_accpet_ctx(sock->accept_oper, sock->oper); + + lpevoper_ov obj = (lpevoper_ov)evoper_private(sock->oper); + evoper_ov_bind_ptr(obj, sock->oper); + + return complete_sock_accept(loop, S_SUCCESS, err, sock->accept_oper, sock->oper, base->ev); +} +static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) +{ + evoper_t* oper = NULL; + int rc = 0; + rc_error(oper_ov != NULL, S_ERROR); + oper = oper_ov->ptr; + rc_error(oper != NULL, S_ERROR); + + if (oper->conn == op_ev_connecting) { + int conn_error = S_SUCCESS; + + // ERROR_INVALID_NETNAME + if (err == ERROR_CONNECTION_REFUSED || err == ERROR_NETWORK_UNREACHABLE || err == ERROR_HOST_UNREACHABLE || err == ERROR_SEM_TIMEOUT) { + conn_error = S_ERROR; + } else { + // https://learn.microsoft.com/zh-cn/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex + win32_sock_connect_ctx(oper); + } + complete_sock_connect(loop, conn_error, err, oper, base->ev); + return S_SUCCESS; + } + + if (bytes == 0) { + // remote close sock + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + return S_SUCCESS; + } + + if (oper->write == op_ev_writeing && bytes) { + oper->bt = ev_io_complete; + base->ev(0, err, oper, NULL, op_ev_write); + evoper_write_op(oper, op_ev_writed); + + if (evoper_write_activeing(oper) == ev_on) + iocp_op_add_write(loop, oper, op_ev_active, NULL); + } + + if (oper->read == op_ev_reading && bytes) { + oper->bt = ev_io_complete; + base->ev(0, err, oper, NULL, op_ev_read); + evoper_read_op(oper, op_ev_readed); + + if (evoper_read_activeing(oper) == ev_on) + iocp_op_add_read(loop, oper, op_ev_active, NULL); + } + return S_SUCCESS; +} +static int sock_iocp_err_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err) +{ + evoper_t* oper = NULL; + int rc = 0; + + if (key == ev_sockpoll) { + lpwsasock sock = NULL; + int rc = 0; + rc_error(oper_ov != NULL, S_ERROR); + sock = oper_ov->ptr; + rc_error(sock->oper != NULL, S_ERROR); + oper = sock->accept_oper; + } else if (key == ev_sock) { + rc_error(oper_ov != NULL, S_ERROR); + oper = oper_ov->ptr; + rc_error(oper != NULL, S_ERROR); + } + + if (err == ERROR_NETNAME_DELETED) { + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + return S_SUCCESS; + } + + if (err == ERROR_NETNAME_DELETED) { + // Operation cancelled. + } else if (err == ERROR_PORT_UNREACHABLE) { + // Connection refused + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + } else if (err == WSAEMSGSIZE) { + // Changed the Windows HANDLE + // backend to treat ERROR_MORE_DATA + // as a non-fatal error when returned by GetOverlappedResult + // for a synchronous read. + } else if (err == ERROR_OPERATION_ABORTED) { + // cancel; + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + } else { + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + } + + return S_SUCCESS; +} +static int sock_iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err, DWORD bytes) +{ + rc_error(oper_ov != NULL, S_ERROR) + if (key == ev_sockpoll) { + poll_handle(loop, base, oper_ov, err, bytes); + } + else if (key == ev_sock) { + oper_handle(loop, base, oper_ov, err, bytes); + } + return S_SUCCESS; +} #endif diff --git a/stdcrt/event/compat_event_iocp.h b/stdcrt/event/compat_event_iocp.h index ce724811..02adec27 100644 --- a/stdcrt/event/compat_event_iocp.h +++ b/stdcrt/event/compat_event_iocp.h @@ -117,6 +117,8 @@ struct iocp_op_s { }; int iocp_evop_t(evsysop_t* op); +int evoper_ov_bind_ptr(evoper_ov* ov, void* ptr); +int wsasock_create(evloop_t* loop, iocp_op_t* base, evoper_t* oper_s, wsasock** sock); #ifdef __cplusplus } diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index c62f6dbf..79eb181c 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -13,10 +13,10 @@ #define ev_oneshot_read_event EV_ONESHOT | EVFILT_READ #define ev_oneshot_write_event EV_ONESHOT | EVFILT_WRITE -#define kevent_add_op (EV_ADD | EV_ERROR) -#define kevent_del_op (EV_DELETE | EV_ERROR) -#define kevent_op_enable (EV_ENABLE | EV_ERROR) -#define kevent_op_disable (EV_DISABLE | EV_ERROR) +#define kevent_add_op (EV_ADD) +#define kevent_del_op (EV_DELETE) +#define kevent_op_enable (EV_ENABLE) +#define kevent_op_disable (EV_DISABLE) static int set_kevent_op(kqueue_event_t* ptr, int16_t op) { @@ -149,6 +149,7 @@ int kqueue_op_alloc_evoper(evloop_t* loop, evoper_t* oper) rc_error(oper != NULL, S_ERROR); kqueue_event_t* ptr = (kqueue_event_t*)loop->mm_malloc(loop, 1, sizeof(kqueue_event_t)); rc_error(ptr != NULL, S_ERROR); + evoper_bind_private(oper, ptr); evoper_op_init(oper); @@ -217,7 +218,8 @@ int kqueue_op_poll(evloop_t* loop, evoper_t* oper) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)heap_calloc(1, sizeof(kqueue_event_t)); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); set_kevent_op(ptr, ev_poll_event| ev_base_event); @@ -228,18 +230,21 @@ int kqueue_op_poll(evloop_t* loop, evoper_t* oper) int kqueue_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { int rc = S_SUCCESS; - + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)heap_calloc(1, sizeof(kqueue_event_t)); - rc_error(ptr != NULL, S_ERROR);; + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + set_kevent_op(ptr, ev_conn_event | ev_base_event); + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + kqueue_op_ctl(base, oper, ptr, NULL); rc = evoper_sock_connect(oper, addr); if (rc == S_PENDING) { - set_kevent_op(ptr, ev_conn_event | ev_base_event); - set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); - kqueue_op_ctl(base, oper, ptr, NULL); + } return S_SUCCESS; @@ -251,37 +256,6 @@ int kqueue_op_del_connect(evloop_t* loop, evoper_t* oper) return S_SUCCESS; } -int kqueue_event_complete(evloop_t* loop, crterr err, kqueue_op_t* base, evoper_t* oper, short ev) -{ - int rc = S_ERROR; - rc_error(oper != NULL, S_ERROR); - - if (oper->accept == op_ev_accepting && (ev == op_ev_readed)) { - rc = complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); - return rc; - } - - if (oper->conn == op_ev_connecting && (ev == op_ev_writed)) { - rc = complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); - return rc; - } - - if (ev & op_ev_closed) { - rc = complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - return rc; - } - - if (ev & op_ev_readed) { - oper->bt = ev_io_complete; - rc = complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); - } - - if (ev & op_ev_writed) { - rc = complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); - } - - return S_SUCCESS; -} static int kqueue_op_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) { struct timespec timeout; @@ -297,29 +271,39 @@ static int kqueue_op_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) int i = 0; for (i = 0; i < nfds; i++) { - short ev = 0; - - evoper_t* oper =base->poll[i].udata; + evoper_t* oper = base->poll[i].udata; if ((base->poll[i].flags & EV_EOF)!= 0) { - ev |= op_ev_closed; + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + continue; } if ((base->poll[i].flags & EV_ERROR)!= 0) { - ev |= op_ev_closed; + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + continue; } if(base->poll[i].filter == EVFILT_READ) { - ev |= op_ev_readed; - - } else if (base->poll[i].filter == EVFILT_WRITE) { - ev |= op_ev_writed; + + if (oper->accept == op_ev_accepting) { + complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); + continue; + } + complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); + continue; } - rc_error_continue(ev != 0) - - kqueue_event_complete(loop, err, base, oper, ev); - + if (base->poll[i].filter == EVFILT_WRITE) { + + if (oper->conn == op_ev_connecting) { + complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); + continue; + } + + complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); + continue; + } + } return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index f6351e42..d957cb7b 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -163,7 +163,9 @@ int evoper_op_init(evoper_t* oper) rc_error(oper != NULL, S_ERROR); oper->read = op_ev_read; + oper->ractive = ev_off; oper->write = op_ev_write; + oper->wactive = ev_off; oper->accept = op_ev_accept; oper->open = op_ev_open; oper->conn = op_ev_connect; @@ -208,6 +210,17 @@ int evoper_listen_size(evoper_t* oper, evoper_ls ls) oper->ls = ls; return S_SUCCESS; } +int evoper_read_active(evoper_t* oper, evevent op) +{ + rc_error(oper != NULL, S_ERROR); + oper->ractive = op; + return S_SUCCESS; +} +int evoper_read_activeing(evoper_t* oper) +{ + rc_error(oper != NULL, S_ERROR); + return oper->ractive == ev_on ? S_SUCCESS : S_ERROR; +} int evoper_read_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); @@ -219,6 +232,17 @@ int evoper_reading(evoper_t* oper) rc_error(oper != NULL, S_ERROR); return oper->read == op_ev_reading ? S_SUCCESS : S_ERROR; } +int evoper_write_active(evoper_t* oper, evevent op) +{ + rc_error(oper != NULL, S_ERROR); + oper->wactive = op; + return S_SUCCESS; +} +int evoper_write_activeing(evoper_t* oper) +{ + rc_error(oper != NULL, S_ERROR); + return oper->wactive == ev_on ? S_SUCCESS : S_ERROR; +} int evoper_write_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 974384c6..43262a92 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -13,51 +13,9 @@ #define ev_maxsec_mesec (((LONG_MAX)-999) / evtime_sec) #endif // !ev_maxsec_mesec -#define ev_use_level_event 0x00000001 -#define ev_use_oneshot_event 0x00000002 -#define ev_use_clear_event 0x00000004 -#define ev_use_kqueue_event 0x00000008 -#define ev_use_epoll_event 0x00000010 -#define ev_use_iocp_event 0x00000020 -#define ev_use_aio_event 0x00000040 -#define ev_use_devpoll_event 0x00000080 -#define ev_use_eventport_event 0x00000100 -#define ev_use_vnode_event 0x00000200 - -#define ev_flush_event 4 -#define ev_lowat_event 0 -#define ev_vnode_event 0 - #define ev_io_complete 1 #define ev_func_complete 2 -#if (TARGET_OS == OS_MACH) - -#elif (TARGET_OS == OS_POSIX) -//linux 2.6.17 -#elif (TARGET_OS == OS_WIN) - -#define ev_conn_event 0 -#define ev_read_event 0 -#define ev_write_event 1 -#define ev_level_event 0 -#define ev_oneshot_event 1 - -#define ev_iocp_accept 0 -#define ev_iocp_io 1 -#define ev_iocp_connect 2 - -#else - -#define ev_conn_event 0 -#define ev_read_event POLLIN -#define ev_write_event POLLOUT - -#define ev_level_event 0 -#define ev_oneshot_event 1 - -#endif - #ifndef op_cmd_poll #define op_cmd_poll 0x01 #endif // !op_cmd_poll @@ -102,10 +60,6 @@ typedef unsigned int evoper_ls; #define ev_off 0x01 #endif // !ev_off -#ifndef ev_bind -#define ev_bind 0x10 -#endif // !ev_bind - struct evbuf_s { buf_ptr ptr; buf_len len; @@ -122,9 +76,11 @@ struct evoper_s { evevent conn; evevent read; + evevent ractive; evbuf_t rbuf; evevent write; + evevent wactive; evbuf_t wbuf; evevent accept; @@ -236,8 +192,12 @@ int evoper_connect_op(evoper_t* oper, evevent op); int evoper_connected(evoper_t* oper); int evoper_accept_op(evoper_t* oper, evevent op); int evoper_listen_size(evoper_t* oper, evoper_ls ls); +int evoper_read_active(evoper_t* oper, evevent op); +int evoper_read_activeing(evoper_t* oper); int evoper_read_op(evoper_t* oper, evevent op); int evoper_reading(evoper_t* oper); +int evoper_write_active(evoper_t* oper, evevent op); +int evoper_write_activeing(evoper_t* oper); int evoper_write_op(evoper_t* oper, evevent op); int evoper_writeing(evoper_t* oper); int evoper_closeing(evoper_t* oper); diff --git a/stdcrt/event/compat_event_win32.c b/stdcrt/event/compat_event_win32.c index def98434..067ac1b0 100644 --- a/stdcrt/event/compat_event_win32.c +++ b/stdcrt/event/compat_event_win32.c @@ -101,11 +101,7 @@ static int win32_sock_connectex(evoper_t* oper, const struct sockaddr* sa, sockl rc = S_COMPLETED; } else if (ret == FALSE && ERROR_IO_PENDING == err) { rc = S_PENDING; - //BOOL ok; - //DWORD numBytes; - //ok = GetOverlappedResult((HANDLE)oper->sock, &ov->overlapped, &numBytes, TRUE); - //err = crt_geterror(); - + } else { rc = S_ERROR; } @@ -345,7 +341,7 @@ int win32_sock_write_op(evoper_t* oper) evbuf_op_off(&oper->wbuf, byte); if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { - rc = WSA_IO_PENDING; + rc = S_PENDING; goto end; } } diff --git a/stdcrt/stdcrt.vcxproj b/stdcrt/stdcrt.vcxproj index 074c6ff0..f11d5b5e 100644 --- a/stdcrt/stdcrt.vcxproj +++ b/stdcrt/stdcrt.vcxproj @@ -144,6 +144,8 @@ + + diff --git a/stdcrt/stdcrt.vcxproj.filters b/stdcrt/stdcrt.vcxproj.filters index 1a60c56a..92dbafe4 100644 --- a/stdcrt/stdcrt.vcxproj.filters +++ b/stdcrt/stdcrt.vcxproj.filters @@ -213,5 +213,11 @@ event + + event + + + event + \ No newline at end of file diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index 106b7bc9..ac75738e 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -23,10 +23,8 @@ _mutex_t r_mutex; void thread_proc1(void* ctx) { - sleep_time(7); - + sleep_time(3); test_conn_oper(loop); - while (1) { sleep_time(1000); } @@ -44,8 +42,9 @@ void thread_proc2(void* ctx) void thread_proc3(void* ctx) { _cond_wait(&w_cond, &w_mutex); + sleep_time(15); + test_write_oper(loop); while (1) { - logi("write_oper"); sleep_time(15); test_write_oper(loop); } @@ -87,7 +86,7 @@ void test_init_evaddr() void test_oper_run() { int rc = S_SUCCESS; - rc = evloop_run(loop, -1); + rc = evloop_run(loop, 5000000); } int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) @@ -122,8 +121,11 @@ void test_accept_oper(evloop_t* loop) int rc; rc = evoper_pollsock(accept_oper, &addr, 1); - if (rc != S_SUCCESS) - logi("evoper_pollsock error"); + if (rc != S_SUCCESS) { + logi("evoper_pollsock error"); + return; + } + bind_loop(loop, accept_oper); evloop_poll(accept_oper, 1); @@ -146,7 +148,7 @@ void test_write_oper(evloop_t* loop) logi("evoper_write"); } - rc = evloop_add_write(loop, w_oper, NULL); + rc = evloop_add_write(loop, w_oper, op_ev_oneshot, NULL); if (rc != S_SUCCESS) { if (rc != S_PENDING) { @@ -167,7 +169,7 @@ void test_read_oper(evloop_t* loop) logi("evoper_bind_handler"); } - rc = evloop_add_read(loop, r_oper, NULL); + rc = evloop_add_read(loop, r_oper, op_ev_active, NULL); if (rc != S_SUCCESS) { if (rc != S_PENDING) { logi("evloop_add_read"); -- Gitee From ea383b11426e4fdc557d9fecb838d713636e6f65 Mon Sep 17 00:00:00 2001 From: com Date: Thu, 8 Aug 2024 18:47:10 +0800 Subject: [PATCH 13/34] up --- crt/crt_event.h | 12 +-- stdcrt/event/compat_event.c | 28 +++---- stdcrt/event/compat_event_epoll.c | 122 ++++++++++++++++++++--------- stdcrt/event/compat_event_epoll.h | 3 +- stdcrt/event/compat_event_iocp.c | 70 ++++++++--------- stdcrt/event/compat_event_kqueue.c | 26 +++--- stdcrt/event/compat_event_util.c | 52 ++++++++++-- stdcrt/event/compat_event_util.h | 24 ++++-- stdcrt_test/test_oper.c | 30 +++++-- 9 files changed, 235 insertions(+), 132 deletions(-) diff --git a/crt/crt_event.h b/crt/crt_event.h index a0323a6d..7c73b94e 100644 --- a/crt/crt_event.h +++ b/crt/crt_event.h @@ -102,8 +102,8 @@ struct evaddr_s { #endif // !op_ev_faild /////////////////////////////////// -int evoper_read(evoper_t* oper, buf_ptr buf, buf_len len); -int evoper_write(evoper_t* oper, buf_ptr buf, buf_len len); +int evoper_read_buf(evoper_t* oper, buf_ptr buf, buf_len len); +int evoper_write_buf(evoper_t* oper, buf_ptr buf, buf_len len); int evoper_set_msec(evoper_t* oper, crt_msec msec); int evoper_get_msec(evoper_t* oper, crt_msec* msec); @@ -134,10 +134,10 @@ int evloop_bind_mmctx(evloop_t* loop, void* mmctx); int evloop_get_mmctx(evloop_t* loop, void** mmctx); int evloop_add_timer(evloop_t* loop, evoper_t* oper, ev_time_t tv); -int evloop_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); -int evloop_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); -int evloop_del_read(evloop_t* loop, evoper_t* oper); -int evloop_del_write(evloop_t* loop, evoper_t* oper); +int evloop_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); +int evloop_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); +int evloop_disable_read(evloop_t* loop, evoper_t* oper); +int evloop_disable_write(evloop_t* loop, evoper_t* oper); int evloop_canncel(evloop_t* loop, evoper_t* oper); int evloop_open(evoper_t* oper, const evaddr_t* addr, ev_time_t tv); int evloop_poll(evoper_t* oper, unsigned int ls); diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index a014bfa0..55eb0507 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -86,12 +86,12 @@ static int evsysop_bind_handler(evloop_t* loop, evsysop_t* op) { return op->op_handler(loop, complete_op); } -int evoper_read(evoper_t* oper, buf_ptr buf, buf_len len) +int evoper_read_buf(evoper_t* oper, buf_ptr buf, buf_len len) { rc_error(oper != NULL, S_ERROR); return evbuf_bind(&oper->rbuf, buf, len, 0); } -int evoper_write(evoper_t* oper, buf_ptr buf, buf_len len) +int evoper_write_buf(evoper_t* oper, buf_ptr buf, buf_len len) { rc_error(oper != NULL, S_ERROR); return evbuf_bind(&oper->wbuf, buf, len, 0); @@ -277,7 +277,7 @@ int evloop_add_timer(evloop_t* loop, evoper_t* oper, ev_time_t tv) evloop_addtime(loop->nodes, oper); return S_SUCCESS; } -int evloop_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int evloop_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { rc_error(oper != NULL, S_MEMERROR); rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); @@ -287,11 +287,11 @@ int evloop_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); - rc_error(evsel->op_add_read != NULL, S_ERROR); + rc_error(evsel->op_enable_read != NULL, S_ERROR); - return evsel->op_add_read(loop, oper, event, tv); + return evsel->op_enable_read(loop, oper, event, tv); } -int evloop_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int evloop_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { rc_error(oper != NULL, S_MEMERROR); rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); @@ -301,11 +301,11 @@ int evloop_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); - rc_error(evsel->op_add_write != NULL, S_ERROR); + rc_error(evsel->op_enable_write != NULL, S_ERROR); - return evsel->op_add_write(loop, oper, event, tv); + return evsel->op_enable_write(loop, oper, event, tv); } -int evloop_del_read(evloop_t* loop, evoper_t* oper) +int evloop_disable_read(evloop_t* loop, evoper_t* oper) { rc_error(oper != NULL, S_MEMERROR); rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); @@ -315,11 +315,11 @@ int evloop_del_read(evloop_t* loop, evoper_t* oper) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); - rc_error(evsel->op_del_read != NULL, S_ERROR); - return evsel->op_del_read(loop, oper, op_ev_read); + rc_error(evsel->op_disable_read != NULL, S_ERROR); + return evsel->op_disable_read(loop, oper, op_ev_read); } -int evloop_del_write(evloop_t* loop, evoper_t* oper) +int evloop_disable_write(evloop_t* loop, evoper_t* oper) { rc_error(oper != NULL, S_MEMERROR); rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); @@ -329,9 +329,9 @@ int evloop_del_write(evloop_t* loop, evoper_t* oper) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); - rc_error(evsel->op_del_write != NULL, S_ERROR); + rc_error(evsel->op_disable_write != NULL, S_ERROR); - return evsel->op_del_write(loop, oper, op_ev_write); + return evsel->op_disable_write(loop, oper, op_ev_write); } int evloop_canncel(evloop_t* loop, evoper_t* oper) { diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index d1ec0d01..b5eb4fa7 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -43,6 +43,8 @@ //EPOLLRDHUP +#define epoll_use 1 + #define ev_base_event (EPOLLET | EPOLLERR) #ifdef EPOLLEXCLUSIVE #define ev_poll_event (EPOLLIN /*| EPOLLEXCLUSIVE*/) @@ -131,27 +133,15 @@ static int sys_hook_api(epoll_op_t* base) static uint32_t epoll_event_add(epoll_event_t* ptr, uint32_t op) { uint32_t event = 0; - - if (ptr->op == ev_base_event) { - event = ptr->op; - event |= op; - } else if (ptr->op == ev_clear_event) { - event |= ev_base_event; - event |= op; - } + event = ptr->op; + event |= op; return event; } static uint32_t epoll_event_del(epoll_event_t* ptr, uint32_t op) { uint32_t event = 0; - - if (ptr->op == ev_base_event) { - event = ptr->op; - event &= ~op; - } else if (ptr->op == ev_clear_event) { - event |= ev_base_event; - event &= ~op; - } + event = ptr->op; + event &= ~op; return event; } static uint32_t get_epoll_op(epoll_event_t* ptr) @@ -175,11 +165,25 @@ static int epoll_op(epoll_op_t* base, evoper_t* oper, epoll_event_t* ptr, int op //ctl_mod --> EPOLLEXCLUSIVE --> 22 sys_epoll_ctl return EINVAL if (base->sys_epoll_ctl(base->epfd, op, oper->fd, &ee) == 0) { - ptr->epoll = ev_on; + + if (ee.events & EPOLLOUT) { + evs_on(&ptr->wepoll); + } else { + evs_off(&ptr->wepoll); + } + + if (ee.events & EPOLLIN) { + evs_on(&ptr->repoll); + } else { + evs_off(&ptr->repoll); + } return S_SUCCESS; } - ptr->epoll = ev_off; + evs_off(&ptr->repoll); + evs_off(&ptr->wepoll); + + //ptr->epoll = ev_off; if (errno == ENOENT) { loge("epoll_ctl error %d, epfd=%d, fd=%d\n", errno, base->epfd, oper->fd); @@ -239,6 +243,8 @@ int epoll_op_alloc(evloop_t* loop, int size) if (base->poll == NULL) goto err; + + return evloop_bind_evbase(loop, base); err: loop->mm_free(loop, base); @@ -275,10 +281,10 @@ int epoll_op_alloc_evoper(evloop_t* loop, evoper_t* oper) uint32_t op = ev_base_event; set_epoll_op(ptr, op); - ptr->epoll = ev_off; + evs_init(&ptr->repoll); + evs_init(&ptr->wepoll); evoper_op_init(oper); - //https://elixir.bootlin.com/linux/v4.19.316/source/fs/eventpoll.c#L2047 return epoll_op(base, oper, ptr, EPOLL_CTL_ADD); } @@ -295,12 +301,14 @@ int epoll_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) set_epoll_op(ptr, ev_clear_event); rc = epoll_op(base, oper, ptr, EPOLL_CTL_DEL); - if (ptr != NULL) - heap_free(ptr); + evs_uninit(&ptr->repoll); + evs_uninit(&ptr->wepoll); + + heap_free(ptr); return rc; } -int epoll_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int epoll_op_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_SUCCESS; rc_error(oper != NULL, S_ERROR); @@ -309,15 +317,33 @@ int epoll_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); + //reading + rc_error(evoper_reading(oper) != S_SUCCESS, S_ERROR); + evoper_read_op(oper, op_ev_reading); + + //activeing + evoper_read_active(oper, ev_off); + if (event == op_ev_active) { + evoper_read_active(oper, ev_on); + } + + //recv rc = posix_tcpsock_recv(oper, 0); + //res if (rc == S_COMPLETED) { oper->bt = ev_func_complete; base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); - + evoper_read_op(oper, op_ev_readed); + } else if (rc == S_PENDING) { + // epoll_ing + if (is_evs_on(&ptr->repoll) == S_SUCCESS) { + return S_SUCCESS; + } + uint32_t op = epoll_event_add(ptr, ev_read_event); set_epoll_op(ptr, op); rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); @@ -329,7 +355,7 @@ int epoll_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) return rc; } -int epoll_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int epoll_op_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_SUCCESS; rc_error(oper != NULL, S_ERROR); @@ -338,24 +364,40 @@ int epoll_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); + //writeing + rc_error(evoper_writeing(oper) != S_SUCCESS, S_ERROR); + evoper_write_op(oper, op_ev_writeing); + + //activeing + evoper_write_active(oper, ev_off); + if (event == op_ev_active) { + evoper_write_active(oper, ev_on); + } + + //send rc = posix_tcpsock_send(oper, 0); + //res if (rc == S_COMPLETED) { - + oper->bt = ev_func_complete; - base->ev(S_SUCCESS, 0, oper, oper, op_ev_writeing); - + base->ev(S_SUCCESS, 0, oper, oper, op_ev_write); + evoper_write_op(oper, op_ev_writed); + } else if (rc == S_PENDING) { - + + //epoll_ing + if (is_evs_on(&ptr->wepoll) == S_SUCCESS) { + return S_SUCCESS; + } + uint32_t op = epoll_event_add(ptr, ev_write_event); set_epoll_op(ptr, op); rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); - } - - return rc; // + return rc; } -int epoll_op_del_read(evloop_t* loop, evoper_t* oper, short event) +int epoll_op_disable_read(evloop_t* loop, evoper_t* oper, short event) { rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); @@ -364,12 +406,14 @@ int epoll_op_del_read(evloop_t* loop, evoper_t* oper, short event) epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); + evoper_read_op(oper, op_ev_read); + uint32_t op = epoll_event_del(ptr, ev_read_event); set_epoll_op(ptr, op); return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } -int epoll_op_del_write(evloop_t* loop, evoper_t* oper, short event) +int epoll_op_disable_write(evloop_t* loop, evoper_t* oper, short event) { rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); @@ -378,6 +422,8 @@ int epoll_op_del_write(evloop_t* loop, evoper_t* oper, short event) epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); + evoper_write_op(oper, op_ev_write); + uint32_t op = epoll_event_del(ptr, ev_read_event); set_epoll_op(ptr, op); @@ -556,10 +602,10 @@ int epoll_evop_t(evsysop_t* op) op->op_alloc_evoper = epoll_op_alloc_evoper; op->op_dealloc_evoper = epoll_op_dealloc_evoper; - op->op_add_read = epoll_op_add_read; - op->op_add_write = epoll_op_add_write; - op->op_del_read = epoll_op_del_read; - op->op_del_write = epoll_op_del_write; + op->op_enable_read = epoll_op_enable_read; + op->op_enable_write = epoll_op_enable_write; + op->op_disable_read = epoll_op_disable_read; + op->op_disable_write = epoll_op_disable_write; op->op_cancel = epoll_op_cancel; op->op_open = epoll_op_open; diff --git a/stdcrt/event/compat_event_epoll.h b/stdcrt/event/compat_event_epoll.h index cd96e201..7ea44f76 100644 --- a/stdcrt/event/compat_event_epoll.h +++ b/stdcrt/event/compat_event_epoll.h @@ -16,7 +16,8 @@ typedef struct epoll_op_s epoll_op_t; struct epoll_event_s { int ctl; uint32_t op; - evevent epoll; + evs_t repoll; + evs_t wepoll; }; typedef int (*epoll_create_fn)(int); diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index a29f7941..ba0fe5b7 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -201,7 +201,7 @@ int iocp_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) return S_SUCCESS; } -int iocp_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int iocp_op_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; @@ -209,46 +209,35 @@ int iocp_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); if (oper->t == ev_sock) { - if (evoper_reading(oper) != S_SUCCESS) { - - if (event == op_ev_active) { - evoper_read_active(oper, ev_on); - } - evoper_read_op(oper, op_ev_reading); - rc = win32_sock_read_op(oper); - if (rc == S_COMPLETED) { - oper->bt = ev_func_complete; - base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); - evoper_read_op(oper, op_ev_readed); - } - } else { - rc = S_PENDING; + rc_error(evoper_reading(oper) != S_SUCCESS, S_PENDING); + evoper_read_active(oper, event == op_ev_active ? ev_on : ev_off); + evoper_read_op(oper, op_ev_reading); + rc = win32_sock_read_op(oper); + if (rc == S_COMPLETED) { + oper->bt = ev_func_complete; + base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); + evoper_read_op(oper, op_ev_readed); } } return rc; } -int iocp_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int iocp_op_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; if (oper->t == ev_sock) { - if (evoper_writeing(oper) != S_SUCCESS) { - - if (event == op_ev_active) { - evoper_write_active(oper, ev_on); - } - - evoper_write_op(oper, op_ev_writeing); - rc = win32_sock_write_op(oper); - } + rc_error(evoper_writeing(oper) != S_SUCCESS, S_PENDING); + evoper_write_active(oper, event == op_ev_active ? ev_on : ev_off); + evoper_write_op(oper, op_ev_writeing); + rc = win32_sock_write_op(oper); } return rc; } -int iocp_op_del_read(evloop_t* loop, evoper_t* oper, short event) +int iocp_op_disable_read(evloop_t* loop, evoper_t* oper, short event) { iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); return S_SUCCESS; } -int iocp_op_del_write(evloop_t* loop, evoper_t* oper, short event) +int iocp_op_disable_write(evloop_t* loop, evoper_t* oper, short event) { iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); return S_SUCCESS; @@ -370,10 +359,10 @@ int iocp_evop_t(evsysop_t* op) op->op_alloc_evoper = iocp_op_alloc_evoper; op->op_dealloc_evoper = iocp_op_dealloc_evoper; - op->op_add_read = iocp_op_add_read; - op->op_add_write = iocp_op_add_write; - op->op_del_read = iocp_op_del_read; - op->op_del_write = iocp_op_del_write; + op->op_enable_read = iocp_op_enable_read; + op->op_enable_write = iocp_op_enable_write; + op->op_disable_read = iocp_op_disable_read; + op->op_disable_write = iocp_op_disable_write; op->op_cancel = iocp_op_cancel; op->op_open = iocp_op_open; @@ -467,23 +456,26 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWO return S_SUCCESS; } + if (oper->read == op_ev_reading && bytes) { + oper->bt = ev_io_complete; + base->ev(0, err, oper, NULL, op_ev_read); + evoper_read_op(oper, op_ev_readed); + + if (evoper_read_activeing(oper) == ev_on) + iocp_op_enable_read(loop, oper, op_ev_active, NULL); + } + + if (oper->write == op_ev_writeing && bytes) { oper->bt = ev_io_complete; base->ev(0, err, oper, NULL, op_ev_write); evoper_write_op(oper, op_ev_writed); if (evoper_write_activeing(oper) == ev_on) - iocp_op_add_write(loop, oper, op_ev_active, NULL); + iocp_op_enable_write(loop, oper, op_ev_active, NULL); } - if (oper->read == op_ev_reading && bytes) { - oper->bt = ev_io_complete; - base->ev(0, err, oper, NULL, op_ev_read); - evoper_read_op(oper, op_ev_readed); - if (evoper_read_activeing(oper) == ev_on) - iocp_op_add_read(loop, oper, op_ev_active, NULL); - } return S_SUCCESS; } static int sock_iocp_err_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err) diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 79eb181c..30d59101 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -13,10 +13,10 @@ #define ev_oneshot_read_event EV_ONESHOT | EVFILT_READ #define ev_oneshot_write_event EV_ONESHOT | EVFILT_WRITE -#define kevent_add_op (EV_ADD) -#define kevent_del_op (EV_DELETE) -#define kevent_op_enable (EV_ENABLE) -#define kevent_op_disable (EV_DISABLE) +#define kevent_add_op (EV_ADD | EV_ERROR) +#define kevent_del_op (EV_DELETE | EV_ERROR) +#define kevent_op_enable (EV_ENABLE | EV_ERROR) +#define kevent_op_disable (EV_DISABLE| EV_ERROR) static int set_kevent_op(kqueue_event_t* ptr, int16_t op) { @@ -223,7 +223,7 @@ int kqueue_op_poll(evloop_t* loop, evoper_t* oper) rc_error(ptr != NULL, S_ERROR); set_kevent_op(ptr, ev_poll_event| ev_base_event); - set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + set_kevent_ctl(ptr, kevent_op_enable); return kqueue_op_ctl(base, oper, ptr, NULL); } @@ -237,14 +237,12 @@ int kqueue_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - set_kevent_op(ptr, ev_conn_event | ev_base_event); - set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); - kqueue_op_ctl(base, oper, ptr, NULL); - rc = evoper_sock_connect(oper, addr); if (rc == S_PENDING) { - + set_kevent_op(ptr, ev_conn_event | ev_base_event); + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + kqueue_op_ctl(base, oper, ptr, NULL); } return S_SUCCESS; @@ -340,10 +338,10 @@ int kqueue_evop_t(evsysop_t* op) op->op_alloc_evoper = kqueue_op_alloc_evoper; op->op_dealloc_evoper = kqueue_op_dealloc_evoper; - op->op_add_read = kqueue_op_add_read; - op->op_add_write = kqueue_op_add_write; - op->op_del_read = kqueue_op_del_read; - op->op_del_write = kqueue_op_del_write; + op->op_enable_read = kqueue_op_add_read; + op->op_enable_write = kqueue_op_add_write; + op->op_disable_read = kqueue_op_del_read; + op->op_disable_write = kqueue_op_del_write; op->op_cancel = kqueue_op_cancel; op->op_open = kqueue_op_open; diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index d957cb7b..5e69cfdc 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -221,27 +221,27 @@ int evoper_read_activeing(evoper_t* oper) rc_error(oper != NULL, S_ERROR); return oper->ractive == ev_on ? S_SUCCESS : S_ERROR; } -int evoper_read_op(evoper_t* oper, evevent op) +int evoper_write_active(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); - oper->read = op; + oper->wactive = op; return S_SUCCESS; } -int evoper_reading(evoper_t* oper) +int evoper_write_activeing(evoper_t* oper) { rc_error(oper != NULL, S_ERROR); - return oper->read == op_ev_reading ? S_SUCCESS : S_ERROR; + return oper->wactive == ev_on ? S_SUCCESS : S_ERROR; } -int evoper_write_active(evoper_t* oper, evevent op) +int evoper_read_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); - oper->wactive = op; + oper->read = op; return S_SUCCESS; } -int evoper_write_activeing(evoper_t* oper) +int evoper_reading(evoper_t* oper) { rc_error(oper != NULL, S_ERROR); - return oper->wactive == ev_on ? S_SUCCESS : S_ERROR; + return oper->read == op_ev_reading ? S_SUCCESS : S_ERROR; } int evoper_write_op(evoper_t* oper, evevent op) { @@ -468,3 +468,39 @@ int is_evbuf_compelete(evbuf_t* buf) rc_error(buf != NULL, S_ERROR); return buf->off == buf->len ? S_SUCCESS : S_ERROR; } +int evs_init(evs_t* on) +{ + rc_error(on != NULL, S_ERROR); + _atomic_init(&on->v); + return S_SUCCESS; +} +int evs_uninit(evs_t* on) +{ + rc_error(on != NULL, S_ERROR); + _atomic_uninit(&on->v); + return S_SUCCESS; +} +int evs_on(evs_t* on) +{ + rc_error(on != NULL, S_ERROR); + _atomic_add(&on->v); + return S_SUCCESS; +} +int evs_off(evs_t* on) +{ + rc_error(on != NULL, S_ERROR); + _atomic_init(&on->v); + return S_SUCCESS; +} +int is_evs_on(evs_t* on) +{ + rc_error(on != NULL, S_ERROR); + if (_atomic_cmp(1, &on->v)) { + return S_SUCCESS; + } + return S_ERROR; +} + + + + diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 43262a92..9e021f23 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -30,6 +30,7 @@ typedef struct evbuf_s evbuf_t; typedef _queue_t evloop_queue_t; typedef _queue_t evoper_queue; typedef unsigned int evoper_ls; +typedef struct evs_s evs_t; #define op_ev_reading 0x01 #define op_ev_readed 0x02 @@ -60,6 +61,11 @@ typedef unsigned int evoper_ls; #define ev_off 0x01 #endif // !ev_off + +struct evs_s { + _atomic_t v; +}; + struct evbuf_s { buf_ptr ptr; buf_len len; @@ -121,10 +127,10 @@ struct evsysop_s { int (*op_handler)(evloop_t* loop, ev_op handler); int (*op_alloc_evoper)(evloop_t* loop, evoper_t* oper); int (*op_dealloc_evoper)(evloop_t* loop, evoper_t* oper); - int (*op_add_read)(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); - int (*op_add_write)(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); - int (*op_del_read)(evloop_t* loop, evoper_t* oper, short event); - int (*op_del_write)(evloop_t* loop, evoper_t* oper, short event); + int (*op_enable_read)(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); + int (*op_enable_write)(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); + int (*op_disable_read)(evloop_t* loop, evoper_t* oper, short event); + int (*op_disable_write)(evloop_t* loop, evoper_t* oper, short event); int (*op_cancel)(evloop_t* loop, evoper_t* oper); int (*op_open)(evloop_t* loop, evoper_t* oper, const evaddr_t* addr); int (*op_poll)(evloop_t* loop, evoper_t* oper); @@ -194,10 +200,10 @@ int evoper_accept_op(evoper_t* oper, evevent op); int evoper_listen_size(evoper_t* oper, evoper_ls ls); int evoper_read_active(evoper_t* oper, evevent op); int evoper_read_activeing(evoper_t* oper); -int evoper_read_op(evoper_t* oper, evevent op); -int evoper_reading(evoper_t* oper); int evoper_write_active(evoper_t* oper, evevent op); int evoper_write_activeing(evoper_t* oper); +int evoper_read_op(evoper_t* oper, evevent op); +int evoper_reading(evoper_t* oper); int evoper_write_op(evoper_t* oper, evevent op); int evoper_writeing(evoper_t* oper); int evoper_closeing(evoper_t* oper); @@ -229,4 +235,10 @@ int evbuf_set_off(evbuf_t* buf, buf_len off); int evbuf_op_off(evbuf_t* buf, buf_len off); int is_evbuf_compelete(evbuf_t* buf); +int evs_init(evs_t* on); +int evs_uninit(evs_t* on); +int evs_on(evs_t* on); +int evs_off(evs_t* on); +int is_evs_on(evs_t* on); + #endif diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index ac75738e..3b7e0756 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -70,6 +70,8 @@ void test_init_evaddr() aa += 1000; addr.port = aa % SHRT_MAX; + logi("port:%u\n", addr.port); + send_data = heap_malloc(4096); recv_data = heap_malloc(4096); @@ -143,15 +145,19 @@ void test_write_oper(evloop_t* loop) int rc = 0; s_strncpy(send_data, "hello", 5); - rc = evoper_write(w_oper, (buf_ptr)send_data, buf_len); + rc = evoper_write_buf(w_oper, (buf_ptr)send_data, buf_len); if (rc != S_SUCCESS) { logi("evoper_write"); } - rc = evloop_add_write(loop, w_oper, op_ev_oneshot, NULL); + rc = evloop_enable_write(loop, w_oper, op_ev_oneshot, NULL); if (rc != S_SUCCESS) { - if (rc != S_PENDING) { + + if (rc == S_COMPLETED) { + + } + else if (rc != S_PENDING) { logi("evloop_add_write"); } } @@ -159,7 +165,7 @@ void test_write_oper(evloop_t* loop) void test_read_oper(evloop_t* loop) { int rc = 0; - rc = evoper_read(r_oper, (buf_ptr)recv_data, buf_len); + rc = evoper_read_buf(r_oper, (buf_ptr)recv_data, buf_len); if (rc != S_SUCCESS) { logi("evoper_read"); } @@ -169,10 +175,22 @@ void test_read_oper(evloop_t* loop) logi("evoper_bind_handler"); } - rc = evloop_add_read(loop, r_oper, op_ev_active, NULL); + rc = evloop_enable_read(loop, r_oper, op_ev_active, NULL); + + if (rc != S_SUCCESS) { + if (rc == S_COMPLETED) { + } else if (rc != S_PENDING) { + logi("evloop_add_read"); + } + } + + rc = evloop_enable_read(loop, r_oper, op_ev_active, NULL); + if (rc != S_SUCCESS) { - if (rc != S_PENDING) { + if (rc == S_COMPLETED) { + } else if (rc != S_PENDING) { logi("evloop_add_read"); } } + } -- Gitee From f2250ff06c914f639d9d0c7e37b328e2a2e11fa1 Mon Sep 17 00:00:00 2001 From: com Date: Fri, 9 Aug 2024 13:25:26 +0800 Subject: [PATCH 14/34] up --- crt/crt_atomic.h | 4 + crt/crt_core.hpp | 4 + crt/crt_error.h | 2 + crt/unixosdef.h | 70 ++++++++ crt/unixossysdef.h | 277 +++++++++++++++++++++++++++++ crt/unixsysvar.hpp | 4 + stdcrt/CMakeLists.txt | 2 + stdcrt/event/compat_event_epoll.c | 68 +++---- stdcrt/event/compat_event_iocp.c | 72 ++++---- stdcrt/event/compat_event_kqueue.c | 123 +++++++------ stdcrt/event/compat_event_kqueue.h | 1 - 11 files changed, 494 insertions(+), 133 deletions(-) create mode 100644 crt/unixosdef.h create mode 100644 crt/unixossysdef.h create mode 100644 crt/unixsysvar.hpp diff --git a/crt/crt_atomic.h b/crt/crt_atomic.h index c8b41b70..91c13ecc 100644 --- a/crt/crt_atomic.h +++ b/crt/crt_atomic.h @@ -22,6 +22,10 @@ typedef long atomic_type; typedef volatile int32_t atomic_type; +#elif (TARGET_OS == OS_UNIX) + +typedef long atomic_type; + #endif #pragma pack(push, 1) diff --git a/crt/crt_core.hpp b/crt/crt_core.hpp index bb2a143b..09ad75a9 100644 --- a/crt/crt_core.hpp +++ b/crt/crt_core.hpp @@ -57,6 +57,10 @@ #include #include #include +#elif (TARGET_OS == OS_UNIX) +#include +#include +#include #endif #include diff --git a/crt/crt_error.h b/crt/crt_error.h index 9237d391..6de0b5a4 100644 --- a/crt/crt_error.h +++ b/crt/crt_error.h @@ -15,6 +15,8 @@ typedef DWORD crterr; typedef int crterr; #elif (TARGET_OS == OS_MACH) typedef int crterr; +#elif (TARGET_OS == OS_UNIX) +typedef int crterr; #endif void crt_setfatalerror(const crterr errorno); diff --git a/crt/unixosdef.h b/crt/unixosdef.h new file mode 100644 index 00000000..6609b087 --- /dev/null +++ b/crt/unixosdef.h @@ -0,0 +1,70 @@ +#ifndef _DARWIN_OSDEF_H_ +#define _DARWIN_OSDEF_H_ + +#include +#include + +// address +#include +// setsockopt opations +#include +#include + +// getpagesize +#include + + +// thread stack size +#include + +// path +#include + +// atomic +#include + +//semp +#include + +#include + +#define INVALID_HANDLE_VALUE 0 +#include + +#define CALLBACK PASCAL +#define WINAPI +#define WINAPIV +#define APIENTRY WINAPI +#define APIPRIVATE +#ifdef _68K_ +#define PASCAL __pascal +#else +#define PASCAL +#endif +#elif _MSC_VER + +#ifndef WINAPI +#define WINAPI __stdcall +#endif + +#ifndef CALLBACK +#define CALLBACK __stdcall +#endif + +#ifndef WINAPIV +#define WINAPIV __cdecl +#endif + +#ifndef APIENTRY +#define APIENTRY WINAPI +#endif + +#ifndef APIPRIVATE +#define APIPRIVATE __stdcall +#endif + +#ifndef PASCAL +#define PASCAL __stdcall +#endif + +#endif diff --git a/crt/unixossysdef.h b/crt/unixossysdef.h new file mode 100644 index 00000000..446941f1 --- /dev/null +++ b/crt/unixossysdef.h @@ -0,0 +1,277 @@ +#ifndef _DARWIN_OSSYSDEF_H_ +#define _DARWIN_OSSYSDEF_H_ + +#include + +#ifndef FALSE +#define FALSE 0 +#define TRUE 1 +#endif // !FALSE + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void*)0) +#endif +#endif + +// 32 clang = int 4bit, long 4bit +// 64 clang = int 4bit, long 8bit +typedef int INT_PTR, *PINT_PTR; +typedef unsigned int UINT_PTR, *PUINT_PTR; +typedef long LONG_PTR, *PLONG_PTR; +typedef unsigned long ULONG_PTR, *PULONG_PTR; + +typedef long long LONGLONG; +typedef unsigned long long ULONGLONG; + +typedef unsigned int UINT; +typedef unsigned int* PUINT; +typedef int INT; + +// typedef int BOOL; + +#ifndef __COREFOUNDATION_CFPLUGINCOM__ +typedef unsigned long ULONG; +typedef ULONG* PULONG; +#endif + +typedef unsigned short USHORT; +typedef USHORT* PUSHORT; +typedef unsigned char UCHAR; +typedef UCHAR* PUCHAR; +typedef short SHORT; +typedef unsigned char byte; +typedef double DOUBLE; +typedef float FLOAT; + +typedef int* PINT; +typedef int* LPINT; + +typedef long* LPLONG; + +typedef void* PVOID; +typedef const void* LPCVOID; + +#ifndef _WCHAR_DEFINED +#define _WCHAR_DEFINED +typedef wchar_t WCHAR; +typedef WCHAR OLECHAR; +typedef OLECHAR* BSTR; +typedef WCHAR* LPWSTR; +typedef const WCHAR* LPCWSTR; +#endif // !_WCHAR_DEFINED + +typedef char CHAR; +typedef char* LPSTR; +typedef const char* LPCSTR; + +#ifdef _UNICODE +#define LPCTSTR LPCWSTR +#define _stprintf _swprintf +#define _T(x) L##x +typedef wchar_t TCHAR; + +#else +#define LPCTSTR LPCSTR +#define _stprintf sprintf +#define _T(x) x +typedef char TCHAR; +#endif + +#ifndef VOID +#define VOID void +typedef void* LPVOID; +#endif // !VOID + +#ifndef _BYTE_DEFINED +#define _BYTE_DEFINED +typedef byte BYTE; +typedef BYTE* PBYTE; +typedef BYTE* LPBYTE; +#endif // !_BYTE_DEFINED + +#ifndef _WORD_DEFINED +#define _WORD_DEFINED +typedef unsigned short WORD; +#endif // !_WORD_DEFINED + +#ifndef _LONG_DEFINED +#define _LONG_DEFINED +typedef long LONG; +#endif // !_LONG_DEFINED + +#ifndef _WPARAM_DEFINED +#define _WPARAM_DEFINED +typedef UINT_PTR WPARAM; +#endif // _WPARAM_DEFINED + +#ifndef _DWORD_DEFINED +#define _DWORD_DEFINED +typedef unsigned long DWORD; +#endif // !_DWORD_DEFINED +#ifndef _LPARAM_DEFINED +#define _LPARAM_DEFINED +typedef LONG_PTR LPARAM; + +#endif // !_LPARAM_DEFINED +#ifndef _LRESULT_DEFINED +#define _LRESULT_DEFINED +typedef LONG_PTR LRESULT; + +#endif // !_LRESULT_DEFINED + +typedef struct _FILETIME { + DWORD dwLowDateTime; + DWORD dwHighDateTime; +} FILETIME, *PFILETIME, *LPFILETIME; + +typedef const FILETIME *PCFILETIME, *LPCFILETIME; + +typedef void* HDC; +typedef void* HANDLE; +typedef void* HMODULE; +typedef pid_t HINSTANCE; +typedef void* HTASK; +typedef void* HKEY; +typedef void* HDESK; +typedef void* HMF; +typedef void* HEMF; +typedef void* HPEN; +typedef void* HRSRC; +typedef void* HSTR; +typedef void* HWINSTA; +typedef void* HKL; +typedef void* HGDIOBJ; +typedef void* HWND; +typedef HANDLE HDWP; + +#ifndef _HFILE_DEFINED +#define _HFILE_DEFINED +typedef INT HFILE; + +#endif // !_HFILE_DEFINED +#ifndef _LPWORD_DEFINED +#define _LPWORD_DEFINED +typedef WORD* LPWORD; +typedef WORD* PWORD; +#endif // !_LPWORD_DEFINED + +#ifndef _LPDWORD_DEFINED +#define _LPDWORD_DEFINED +typedef DWORD* LPDWORD; +typedef DWORD* PDWORD; +#endif // !_LPDWORD_DEFINED + +#ifndef _COLORREF_DEFINED +#define _COLORREF_DEFINED +typedef DWORD COLORREF; +#endif // !_COLORREF_DEFINED + +#ifndef _LPCOLORREF_DEFINED +#define _LPCOLORREF_DEFINED +typedef DWORD* LPCOLORREF; +#endif // !_LPCOLORREF_DEFINED + +typedef HANDLE* LPHANDLE; + +typedef struct tagRECT { + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECT; + +typedef struct tagRECT* PRECT; +typedef struct tagRECT* LRECT; + +typedef struct _RECTL { + LONG left; + LONG top; + LONG right; + LONG bottom; + +} RECTL; + +typedef struct _RECTL* PRECTL; +typedef struct _RECTL* LPRECTL; + +typedef struct tagPOINT { + LONG x; + LONG y; +} POINT; + +typedef struct tagPOINT* PPOINT; + +typedef struct tagPOINT* LPPOINT; + +typedef struct _POINTL { + LONG x; + LONG y; +} POINTL; +typedef struct _POINTL* PPOINTL; +typedef struct tagSIZE { + LONG cx; + LONG cy; +} SIZE; + +typedef struct tagSIZE* PSIZE; +typedef struct tagSIZE* LPSIZE; + +typedef struct tagSIZEL { + LONG cx; + LONG cy; +} SIZEL; + +typedef struct tagSIZEL* PSIZEL; +typedef struct tagSIZEL* LPSIZEL; + +typedef struct _LARGE_INTEGER { + LONGLONG QuadPart; +} LARGE_INTEGER; + +typedef LARGE_INTEGER* PLARGE_INTEGER; + +typedef struct _ULARGE_INTEGER { + ULONGLONG QuadPart; +} ULARGE_INTEGER; + +typedef LONG SCODE; + +#define DLL_PROCESS_ATTACH 1 +#define DLL_THREAD_ATTACH 2 +#define DLL_THREAD_DETACH 3 +#define DLL_PROCESS_DETACH 0 + +// #ifndef _LINUX_LIMITS_H +// #define _LINUX_LIMITS_H +// #define NR_OPEN 1024 +// #define NGROUPS_MAX 65536 /* supplemental group IDs are available */ +// #define ARG_MAX 131072 /* bytes of args + environ for exec() */ +// #define LINK_MAX 127 /* # links a file may have */ +// #define MAX_CANON 255 /* size of the canonical input queue */ +// #define MAX_INPUT 255 /* size of the type-ahead buffer */ +// #define NAME_MAX 255 /* */ +// #define PATH_MAX 4096 /* */ +// #define PIPE_BUF 4096 /* bytes in atomic write to a pipe */ +// #define XATTR_NAME_MAX 255 /* chars in an extended attribute name */ +// #define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */ +// #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ +// #define RTSIG_MAX 32 +// #endif + +// look #include + +#ifndef MAX_PATH +#define MAX_PATH 1024 +#endif + +#ifndef _MAX_PATH +#define _MAX_PATH 1024 +#endif + +typedef char basic_tchar; +typedef const char* LPSTRING; + +#endif diff --git a/crt/unixsysvar.hpp b/crt/unixsysvar.hpp new file mode 100644 index 00000000..b0d0368a --- /dev/null +++ b/crt/unixsysvar.hpp @@ -0,0 +1,4 @@ +#ifndef _DARWIN_SYSVAR_HPP_ +#define _DARWIN_SYSVAR_HPP_ + +#endif diff --git a/stdcrt/CMakeLists.txt b/stdcrt/CMakeLists.txt index c0953101..76060b7f 100644 --- a/stdcrt/CMakeLists.txt +++ b/stdcrt/CMakeLists.txt @@ -104,6 +104,8 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") target_link_libraries(stdcrt pthread dl) elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") target_link_libraries(stdcrt pthread dl) +elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") + target_link_libraries(stdcrt pthread dl) elseif (CMAKE_SYSTEM_NAME MATCHES "CYGWIN") target_link_libraries(stdcrt pthread dl) elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index b5eb4fa7..618b7b0d 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -196,7 +196,7 @@ static int epoll_op(epoll_op_t* base, evoper_t* oper, epoll_event_t* ptr, int op end: return S_NOFOUND; } -int epoll_op_alloc(evloop_t* loop, int size) +int epoll_alloc(evloop_t* loop, int size) { int rc = S_ERROR; @@ -250,14 +250,14 @@ err: loop->mm_free(loop, base); return S_ERROR; } -int epoll_op_dealloc(evloop_t* loop) +int epoll_dealloc(evloop_t* loop) { rc_error(loop != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evloop_evbase(loop); loop->mm_free(loop, base->poll); return S_SUCCESS; } -int epoll_op_handler(evloop_t* loop, ev_op ev) +int epoll_handler(evloop_t* loop, ev_op ev) { int rc = S_ERROR; rc_error(loop != NULL, S_ERROR); @@ -266,7 +266,7 @@ int epoll_op_handler(evloop_t* loop, ev_op ev) base->ev = ev; return rc; } -int epoll_op_alloc_evoper(evloop_t* loop, evoper_t* oper) +int epoll_alloc_evoper(evloop_t* loop, evoper_t* oper) { rc_error(loop != NULL, S_ERROR); rc_error(oper != NULL, S_ERROR); @@ -288,7 +288,7 @@ int epoll_op_alloc_evoper(evloop_t* loop, evoper_t* oper) //https://elixir.bootlin.com/linux/v4.19.316/source/fs/eventpoll.c#L2047 return epoll_op(base, oper, ptr, EPOLL_CTL_ADD); } -int epoll_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) +int epoll_dealloc_evoper(evloop_t* loop, evoper_t* oper) { int rc = S_ERROR; rc_error(oper != NULL, S_ERROR); @@ -308,7 +308,7 @@ int epoll_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) return rc; } -int epoll_op_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int epoll_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_SUCCESS; rc_error(oper != NULL, S_ERROR); @@ -355,7 +355,7 @@ int epoll_op_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t return rc; } -int epoll_op_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int epoll_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_SUCCESS; rc_error(oper != NULL, S_ERROR); @@ -397,7 +397,7 @@ int epoll_op_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t } return rc; } -int epoll_op_disable_read(evloop_t* loop, evoper_t* oper, short event) +int epoll_disable_read(evloop_t* loop, evoper_t* oper, short event) { rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); @@ -413,7 +413,7 @@ int epoll_op_disable_read(evloop_t* loop, evoper_t* oper, short event) return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } -int epoll_op_disable_write(evloop_t* loop, evoper_t* oper, short event) +int epoll_disable_write(evloop_t* loop, evoper_t* oper, short event) { rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); @@ -429,7 +429,7 @@ int epoll_op_disable_write(evloop_t* loop, evoper_t* oper, short event) return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } -int epoll_op_cancel(evloop_t* loop, evoper_t* oper) +int epoll_cancel(evloop_t* loop, evoper_t* oper) { epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); @@ -441,11 +441,11 @@ int epoll_op_cancel(evloop_t* loop, evoper_t* oper) return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } -int epoll_op_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) +int epoll_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) { return S_ERROR; } -int epoll_op_poll(evloop_t* loop, evoper_t* oper) +int epoll_poll(evloop_t* loop, evoper_t* oper) { rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); @@ -458,7 +458,7 @@ int epoll_op_poll(evloop_t* loop, evoper_t* oper) return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } -int epoll_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) +int epoll_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { int rc = S_ERROR; rc_error(oper != NULL, S_ERROR); @@ -478,7 +478,7 @@ int epoll_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, e return rc; } -int epoll_op_del_connect(evloop_t* loop, evoper_t* oper) +int epoll_del_connect(evloop_t* loop, evoper_t* oper) { rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); @@ -496,7 +496,7 @@ int epoll_op_del_connect(evloop_t* loop, evoper_t* oper) //https://elixir.bootlin.com/linux/v2.6.26/source/fs/eventpoll.c#L99 #define MAX_TIMEOUT_MSEC (35 * 60 * 1000) -static int epoll_op_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) +static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) { crt_msec timeout = 0; @@ -568,11 +568,11 @@ static int epoll_op_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) return S_SUCCESS; } -static int epoll_op_cmd_exit(const epoll_op_t* base, evloop_t* loop) +static int epoll_cmd_exit(const epoll_op_t* base, evloop_t* loop) { return S_SUCCESS; } -static int epoll_op_dispatch(evloop_t* loop, short event, crt_msec time) +static int epoll_dispatch(evloop_t* loop, short event, crt_msec time) { int rc = S_SUCCESS; @@ -580,10 +580,10 @@ static int epoll_op_dispatch(evloop_t* loop, short event, crt_msec time) switch (event) { case op_cmd_poll: - rc = epoll_op_cmd_poll(base, loop, time); + rc = epoll_cmd_poll(base, loop, time); break; case op_cmd_exit: - rc = epoll_op_cmd_exit(base, loop); + rc = epoll_cmd_exit(base, loop); break; default: break; @@ -594,26 +594,26 @@ static int epoll_op_dispatch(evloop_t* loop, short event, crt_msec time) int epoll_evop_t(evsysop_t* op) { - op->op_alloc = epoll_op_alloc; - op->op_dealloc = epoll_op_dealloc; + op->op_alloc = epoll_alloc; + op->op_dealloc = epoll_dealloc; - op->op_handler = epoll_op_handler; + op->op_handler = epoll_handler; - op->op_alloc_evoper = epoll_op_alloc_evoper; - op->op_dealloc_evoper = epoll_op_dealloc_evoper; + op->op_alloc_evoper = epoll_alloc_evoper; + op->op_dealloc_evoper = epoll_dealloc_evoper; - op->op_enable_read = epoll_op_enable_read; - op->op_enable_write = epoll_op_enable_write; - op->op_disable_read = epoll_op_disable_read; - op->op_disable_write = epoll_op_disable_write; + op->op_enable_read = epoll_enable_read; + op->op_enable_write = epoll_enable_write; + op->op_disable_read = epoll_disable_read; + op->op_disable_write = epoll_disable_write; - op->op_cancel = epoll_op_cancel; - op->op_open = epoll_op_open; - op->op_poll = epoll_op_poll; - op->op_add_connect = epoll_op_add_connect; - op->op_del_connect = epoll_op_del_connect; + op->op_cancel = epoll_cancel; + op->op_open = epoll_open; + op->op_poll = epoll_poll; + op->op_add_connect = epoll_add_connect; + op->op_del_connect = epoll_del_connect; - op->op_dispatch = epoll_op_dispatch; + op->op_dispatch = epoll_dispatch; return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index ba0fe5b7..02b91717 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -122,7 +122,7 @@ err: } -int iocp_op_alloc(evloop_t* loop, int size) +int iocp_alloc(evloop_t* loop, int size) { int rc = 0; iocp_op_t* base = NULL; @@ -158,11 +158,11 @@ err: return S_ERROR; } -int iocp_op_dealloc(evloop_t* loop) +int iocp_dealloc(evloop_t* loop) { return S_SUCCESS; } -int iocp_op_handler(evloop_t* loop, ev_op ev) +int iocp_handler(evloop_t* loop, ev_op ev) { int rc = S_ERROR; rc_error(loop != NULL, S_ERROR); @@ -171,7 +171,7 @@ int iocp_op_handler(evloop_t* loop, ev_op ev) base->ev = ev; return S_SUCCESS; } -int iocp_op_alloc_evoper(evloop_t* loop, evoper_t* oper) +int iocp_alloc_evoper(evloop_t* loop, evoper_t* oper) { iocp_op_t* base = (iocp_op_t*)evloop_evbase(loop); rc_error(base != NULL, S_ERROR); @@ -192,7 +192,7 @@ int iocp_op_alloc_evoper(evloop_t* loop, evoper_t* oper) return S_SUCCESS; } -int iocp_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) +int iocp_dealloc_evoper(evloop_t* loop, evoper_t* oper) { lpevoper_ov obj = (lpevoper_ov)evoper_private(oper); if (HasOverlappedIoCompleted(&obj->overlapped)) { @@ -201,7 +201,7 @@ int iocp_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) return S_SUCCESS; } -int iocp_op_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int iocp_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; @@ -221,7 +221,7 @@ int iocp_op_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t t } return rc; } -int iocp_op_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int iocp_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; if (oper->t == ev_sock) { @@ -232,28 +232,28 @@ int iocp_op_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t } return rc; } -int iocp_op_disable_read(evloop_t* loop, evoper_t* oper, short event) +int iocp_disable_read(evloop_t* loop, evoper_t* oper, short event) { iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); return S_SUCCESS; } -int iocp_op_disable_write(evloop_t* loop, evoper_t* oper, short event) +int iocp_disable_write(evloop_t* loop, evoper_t* oper, short event) { iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); return S_SUCCESS; } -int iocp_op_cancel(evloop_t* loop, evoper_t* oper) +int iocp_cancel(evloop_t* loop, evoper_t* oper) { iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); return S_SUCCESS; } -int iocp_op_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) +int iocp_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) { int rc = S_ERROR; iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); return rc; } -int iocp_op_poll(evloop_t* loop, evoper_t* oper) +int iocp_poll(evloop_t* loop, evoper_t* oper) { int rc = S_ERROR; iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); @@ -265,16 +265,16 @@ int iocp_op_poll(evloop_t* loop, evoper_t* oper) return win32_sock_accept(oper, sk); } -int icop_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) +int icop_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { rc_error(oper->t == ev_sock, S_ERROR); return win32_sock_connect(oper, addr, tv); } -int icop_op_del_connect(evloop_t* loop, evoper_t* oper) +int icop_del_connect(evloop_t* loop, evoper_t* oper) { return S_SUCCESS; } -int iocp_op_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) +int iocp_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) { DWORD timeout = 0; if (timer == 0) @@ -325,13 +325,13 @@ int iocp_op_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) return S_SUCCESS; } -static int iocp_op_cmd_exit(iocp_op_t* base, evloop_t* loop) +static int iocp_cmd_exit(iocp_op_t* base, evloop_t* loop) { int ret; ret = PostQueuedCompletionStatus(base->hiocp, 0, iocp_exit, NULL); return ret > 0 ? S_SUCCESS : S_ERROR; } -int iocp_op_dispatch(evloop_t* loop, short event, crt_msec time) +int iocp_dispatch(evloop_t* loop, short event, crt_msec time) { int rc = S_ERROR; @@ -339,10 +339,10 @@ int iocp_op_dispatch(evloop_t* loop, short event, crt_msec time) switch (event) { case op_cmd_poll: - rc = iocp_op_cmd_poll(base, loop, time); + rc = iocp_cmd_poll(base, loop, time); break; case op_cmd_exit: - rc = iocp_op_cmd_exit(base, loop); + rc = iocp_cmd_exit(base, loop); break; default: break; @@ -352,25 +352,25 @@ int iocp_op_dispatch(evloop_t* loop, short event, crt_msec time) int iocp_evop_t(evsysop_t* op) { - op->op_alloc = iocp_op_alloc; - op->op_dealloc = iocp_op_dealloc; - op->op_handler = iocp_op_handler; + op->op_alloc = iocp_alloc; + op->op_dealloc = iocp_dealloc; + op->op_handler = iocp_handler; - op->op_alloc_evoper = iocp_op_alloc_evoper; - op->op_dealloc_evoper = iocp_op_dealloc_evoper; + op->op_alloc_evoper = iocp_alloc_evoper; + op->op_dealloc_evoper = iocp_dealloc_evoper; - op->op_enable_read = iocp_op_enable_read; - op->op_enable_write = iocp_op_enable_write; - op->op_disable_read = iocp_op_disable_read; - op->op_disable_write = iocp_op_disable_write; + op->op_enable_read = iocp_enable_read; + op->op_enable_write = iocp_enable_write; + op->op_disable_read = iocp_disable_read; + op->op_disable_write = iocp_disable_write; - op->op_cancel = iocp_op_cancel; - op->op_open = iocp_op_open; - op->op_poll = iocp_op_poll; - op->op_add_connect = icop_op_add_connect; - op->op_del_connect = icop_op_del_connect; + op->op_cancel = iocp_cancel; + op->op_open = iocp_open; + op->op_poll = iocp_poll; + op->op_add_connect = icop_add_connect; + op->op_del_connect = icop_del_connect; - op->op_dispatch = iocp_op_dispatch; + op->op_dispatch = iocp_dispatch; return S_SUCCESS; } @@ -462,7 +462,7 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWO evoper_read_op(oper, op_ev_readed); if (evoper_read_activeing(oper) == ev_on) - iocp_op_enable_read(loop, oper, op_ev_active, NULL); + iocp_enable_read(loop, oper, op_ev_active, NULL); } @@ -472,7 +472,7 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWO evoper_write_op(oper, op_ev_writed); if (evoper_write_activeing(oper) == ev_on) - iocp_op_enable_write(loop, oper, op_ev_active, NULL); + iocp_enable_write(loop, oper, op_ev_active, NULL); } diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 30d59101..21d6202a 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -3,37 +3,32 @@ #if (TARGET_OS == OS_MACH) -#define ev_base_event (EVFILT_READ | EVFILT_WRITE) +#define ev_base_event 0 + #define ev_poll_event EVFILT_READ #define ev_conn_event EVFILT_WRITE + #define ev_read_event EVFILT_READ #define ev_write_event EVFILT_WRITE + #define ev_close_event EV_EOF #define ev_clear_event EV_CLEAR + #define ev_oneshot_read_event EV_ONESHOT | EVFILT_READ #define ev_oneshot_write_event EV_ONESHOT | EVFILT_WRITE -#define kevent_add_op (EV_ADD | EV_ERROR) -#define kevent_del_op (EV_DELETE | EV_ERROR) -#define kevent_op_enable (EV_ENABLE | EV_ERROR) -#define kevent_op_disable (EV_DISABLE| EV_ERROR) +#define kevent_add_op (EV_ADD | EV_ERROR | EV_CLEAR) +#define kevent_del_op (EV_DELETE | EV_ERROR | EV_CLEAR) +#define kevent_op_enable (EV_ENABLE | EV_ERROR | EV_CLEAR) +#define kevent_op_disable (EV_DISABLE| EV_ERROR| EV_CLEAR) -static int set_kevent_op(kqueue_event_t* ptr, int16_t op) -{ - rc_error(ptr != NULL, S_ERROR); - ptr->op = op; - return S_SUCCESS; -} static int set_kevent_ctl(kqueue_event_t* ptr, uint32_t ctl) { rc_error(ptr != NULL, S_ERROR); ptr->ctl = ctl; return S_SUCCESS; } -static int16_t get_kevent_op(kqueue_event_t* ptr) -{ - return ptr->op; -} + static uint32_t get_kevent_ctl(kqueue_event_t* ptr) { return ptr->ctl; @@ -41,12 +36,17 @@ static uint32_t get_kevent_ctl(kqueue_event_t* ptr) static int kqueue_op_ctl(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr, const struct timespec* tm) { int rc = 0; - struct kevent ev; - int16_t filter = get_kevent_op(ptr); - uint32_t fflags = get_kevent_ctl(ptr); - EV_SET(&ev, oper->fd, filter, fflags, 0, 0, oper); - rc = base->sys_kevent(base->kqfd, &ev, 1, NULL, 0, tm); + + if (oper->t == ev_sock || oper->t == ev_sockpoll) { + struct kevent events[2]; + EV_SET(&events[0], oper->fd, EVFILT_READ, get_kevent_ctl(ptr), 0, 0, oper); + EV_SET(&events[1], oper->fd, EVFILT_WRITE, get_kevent_ctl(ptr), 0, 0, oper); + rc = base->sys_kevent(base->kqfd, events, 2, NULL, 0, tm); + } else { + return S_ERROR; + } + if (rc == -1) { crterr err = crt_geterror(); @@ -90,7 +90,7 @@ static int kqueue_hook_api(kqueue_op_t* base) return S_SUCCESS; } -int kqueue_op_alloc(evloop_t* loop, int size) +int kqueue_alloc(evloop_t* loop, int size) { int rc = S_ERROR; @@ -128,21 +128,21 @@ err: loop->mm_free(loop, base); return S_ERROR; } -int kqueue_op_dealloc(evloop_t* loop) +int kqueue_dealloc(evloop_t* loop) { kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); loop->mm_free(loop, base->poll); loop->mm_free(loop, base->change); return S_SUCCESS; } -int kqueue_op_handler(evloop_t* loop, ev_op ev) +int kqueue_handler(evloop_t* loop, ev_op ev) { rc_error(loop != NULL, S_ERROR); kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); base->ev = ev; return S_SUCCESS; } -int kqueue_op_alloc_evoper(evloop_t* loop, evoper_t* oper) +int kqueue_alloc_evoper(evloop_t* loop, evoper_t* oper) { rc_error(loop != NULL, S_ERROR); kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); @@ -154,12 +154,12 @@ int kqueue_op_alloc_evoper(evloop_t* loop, evoper_t* oper) evoper_op_init(oper); - set_kevent_op(ptr, ev_base_event); - set_kevent_ctl(ptr, kevent_add_op); - - return kqueue_op_ctl(base, oper, ptr, NULL); + //Adding kqueue causes multiple event triggers + //set_kevent_ctl(ptr, kevent_add_op); + //kqueue_op_ctl(base, oper, ptr, NULL); + return S_SUCCESS; } -int kqueue_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) +int kqueue_dealloc_evoper(evloop_t* loop, evoper_t* oper) { rc_error(oper != NULL, S_ERROR); @@ -169,7 +169,6 @@ int kqueue_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - set_kevent_op(ptr, ev_base_event); set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); kqueue_op_ctl(base, oper, ptr, NULL); @@ -178,43 +177,43 @@ int kqueue_op_dealloc_evoper(evloop_t* loop, evoper_t* oper) return S_SUCCESS; } -int kqueue_op_add_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int kqueue_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); return S_SUCCESS; } -int kqueue_op_add_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int kqueue_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); return S_SUCCESS; } -int kqueue_op_del_read(evloop_t* loop, evoper_t* oper, short event) +int kqueue_disable_read(evloop_t* loop, evoper_t* oper, short event) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); return S_SUCCESS; } -int kqueue_op_del_write(evloop_t* loop, evoper_t* oper, short event) +int kqueue_disable_write(evloop_t* loop, evoper_t* oper, short event) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); return S_SUCCESS; } -int kqueue_op_cancel(evloop_t* loop, evoper_t* oper) +int kqueue_cancel(evloop_t* loop, evoper_t* oper) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); return S_SUCCESS; } -int kqueue_op_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) +int kqueue_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); return S_SUCCESS; } -int kqueue_op_poll(evloop_t* loop, evoper_t* oper) +int kqueue_poll(evloop_t* loop, evoper_t* oper) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); @@ -222,12 +221,11 @@ int kqueue_op_poll(evloop_t* loop, evoper_t* oper) kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - set_kevent_op(ptr, ev_poll_event| ev_base_event); - set_kevent_ctl(ptr, kevent_op_enable); + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); return kqueue_op_ctl(base, oper, ptr, NULL); } -int kqueue_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) +int kqueue_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { int rc = S_SUCCESS; @@ -240,21 +238,20 @@ int kqueue_op_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, rc = evoper_sock_connect(oper, addr); if (rc == S_PENDING) { - set_kevent_op(ptr, ev_conn_event | ev_base_event); set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); kqueue_op_ctl(base, oper, ptr, NULL); } return S_SUCCESS; } -int kqueue_op_del_connect(evloop_t* loop, evoper_t* oper) +int kqueue_del_connect(evloop_t* loop, evoper_t* oper) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); return S_SUCCESS; } -static int kqueue_op_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) +static int kqueue_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) { struct timespec timeout; timeout.tv_sec = timer / 1000; @@ -269,6 +266,8 @@ static int kqueue_op_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) int i = 0; for (i = 0; i < nfds; i++) { + logi("sys_kevent"); + evoper_t* oper = base->poll[i].udata; if ((base->poll[i].flags & EV_EOF)!= 0) { @@ -305,11 +304,11 @@ static int kqueue_op_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) } return S_SUCCESS; } -static int kqueue_op_cmd_exit(const kqueue_op_t* base, evloop_t* loop) +static int kqueue_cmd_exit(const kqueue_op_t* base, evloop_t* loop) { return S_SUCCESS; } -static int kqueue_op_dispatch(evloop_t* loop, short event, crt_msec time) +static int kqueue_dispatch(evloop_t* loop, short event, crt_msec time) { int rc = S_SUCCESS; @@ -317,10 +316,10 @@ static int kqueue_op_dispatch(evloop_t* loop, short event, crt_msec time) switch (event) { case op_cmd_poll: - rc = kqueue_op_cmd_poll(base, loop, time); + rc = kqueue_cmd_poll(base, loop, time); break; case op_cmd_exit: - rc = kqueue_op_cmd_exit(base, loop); + rc = kqueue_cmd_exit(base, loop); break; default: break; @@ -330,26 +329,26 @@ static int kqueue_op_dispatch(evloop_t* loop, short event, crt_msec time) } int kqueue_evop_t(evsysop_t* op) { - op->op_alloc = kqueue_op_alloc; - op->op_dealloc = kqueue_op_dealloc; + op->op_alloc = kqueue_alloc; + op->op_dealloc = kqueue_dealloc; - op->op_handler = kqueue_op_handler; + op->op_handler = kqueue_handler; - op->op_alloc_evoper = kqueue_op_alloc_evoper; - op->op_dealloc_evoper = kqueue_op_dealloc_evoper; + op->op_alloc_evoper = kqueue_alloc_evoper; + op->op_dealloc_evoper = kqueue_dealloc_evoper; - op->op_enable_read = kqueue_op_add_read; - op->op_enable_write = kqueue_op_add_write; - op->op_disable_read = kqueue_op_del_read; - op->op_disable_write = kqueue_op_del_write; + op->op_enable_read = kqueue_enable_read; + op->op_enable_write = kqueue_enable_write; + op->op_disable_read = kqueue_disable_read; + op->op_disable_write = kqueue_disable_write; - op->op_cancel = kqueue_op_cancel; - op->op_open = kqueue_op_open; - op->op_poll = kqueue_op_poll; - op->op_add_connect = kqueue_op_add_connect; - op->op_del_connect = kqueue_op_del_connect; + op->op_cancel = kqueue_cancel; + op->op_open = kqueue_open; + op->op_poll = kqueue_poll; + op->op_add_connect = kqueue_add_connect; + op->op_del_connect = kqueue_del_connect; - op->op_dispatch = kqueue_op_dispatch; + op->op_dispatch = kqueue_dispatch; return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_kqueue.h b/stdcrt/event/compat_event_kqueue.h index 16dece5f..5e7fc060 100644 --- a/stdcrt/event/compat_event_kqueue.h +++ b/stdcrt/event/compat_event_kqueue.h @@ -16,7 +16,6 @@ typedef struct kevent_s kqueue_event_t; struct kevent_s { uint32_t ctl; - int16_t op; }; typedef int (*kqueue_fn)(void); -- Gitee From bb5c7413577991bc6e553e78efcc5ea9f2e737c5 Mon Sep 17 00:00:00 2001 From: com Date: Fri, 9 Aug 2024 15:35:59 +0800 Subject: [PATCH 15/34] up --- stdcrt/event/compat_event_epoll.c | 35 +---- stdcrt/event/compat_event_epoll.h | 4 - stdcrt/event/compat_event_iocp.c | 236 +++++++++++++++--------------- stdcrt/event/compat_event_util.c | 10 +- stdcrt/event/compat_event_util.h | 3 +- stdcrt_test/test_oper.c | 1 - 6 files changed, 120 insertions(+), 169 deletions(-) diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index 618b7b0d..8ab1ac0f 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -166,25 +166,9 @@ static int epoll_op(epoll_op_t* base, evoper_t* oper, epoll_event_t* ptr, int op //ctl_mod --> EPOLLEXCLUSIVE --> 22 sys_epoll_ctl return EINVAL if (base->sys_epoll_ctl(base->epfd, op, oper->fd, &ee) == 0) { - if (ee.events & EPOLLOUT) { - evs_on(&ptr->wepoll); - } else { - evs_off(&ptr->wepoll); - } - - if (ee.events & EPOLLIN) { - evs_on(&ptr->repoll); - } else { - evs_off(&ptr->repoll); - } return S_SUCCESS; } - evs_off(&ptr->repoll); - evs_off(&ptr->wepoll); - - //ptr->epoll = ev_off; - if (errno == ENOENT) { loge("epoll_ctl error %d, epfd=%d, fd=%d\n", errno, base->epfd, oper->fd); goto end; @@ -281,9 +265,6 @@ int epoll_alloc_evoper(evloop_t* loop, evoper_t* oper) uint32_t op = ev_base_event; set_epoll_op(ptr, op); - evs_init(&ptr->repoll); - evs_init(&ptr->wepoll); - evoper_op_init(oper); //https://elixir.bootlin.com/linux/v4.19.316/source/fs/eventpoll.c#L2047 return epoll_op(base, oper, ptr, EPOLL_CTL_ADD); @@ -301,9 +282,6 @@ int epoll_dealloc_evoper(evloop_t* loop, evoper_t* oper) set_epoll_op(ptr, ev_clear_event); rc = epoll_op(base, oper, ptr, EPOLL_CTL_DEL); - evs_uninit(&ptr->repoll); - evs_uninit(&ptr->wepoll); - heap_free(ptr); return rc; @@ -339,16 +317,11 @@ int epoll_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) } else if (rc == S_PENDING) { - // epoll_ing - if (is_evs_on(&ptr->repoll) == S_SUCCESS) { - return S_SUCCESS; - } - uint32_t op = epoll_event_add(ptr, ev_read_event); set_epoll_op(ptr, op); rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); logi("epoll_read_pending"); - + } else { logi("epoll_read_error"); } @@ -386,14 +359,10 @@ int epoll_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv } else if (rc == S_PENDING) { - //epoll_ing - if (is_evs_on(&ptr->wepoll) == S_SUCCESS) { - return S_SUCCESS; - } - uint32_t op = epoll_event_add(ptr, ev_write_event); set_epoll_op(ptr, op); rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); + } return rc; } diff --git a/stdcrt/event/compat_event_epoll.h b/stdcrt/event/compat_event_epoll.h index 7ea44f76..b3f59f12 100644 --- a/stdcrt/event/compat_event_epoll.h +++ b/stdcrt/event/compat_event_epoll.h @@ -16,8 +16,6 @@ typedef struct epoll_op_s epoll_op_t; struct epoll_event_s { int ctl; uint32_t op; - evs_t repoll; - evs_t wepoll; }; typedef int (*epoll_create_fn)(int); @@ -39,8 +37,6 @@ typedef int (*sys_eventfd_fn)(unsigned int, int); typedef int (*base_notify_handler)(epoll_op_t* base); - - struct epoll_op_s { int epfd; diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index 02b91717..c7c7397c 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -274,6 +274,122 @@ int icop_del_connect(evloop_t* loop, evoper_t* oper) { return S_SUCCESS; } +static int poll_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) +{ + lpwsasock sock = NULL; + int rc = 0; + rc_error(oper_ov != NULL, S_ERROR); + sock = oper_ov->ptr; + rc_error(sock->oper != NULL, S_ERROR); + rc_error(base->ev != NULL, S_ERROR); + win32_sock_accpet_ctx(sock->accept_oper, sock->oper); + + lpevoper_ov obj = (lpevoper_ov)evoper_private(sock->oper); + evoper_ov_bind_ptr(obj, sock->oper); + + return complete_sock_accept(loop, S_SUCCESS, err, sock->accept_oper, sock->oper, base->ev); +} +static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) +{ + evoper_t* oper = NULL; + int rc = 0; + rc_error(oper_ov != NULL, S_ERROR); + oper = oper_ov->ptr; + rc_error(oper != NULL, S_ERROR); + + if (oper->conn == op_ev_connecting) { + int conn_error = S_SUCCESS; + + // ERROR_INVALID_NETNAME + if (err == ERROR_CONNECTION_REFUSED || err == ERROR_NETWORK_UNREACHABLE || err == ERROR_HOST_UNREACHABLE || err == ERROR_SEM_TIMEOUT) { + conn_error = S_ERROR; + } else { + // https://learn.microsoft.com/zh-cn/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex + win32_sock_connect_ctx(oper); + } + complete_sock_connect(loop, conn_error, err, oper, base->ev); + return S_SUCCESS; + } + + if (bytes == 0) { + // remote close sock + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + return S_SUCCESS; + } + + if (oper->read == op_ev_reading && bytes) { + oper->bt = ev_io_complete; + base->ev(0, err, oper, NULL, op_ev_read); + evoper_read_op(oper, op_ev_readed); + + if (evoper_read_activeing(oper) == ev_on) + iocp_enable_read(loop, oper, op_ev_active, NULL); + } + + if (oper->write == op_ev_writeing && bytes) { + oper->bt = ev_io_complete; + base->ev(0, err, oper, NULL, op_ev_write); + evoper_write_op(oper, op_ev_writed); + + if (evoper_write_activeing(oper) == ev_on) + iocp_enable_write(loop, oper, op_ev_active, NULL); + } + + return S_SUCCESS; +} +static int sock_iocp_err_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err) +{ + evoper_t* oper = NULL; + int rc = 0; + + if (key == ev_sockpoll) { + lpwsasock sock = NULL; + int rc = 0; + rc_error(oper_ov != NULL, S_ERROR); + sock = oper_ov->ptr; + rc_error(sock->oper != NULL, S_ERROR); + oper = sock->accept_oper; + } else if (key == ev_sock) { + rc_error(oper_ov != NULL, S_ERROR); + oper = oper_ov->ptr; + rc_error(oper != NULL, S_ERROR); + } + + if (err == ERROR_NETNAME_DELETED) { + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + return S_SUCCESS; + } + + if (err == ERROR_NETNAME_DELETED) { + // Operation cancelled. + } else if (err == ERROR_PORT_UNREACHABLE) { + // Connection refused + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + } else if (err == WSAEMSGSIZE) { + // Changed the Windows HANDLE + // backend to treat ERROR_MORE_DATA + // as a non-fatal error when returned by GetOverlappedResult + // for a synchronous read. + } else if (err == ERROR_OPERATION_ABORTED) { + // cancel; + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + } else { + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + } + + return S_SUCCESS; +} +static int sock_iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err, DWORD bytes) +{ + rc_error(oper_ov != NULL, S_ERROR) + + if (key == ev_sockpoll) + { + poll_handle(loop, base, oper_ov, err, bytes); + } + else if (key == ev_sock) { oper_handle(loop, base, oper_ov, err, bytes); } + return S_SUCCESS; +} int iocp_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) { DWORD timeout = 0; @@ -380,7 +496,6 @@ int evoper_ov_bind_ptr(evoper_ov* ov, void* ptr) ov->ptr = ptr; return S_SUCCESS; } - int wsasock_create(evloop_t* loop, iocp_op_t* base, evoper_t* oper_s, wsasock** sock) { int rc = S_ERROR; @@ -413,123 +528,4 @@ int wsasock_create(evloop_t* loop, iocp_op_t* base, evoper_t* oper_s, wsasock** return S_SUCCESS; } -static int poll_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) -{ - lpwsasock sock = NULL; - int rc = 0; - rc_error(oper_ov != NULL, S_ERROR); - sock = oper_ov->ptr; - rc_error(sock->oper != NULL, S_ERROR); - rc_error(base->ev != NULL, S_ERROR); - win32_sock_accpet_ctx(sock->accept_oper, sock->oper); - - lpevoper_ov obj = (lpevoper_ov)evoper_private(sock->oper); - evoper_ov_bind_ptr(obj, sock->oper); - - return complete_sock_accept(loop, S_SUCCESS, err, sock->accept_oper, sock->oper, base->ev); -} -static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) -{ - evoper_t* oper = NULL; - int rc = 0; - rc_error(oper_ov != NULL, S_ERROR); - oper = oper_ov->ptr; - rc_error(oper != NULL, S_ERROR); - - if (oper->conn == op_ev_connecting) { - int conn_error = S_SUCCESS; - - // ERROR_INVALID_NETNAME - if (err == ERROR_CONNECTION_REFUSED || err == ERROR_NETWORK_UNREACHABLE || err == ERROR_HOST_UNREACHABLE || err == ERROR_SEM_TIMEOUT) { - conn_error = S_ERROR; - } else { - // https://learn.microsoft.com/zh-cn/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex - win32_sock_connect_ctx(oper); - } - complete_sock_connect(loop, conn_error, err, oper, base->ev); - return S_SUCCESS; - } - - if (bytes == 0) { - // remote close sock - complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - return S_SUCCESS; - } - - if (oper->read == op_ev_reading && bytes) { - oper->bt = ev_io_complete; - base->ev(0, err, oper, NULL, op_ev_read); - evoper_read_op(oper, op_ev_readed); - - if (evoper_read_activeing(oper) == ev_on) - iocp_enable_read(loop, oper, op_ev_active, NULL); - } - - - if (oper->write == op_ev_writeing && bytes) { - oper->bt = ev_io_complete; - base->ev(0, err, oper, NULL, op_ev_write); - evoper_write_op(oper, op_ev_writed); - - if (evoper_write_activeing(oper) == ev_on) - iocp_enable_write(loop, oper, op_ev_active, NULL); - } - - - return S_SUCCESS; -} -static int sock_iocp_err_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err) -{ - evoper_t* oper = NULL; - int rc = 0; - - if (key == ev_sockpoll) { - lpwsasock sock = NULL; - int rc = 0; - rc_error(oper_ov != NULL, S_ERROR); - sock = oper_ov->ptr; - rc_error(sock->oper != NULL, S_ERROR); - oper = sock->accept_oper; - } else if (key == ev_sock) { - rc_error(oper_ov != NULL, S_ERROR); - oper = oper_ov->ptr; - rc_error(oper != NULL, S_ERROR); - } - - if (err == ERROR_NETNAME_DELETED) { - complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - return S_SUCCESS; - } - - if (err == ERROR_NETNAME_DELETED) { - // Operation cancelled. - } else if (err == ERROR_PORT_UNREACHABLE) { - // Connection refused - complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - } else if (err == WSAEMSGSIZE) { - // Changed the Windows HANDLE - // backend to treat ERROR_MORE_DATA - // as a non-fatal error when returned by GetOverlappedResult - // for a synchronous read. - } else if (err == ERROR_OPERATION_ABORTED) { - // cancel; - complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - } else { - complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - } - - return S_SUCCESS; -} -static int sock_iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err, DWORD bytes) -{ - rc_error(oper_ov != NULL, S_ERROR) - - if (key == ev_sockpoll) { - poll_handle(loop, base, oper_ov, err, bytes); - } - else if (key == ev_sock) { - oper_handle(loop, base, oper_ov, err, bytes); - } - return S_SUCCESS; -} #endif diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index 5e69cfdc..dec8aac1 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -177,16 +177,9 @@ int evoper_op_init(evoper_t* oper) oper->err = ev_off; oper->vnode = ev_off; oper->pending_eof = ev_off; - oper->s = ev_off; return S_SUCCESS; } -int evoper_state_op(evoper_t* oper, evevent op) -{ - rc_error(oper != NULL, S_ERROR); - oper->s = op; - return S_SUCCESS; -} int evoper_connect_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); @@ -286,7 +279,6 @@ int evoper_eof_op(evoper_t* oper, evevent op) oper->eof = op; return S_SUCCESS; } - int evoper_erring(evoper_t* oper) { rc_error(oper != NULL, S_ERROR); @@ -384,7 +376,7 @@ int complete_sock_close(evloop_t* loop, int err, crterr code, evoper_t* oper, ev rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); func(err, code, oper, NULL, op_ev_close); - evoper_state_op(oper, op_ev_closed); + evoper_close_op(oper, op_ev_closed); return S_SUCCESS; } int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func) diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 9e021f23..61ba973f 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -101,7 +101,7 @@ struct evoper_s { evevent vnode; // kqueue_vnode; evevent pending_eof; // kqueue_vnode; - evevent s; // enable,disable,close + union { _fd_t fd; @@ -193,7 +193,6 @@ void* evoper_private(evoper_t* oper); int evoper_bind_private(evoper_t* oper, void* obj); int evoper_op_init(evoper_t* oper); -int evoper_state_op(evoper_t* oper, evevent op); int evoper_connect_op(evoper_t* oper, evevent op); int evoper_connected(evoper_t* oper); int evoper_accept_op(evoper_t* oper, evevent op); diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index 3b7e0756..152ed26d 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -128,7 +128,6 @@ void test_accept_oper(evloop_t* loop) return; } - bind_loop(loop, accept_oper); evloop_poll(accept_oper, 1); } -- Gitee From 3b503c163db548fa1b8295f1ba2ce184a624741a Mon Sep 17 00:00:00 2001 From: com Date: Mon, 12 Aug 2024 10:27:49 +0800 Subject: [PATCH 16/34] up --- crt/crt_barrier.h | 15 +++- crt/crt_clock.h | 2 + crt/crt_common.hpp | 19 +++++ crt/crt_comutil.hpp | 9 ++- crt/crt_cond.h | 13 +++- crt/crt_debug.hpp | 3 + crt/crt_def.h | 20 +++++ crt/crt_file.h | 11 +++ crt/crt_log.h | 12 +-- crt/crt_mutex.h | 9 +++ crt/crt_path.h | 2 + crt/crt_proctl.h | 7 ++ crt/crt_rwlock.h | 7 ++ crt/crt_sem.h | 2 + crt/crt_sleep.hpp | 2 + crt/crt_sock.h | 39 ++++++++++ crt/crt_thread.h | 5 ++ crt/crt_tstring.h | 10 +++ crt/unixosdef.h | 15 +++- crt/unixossysdef.h | 4 +- crt/unixsysvar.hpp | 4 +- stdcrt/CMakeLists.txt | 5 +- stdcrt/compat_error.c | 6 ++ stdcrt/event/compat_event.c | 11 ++- stdcrt/event/compat_event_epoll.c | 53 +++---------- stdcrt/event/compat_event_iocp.c | 34 +++------ stdcrt/event/compat_event_iocp.h | 2 + stdcrt/event/compat_event_kqueue.c | 115 +++++++++++++++++++++-------- stdcrt/event/compat_event_mach.c | 4 +- stdcrt/event/compat_event_posix.c | 2 - stdcrt/event/compat_event_util.c | 66 +++++++---------- stdcrt/event/compat_event_util.h | 42 +++++------ stdcrt/event/compat_event_win32.c | 79 +++++--------------- stdcrt/event/compat_event_win32.h | 2 - stdcrt/io/compat_file.c | 63 ++++++++++++++++ stdcrt/io/compat_path.c | 104 ++++++++++++++++++++++++++ stdcrt/net/compat_sockinet.c | 12 ++- stdcrt/stdlib/compat_atomic.c | 24 ++++++ stdcrt/stdlib/compat_clock.c | 4 +- stdcrt/stdlib/compat_dll.c | 10 +++ stdcrt/stdlib/compat_list.c | 2 +- stdcrt/stdlib/compat_stdtime.c | 11 ++- stdcrt/string/compat_utf8.c | 4 + stdcrt/thread/compat_barrier.c | 68 +++++++++++++++++ stdcrt/thread/compat_cond.c | 108 +++++++++++++++++++++++++++ stdcrt/thread/compat_mutex.c | 72 ++++++++++++++++++ stdcrt/thread/compat_rwlock.c | 82 ++++++++++++++++++++ stdcrt/thread/compat_sem.c | 48 ++++++++++++ stdcrt/thread/compat_thread.c | 65 ++++++++++++++++ stdcrt_test/main.c | 2 - stdcrt_test/test_oper.c | 37 ++++------ 51 files changed, 1077 insertions(+), 270 deletions(-) diff --git a/crt/crt_barrier.h b/crt/crt_barrier.h index 09a613bd..c7ff85b9 100644 --- a/crt/crt_barrier.h +++ b/crt/crt_barrier.h @@ -8,6 +8,7 @@ extern "C" { #endif + #if (TARGET_OS == OS_WIN) typedef struct { @@ -26,17 +27,27 @@ typedef struct { unsigned out; pthread_mutex_t mutex; pthread_cond_t cond; -} _barrier_t; +}_barrier_t; #elif (TARGET_OS == OS_MACH) +typedef struct { // mach .....no found ==> myself devlop + unsigned threshold; + unsigned in; + unsigned out; + pthread_mutex_t mutex; + pthread_cond_t cond; +}_barrier_t; + +#elif (TARGET_OS == OS_UNIX) + typedef struct { // unix .....no found ==> myself devlop unsigned threshold; unsigned in; unsigned out; pthread_mutex_t mutex; pthread_cond_t cond; -} _barrier_t; +}_barrier_t; #endif diff --git a/crt/crt_clock.h b/crt/crt_clock.h index 39f8efee..be171875 100644 --- a/crt/crt_clock.h +++ b/crt/crt_clock.h @@ -19,6 +19,8 @@ struct _clock_s { clockid_t id; #elif (TARGET_OS == OS_MACH) struct mach_timebase_info mach_timebase; +#elif (TARGET_OS == OS_UNIX) + clockid_t id; #else #endif diff --git a/crt/crt_common.hpp b/crt/crt_common.hpp index 3aec6e44..9ee12078 100644 --- a/crt/crt_common.hpp +++ b/crt/crt_common.hpp @@ -28,7 +28,9 @@ typedef long _off_t; #define _aligned(g) __attribute__((aligned(g))) #endif +#ifndef __aligned #define __aligned(g, type) _aligned(g) type +#endif #define PACK_ONEBYTE __attribute__((packed)) #define PACK_EIGHTBYTE __attribute__((aligned(8))) @@ -168,6 +170,23 @@ typedef uint64_t uint64; #define fmt_i64d "%lld" #define fmt_i64u "%llu" + + +#elif (TARGET_OS == OS_UNIX) + +typedef int8_t int8; +typedef int16_t int16; +typedef int32_t int32; +typedef int64_t int64; + +typedef uint8_t uint8; +typedef uint16_t uint16; +typedef uint32_t uint32; +typedef uint64_t uint64; + +#define fmt_i64d "%lld" +#define fmt_i64u "%llu" + #endif #endif diff --git a/crt/crt_comutil.hpp b/crt/crt_comutil.hpp index d8595d13..8973db52 100644 --- a/crt/crt_comutil.hpp +++ b/crt/crt_comutil.hpp @@ -17,7 +17,7 @@ typedef long HRESULT; #endif #elif (TARGET_OS == OS_POSIX) typedef long HRESULT; -#elif (TARGET_OS == OS_POSIX) +#elif (TARGET_OS == OS_UNIX) typedef long HRESULT; #endif @@ -79,6 +79,13 @@ typedef long HRESULT; #define E_INVALIDARG 1004 #define E_NOINTERFACE 1005 #define E_FAIL 1009 +#elif (TARGET_OS == OS_UNIX) +#define MODULE_API HRESULT _VISIBILITY_DEFAULT +#define E_NOTIMPL 1002 +#define E_OUTOFMEMORY 1003 +#define E_INVALIDARG 1004 +#define E_NOINTERFACE 1005 +#define E_FAIL 1009 #endif #define std_method(method) virtual HRESULT method diff --git a/crt/crt_cond.h b/crt/crt_cond.h index ec55de09..e78d9e2d 100644 --- a/crt/crt_cond.h +++ b/crt/crt_cond.h @@ -25,7 +25,7 @@ typedef struct { _sem_t wait_sem; _sem_t wait_done; _mutex_t lock; -} _cond_t; +}_cond_t; #elif (TARGET_OS == OS_POSIX) @@ -47,6 +47,17 @@ typedef struct { pthread_mutex_t mutex; } _cond_t; +#elif (TARGET_OS == OS_UNIX) + +typedef struct { + int process_shared; + int relative; + pthread_condattr_t attr; + pthread_cond_t c; + pthread_mutex_t mutex; +} _cond_t; + + #endif /* Wait on the condition variable for at most 'ms' milliseconds. diff --git a/crt/crt_debug.hpp b/crt/crt_debug.hpp index cd258714..d939a874 100644 --- a/crt/crt_debug.hpp +++ b/crt/crt_debug.hpp @@ -34,6 +34,9 @@ extern "C" { #elif (TARGET_OS == OS_MACH) #define debug_view(x) printf("%s", x); #define wdebug_view(x) printf("%s", x); +#elif (TARGET_OS == OS_UNIX) +#define debug_view(x) printf("%s", x); +#define wdebug_view(x) printf("%s", x); #endif #ifdef __cplusplus diff --git a/crt/crt_def.h b/crt/crt_def.h index e260882b..ecb2de6d 100644 --- a/crt/crt_def.h +++ b/crt/crt_def.h @@ -190,6 +190,26 @@ typedef size_t buf_len; (type*)((char*)__mptr - offsetof(type, member)); \ }) + + + +#elif (TARGET_OS == OS_UNIX) + +#if defined __GNUC__ || defined __llvm__ +#define uu_fast(x) __builtin_expect((x), 1) +#define uu_slow(x) __builtin_expect((x), 0) +#else +#define uu_fast(x) (x) +#define uu_slow(x) (x) +#endif + +// gcc 4.6 +#define _container_of(ptr, type, member) \ + ({ \ + const typeof(((type*)0)->member)* __mptr = (ptr); \ + (type*)((char*)__mptr - offsetof(type, member)); \ + }) + #endif #ifdef __cplusplus diff --git a/crt/crt_file.h b/crt/crt_file.h index b4852e11..3d22fe2a 100644 --- a/crt/crt_file.h +++ b/crt/crt_file.h @@ -40,6 +40,17 @@ typedef ssize_t _fd_len; #define FILE_INVALID (int)(-1) #define FILE_INVALID_VALUE -1 +#elif (TARGET_OS == OS_UNIX) + +typedef int _fd_t; +typedef int _pipe_t; +typedef long _fd_size; +typedef ssize_t _fd_len; +#define FILE_HANDLE int +#define FILE_INVALID (int)(-1) +#define FILE_INVALID_VALUE -1 + + #endif _fd_t _file_snamepipe(const char* name, long rsize, long wsize, int timeout, int flags, int mode); diff --git a/crt/crt_log.h b/crt/crt_log.h index bbc7220a..ba0f5135 100644 --- a/crt/crt_log.h +++ b/crt/crt_log.h @@ -26,8 +26,7 @@ typedef enum sys_LogPriority { } sys_LogPriority; -_VISIBILITY_HIDDEN int - log_print(int proi, const char* tag, int line, const char* func, const char* fmt, ...); +int log_print(int proi, const char* tag, int line, const char* func, const char* fmt, ...); #if (TARGET_OS == OS_WIN) @@ -41,14 +40,17 @@ _VISIBILITY_HIDDEN int #define _LOG_FUNCTION_ __PRETTY_FUNCTION__ +#elif (TARGET_OS == OS_UNIX) + +#define _LOG_FUNCTION_ __PRETTY_FUNCTION__ + #endif -#define loge(...) log_print(SYS_LOG_ERROR, log_error_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) -#define logw(...) log_print(SYS_LOG_WARN, log_warning_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) +#define loge(...) log_print(SYS_LOG_ERROR, log_error_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) +#define logw(...) log_print(SYS_LOG_WARN, log_warning_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) #define logi(...) log_print(SYS_LOG_INFO, log_info_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) - #define logd(...) log_print(SYS_LOG_DEBUG, log_debug_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) diff --git a/crt/crt_mutex.h b/crt/crt_mutex.h index 11c8c274..e1d2cd56 100644 --- a/crt/crt_mutex.h +++ b/crt/crt_mutex.h @@ -32,6 +32,15 @@ typedef struct { pthread_mutex_t mutex; } _mutex_t; + +#elif (TARGET_OS == OS_UNIX) + +typedef struct { + int setrobus; + int process_shared; + pthread_mutex_t mutex; +} _mutex_t; + #endif int _mutex_init(_mutex_t* lock); diff --git a/crt/crt_path.h b/crt/crt_path.h index debffa8d..023f63cd 100644 --- a/crt/crt_path.h +++ b/crt/crt_path.h @@ -13,6 +13,8 @@ typedef size_t pathlen; typedef size_t pathlen; #elif (TARGET_OS == OS_MACH) typedef uint32_t pathlen; +#elif (TARGET_OS == OS_UNIX) +typedef size_t pathlen; #endif int fileisexist(const basic_tchar* file); diff --git a/crt/crt_proctl.h b/crt/crt_proctl.h index e06a833f..5f38f223 100644 --- a/crt/crt_proctl.h +++ b/crt/crt_proctl.h @@ -28,6 +28,13 @@ typedef pid_t _pid_instance; typedef pid_t _pid_t; typedef pid_t _pid_instance; +#elif (TARGET_OS == OS_UNIX) + +#define pid_null -1 +#define pid_instance -1 +typedef pid_t _pid_t; +typedef pid_t _pid_instance; + #endif _pid_t get_processid(void); diff --git a/crt/crt_rwlock.h b/crt/crt_rwlock.h index f7fe7760..c859a3cc 100644 --- a/crt/crt_rwlock.h +++ b/crt/crt_rwlock.h @@ -30,6 +30,13 @@ typedef struct { pthread_rwlock_t rwlock; } _rwlock_t; +#elif (TARGET_OS == OS_UNIX) + +typedef struct { + int process_shared; + pthread_rwlock_t rwlock; +} _rwlock_t; + #endif int _rwlock_init(_rwlock_t* lock); diff --git a/crt/crt_sem.h b/crt/crt_sem.h index d4c92358..3b9aea3d 100644 --- a/crt/crt_sem.h +++ b/crt/crt_sem.h @@ -14,6 +14,8 @@ typedef HANDLE _sem_t; typedef sem_t _sem_t; #elif (TARGET_OS == OS_MACH) typedef semaphore_t _sem_t; +#elif (TARGET_OS == OS_UNIX) +typedef int _sem_t; #endif int _sem_init(_sem_t* sem, unsigned int value); diff --git a/crt/crt_sleep.hpp b/crt/crt_sleep.hpp index 8e06d10a..e2f87304 100644 --- a/crt/crt_sleep.hpp +++ b/crt/crt_sleep.hpp @@ -14,6 +14,8 @@ extern "C" { #define sleep_time(x) sleep(x); #elif (TARGET_OS == OS_MACH) #define sleep_time(x) sleep(x); +#elif (TARGET_OS == OS_UNIX) +#define sleep_time(x) sleep(x); #endif #ifdef __cplusplus diff --git a/crt/crt_sock.h b/crt/crt_sock.h index 12c1eb02..13ada9cc 100644 --- a/crt/crt_sock.h +++ b/crt/crt_sock.h @@ -177,15 +177,54 @@ typedef int sock_size; #define _socket_geterror(sock) (errno) +#elif (TARGET_OS == OS_UNIX) + +#define INVALID_SOCKET -1 +typedef int _sock_t; +typedef int sock_size; +#define SHUT_SOCK_RD SHUT_RD +#define SHUT_SOCK_RW SHUT_WR +#define SHUT_SOCK_BOTN SHUT_RDWR + +#define SC_ETIMEDOUT ETIMEDOUT +#define SC_ENOMEM ENOMEM +#define SC_EINVAL EINVAL +#define SC_ECONNREFUSED ECONNREFUSED +#define SC_ECONNRESET ECONNRESET +#define SC_EHOSTDOWN EHOSTDOWN +#define SC_EHOSTUNREACH EHOSTUNREACH +#define SC_EINTR EINTR +#define SC_EAGAIN EAGAIN +#define SC_ENETDOWN ENETDOWN +#define SC_ENETUNREACH ENETUNREACH +#define SC_ENOTCONN ENOTCONN +#define SC_EISCONN EISCONN +#define SC_EWOULDBLOCK EWOULDBLOCK +#define SC_ENOBUFS ENOBUFS +#define SC_ECONNABORTED ECONNABORTED +#define SC_EINPROGRESS EINPROGRESS + +#define _ERR_CONNECT_RETRIABLE(e) ((e) == SC_EINTR || (e) == SC_EINPROGRESS) +#define _ERR_CONNECT_REFUSED(e) ((e) == SC_ECONNREFUSED || (e) == SC_EAGAIN) + +#define _ERR_CONNECT_ERRORRESET(e) ((e) == SC_ECONNRESET) +#define _ERR_CONNECT_ERROR_ENET(e) ((e) == SC_ENETDOWN || (e) == SC_ENETUNREACH) +#define _ERR_CONNECT_ERROR_EHOST(e) ((e) == SC_EHOSTDOWN || (e) == SC_EHOSTUNREACH) + +#define _socket_geterror(sock) (errno) + #endif typedef union { + struct sockaddr_storage ss; struct sockaddr_in6 in6; struct sockaddr_in in; + #if (TARGET_OS != OS_WIN) struct sockaddr_un un; #endif + struct sockaddr sa; } sock_addr; diff --git a/crt/crt_thread.h b/crt/crt_thread.h index cb4bdba9..db4625db 100644 --- a/crt/crt_thread.h +++ b/crt/crt_thread.h @@ -26,6 +26,11 @@ typedef uint64_t _thread_id; typedef pthread_t _thread_t; typedef uint64_t _thread_id; +#elif (TARGET_OS == OS_UNIX) + +typedef pthread_t _thread_t; +typedef uint64_t _thread_id; + #endif typedef void (*_thread_proc)(void* arg); diff --git a/crt/crt_tstring.h b/crt/crt_tstring.h index ff104fa1..9b52fbcf 100644 --- a/crt/crt_tstring.h +++ b/crt/crt_tstring.h @@ -53,6 +53,16 @@ extern "C" { #define tstring_strlen(x) s_strlen(x) #define tstring_ststr(x, y) s_strstr(x, y) #define tmemset(x, y, z) s_memset(x, y, z) +#elif (TARGET_OS == OS_UNIX) +#define wstring_stricmp(x, y) s_wstrcasecmp(x, y) +#define string_stricmp(x, y) s_strcasecmp(x, y) +#define tstring_stricmp(x, y) s_strcasecmp(x, y) +#define tstring_strcpy(x, n, y) s_strcpy(x, n, y) +#define tstring_strcat(x, n, y) s_strcat(x, n, y) +#define tstring_strchr(x, y) s_strchr(x, y) +#define tstring_strlen(x) s_strlen(x) +#define tstring_ststr(x, y) s_strstr(x, y) +#define tmemset(x, y, z) s_memset(x, y, z) #endif #ifdef __cplusplus diff --git a/crt/unixosdef.h b/crt/unixosdef.h index 6609b087..a1ba6d99 100644 --- a/crt/unixosdef.h +++ b/crt/unixosdef.h @@ -1,5 +1,5 @@ -#ifndef _DARWIN_OSDEF_H_ -#define _DARWIN_OSDEF_H_ +#ifndef _UNIX_OSDEF_H_ +#define _UNIX_OSDEF_H_ #include #include @@ -10,9 +10,20 @@ #include #include +//socket +#include +#include + + +//thread +#include + // getpagesize #include +//error +#include + // thread stack size #include diff --git a/crt/unixossysdef.h b/crt/unixossysdef.h index 446941f1..85065410 100644 --- a/crt/unixossysdef.h +++ b/crt/unixossysdef.h @@ -1,5 +1,5 @@ -#ifndef _DARWIN_OSSYSDEF_H_ -#define _DARWIN_OSSYSDEF_H_ +#ifndef _UNIX_OSSYSDEF_H_ +#define _UNIX_OSSYSDEF_H_ #include diff --git a/crt/unixsysvar.hpp b/crt/unixsysvar.hpp index b0d0368a..04342d79 100644 --- a/crt/unixsysvar.hpp +++ b/crt/unixsysvar.hpp @@ -1,4 +1,4 @@ -#ifndef _DARWIN_SYSVAR_HPP_ -#define _DARWIN_SYSVAR_HPP_ +#ifndef _UNIX_SYSVAR_HPP_ +#define _UNIX_SYSVAR_HPP_ #endif diff --git a/stdcrt/CMakeLists.txt b/stdcrt/CMakeLists.txt index 76060b7f..31e3f387 100644 --- a/stdcrt/CMakeLists.txt +++ b/stdcrt/CMakeLists.txt @@ -44,7 +44,6 @@ else() include(CheckLibraryExists) include(CheckFunctionExists) - check_type_size("struct sockaddr_un" EVENT__HAVE_STRUCT_SOCKADDR_UN) check_type_size("uint8_t" EVENT__HAVE_UINT8_T) check_type_size("uint16_t" EVENT__HAVE_UINT16_T) check_type_size("uint32_t" EVENT__HAVE_UINT32_T) @@ -103,9 +102,9 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") target_link_libraries(stdcrt pthread dl) elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - target_link_libraries(stdcrt pthread dl) + target_link_libraries(stdcrt pthread) elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") - target_link_libraries(stdcrt pthread dl) + target_link_libraries(stdcrt pthread) elseif (CMAKE_SYSTEM_NAME MATCHES "CYGWIN") target_link_libraries(stdcrt pthread dl) elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") diff --git a/stdcrt/compat_error.c b/stdcrt/compat_error.c index 4f1e1a2c..e70dec4e 100644 --- a/stdcrt/compat_error.c +++ b/stdcrt/compat_error.c @@ -18,6 +18,12 @@ #define ERRNO (errno) #define SET_ERRNO(x) (errno = (x)) +#elif (TARGET_OS == OS_UNIX) + +#define WSAERRNO (errno) +#define ERRNO (errno) +#define SET_ERRNO(x) (errno = (x)) + #endif void crt_setfatalerror(const crterr errorno) diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index 55eb0507..bc554df2 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -12,8 +12,7 @@ static int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) { if (op == op_ev_connect) { - evevent res = evoper_sock_connected(oper) == S_SUCCESS ? op_ev_success : op_ev_faild; - oper->handler(res, oper, oper, op_ev_connect); + oper->handler(op_ev_success, oper, oper, op_ev_connect); } else if(op == op_ev_open) { oper->handler(op_ev_success, oper, oper, op_ev_open); } else if (op == op_ev_close) { @@ -283,6 +282,10 @@ int evloop_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); rs_error(evoper_erring(oper) == S_SUCCESS, S_ERROR); rs_error(evoper_closeing(oper) == S_SUCCESS, S_CLOSE); + rc_error(loop != NULL, S_MEMERROR); + rc_error(evoper_reading(oper) != S_SUCCESS, S_PENDING); + evoper_read_op(oper, op_ev_reading); + rc_error(loop != NULL, S_MEMERROR); const evsysop_t* evsel = evloop_sysop(loop); @@ -298,6 +301,8 @@ int evloop_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t t rs_error(evoper_erring(oper) == S_SUCCESS, S_ERROR); rs_error(evoper_closeing(oper) == S_SUCCESS, S_CLOSE); rc_error(loop != NULL, S_MEMERROR); + rc_error(evoper_writeing(oper) != S_SUCCESS, S_PENDING); + evoper_write_op(oper, op_ev_writeing); const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); @@ -312,6 +317,7 @@ int evloop_disable_read(evloop_t* loop, evoper_t* oper) rs_error(evoper_erring(oper) == S_SUCCESS, S_ERROR); rs_error(evoper_closeing(oper) == S_SUCCESS, S_CLOSE); rc_error(loop != NULL, S_MEMERROR); + evoper_read_op(oper, op_ev_read); const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); @@ -326,6 +332,7 @@ int evloop_disable_write(evloop_t* loop, evoper_t* oper) rs_error(evoper_erring(oper) == S_SUCCESS, S_ERROR); rs_error(evoper_closeing(oper) == S_SUCCESS, S_CLOSE); rc_error(loop != NULL, S_MEMERROR); + evoper_write_op(oper, op_ev_write); const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index 8ab1ac0f..deef9e89 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -294,36 +294,19 @@ int epoll_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) rc_error(base != NULL, S_ERROR); epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - //reading rc_error(evoper_reading(oper) != S_SUCCESS, S_ERROR); evoper_read_op(oper, op_ev_reading); - - //activeing - evoper_read_active(oper, ev_off); - if (event == op_ev_active) { - evoper_read_active(oper, ev_on); - } - + // add epoll + uint32_t op = epoll_event_add(ptr, ev_read_event); + set_epoll_op(ptr, op); + epoll_op(base, oper, ptr, EPOLL_CTL_MOD); //recv rc = posix_tcpsock_recv(oper, 0); - - //res + // res if (rc == S_COMPLETED) { - - oper->bt = ev_func_complete; + oper->bt = ev_func_complete; base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); - evoper_read_op(oper, op_ev_readed); - - } else if (rc == S_PENDING) { - - uint32_t op = epoll_event_add(ptr, ev_read_event); - set_epoll_op(ptr, op); - rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); - logi("epoll_read_pending"); - - } else { - logi("epoll_read_error"); } return rc; @@ -336,33 +319,19 @@ int epoll_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv rc_error(base != NULL, S_ERROR); epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - //writeing rc_error(evoper_writeing(oper) != S_SUCCESS, S_ERROR); evoper_write_op(oper, op_ev_writeing); - - //activeing - evoper_write_active(oper, ev_off); - if (event == op_ev_active) { - evoper_write_active(oper, ev_on); - } - + // add epoll + uint32_t op = epoll_event_add(ptr, ev_write_event); + set_epoll_op(ptr, op); + rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); //send rc = posix_tcpsock_send(oper, 0); - //res if (rc == S_COMPLETED) { - oper->bt = ev_func_complete; base->ev(S_SUCCESS, 0, oper, oper, op_ev_write); - evoper_write_op(oper, op_ev_writed); - - } else if (rc == S_PENDING) { - - uint32_t op = epoll_event_add(ptr, ev_write_event); - set_epoll_op(ptr, op); - rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); - } return rc; } @@ -375,8 +344,6 @@ int epoll_disable_read(evloop_t* loop, evoper_t* oper, short event) epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - evoper_read_op(oper, op_ev_read); - uint32_t op = epoll_event_del(ptr, ev_read_event); set_epoll_op(ptr, op); diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index c7c7397c..c333b588 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -186,6 +186,8 @@ int iocp_alloc_evoper(evloop_t* loop, evoper_t* oper) evoper_bind_private(oper, obj); obj->ptr = oper; + obj->r = ev_off; + obj->w = ev_off; s_memset(&obj->overlapped, 0, sizeof(OVERLAPPED)); @@ -209,15 +211,7 @@ int iocp_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); if (oper->t == ev_sock) { - rc_error(evoper_reading(oper) != S_SUCCESS, S_PENDING); - evoper_read_active(oper, event == op_ev_active ? ev_on : ev_off); - evoper_read_op(oper, op_ev_reading); rc = win32_sock_read_op(oper); - if (rc == S_COMPLETED) { - oper->bt = ev_func_complete; - base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); - evoper_read_op(oper, op_ev_readed); - } } return rc; } @@ -225,9 +219,6 @@ int iocp_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { int rc = S_ERROR; if (oper->t == ev_sock) { - rc_error(evoper_writeing(oper) != S_SUCCESS, S_PENDING); - evoper_write_active(oper, event == op_ev_active ? ev_on : ev_off); - evoper_write_op(oper, op_ev_writeing); rc = win32_sock_write_op(oper); } return rc; @@ -317,21 +308,23 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWO return S_SUCCESS; } - if (oper->read == op_ev_reading && bytes) { + if (oper_ov->r == ev_on && bytes) { + oper->bt = ev_io_complete; base->ev(0, err, oper, NULL, op_ev_read); - evoper_read_op(oper, op_ev_readed); + oper_ov->r = ev_off; - if (evoper_read_activeing(oper) == ev_on) + if (evoper_reading(oper) == S_SUCCESS) iocp_enable_read(loop, oper, op_ev_active, NULL); } - if (oper->write == op_ev_writeing && bytes) { + if (oper_ov->w == ev_on && bytes) { + oper->bt = ev_io_complete; base->ev(0, err, oper, NULL, op_ev_write); - evoper_write_op(oper, op_ev_writed); - - if (evoper_write_activeing(oper) == ev_on) + oper_ov->w = ev_off; + int rc = evoper_writeing(oper); + if (rc == S_SUCCESS) iocp_enable_write(loop, oper, op_ev_active, NULL); } @@ -383,10 +376,7 @@ static int sock_iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, { rc_error(oper_ov != NULL, S_ERROR) - if (key == ev_sockpoll) - { - poll_handle(loop, base, oper_ov, err, bytes); - } + if (key == ev_sockpoll){ poll_handle(loop, base, oper_ov, err, bytes);} else if (key == ev_sock) { oper_handle(loop, base, oper_ov, err, bytes); } return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_iocp.h b/stdcrt/event/compat_event_iocp.h index 02adec27..aee9f1a7 100644 --- a/stdcrt/event/compat_event_iocp.h +++ b/stdcrt/event/compat_event_iocp.h @@ -95,6 +95,8 @@ typedef struct { void* ptr; //lpwsascok char addr[ACCEPT_ADDRESS_LENGTH * 2 + 20]; crterr error; + evevent r; + evevent w; } evoper_ov, *lpevoper_ov; diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 21d6202a..794ebac5 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -14,13 +14,11 @@ #define ev_close_event EV_EOF #define ev_clear_event EV_CLEAR -#define ev_oneshot_read_event EV_ONESHOT | EVFILT_READ -#define ev_oneshot_write_event EV_ONESHOT | EVFILT_WRITE +#define kevent_add_op EV_ADD | EV_CLEAR +#define kevent_del_op EV_DELETE | EV_CLEAR +#define kevent_op_enable EV_ENABLE | EV_CLEAR +#define kevent_op_disable EV_DISABLE| EV_CLEAR -#define kevent_add_op (EV_ADD | EV_ERROR | EV_CLEAR) -#define kevent_del_op (EV_DELETE | EV_ERROR | EV_CLEAR) -#define kevent_op_enable (EV_ENABLE | EV_ERROR | EV_CLEAR) -#define kevent_op_disable (EV_DISABLE| EV_ERROR| EV_CLEAR) static int set_kevent_ctl(kqueue_event_t* ptr, uint32_t ctl) { @@ -33,24 +31,28 @@ static uint32_t get_kevent_ctl(kqueue_event_t* ptr) { return ptr->ctl; } -static int kqueue_op_ctl(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr, const struct timespec* tm) +static int kqueue_op_ctl(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr, const struct timespec* tm, int op) { int rc = 0; - if (oper->t == ev_sock || oper->t == ev_sockpoll) { - struct kevent events[2]; - EV_SET(&events[0], oper->fd, EVFILT_READ, get_kevent_ctl(ptr), 0, 0, oper); - EV_SET(&events[1], oper->fd, EVFILT_WRITE, get_kevent_ctl(ptr), 0, 0, oper); - rc = base->sys_kevent(base->kqfd, events, 2, NULL, 0, tm); - } else { - return S_ERROR; + uint32_t flags = get_kevent_ctl(ptr); + + + if (op == ev_poll_event || op == ev_read_event) { + struct kevent event; + EV_SET(&event, oper->fd, EVFILT_READ, flags, 0, 0, oper); + rc = base->sys_kevent(base->kqfd, &event, 1, NULL, 0, tm); } - + if (op == ev_conn_event || op == ev_write_event) { + struct kevent event; + EV_SET(&event, oper->fd, EVFILT_WRITE, flags, 0, 0, oper); + rc = base->sys_kevent(base->kqfd, &event, 1, NULL, 0, tm); + } + if (rc == -1) { crterr err = crt_geterror(); - if (err == EINVAL) { loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); } else if (err == ENOENT) { @@ -58,7 +60,6 @@ static int kqueue_op_ctl(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr, } else if (err != EPERM) { loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); } - return S_ERROR; } @@ -157,6 +158,7 @@ int kqueue_alloc_evoper(evloop_t* loop, evoper_t* oper) //Adding kqueue causes multiple event triggers //set_kevent_ctl(ptr, kevent_add_op); //kqueue_op_ctl(base, oper, ptr, NULL); + return S_SUCCESS; } int kqueue_dealloc_evoper(evloop_t* loop, evoper_t* oper) @@ -170,8 +172,7 @@ int kqueue_dealloc_evoper(evloop_t* loop, evoper_t* oper) rc_error(ptr != NULL, S_ERROR); set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); - - kqueue_op_ctl(base, oper, ptr, NULL); + kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event | ev_write_event); loop->mm_free(loop, evoper_private(oper)); @@ -179,26 +180,81 @@ int kqueue_dealloc_evoper(evloop_t* loop, evoper_t* oper) } int kqueue_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { + int rc = S_SUCCESS; kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + //reading + rc_error(evoper_reading(oper) != S_SUCCESS, S_ERROR); + evoper_read_op(oper, op_ev_reading); + //activeing + evoper_read_active(oper, event == op_ev_active ? ev_on : ev_off); + //recv + rc = mach_tcpsock_recv(oper, 0); + //add kqueue + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event); + + //res + if (rc == S_COMPLETED) { + oper->bt = ev_func_complete; + base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); + } + return S_SUCCESS; } int kqueue_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { + int rc = S_SUCCESS; kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + rc_error(evoper_writeing(oper) != S_SUCCESS, S_ERROR); + evoper_write_op(oper, op_ev_writeing); + //activeing + evoper_write_active(oper, event == op_ev_active ? ev_on : ev_off); + //send + rc = mach_tcpsock_send(oper, 0); + //add kqueue + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_write_event); + return S_SUCCESS; } int kqueue_disable_read(evloop_t* loop, evoper_t* oper, short event) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); - rc_error(base != NULL, S_ERROR); + rc_error(base != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + evoper_read_op(oper, op_ev_readed); + + set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event); + return S_SUCCESS; } int kqueue_disable_write(evloop_t* loop, evoper_t* oper, short event) { kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + evoper_write_op(oper, op_ev_writed); + + set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_write_event); + return S_SUCCESS; } int kqueue_cancel(evloop_t* loop, evoper_t* oper) @@ -223,7 +279,7 @@ int kqueue_poll(evloop_t* loop, evoper_t* oper) set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); - return kqueue_op_ctl(base, oper, ptr, NULL); + return kqueue_op_ctl(base, oper, ptr, NULL, ev_poll_event); } int kqueue_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { @@ -239,7 +295,7 @@ int kqueue_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_ if (rc == S_PENDING) { set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); - kqueue_op_ctl(base, oper, ptr, NULL); + kqueue_op_ctl(base, oper, ptr, NULL, ev_conn_event); } return S_SUCCESS; @@ -266,26 +322,25 @@ static int kqueue_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) int i = 0; for (i = 0; i < nfds; i++) { - logi("sys_kevent"); - evoper_t* oper = base->poll[i].udata; - if ((base->poll[i].flags & EV_EOF)!= 0) { + if (base->poll[i].flags & EV_ERROR) { complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); continue; } - if ((base->poll[i].flags & EV_ERROR)!= 0) { - complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - continue; + if (base->poll[i].flags & EV_EOF) { + evoper_eof_op(oper, ev_on); } - + if(base->poll[i].filter == EVFILT_READ) { if (oper->accept == op_ev_accepting) { complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); continue; } + + oper->bt = ev_io_complete; complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); continue; } @@ -296,7 +351,7 @@ static int kqueue_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); continue; } - + oper->bt = ev_io_complete; complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); continue; } diff --git a/stdcrt/event/compat_event_mach.c b/stdcrt/event/compat_event_mach.c index 89f095cc..aae8845c 100644 --- a/stdcrt/event/compat_event_mach.c +++ b/stdcrt/event/compat_event_mach.c @@ -48,6 +48,7 @@ int mach_tcpsock_send(evoper_t* oper, int flags) end: return rc; } + int mach_tcpsock_recv(evoper_t* oper, int flags) { int rc = S_SUCCESS; @@ -55,7 +56,7 @@ int mach_tcpsock_recv(evoper_t* oper, int flags) ssize_t n; buf_ptr ptr = NULL; buf_len len = 0; - + rc = evbuf_get_buf(&oper->rbuf, &ptr); rc_error(rc != S_ERROR, S_ERROR); @@ -68,7 +69,6 @@ int mach_tcpsock_recv(evoper_t* oper, int flags) int err = 0; n = recv(oper->fd, ptr, len, flags); err = (n == -1) ? errno : 0; - if (n > 0) { evbuf_op_off(&oper->rbuf, n); if (is_evbuf_compelete(&oper->rbuf) == S_SUCCESS) { diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index 9562f606..b4f8ceb5 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -71,8 +71,6 @@ int posix_tcpsock_recv(evoper_t* oper, int flags) if (n > 0) { evbuf_op_off(&oper->rbuf, n); if (is_evbuf_compelete(&oper->rbuf) == S_SUCCESS) { - n = recv(oper->fd, ptr, len, MSG_PEEK); - logi("msg_peek %d\n", n); rc = S_COMPLETED; goto end; } diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index dec8aac1..5f319020 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -10,6 +10,9 @@ #elif (TARGET_OS == OS_MACH) #include "compat_event_kqueue.h" #include "compat_event_mach.h" +#elif (TARGET_OS == OS_UNIX) +#include "compat_event_kqueue.h" +#include "compat_event_mach.h" #endif static int oper_msec_less_than(const _heap_node_t* node_a, const _heap_node_t* node_b) @@ -163,9 +166,7 @@ int evoper_op_init(evoper_t* oper) rc_error(oper != NULL, S_ERROR); oper->read = op_ev_read; - oper->ractive = ev_off; oper->write = op_ev_write; - oper->wactive = ev_off; oper->accept = op_ev_accept; oper->open = op_ev_open; oper->conn = op_ev_connect; @@ -203,28 +204,6 @@ int evoper_listen_size(evoper_t* oper, evoper_ls ls) oper->ls = ls; return S_SUCCESS; } -int evoper_read_active(evoper_t* oper, evevent op) -{ - rc_error(oper != NULL, S_ERROR); - oper->ractive = op; - return S_SUCCESS; -} -int evoper_read_activeing(evoper_t* oper) -{ - rc_error(oper != NULL, S_ERROR); - return oper->ractive == ev_on ? S_SUCCESS : S_ERROR; -} -int evoper_write_active(evoper_t* oper, evevent op) -{ - rc_error(oper != NULL, S_ERROR); - oper->wactive = op; - return S_SUCCESS; -} -int evoper_write_activeing(evoper_t* oper) -{ - rc_error(oper != NULL, S_ERROR); - return oper->wactive == ev_on ? S_SUCCESS : S_ERROR; -} int evoper_read_op(evoper_t* oper, evevent op) { rc_error(oper != NULL, S_ERROR); @@ -366,8 +345,12 @@ int complete_sock_connect(evloop_t* loop, int err, crterr code, evoper_t* oper, rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); + + evevent res = evoper_sock_connected(oper) == S_SUCCESS ? op_ev_connected : op_ev_connectfailed; + evoper_connect_op(oper, res); + func(err, code, oper, NULL, op_ev_connect); - evoper_connect_op(oper, op_ev_connected); + return S_SUCCESS; } int complete_sock_close(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func) @@ -385,18 +368,22 @@ int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_ rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); -#if (TARGET_OS == OS_WIN) - -#elif (TARGET_OS == OS_POSIX) - posix_tcpsock_recv(oper, 0); -#elif (TARGET_OS == OS_MACH) - mach_tcpsock_recv(oper, 0); -#else - -#endif + if(evoper_reading(oper) == S_SUCCESS) { + + #if (TARGET_OS == OS_WIN) + + #elif (TARGET_OS == OS_POSIX) + posix_tcpsock_recv(oper, 0); + #elif (TARGET_OS == OS_MACH) + mach_tcpsock_recv(oper, 0); + #elif (TARGET_OS == OS_UNIX) + //mach_tcpsock_recv(oper, 0); + #else + + #endif + func(err, code, oper, NULL, op_ev_read); + } - func(err, code, oper, NULL, op_ev_read); - evoper_read_op(oper, op_ev_readed); return S_SUCCESS; } int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func) @@ -404,8 +391,11 @@ int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - func(err, code, oper, NULL, op_ev_write); - evoper_write_op(oper, op_ev_writed); + + if(evoper_writeing(oper) == S_SUCCESS) { + func(err, code, oper, NULL, op_ev_write); + } + return S_SUCCESS; } int evbuf_is_eof(evbuf_t* buf) diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 61ba973f..572a21ed 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -32,33 +32,37 @@ typedef _queue_t evoper_queue; typedef unsigned int evoper_ls; typedef struct evs_s evs_t; -#define op_ev_reading 0x01 -#define op_ev_readed 0x02 +#define op_ev_reading 0x01 +#define op_ev_readed 0x02 -#define op_ev_writeing 0x03 -#define op_ev_writed 0x04 +#define op_ev_writeing 0x11 +#define op_ev_writed 0x12 -#define op_ev_timering 0x05 -#define op_ev_timered 0x06 +#define op_ev_timering 0x21 +#define op_ev_timered 0x22 +#define op_ev_timerfailed 0x23 -#define op_ev_opening 0x07 -#define op_ev_opened 0x08 +#define op_ev_opening 0x31 +#define op_ev_opened 0x32 +#define op_ev_openfailed 0x33 -#define op_ev_connecting 0x09 -#define op_ev_connected 0x0A +#define op_ev_connecting 0x41 +#define op_ev_connected 0x42 +#define op_ev_connectfailed 0x43 -#define op_ev_accepting 0x0B -#define op_ev_accepted 0x0C +#define op_ev_accepting 0x51 +#define op_ev_accepted 0x52 +#define op_ev_acceptfailed 0x53 -#define op_ev_closeing 0x0D -#define op_ev_closed 0x0E +#define op_ev_closeing 0x61 +#define op_ev_closed 0x62 #ifndef ev_on -#define ev_on 0x00 +#define ev_on 0x00 #endif // !ev_on #ifndef ev_off -#define ev_off 0x01 +#define ev_off 0x01 #endif // !ev_off @@ -82,11 +86,9 @@ struct evoper_s { evevent conn; evevent read; - evevent ractive; evbuf_t rbuf; evevent write; - evevent wactive; evbuf_t wbuf; evevent accept; @@ -197,10 +199,6 @@ int evoper_connect_op(evoper_t* oper, evevent op); int evoper_connected(evoper_t* oper); int evoper_accept_op(evoper_t* oper, evevent op); int evoper_listen_size(evoper_t* oper, evoper_ls ls); -int evoper_read_active(evoper_t* oper, evevent op); -int evoper_read_activeing(evoper_t* oper); -int evoper_write_active(evoper_t* oper, evevent op); -int evoper_write_activeing(evoper_t* oper); int evoper_read_op(evoper_t* oper, evevent op); int evoper_reading(evoper_t* oper); int evoper_write_op(evoper_t* oper, evevent op); diff --git a/stdcrt/event/compat_event_win32.c b/stdcrt/event/compat_event_win32.c index 067ac1b0..467c6cf4 100644 --- a/stdcrt/event/compat_event_win32.c +++ b/stdcrt/event/compat_event_win32.c @@ -164,7 +164,7 @@ int win32_sock_accept(evoper_t* accept_oper, wsasock* sk) return rc; } -static int wsa_sock_recv(evoper_t* oper, int* ret, sock_size* bytes, evevent op) +static int wsa_sock_recv(evoper_t* oper, int* ret, sock_size* bytes) { int rc = S_ERROR; DWORD bytes_transferred = 0; @@ -189,16 +189,17 @@ static int wsa_sock_recv(evoper_t* oper, int* ret, sock_size* bytes, evevent op) wsabuf.buf = ptr; wsabuf.len = len & 0xFFFFFFFF; - if (op == ev_on) - *ret = WSARecv(oper->sock, &wsabuf, 1, &bytes_transferred, &flags, &ov->overlapped, NULL); - else - *ret = WSARecv(oper->sock, &wsabuf, 1, &bytes_transferred, &flags, NULL, NULL); - + /* + * if a socket was bound with I/O completion port + * then GetQueuedCompletionStatus() would anyway return its status + * despite that WSARecv() was already complete + */ + ov->r = ev_on; + *ret = WSARecv(oper->sock, &wsabuf, 1, &bytes_transferred, &flags, &ov->overlapped, NULL); *bytes = bytes_transferred; - return rc; } -static int wsa_sock_send(evoper_t* oper, int* ret, sock_size* bytes, evevent op) +static int wsa_sock_send(evoper_t* oper, int* ret, sock_size* bytes) { int rc = S_ERROR; DWORD bytes_transferred = 0; @@ -224,61 +225,17 @@ static int wsa_sock_send(evoper_t* oper, int* ret, sock_size* bytes, evevent op) wsabuf.buf = ptr; wsabuf.len = len & 0xFFFFFFFF; - if (op == ev_on) - *ret = WSASend(oper->sock, &wsabuf, 1, &bytes_transferred, flags, &ov->overlapped, NULL); - else - *ret = WSASend(oper->sock, &wsabuf, 1, &bytes_transferred, flags, NULL, NULL); - - + /* + * if a socket was bound with I/O completion port then + * GetQueuedCompletionStatus() would anyway return its status + * despite that WSASend() was already complete + */ + ov->w = ev_on; + *ret = WSASend(oper->sock, &wsabuf, 1, &bytes_transferred, flags, &ov->overlapped, NULL); *bytes = bytes_transferred; - return rc; } -sock_size win32_sock_read(evoper_t* oper, sock_size size) -{ - int ret = 0; - int rc = S_ERROR; - sock_size byte = 0; - crterr err = 0; - rc_error(oper != NULL, S_ERROR); - - rc = wsa_sock_recv(oper, &ret, &byte, ev_off); - err = crt_geterror(); - - if (err == ERROR_NETNAME_DELETED) - byte = 0; - else if (err == ERROR_PORT_UNREACHABLE) - byte = 0; - else if (err == WSAEMSGSIZE || err == ERROR_MORE_DATA) - ret = 0; - - if (ret != 0) - byte = 0; - - return byte; -} -sock_size win32_sock_write(evoper_t* oper, sock_size size) -{ - int ret = 0; - int rc = S_ERROR; - sock_size byte = 0; - crterr err = 0; - rc_error(oper != NULL, S_ERROR); - rc = wsa_sock_send(oper, &ret, &byte, ev_off); - err = crt_geterror(); - - if (err == ERROR_NETNAME_DELETED) - byte = 0; - else if (err == ERROR_PORT_UNREACHABLE) - byte = 0; - - if (ret != 0) - byte = -1; - - return byte; -} - int win32_sock_read_op(evoper_t* oper) { int ret = 0; @@ -286,7 +243,7 @@ int win32_sock_read_op(evoper_t* oper) sock_size byte = 0; crterr err = 0; rc_error(oper != NULL, S_ERROR); - rc = wsa_sock_recv(oper, &ret, &byte, ev_on); + rc = wsa_sock_recv(oper, &ret, &byte); err = crt_geterror(); if (err == ERROR_NETNAME_DELETED) @@ -326,7 +283,7 @@ int win32_sock_write_op(evoper_t* oper) crterr err = 0; rc_error(oper != NULL, S_ERROR); - rc = wsa_sock_send(oper, &ret, &byte, ev_on); + rc = wsa_sock_send(oper, &ret, &byte); err = crt_geterror(); if (err == ERROR_PORT_UNREACHABLE) diff --git a/stdcrt/event/compat_event_win32.h b/stdcrt/event/compat_event_win32.h index 447833cc..75cafaf6 100644 --- a/stdcrt/event/compat_event_win32.h +++ b/stdcrt/event/compat_event_win32.h @@ -14,8 +14,6 @@ int win32_sock_connect_ctx(evoper_t* oper); int win32_sock_accpet_ctx(evoper_t* oper, evoper_t* oper_s); int win32_sock_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv); int win32_sock_accept(evoper_t* oper, wsasock* sock); -sock_size win32_sock_read(evoper_t* oper, sock_size size); -sock_size win32_sock_write(evoper_t* oper, sock_size size); int win32_sock_read_op(evoper_t* oper); int win32_sock_write_op(evoper_t* oper); diff --git a/stdcrt/io/compat_file.c b/stdcrt/io/compat_file.c index bf95a93a..6c62ac12 100644 --- a/stdcrt/io/compat_file.c +++ b/stdcrt/io/compat_file.c @@ -341,4 +341,67 @@ int _file_unlink(const char* filepath) return unlink(filepath) == 0 ? S_SUCCESS : S_ERROR; } + +#elif (TARGET_OS == OS_UNIX) + +_fd_t _file_snamepipe(const char* name, long rsize, long wsize, int timeout, int flags, int mode) +{ + unlink(name); + + if (-1 == mkfifo(name, mode)) + return -1; + + return open(name, flags, mode); +} + +int _close_snamepipe(_fd_t fh) +{ + return _file_close(fh); +} +_fd_t _file_cnamepipe(const char* name, int flags, int mode) +{ + return _file_open(name, flags, mode); +} +int _close_cnamepipe(_fd_t fh) +{ + return _file_close(fh); +} +_fd_t _file_open(const basic_tchar* filepath, int flags, int mode) +{ + return open(filepath, flags, mode); +} +int _file_close(_fd_t fh) +{ + return close(fh); +} +_fd_size _file_lseek(_fd_t fh, _off_t offset, int whence) +{ + return lseek(fh, offset, whence); +} +_fd_len _file_read(_fd_t fh, void* buf, size_t size) +{ + return read(fh, buf, size); +} +_fd_len _file_write(_fd_t fh, const void* buf, size_t size) +{ + ssize_t len = write(fh, buf, size); + return size - len; +} +int64_t _file_fsize(_fd_t fh) +{ + struct stat sbuf; + if (fstat(fh, &sbuf) == -1) + return FILE_INVALID_VALUE; + return sbuf.st_size; +} + +int _file_delete(const basic_tchar* filepath) +{ + return unlink(filepath) == 0 ? S_SUCCESS : S_ERROR; +} +int _file_unlink(const char* filepath) +{ + return unlink(filepath) == 0 ? S_SUCCESS : S_ERROR; +} + #endif diff --git a/stdcrt/io/compat_path.c b/stdcrt/io/compat_path.c index c659b493..b4b28a80 100644 --- a/stdcrt/io/compat_path.c +++ b/stdcrt/io/compat_path.c @@ -20,6 +20,8 @@ #endif +#elif (TARGET_OS == OS_UNIX) +#define CTL_PluginExtName _T(".so") #endif int fileisexist(const basic_tchar* file) @@ -45,6 +47,12 @@ int fileisexist(const basic_tchar* file) if (fd != F_OK) return S_ERROR; +#elif (TARGET_OS == OS_UNIX) + + int fd = access(file, F_OK); + if (fd != F_OK) + return S_ERROR; + #endif return S_SUCCESS; } @@ -72,6 +80,13 @@ int fileisdirectory(const basic_tchar* dir) if (res == 0 && S_ISDIR(st.st_mode)) rc = S_SUCCESS; +#elif (TARGET_OS == OS_UNIX) + + struct stat st; + int res = stat(dir, &st); + if (res == 0 && S_ISDIR(st.st_mode)) + rc = S_SUCCESS; + #endif return rc; @@ -97,6 +112,14 @@ int get_dynamicpath(void* name, basic_tchar* path, size_t len) string_strcpy(path, len, info.dli_fname); return rc == 0 ? S_SUCCESS : S_ERROR; +#elif (TARGET_OS == OS_UNIX) + + Dl_info info = {0x00}; + int rc = 0; + rc = dladdr((void*)name, &info); + string_strcpy(path, len, info.dli_fname); + return rc == 0 ? S_SUCCESS : S_ERROR; + #endif return S_SUCCESS; } @@ -147,6 +170,29 @@ int get_executepath(_pid_t pid, basic_tchar* path, pathlen len) s_strcpy(path, count, buf); return S_SUCCESS; +#elif (TARGET_OS == OS_UNIX) + + int count = 0; + char* path_end = NULL; + pid_t cur_pid = getpid(); + char cur_exe_link[MAX_PATH] = {0}; + sprintf(cur_exe_link, "/proc/%u/exe", cur_pid); + count = readlink(cur_exe_link, buf, MAX_PATH + 1); + if (count < 0 || count >= MAX_PATH) + return FALSE; + + int iloop; + buf[count] = '\0'; + for (iloop = count; iloop >= 0; iloop--) { + if (buf[iloop] == '/') { + buf[iloop + 1] = '\0'; + break; + } + } + + s_strcpy(path, len, buf); + return S_SUCCESS; + #endif return S_SUCCESS; } @@ -183,6 +229,10 @@ int get_dynamicname(const basic_tchar* name, basic_tchar* pluginame, size_t len) #endif +#elif (TARGET_OS == OS_UNIX) + s_strcat(pluginame, len, _T("lib")); + s_strcat(pluginame, len, name); + #endif tstring_strcat(pluginame, len, CTL_PluginExtName); @@ -339,6 +389,60 @@ int get_file_info(basic_tchar* name, get_file_cb entry, void* ctx) return S_SUCCESS; } + + +#elif (TARGET_OS == OS_UNIX) + +#include +#include + +#define FILE_MAX_PATH 512 + +void dirwalk(basic_tchar* dir, int (*func)(basic_tchar* name, get_file_cb entry, void* ctx), get_file_cb entry, void* ctx) +{ + char name[FILE_MAX_PATH] = {0x00}; + struct dirent* dp = NULL; + DIR* dfd = NULL; + + if ((dfd = opendir(dir)) == NULL) { + fprintf(stderr, "dirwalk: can't open %s\n", dir); + return; + } + + while ((dp = readdir(dfd)) != NULL) { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) { + continue; + } + + if (strlen(dir) + strlen(dp->d_name) + 2 > sizeof(name)) { + fprintf(stderr, "dirwalk : name %s %s too long\n", dir, dp->d_name); + } else { + sprintf(name, "%s/%s", dir, dp->d_name); + (*func)(name, entry, ctx); + } + } + closedir(dfd); +} + +int get_file_info(basic_tchar* name, get_file_cb entry, void* ctx) +{ + struct stat stbuf; + + if (stat(name, &stbuf) == -1) { + fprintf(stderr, "file size: open %s failed\n", name); + return S_ERROR; + } + + if ((stbuf.st_mode & S_IFMT) == S_IFDIR) { + dirwalk(name, get_file_info, entry, ctx); + } else { + // printf("%8ld %s\n", stbuf.st_size, name); + entry(name, ctx); + } + return S_SUCCESS; +} + + #endif int get_files(basic_tchar* path, get_file_cb entry, void* ctx) diff --git a/stdcrt/net/compat_sockinet.c b/stdcrt/net/compat_sockinet.c index 945e18db..f5c92fd4 100644 --- a/stdcrt/net/compat_sockinet.c +++ b/stdcrt/net/compat_sockinet.c @@ -380,16 +380,26 @@ int _inet_pton(int af, const char* src, void* dst) return -1; } + char* inet_ntop4(const unsigned char* src, char* dst, size_t size) { + int alen = s_strlen("255.255.255.255"); + char tmp[sizeof("255.255.255.255")]; size_t len; tmp[0] = '\0'; + +#if (TARGET_OS == OS_UNIX) + + snprintf( + tmp, alen, "%d.%d.%d.%d", ((int)((unsigned char)src[0])) & 0xff, ((int)((unsigned char)src[1])) & 0xff, ((int)((unsigned char)src[2])) & 0xff, + ((int)((unsigned char)src[3])) & 0xff); +#else sprintf( tmp, "%d.%d.%d.%d", ((int)((unsigned char)src[0])) & 0xff, ((int)((unsigned char)src[1])) & 0xff, ((int)((unsigned char)src[2])) & 0xff, ((int)((unsigned char)src[3])) & 0xff); - +#endif // a[0] = ((inaddr & 0xff000000) >> 24); // a[1] = ((inaddr & 0x00ff0000) >> 16); // a[2] = ((inaddr & 0x0000ff00) >> 8); diff --git a/stdcrt/stdlib/compat_atomic.c b/stdcrt/stdlib/compat_atomic.c index 26ccc058..0f18d403 100644 --- a/stdcrt/stdlib/compat_atomic.c +++ b/stdcrt/stdlib/compat_atomic.c @@ -86,6 +86,11 @@ atomic_type _atomic_uninit(_atomic_t* self) self->value = 0; OSAtomicCompareAndSwap32Barrier(self->value, 0, &self->value); return self->value; + +#elif (TARGET_OS == OS_UNIX) + __sync_lock_test_and_set(&self->value, 0); + return self->value; + #endif } @@ -194,5 +199,24 @@ int _atomic_cmp(atomic_type comp, _atomic_t* self) _mutex_unlock(&self->lock); return OSAtomicCompareAndSwap32Barrier(comp, value, &self->value); + + + +#elif (TARGET_OS == OS_UNIX) + + atomic_type original = 0; +#if defined(__GNUC__) && (__GNUC__ >= 4) + value = self->value; + return __sync_bool_compare_and_swap(&self->value, comp, value); +#else + _mutex_lock(&self->lock); + original = self->value; + _mutex_unlock(&self->lock); + + return comp == original; +#endif + + #endif + } diff --git a/stdcrt/stdlib/compat_clock.c b/stdcrt/stdlib/compat_clock.c index 29b9fb13..da36501d 100644 --- a/stdcrt/stdlib/compat_clock.c +++ b/stdcrt/stdlib/compat_clock.c @@ -101,9 +101,9 @@ int get_clock(_clock_t* clock, struct timeval* tv) tv->tv_sec = usec / 1000000; tv->tv_usec = usec % 1000000; -#else +#elif (TARGET_OS == OS_UNIX) - rc = gettimeofday(&tv, NULL); + gettimeofday(tv, NULL); #endif diff --git a/stdcrt/stdlib/compat_dll.c b/stdcrt/stdlib/compat_dll.c index 43fc14e8..a1502e11 100644 --- a/stdcrt/stdlib/compat_dll.c +++ b/stdcrt/stdlib/compat_dll.c @@ -32,6 +32,14 @@ void* dllsym(HMODULE handler, char* sym) return pFunc; } return pFunc; +#elif (TARGET_OS == OS_UNIX) + void* pFunc = dlsym(handler, sym); + if (pFunc == NULL) { + char* pszErr = dlerror(); + printf("%s\n", pszErr); + return pFunc; + } + return pFunc; #endif return 0; } @@ -44,6 +52,8 @@ int dllclose(HMODULE handler) return dlclose(handler); #elif (TARGET_OS == OS_MACH) return dlclose(handler); +#elif (TARGET_OS == OS_UNIX) + return dlclose(handler); #endif return 0; } diff --git a/stdcrt/stdlib/compat_list.c b/stdcrt/stdlib/compat_list.c index 02dc7a62..4362a8d4 100644 --- a/stdcrt/stdlib/compat_list.c +++ b/stdcrt/stdlib/compat_list.c @@ -35,7 +35,7 @@ struct _list_item* _list_prev(struct _list_s* self, struct _list_item* it) return it->prev; } -struct _list_item* _list_next(_unused struct _list_s* self, struct _list_item* it) +struct _list_item* _list_next(struct _list_s* self, struct _list_item* it) { rc_error(it->next != _LIST_NOTINLIST, NULL); return it->next; diff --git a/stdcrt/stdlib/compat_stdtime.c b/stdcrt/stdlib/compat_stdtime.c index 638b7b1f..c1c1673f 100644 --- a/stdcrt/stdlib/compat_stdtime.c +++ b/stdcrt/stdlib/compat_stdtime.c @@ -73,6 +73,12 @@ unsigned long GetTickCount(void) return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000); } +#elif (TARGET_OS == OS_UNIX) + +unsigned long GetTickCount(void) +{ + return 1000000; +} #endif uint64_t _gettimeofday_s(void) @@ -108,6 +114,7 @@ uint64_t _gettimeofday_us(void) uint64_t _getclock_ms(void) { + int rc; #if (TARGET_OS == OS_WIN) LARGE_INTEGER tps; @@ -120,7 +127,7 @@ uint64_t _getclock_ms(void) #elif (TARGET_OS == OS_POSIX) - int rc; + struct timespec tv; #ifdef CLOCK_MONOTONIC_FAST @@ -163,6 +170,8 @@ struct tm* _localtime_t(const time_t* timep, struct tm* result) return localtime_r(timep, result); #elif (TARGET_OS == OS_MACH) return localtime_r(timep, result); +#elif (TARGET_OS == OS_UNIX) + return localtime_r(timep, result); #endif } diff --git a/stdcrt/string/compat_utf8.c b/stdcrt/string/compat_utf8.c index d9f85bae..b422e13e 100644 --- a/stdcrt/string/compat_utf8.c +++ b/stdcrt/string/compat_utf8.c @@ -42,6 +42,8 @@ size_t wchar_to_char_s(const wchar_t* in, size_t inlen, char* out, size_t outlen return wcstombs(out, in, outlen); #elif (TARGET_OS == OS_MACH) return wcstombs(out, in, outlen); +#elif (TARGET_OS == OS_UNIX) + return wcstombs(out, in, outlen); #endif } size_t char_to_wchar_s(const char* in, size_t len, wchar_t* out, size_t outlen) @@ -52,6 +54,8 @@ size_t char_to_wchar_s(const char* in, size_t len, wchar_t* out, size_t outlen) return mbstowcs(out, in, outlen); #elif (TARGET_OS == OS_MACH) return mbstowcs(out, in, outlen); +#elif (TARGET_OS == OS_UNIX) + return mbstowcs(out, in, outlen); #endif } diff --git a/stdcrt/thread/compat_barrier.c b/stdcrt/thread/compat_barrier.c index 6afb5165..994124ee 100644 --- a/stdcrt/thread/compat_barrier.c +++ b/stdcrt/thread/compat_barrier.c @@ -201,4 +201,72 @@ int _barrier_wait(_barrier_t* barrier) return last; } +#elif (TARGET_OS == OS_UNIX) + +int _barrier_init(_barrier_t* barrier, unsigned int count) +{ + rc_error(barrier != NULL, S_ERROR); + int rc = 0; + barrier->in = 0; + barrier->out = 0; + barrier->threshold = count; + + rc = pthread_mutex_init(&barrier->mutex, NULL); + if (rc != 0) + goto error2; + + rc = pthread_cond_init(&barrier->cond, NULL); + if (rc != 0) + goto error; + + return S_SUCCESS; + +error: + pthread_mutex_destroy(&barrier->mutex); +error2: + return rc; +} +int _barrier_destroy(_barrier_t* barrier) +{ + rc_error(barrier != NULL, S_ERROR); + pthread_mutex_lock(&barrier->mutex); + + while (barrier->out != 0) + pthread_cond_wait(&barrier->cond, &barrier->mutex); + + if (barrier->in != 0) + abort(); + + pthread_mutex_unlock(&barrier->mutex); + + pthread_mutex_destroy(&barrier->mutex); + pthread_cond_destroy(&barrier->cond); + + return S_SUCCESS; +} +int _barrier_wait(_barrier_t* barrier) +{ + rc_error(barrier != NULL, S_ERROR); + int last = 0; + + pthread_mutex_lock(&barrier->mutex); + + if (++barrier->in == barrier->threshold) { + barrier->in = 0; + barrier->out = barrier->threshold; + pthread_cond_signal(&barrier->cond); + } else { + do { + pthread_cond_wait(&barrier->cond, &barrier->mutex); + } while (barrier->in != 0); + } + + last = (--barrier->out == 0); + pthread_cond_signal(&barrier->cond); + + pthread_mutex_unlock(&barrier->mutex); + + return last; +} + #endif diff --git a/stdcrt/thread/compat_cond.c b/stdcrt/thread/compat_cond.c index f75701d5..e3f296f9 100644 --- a/stdcrt/thread/compat_cond.c +++ b/stdcrt/thread/compat_cond.c @@ -343,4 +343,112 @@ int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) return S_SUCCESS; } +#elif (TARGET_OS == OS_UNIX) + +int _cond_init(_cond_t* cond) +{ + rc_error(cond != NULL, S_ERROR); + + if (pthread_mutex_init(&cond->mutex, NULL)) { + return S_ERROR; + } + + if (cond->relative) { + int ret = 0; + ret = pthread_condattr_init(&cond->attr); + ret = pthread_condattr_setclock(&cond->attr, CLOCK_MONOTONIC); + + if (pthread_cond_init(&cond->c, &cond->attr)) { + return S_ERROR; + } + } else { + if (pthread_cond_init(&cond->c, NULL)) { + return S_ERROR; + } + } + return S_SUCCESS; +} + +int _cond_destroy(_cond_t* cond) +{ + rc_error(cond != NULL, S_ERROR); + + if (cond->relative) { + pthread_condattr_destroy(&(cond->attr)); + } + + if (pthread_mutex_destroy(&cond->mutex)) { } + + if (pthread_cond_destroy(&cond->c)) { + return S_ERROR; + } + return S_SUCCESS; +} + +int _cond_signal(_cond_t* cond) +{ + rc_error(cond != NULL, S_ERROR); + if (pthread_cond_signal(&cond->c)) { + return S_ERROR; + } + return S_SUCCESS; +} + +int _cond_broadcast(_cond_t* cond) +{ + rc_error(cond != NULL, S_ERROR); + if (pthread_cond_broadcast(&cond->c)) { + return S_ERROR; + } + return S_SUCCESS; +} + +int _cond_wait(_cond_t* cond, _mutex_t* lock) +{ + rc_error(cond != NULL, S_ERROR); + rc_error(lock != NULL, S_ERROR); + if (pthread_cond_wait(&cond->c, &lock->mutex)) { + return S_ERROR; + } + return S_SUCCESS; +} + +int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) +{ + rc_error(cond != NULL, S_ERROR); + rc_error(lock != NULL, S_ERROR); + int rc; + int retval; + + struct timeval delta; + struct timespec abstime; + + if (cond->relative) { + clock_gettime(CLOCK_MONOTONIC, &abstime); + abstime.tv_nsec += (ms % 1000) * 1000000; + abstime.tv_sec += ms / 1000; + } else { + gettimeofday(&delta, NULL); + abstime.tv_sec = delta.tv_sec + (ms / 1000); + abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000; + } + + if (abstime.tv_nsec > 1000000000) { + abstime.tv_sec += 1; + abstime.tv_nsec -= 1000000000; + } + + rc = pthread_cond_timedwait(&cond->c, &lock->mutex, &abstime); + + if (rc == ETIMEDOUT) + return S_TIMEOUT; + + if (rc) { + return S_ERROR; + } + + return S_SUCCESS; +} + + #endif diff --git a/stdcrt/thread/compat_mutex.c b/stdcrt/thread/compat_mutex.c index 7b90153c..d8348ad9 100644 --- a/stdcrt/thread/compat_mutex.c +++ b/stdcrt/thread/compat_mutex.c @@ -193,4 +193,76 @@ int _mutex_unlock(_mutex_t* lock) return S_SUCCESS; } + +#elif (TARGET_OS == OS_UNIX) + +int _mutex_init(_mutex_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_mutex_init(&lock->mutex, NULL)) { + return S_ERROR; + } + return S_SUCCESS; +} + +int _mutex_init_recursive(_mutex_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + pthread_mutexattr_t attr; + + if (pthread_mutexattr_init(&attr)) { + return S_ERROR; + } + + if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) { + return S_ERROR; + } + + if (pthread_mutex_init(&lock->mutex, &attr)) { + return S_ERROR; + } + + if (pthread_mutexattr_destroy(&attr)) { + return S_ERROR; + } + + return S_SUCCESS; +} + +int _mutex_destroy(_mutex_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_mutex_destroy(&lock->mutex)) { + return S_ERROR; + } + return S_SUCCESS; +} + +int _mutex_lock(_mutex_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_mutex_lock(&lock->mutex)) { + return S_ERROR; + } + return S_SUCCESS; +} + +int _mutex_trylock(_mutex_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_mutex_trylock(&lock->mutex)) { + return S_ERROR; + } + return S_SUCCESS; +} + +int _mutex_unlock(_mutex_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_mutex_unlock(&lock->mutex)) { + return S_ERROR; + } + return S_SUCCESS; +} + #endif diff --git a/stdcrt/thread/compat_rwlock.c b/stdcrt/thread/compat_rwlock.c index 8f80dcae..e8ae0d53 100644 --- a/stdcrt/thread/compat_rwlock.c +++ b/stdcrt/thread/compat_rwlock.c @@ -297,4 +297,86 @@ int _rwlock_wrunlock(_rwlock_t* lock) return S_SUCCESS; } +#elif (TARGET_OS == OS_UNIX) + +int _rwlock_init(_rwlock_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_rwlock_init(&lock->rwlock, NULL)) { + return S_ERROR; + } + + return S_SUCCESS; +} + +int _rwlock_destroy(_rwlock_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_rwlock_destroy(&lock->rwlock)) { + return S_ERROR; + } + + return S_SUCCESS; +} + +int _rwlock_rdlock(_rwlock_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_rwlock_rdlock(&lock->rwlock)) { + return S_ERROR; + } + return S_SUCCESS; +} + +int _rwlock_tryrdlock(_rwlock_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_rwlock_tryrdlock(&lock->rwlock)) { + return S_ERROR; + } + + return S_SUCCESS; +} + +int _rwlock_rdunlock(_rwlock_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_rwlock_unlock(&lock->rwlock)) { + return S_ERROR; + } + + return S_SUCCESS; +} + +int _rwlock_wrlock(_rwlock_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_rwlock_wrlock(&lock->rwlock)) { + return S_ERROR; + } + + return S_SUCCESS; +} + +int _rwlock_trywrlock(_rwlock_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_rwlock_trywrlock(&lock->rwlock)) { + return S_ERROR; + } + + return S_SUCCESS; +} + +int _rwlock_wrunlock(_rwlock_t* lock) +{ + rc_error(lock != NULL, S_ERROR); + if (pthread_rwlock_unlock(&lock->rwlock)) { + return S_ERROR; + } + + return S_SUCCESS; +} + + #endif diff --git a/stdcrt/thread/compat_sem.c b/stdcrt/thread/compat_sem.c index b961392d..eee50c91 100644 --- a/stdcrt/thread/compat_sem.c +++ b/stdcrt/thread/compat_sem.c @@ -245,4 +245,52 @@ int _sem_wait_time(_sem_t* sem, unsigned int sec) return S_ERROR; } +#elif (TARGET_OS == OS_UNIX) + +int _sem_init(_sem_t* sem, unsigned int value) +{ + int r = 0; + rc_error(sem != NULL, S_ERROR); + + return S_SUCCESS; +} + +int _sem_destroy(_sem_t* sem) +{ + int r = 0; + rc_error(sem != NULL, S_ERROR); + + return S_SUCCESS; +} + +int _sem_post(_sem_t* sem) +{ + int r = 0; + rc_error(sem != NULL, S_ERROR); + return S_SUCCESS; +} +int _sem_wait(_sem_t* sem) +{ + int r = 0; + rc_error(sem != NULL, S_ERROR); + + return S_SUCCESS; +} + +int _sem_trywait(_sem_t* sem) +{ + int r = 0; + + rc_error(sem != NULL, S_ERROR); + + return S_SUCCESS; +} +int _sem_wait_time(_sem_t* sem, unsigned int sec) +{ + int r = 0; + rc_error(sem != NULL, S_ERROR); + + return S_SUCCESS; +} + #endif diff --git a/stdcrt/thread/compat_thread.c b/stdcrt/thread/compat_thread.c index 16775edc..9866db82 100644 --- a/stdcrt/thread/compat_thread.c +++ b/stdcrt/thread/compat_thread.c @@ -201,4 +201,69 @@ _thread_id _get_threadid(_thread_t* tid) return (uint64_t)(uintptr_t)pthread_self(); } +#elif (TARGET_OS == OS_UNIX) + +static size_t thread_stack_size(void) +{ + struct rlimit lim; + + if (getrlimit(RLIMIT_STACK, &lim)) { + abort(); + } + + if (lim.rlim_cur != RLIM_INFINITY) { + lim.rlim_cur -= lim.rlim_cur % (rlim_t)getpagesize(); + if (lim.rlim_cur >= PTHREAD_STACK_MIN) + return lim.rlim_cur; + } + return 0; +} + +int _thread_create(_thread_t* tid, _thread_proc entry, void* arg) +{ + int err; + size_t stack_size; + pthread_attr_t* attr; + pthread_attr_t attr_storage; + + attr = NULL; + stack_size = thread_stack_size(); + + if (stack_size > 0) { + attr = &attr_storage; + + if (pthread_attr_init(attr)) + abort(); + + if (pthread_attr_setstacksize(attr, stack_size)) + abort(); + } + + err = pthread_create(tid, attr, (void* (*)(void*))entry, arg); + + if (attr != NULL) + pthread_attr_destroy(attr); + + return err; +} +int _thread_join(_thread_t* tid) +{ + return pthread_join(*tid, NULL); +} + +int _thread_equal(const _thread_t* t1, const _thread_t* t2) +{ + return pthread_equal(*t1, *t2); +} + +_thread_id _get_cthreadid(void) +{ + return (uint64_t)(uintptr_t)pthread_self(); +} +_thread_id _get_threadid(_thread_t* tid) +{ + return (uint64_t)(uintptr_t)pthread_self(); +} + + #endif diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index e30ff8f0..3fef9ba7 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -5,8 +5,6 @@ // #pragma comment(lib, "shell32.lib") // #pragma comment(linker, "/ENTRY:main") - - int main(int argc, char* argv[]) { init_sockenv(2, 2); diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index 152ed26d..e01746f3 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -7,7 +7,7 @@ evoper_t* w_oper; evoper_t* r_oper; evoper_t* accept_oper; -#define buf_len 5 +#define buf_len 1 unsigned char* send_data; unsigned char* recv_data; @@ -32,6 +32,7 @@ void thread_proc1(void* ctx) void thread_proc2(void* ctx) { _cond_wait(&r_cond, &r_mutex); + sleep_time(10); test_read_oper(loop); while (1) { sleep_time(10); @@ -42,15 +43,11 @@ void thread_proc2(void* ctx) void thread_proc3(void* ctx) { _cond_wait(&w_cond, &w_mutex); - sleep_time(15); test_write_oper(loop); while (1) { sleep_time(15); - test_write_oper(loop); } } - - void test_init_evaddr() { _cond_init(&r_cond); @@ -105,9 +102,20 @@ int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) } else if (event == op_ev_write && res == op_ev_success) { iwrite++; logi("write %d\n", iwrite); + + evoper_write_buf(w_oper, (buf_ptr)send_data + iwrite, buf_len); + + if (iwrite == 10) + evloop_disable_write(loop, oper); + } else if (event == op_ev_read && res == op_ev_success) { iread++; - logi("read %d == %d\n", iread, iwrite); + logi("read %d\n", iread); + + printf("read string %s\n", recv_data); + + if (iread == 10) + evloop_disable_read(loop, oper); } return S_SUCCESS; } @@ -127,7 +135,6 @@ void test_accept_oper(evloop_t* loop) logi("evoper_pollsock error"); return; } - bind_loop(loop, accept_oper); evloop_poll(accept_oper, 1); } @@ -142,7 +149,7 @@ void test_conn_oper(evloop_t* loop) void test_write_oper(evloop_t* loop) { int rc = 0; - s_strncpy(send_data, "hello", 5); + s_strncpy(send_data, "hello,hello", 11); rc = evoper_write_buf(w_oper, (buf_ptr)send_data, buf_len); if (rc != S_SUCCESS) { @@ -152,11 +159,8 @@ void test_write_oper(evloop_t* loop) rc = evloop_enable_write(loop, w_oper, op_ev_oneshot, NULL); if (rc != S_SUCCESS) { - if (rc == S_COMPLETED) { - - } - else if (rc != S_PENDING) { + } else if (rc != S_PENDING) { logi("evloop_add_write"); } } @@ -183,13 +187,4 @@ void test_read_oper(evloop_t* loop) } } - rc = evloop_enable_read(loop, r_oper, op_ev_active, NULL); - - if (rc != S_SUCCESS) { - if (rc == S_COMPLETED) { - } else if (rc != S_PENDING) { - logi("evloop_add_read"); - } - } - } -- Gitee From 9d3710c650243af3863ce86f206b1965219c081f Mon Sep 17 00:00:00 2001 From: com Date: Mon, 12 Aug 2024 10:59:58 +0800 Subject: [PATCH 17/34] up --- stdcrt/event/compat_event_win32.c | 42 +++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/stdcrt/event/compat_event_win32.c b/stdcrt/event/compat_event_win32.c index 467c6cf4..bee6ede0 100644 --- a/stdcrt/event/compat_event_win32.c +++ b/stdcrt/event/compat_event_win32.c @@ -246,11 +246,19 @@ int win32_sock_read_op(evoper_t* oper) rc = wsa_sock_recv(oper, &ret, &byte); err = crt_geterror(); - if (err == ERROR_NETNAME_DELETED) - rc = S_ERROR; - else if (err == ERROR_PORT_UNREACHABLE) - rc = S_ERROR; + if (ret == SOCKET_ERROR) { + + if (err == ERROR_NETNAME_DELETED) { + rc = S_ERROR; + goto end; + } else if (err == ERROR_PORT_UNREACHABLE) { + rc = S_ERROR; + goto end; + } + + } + if (ret == 0) { evbuf_op_off(&oper->rbuf, byte); if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { @@ -284,10 +292,29 @@ int win32_sock_write_op(evoper_t* oper) rc_error(oper != NULL, S_ERROR); rc = wsa_sock_send(oper, &ret, &byte); - err = crt_geterror(); + + if (ret == SOCKET_ERROR) { - if (err == ERROR_PORT_UNREACHABLE) - rc = S_ERROR; + err = crt_geterror(); + + if (err == WSAEWOULDBLOCK) { + + } else if (err == WSAECONNABORTED || err == WSAECONNRESET) { + // Connection aborted or reset, close and reconnect + rc = S_ERROR; + } else if (err == WSAENETDOWN || err == WSAENETUNREACH) { + // Network malfunction, check network connection + rc = S_ERROR; + } else if (err == WSAETIMEDOUT) { + // Connection timeout, try reconnecting or increasing timeout + rc = S_ERROR; + } else if (err == WSAECONNREFUSED) { + // Connection rejected, ensure that the server is running and accepting the connection + rc = S_ERROR; + } else if (err == ERROR_PORT_UNREACHABLE) { + rc = S_ERROR; + } + } if (ret == 0) { @@ -308,7 +335,6 @@ int win32_sock_write_op(evoper_t* oper) goto end; } - return S_ERROR; end: return rc; -- Gitee From 69390ca34799568e13cd907aca76048a781255b3 Mon Sep 17 00:00:00 2001 From: com Date: Tue, 13 Aug 2024 13:18:12 +0800 Subject: [PATCH 18/34] up --- crt/crt_sock.h | 2 + crt/crt_vsnprintf.h | 1 + stdcrt/code/compat_sjson.c | 2 +- stdcrt/event/compat_event.c | 8 +-- stdcrt/event/compat_event_epoll.c | 32 ++++------- stdcrt/event/compat_event_kqueue.c | 31 ++++------- stdcrt/event/compat_event_kqueue.h | 2 +- stdcrt/event/compat_event_mach.c | 66 ++++++++++++++++++++++- stdcrt/event/compat_event_mach.h | 4 +- stdcrt/event/compat_event_posix.c | 64 ++++++++++++++++++++++ stdcrt/event/compat_event_posix.h | 2 + stdcrt/event/compat_event_util.c | 14 ++--- stdcrt/net/compat_sock.c | 16 ++++++ stdcrt/net/compat_sockinet.c | 4 +- stdcrt/stdlib/compat_atomic.c | 85 ++++++++++++++++++------------ stdcrt/stdlib/compat_memory.c | 8 +++ stdcrt/stdlib/compat_proctl.c | 4 ++ stdcrt/stdlib/compat_vsnprintf.c | 17 +++++- stdcrt/string/compat_utf8.c | 5 ++ stdcrt_test/main.c | 4 ++ stdcrt_test/test.h | 1 + stdcrt_test/test_oper.c | 33 ++++++++---- 22 files changed, 301 insertions(+), 104 deletions(-) diff --git a/crt/crt_sock.h b/crt/crt_sock.h index 13ada9cc..f4f67df4 100644 --- a/crt/crt_sock.h +++ b/crt/crt_sock.h @@ -12,6 +12,8 @@ extern "C" { #elif (TARGET_OS == OS_POSIX) #include #elif (TARGET_OS == OS_MACH) +#include + #elif (TARGET_OS == OS_UNIX) #include #endif diff --git a/crt/crt_vsnprintf.h b/crt/crt_vsnprintf.h index 0d7dc0fd..7f0127e5 100644 --- a/crt/crt_vsnprintf.h +++ b/crt/crt_vsnprintf.h @@ -8,6 +8,7 @@ extern "C" { #endif int s_vsnprintf(char* str, int size, const char* format, ...); +int s_snprintf(char* str, int size, const char* format, ...); #ifdef __cplusplus } diff --git a/stdcrt/code/compat_sjson.c b/stdcrt/code/compat_sjson.c index ff9c7fe7..4d97dcbb 100644 --- a/stdcrt/code/compat_sjson.c +++ b/stdcrt/code/compat_sjson.c @@ -589,7 +589,7 @@ static int print_string_ptr(const unsigned char* const input, sjsonprintvptr out if (output == NULL) { return sjson_false; } - strcpy((char*)output, "\"\""); + s_strncpy((char*)output, "\"\"", s_strlen("\"\"")); return sjson_true; } diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index bc554df2..c17165d3 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -7,6 +7,8 @@ #include "compat_event_epoll.h" #elif (TARGET_OS == OS_MACH) #include "compat_event_kqueue.h" +#elif (TARGET_OS == OS_UNIX) +#include "compat_event_kqueue.h" #endif static int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) @@ -23,20 +25,16 @@ static int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, e if (op == op_ev_read) { if (oper->bt == ev_io_complete) { - logi("ev_io_complete"); oper->handler(op_ev_success, oper, oper, op_ev_read); } else if (oper->bt == ev_func_complete) { - logi("ev_func_complete"); oper->handler(op_ev_success, oper, oper, op_ev_read); } } if (op == op_ev_write) { if (oper->bt == ev_io_complete) { - logi("ev_io_complete"); oper->handler(op_ev_success, oper, oper, op_ev_write); } else if (oper->bt == ev_func_complete) { - logi("ev_func_complete"); oper->handler(op_ev_success, oper, oper, op_ev_write); } } @@ -78,6 +76,8 @@ static int evsysop_init(evsysop_t* op, int flag) rc = epoll_evop_t(op); #elif (TARGET_OS == OS_MACH) rc = kqueue_evop_t(op); +#elif (TARGET_OS == OS_UNIX) + rc = kqueue_evop_t(op); #endif return rc; } diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index deef9e89..b2448eec 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -45,7 +45,7 @@ #define epoll_use 1 -#define ev_base_event (EPOLLET | EPOLLERR) +#define ev_base_event (EPOLLET |EPOLLERR) #ifdef EPOLLEXCLUSIVE #define ev_poll_event (EPOLLIN /*| EPOLLEXCLUSIVE*/) #else @@ -54,7 +54,7 @@ #define ev_conn_event (EPOLLOUT) #define ev_read_event (EPOLLIN | EPOLLRDHUP) #define ev_write_event (EPOLLOUT) -#define ev_clear_event (EPOLLET) +#define ev_clear_event (0) #define ev_oneshot_write_event (EPOLLOUT | EPOLLONESHOT) #define ev_oneshot_read_event (EPOLLIN | EPOLLONESHOT) @@ -227,8 +227,6 @@ int epoll_alloc(evloop_t* loop, int size) if (base->poll == NULL) goto err; - - return evloop_bind_evbase(loop, base); err: loop->mm_free(loop, base); @@ -294,20 +292,12 @@ int epoll_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) rc_error(base != NULL, S_ERROR); epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - //reading - rc_error(evoper_reading(oper) != S_SUCCESS, S_ERROR); - evoper_read_op(oper, op_ev_reading); // add epoll uint32_t op = epoll_event_add(ptr, ev_read_event); set_epoll_op(ptr, op); epoll_op(base, oper, ptr, EPOLL_CTL_MOD); //recv rc = posix_tcpsock_recv(oper, 0); - // res - if (rc == S_COMPLETED) { - oper->bt = ev_func_complete; - base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); - } return rc; } @@ -319,20 +309,15 @@ int epoll_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv rc_error(base != NULL, S_ERROR); epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - //writeing - rc_error(evoper_writeing(oper) != S_SUCCESS, S_ERROR); - evoper_write_op(oper, op_ev_writeing); + // add epoll uint32_t op = epoll_event_add(ptr, ev_write_event); set_epoll_op(ptr, op); rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); + //send rc = posix_tcpsock_send(oper, 0); - //res - if (rc == S_COMPLETED) { - oper->bt = ev_func_complete; - base->ev(S_SUCCESS, 0, oper, oper, op_ev_write); - } + return rc; } int epoll_disable_read(evloop_t* loop, evoper_t* oper, short event) @@ -492,13 +477,18 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) oper->bt = ev_io_complete; complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); } - if (events & EPOLLOUT) { + if (oper->conn == op_ev_connecting) { complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); continue; } + + oper->bt = ev_io_complete; complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); + + if (evoper_writeing(oper) == S_SUCCESS) + epoll_tcpsock_send(oper, S_SUCCESS, err, base->ev); } } diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 794ebac5..23e43381 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -1,7 +1,7 @@ #include "compat_event_kqueue.h" #include "compat_event_mach.h" -#if (TARGET_OS == OS_MACH) +#if (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) #define ev_base_event 0 @@ -187,23 +187,13 @@ int kqueue_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - //reading - rc_error(evoper_reading(oper) != S_SUCCESS, S_ERROR); - evoper_read_op(oper, op_ev_reading); - //activeing - evoper_read_active(oper, event == op_ev_active ? ev_on : ev_off); - //recv - rc = mach_tcpsock_recv(oper, 0); //add kqueue set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event); - //res - if (rc == S_COMPLETED) { - oper->bt = ev_func_complete; - base->ev(S_SUCCESS, 0, oper, oper, op_ev_read); - } - + //recv + rc = mach_tcpsock_recv(oper, 0); + return S_SUCCESS; } int kqueue_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) @@ -215,16 +205,13 @@ int kqueue_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t t kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - rc_error(evoper_writeing(oper) != S_SUCCESS, S_ERROR); - evoper_write_op(oper, op_ev_writeing); - //activeing - evoper_write_active(oper, event == op_ev_active ? ev_on : ev_off); - //send - rc = mach_tcpsock_send(oper, 0); //add kqueue set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); kqueue_op_ctl(base, oper, ptr, NULL, ev_write_event); + //send + rc = mach_tcpsock_send(oper, 0); + return S_SUCCESS; } int kqueue_disable_read(evloop_t* loop, evoper_t* oper, short event) @@ -353,6 +340,10 @@ static int kqueue_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) } oper->bt = ev_io_complete; complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); + + if (evoper_writeing(oper) == S_SUCCESS) + kqueue_tcpsock_send(oper, S_SUCCESS, err, base->ev); + continue; } diff --git a/stdcrt/event/compat_event_kqueue.h b/stdcrt/event/compat_event_kqueue.h index 5e7fc060..8f7b27e5 100644 --- a/stdcrt/event/compat_event_kqueue.h +++ b/stdcrt/event/compat_event_kqueue.h @@ -8,7 +8,7 @@ extern "C" { #include #include "compat_event_util.h" -#if (TARGET_OS == OS_MACH) +#if (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) typedef struct kqueue_op_s kqueue_op_t; diff --git a/stdcrt/event/compat_event_mach.c b/stdcrt/event/compat_event_mach.c index aae8845c..874f1abf 100644 --- a/stdcrt/event/compat_event_mach.c +++ b/stdcrt/event/compat_event_mach.c @@ -1,11 +1,75 @@ #include #include "compat_event_util.h" -#if (TARGET_OS == OS_MACH) +#if (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) #include "compat_event_kqueue.h" #include "compat_event_mach.h" + +int kqueue_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func) +{ + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n = 0; + + + int error = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + while (n != -1) { + + rc = evbuf_get_buf(&oper->wbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->wbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + n = send(oper->fd, ptr, len, 0); + error = (n == -1) ? errno : 0; + if (n > 0) { + func(error, code, oper, NULL, op_ev_write); + } + + if (evoper_writeing(oper) == S_ERROR) + break; + } + + return rc; +} + +int kqueue_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) +{ + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n = 0; + + while (n != -1) { + + int err = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->rbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->rbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + n = recv(oper->fd, ptr, len, 0); + err = (n == -1) ? errno : 0; + if (n > 0) { + func(err, code, oper, NULL, op_ev_read); + } + + if (evoper_reading(oper) == S_ERROR) + break; + } + return rc; +} + + int mach_tcpsock_send(evoper_t* oper, int flags) { int rc = S_SUCCESS; diff --git a/stdcrt/event/compat_event_mach.h b/stdcrt/event/compat_event_mach.h index 664e3794..289cab08 100644 --- a/stdcrt/event/compat_event_mach.h +++ b/stdcrt/event/compat_event_mach.h @@ -7,8 +7,10 @@ extern "C" { #endif -#if (TARGET_OS == OS_MACH) +#if (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) +int kqueue_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func); +int kqueue_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func); int mach_tcpsock_send(evoper_t* oper, int flags); int mach_tcpsock_recv(evoper_t* oper, int flags); diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index b4f8ceb5..9001983f 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -6,6 +6,68 @@ #include "compat_event_epoll.h" #include "compat_event_posix.h" +int epoll_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func) +{ + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n = 0; + + + int error = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + while (n != -1) { + + rc = evbuf_get_buf(&oper->wbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->wbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + n = send(oper->fd, ptr, len, 0); + error = (n == -1) ? errno : 0; + if (n > 0) { + func(error, code, oper, NULL, op_ev_write); + } + + if (evoper_writeing(oper) == S_ERROR) + break; + } + + return rc; +} + +int epoll_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) +{ + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n = 0; + + while (n != -1) { + + int err = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->rbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->rbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + n = recv(oper->fd, ptr, len, 0); + err = (n == -1) ? errno : 0; + if (n > 0) { + func(err, code, oper, NULL, op_ev_read); + } + + if (evoper_reading(oper) == S_ERROR) + break; + } + return rc; +} + int posix_tcpsock_send(evoper_t* oper, int flags) { int rc = S_SUCCESS; @@ -39,6 +101,8 @@ int posix_tcpsock_send(evoper_t* oper, int flags) goto end; } else if (err == EINTR) { // sync + printf("error"); + } else { rc = S_ERROR; goto end; diff --git a/stdcrt/event/compat_event_posix.h b/stdcrt/event/compat_event_posix.h index 64a12e88..57e83185 100644 --- a/stdcrt/event/compat_event_posix.h +++ b/stdcrt/event/compat_event_posix.h @@ -9,6 +9,8 @@ extern "C" { #if (TARGET_OS == OS_POSIX) +int epoll_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func); +int epoll_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func); int posix_tcpsock_send(evoper_t* oper, int flags); int posix_tcpsock_recv(evoper_t* oper, int flags); diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index 5f319020..9c266607 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -371,19 +371,16 @@ int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_ if(evoper_reading(oper) == S_SUCCESS) { #if (TARGET_OS == OS_WIN) - + func(err, code, oper, NULL, op_ev_read); #elif (TARGET_OS == OS_POSIX) - posix_tcpsock_recv(oper, 0); - #elif (TARGET_OS == OS_MACH) - mach_tcpsock_recv(oper, 0); - #elif (TARGET_OS == OS_UNIX) - //mach_tcpsock_recv(oper, 0); + epoll_tcpsock_recv(oper, err, code, func); + #elif (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) + kqueue_tcpsock_recv(oper, err, code, func); #else #endif - func(err, code, oper, NULL, op_ev_read); + } - return S_SUCCESS; } int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func) @@ -395,7 +392,6 @@ int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev if(evoper_writeing(oper) == S_SUCCESS) { func(err, code, oper, NULL, op_ev_write); } - return S_SUCCESS; } int evbuf_is_eof(evbuf_t* buf) diff --git a/stdcrt/net/compat_sock.c b/stdcrt/net/compat_sock.c index f5519156..04cbd51b 100644 --- a/stdcrt/net/compat_sock.c +++ b/stdcrt/net/compat_sock.c @@ -219,6 +219,10 @@ int _closesock(_sock_t s) return closesocket(s); #elif (TARGET_OS == OS_POSIX) return close(s); +#elif (TARGET_OS == OS_MACH) + return close(s); +#elif (TARGET_OS == OS_UNIX) + return close(s); #endif } return S_ERROR; @@ -231,6 +235,10 @@ int _stable__closesock(_sock_t s) return closesocket(s); #elif (TARGET_OS == OS_POSIX) return close(s); +#elif (TARGET_OS == OS_MACH) + return close(s); +#elif (TARGET_OS == OS_UNIX) + return close(s); #endif } return S_ERROR; @@ -292,6 +300,14 @@ int getsocktype(_sock_t s) #define PATTERN O_NONBLOCK #endif +#elif (TARGET_OS == OS_UNIX) + +#ifndef O_NONBLOCK +#define PATTERN FNDELAY +#else +#define PATTERN O_NONBLOCK +#endif + #endif int set_blocking(_sock_t s, int turn) diff --git a/stdcrt/net/compat_sockinet.c b/stdcrt/net/compat_sockinet.c index f5c92fd4..e773f217 100644 --- a/stdcrt/net/compat_sockinet.c +++ b/stdcrt/net/compat_sockinet.c @@ -416,6 +416,8 @@ char* inet_ntop4(const unsigned char* src, char* dst, size_t size) char* inet_ntop6(const unsigned char* src, char* dst, size_t size) { + int max_size = sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"); + char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; char* tp; struct { @@ -479,7 +481,7 @@ char* inet_ntop6(const unsigned char* src, char* dst, size_t size) tp += strlen(tp); break; } - tp += sprintf(tp, "%lx", words[i]); + tp += s_snprintf(tp, max_size, "%lx", words[i]); } /* Was it a trailing run of 0x00's? diff --git a/stdcrt/stdlib/compat_atomic.c b/stdcrt/stdlib/compat_atomic.c index 0f18d403..6728a199 100644 --- a/stdcrt/stdlib/compat_atomic.c +++ b/stdcrt/stdlib/compat_atomic.c @@ -18,6 +18,9 @@ atomic_type xadd(atomic_type* ptr) // OSAtomicCompareAndSwap32Barrier(*ptr, new_value, ptr); // return *ptr; return OSAtomicIncrement32Barrier(ptr); +#elif (TARGET_OS == OS_UNIX) + __sync_add_and_fetch(ptr, 1); + return *ptr; #endif return 0; } @@ -27,7 +30,6 @@ atomic_type xdel(atomic_type* ptr) #if (TARGET_OS == OS_POSIX) __sync_sub_and_fetch(ptr, 1); return *ptr; - #elif (TARGET_OS == OS_WIN) #if (TARGET_BITS == ARCH_64BIT) @@ -41,6 +43,9 @@ atomic_type xdel(atomic_type* ptr) // OSAtomicCompareAndSwap32Barrier(*ptr, new_value, ptr); // return *ptr; return OSAtomicDecrement32Barrier(ptr); +#elif (TARGET_OS == OS_UNIX) + __sync_sub_and_fetch(ptr, 1); + return *ptr; #endif return 0; } @@ -63,6 +68,9 @@ atomic_type _atomic_init(_atomic_t* self) self->value = 0; OSAtomicCompareAndSwap32Barrier(self->value, 0, &self->value); return self->value; +#elif (TARGET_OS == OS_UNIX) + __sync_lock_test_and_set(&self->value, 0); + return self->value; #endif return S_SUCCESS; @@ -90,7 +98,6 @@ atomic_type _atomic_uninit(_atomic_t* self) #elif (TARGET_OS == OS_UNIX) __sync_lock_test_and_set(&self->value, 0); return self->value; - #endif } @@ -113,6 +120,9 @@ atomic_type _atomic_add(_atomic_t* self) // OSAtomicCompareAndSwap32Barrier(self->value, new_value, &self->value); // return self->value; return xadd(&self->value); +#elif (TARGET_OS == OS_UNIX) + __sync_add_and_fetch(&self->value, 1); + return self->value; #endif return S_SUCCESS; @@ -137,6 +147,9 @@ atomic_type _atomic_del(_atomic_t* self) // OSAtomicCompareAndSwap32Barrier(self->value, new_value, &self->value); // return self->value; return xdel(&self->value); +#elif (TARGET_OS == OS_MACH) + __sync_sub_and_fetch(&self->value, 1); + return self->value; #endif return S_SUCCESS; } @@ -151,16 +164,26 @@ atomic_type _atomic_set(atomic_type set, _atomic_t* self) #if (TARGET_OS == OS_WIN) _InterlockedCompareExchange(&self->value, set, value); #elif (TARGET_OS == OS_POSIX) -#if defined(__GNUC__) && (__GNUC__ >= 4) - __sync_bool_compare_and_swap(&self->value, value, set); -#else - _mutex_lock(&self->lock); - self->value = set; - _mutex_unlock(&self->lock); -#endif + + #if defined(__GNUC__) && (__GNUC__ >= 4) + __sync_bool_compare_and_swap(&self->value, value, set); + #else + _mutex_lock(&self->lock); + self->value = set; + _mutex_unlock(&self->lock); + #endif #elif (TARGET_OS == OS_MACH) OSAtomicCompareAndSwap32Barrier(value, set, &self->value); +#elif (TARGET_OS == OS_UNIX) + #if defined(__GNUC__) && (__GNUC__ >= 4) + __sync_bool_compare_and_swap(&self->value, value, set); + #else + _mutex_lock(&self->lock); + self->value = set; + _mutex_unlock(&self->lock); + #endif + #endif return self->value; @@ -179,19 +202,17 @@ int _atomic_cmp(atomic_type comp, _atomic_t* self) original = _InterlockedCompareExchange(&self->value, value, comp); return (original == comp); #elif (TARGET_OS == OS_POSIX) - atomic_type original = 0; -#if defined(__GNUC__) && (__GNUC__ >= 4) - value = self->value; - return __sync_bool_compare_and_swap(&self->value, comp, value); -#else - _mutex_lock(&self->lock); - original = self->value; - _mutex_unlock(&self->lock); - - return comp == original; -#endif - + #if defined(__GNUC__) && (__GNUC__ >= 4) + value = self->value; + return __sync_bool_compare_and_swap(&self->value, comp, value); + #else + _mutex_lock(&self->lock); + original = self->value; + _mutex_unlock(&self->lock); + + return comp == original; + #endif #elif (TARGET_OS == OS_MACH) _mutex_lock(&self->lock); @@ -205,18 +226,16 @@ int _atomic_cmp(atomic_type comp, _atomic_t* self) #elif (TARGET_OS == OS_UNIX) atomic_type original = 0; -#if defined(__GNUC__) && (__GNUC__ >= 4) - value = self->value; - return __sync_bool_compare_and_swap(&self->value, comp, value); -#else - _mutex_lock(&self->lock); - original = self->value; - _mutex_unlock(&self->lock); - - return comp == original; -#endif - - + #if defined(__GNUC__) && (__GNUC__ >= 4) + value = self->value; + return __sync_bool_compare_and_swap(&self->value, comp, value); + #else + _mutex_lock(&self->lock); + original = self->value; + _mutex_unlock(&self->lock); + + return comp == original; + #endif #endif } diff --git a/stdcrt/stdlib/compat_memory.c b/stdcrt/stdlib/compat_memory.c index 8ea071bb..0b65798e 100644 --- a/stdcrt/stdlib/compat_memory.c +++ b/stdcrt/stdlib/compat_memory.c @@ -16,6 +16,8 @@ void* heap_malloc(size_t size) ptr = malloc(size); #elif (TARGET_OS == OS_MACH) ptr = malloc(size); +#elif (TARGET_OS == OS_UNIX) + ptr = malloc(size); #endif return ptr; @@ -36,6 +38,8 @@ void heap_free(void* ptr) free(ptr); #elif (TARGET_OS == OS_MACH) free(ptr); +#elif (TARGET_OS == OS_UNIX) + free(ptr); #endif ptr = NULL; } @@ -54,6 +58,8 @@ void* heap_calloc(size_t count, size_t size) ptr = calloc(count, size); #elif (TARGET_OS == OS_MACH) ptr = calloc(count, size); +#elif (TARGET_OS == OS_UNIX) + ptr = calloc(count, size); #endif return ptr; } @@ -69,6 +75,8 @@ void* heap_realloc(void* mem_address, size_t size) ptr = realloc(mem_address, size); #elif (TARGET_OS == OS_MACH) ptr = realloc(mem_address, size); +#elif (TARGET_OS == OS_UNIX) + ptr = realloc(mem_address, size); #endif return ptr; } diff --git a/stdcrt/stdlib/compat_proctl.c b/stdcrt/stdlib/compat_proctl.c index 3902afa4..e5328907 100644 --- a/stdcrt/stdlib/compat_proctl.c +++ b/stdcrt/stdlib/compat_proctl.c @@ -9,6 +9,8 @@ _pid_t get_processid(void) p = getpid(); #elif (TARGET_OS == OS_MACH) p = getpid(); +#elif (TARGET_OS == OS_UNIX) + p = getpid(); #endif return p; } @@ -21,6 +23,8 @@ _pid_instance get_instance(void) p = getpid(); #elif (TARGET_OS == OS_MACH) p = getpid(); +#elif (TARGET_OS == OS_UNIX) + p = getpid(); #endif return p; } diff --git a/stdcrt/stdlib/compat_vsnprintf.c b/stdcrt/stdlib/compat_vsnprintf.c index c0ceeff4..3c64306f 100644 --- a/stdcrt/stdlib/compat_vsnprintf.c +++ b/stdcrt/stdlib/compat_vsnprintf.c @@ -1,6 +1,19 @@ #include -int s_vsnprintf(char* str, int size, const char* format, ...) +int s_vsnprintf(char* str, int size, const char* fmt, ...) { - return 0; + return S_SUCCESS; } +int s_snprintf(char* str, int size, const char* fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + +#if (TARGET_OS == OS_WIN) + _vsnprintf_s(str, size, size, fmt, ap); +#else + vsnprintf(str, size, fmt, ap); +#endif + + return S_SUCCESS; +} \ No newline at end of file diff --git a/stdcrt/string/compat_utf8.c b/stdcrt/string/compat_utf8.c index b422e13e..68f54c87 100644 --- a/stdcrt/string/compat_utf8.c +++ b/stdcrt/string/compat_utf8.c @@ -78,6 +78,11 @@ char* wchar_to_char(const wchar_t* in, size_t len) ptr = (char*)calloc(size + 1, sizeof(char)); rc_error(ptr != NULL, NULL); wcstombs(ptr, in, size); +#elif (TARGET_OS == OS_UNIX) + size_t size = wcstombs(NULL, in, 0); + ptr = (char*)calloc(size + 1, sizeof(char)); + rc_error(ptr != NULL, NULL); + wcstombs(ptr, in, size); #endif return ptr; } diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index 3fef9ba7..6f81ae7e 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -27,6 +27,10 @@ int main(int argc, char* argv[]) rc = _thread_create(&thread3, thread_proc3, NULL); rc_error(rc == S_SUCCESS, S_ERROR); + _thread_t thread4; + rc = _thread_create(&thread4, thread_proc4, NULL); + rc_error(rc == S_SUCCESS, S_ERROR); + test_oper_run(); diff --git a/stdcrt_test/test.h b/stdcrt_test/test.h index a0fd630c..5b5da431 100644 --- a/stdcrt_test/test.h +++ b/stdcrt_test/test.h @@ -32,6 +32,7 @@ void test_oper_run(); void thread_proc1(void* ctx); void thread_proc2(void* ctx); void thread_proc3(void* ctx); +void thread_proc4(void* ctx); void test_init_evaddr(); void test_timer(evloop_t* loop); diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index e01746f3..751f5e5e 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -32,7 +32,6 @@ void thread_proc1(void* ctx) void thread_proc2(void* ctx) { _cond_wait(&r_cond, &r_mutex); - sleep_time(10); test_read_oper(loop); while (1) { sleep_time(10); @@ -43,11 +42,28 @@ void thread_proc2(void* ctx) void thread_proc3(void* ctx) { _cond_wait(&w_cond, &w_mutex); + sleep_time(10); test_write_oper(loop); while (1) { sleep_time(15); } } + +void thread_proc4(void* ctx) +{ + sleep_time(30); + iwrite = 0; + iread = 0; + s_memset(recv_data, 0x00, 4096); + evoper_read_buf(r_oper, (buf_ptr)recv_data, buf_len); + evloop_enable_read(loop, r_oper, op_ev_active, NULL); + test_write_oper(loop); + while (1) { + sleep_time(15); + } +} + + void test_init_evaddr() { _cond_init(&r_cond); @@ -78,7 +94,6 @@ void test_init_evaddr() evoper_alloc(&w_oper, NULL, oper_alloc); evoper_alloc(&accept_oper, NULL, oper_alloc); - test_accept_oper(loop); } @@ -100,20 +115,18 @@ int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) } else if (event == op_ev_close && res == op_ev_success) { logi("close_connect"); } else if (event == op_ev_write && res == op_ev_success) { - iwrite++; - logi("write %d\n", iwrite); - - evoper_write_buf(w_oper, (buf_ptr)send_data + iwrite, buf_len); + iwrite++; + buf_ptr s = send_data + iwrite; + evoper_write_buf(oper, s, buf_len); if (iwrite == 10) evloop_disable_write(loop, oper); } else if (event == op_ev_read && res == op_ev_success) { + iread++; - logi("read %d\n", iread); - - printf("read string %s\n", recv_data); - + logi("read string:%s=%d\n", recv_data, iread); + evoper_read_buf(oper, (buf_ptr)recv_data + iread, buf_len); if (iread == 10) evloop_disable_read(loop, oper); } -- Gitee From 3dc64af9cfa2b537c8b67e6377a42106cc74b34e Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Tue, 13 Aug 2024 13:22:18 +0800 Subject: [PATCH 19/34] up --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1934eca2..a8427572 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,9 @@ elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64") add_definitions("-DTARGET64BIT") set(Target64Bit true) +elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "amd64") + add_definitions("-DTARGET64BIT") + set(Target64Bit true) else() message(FATAL_ERROR "Unknown Process Bit=${CMAKE_SYSTEM_PROCESSOR}") endif() @@ -128,6 +131,10 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") add_definitions("-DUNIX") set(UNIX_OS true) set(compile_os "FreeBSD") +elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") + add_definitions("-DUNIX") + set(UNIX_OS true) + set(compile_os "OpenBSD") elseif (CMAKE_SYSTEM_NAME MATCHES "CYGWIN") add_definitions("-DWINDOWS") set(WIN_OS true) @@ -163,7 +170,11 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/) link_directories(${PROJECT_SOURCE_DIR}/libs/) elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/) + set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/) + set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/) + link_directories(${PROJECT_SOURCE_DIR}/libs/) +elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") + set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/) set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/) link_directories(${PROJECT_SOURCE_DIR}/libs/) elseif (CMAKE_SYSTEM_NAME MATCHES "CYGWIN") -- Gitee From 4b1bee4b0766804068e2cec7c952001903f49572 Mon Sep 17 00:00:00 2001 From: com Date: Tue, 13 Aug 2024 13:38:20 +0800 Subject: [PATCH 20/34] up --- stdcrt/event/compat_event_kqueue.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 23e43381..16a336a7 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -66,6 +66,8 @@ static int kqueue_op_ctl(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr, return S_SUCCESS; } +#if (TARGET_OS == OS_MACH) + static int kqueue_notify_init(kqueue_op_t* base) { base->notify_kev.ident = 0; @@ -80,6 +82,7 @@ static int kqueue_notify_init(kqueue_op_t* base) } return S_SUCCESS; } +#endif static int kqueue_hook_api(kqueue_op_t* base) { @@ -109,9 +112,12 @@ int kqueue_alloc(evloop_t* loop, int size) if (base->kqfd == 0) goto err; +#if (TARGET_OS == OS_MACH) rc = kqueue_notify_init(base); if(rc != S_SUCCESS) goto err; +#endif + base->poll = NULL; base->poll = loop->mm_malloc(loop, base->size, sizeof(struct kevent)); -- Gitee From 8450f4cd5b967cb2fe6d1d2bd8602ae0d54b4380 Mon Sep 17 00:00:00 2001 From: com Date: Tue, 13 Aug 2024 14:01:02 +0800 Subject: [PATCH 21/34] up --- access/dbimpl.h | 4 +- access/dllmain.cpp | 4 +- access/fieldinfo.h | 3 +- access/recordset.h | 9 +- access/sqlite3.h | 6 +- access/statement.h | 3 +- access/tableinfo.h | 3 +- asynio/asynframeimpl.cpp | 81 +- asynio/asynframeimpl.h | 8 +- asynio/dllmain.cpp | 4 +- asynio/eventwrap.cpp | 217 ++- asynio/eventwrap.h | 25 +- asynio/iooperationimpl.cpp | 2 +- asynio/iooperationimpl.h | 5 +- asynio/pipeimpl.h | 3 +- asynio/spipeimpl.h | 3 +- asynio/tcplistensocketimpl.h | 5 +- asynio/tcplistensocketsslimpl.cpp | 8 +- asynio/tcplistensocketsslimpl.h | 7 +- asynio/tcpsocketimpl.cpp | 42 +- asynio/tcpsocketimpl.h | 3 +- asynio/tcpsocketsslimpl.cpp | 246 ++-- asynio/tcpsocketsslimpl.h | 51 +- asynio/timerimpl.cpp | 10 +- asynio/timerimpl.h | 11 +- asynio/tlswrap.cpp | 443 +++--- asynio/tlswrap.h | 24 +- asynio/udpsocketimpl.cpp | 2 +- asynio/udpsocketimpl.h | 5 +- container/dllmain.cpp | 4 +- container/mainrun.h | 5 +- container/msg.h | 3 +- container/objectloader.h | 4 +- container/objectrun.cpp | 20 +- container/objectrun.h | 8 +- container/plugins.cpp | 10 +- container/rot.h | 3 +- container/stdafx.h | 33 +- crt/crt_aes.h | 2 +- crt/crt_barrier.h | 7 +- crt/crt_common.hpp | 6 +- crt/crt_cond.h | 3 +- crt/crt_core.hpp | 35 +- crt/crt_def.h | 48 +- crt/crt_event.h | 55 +- crt/crt_file.h | 1 - crt/crt_heap.h | 1 - crt/crt_htable.h | 69 +- crt/crt_log.h | 7 +- crt/crt_md5.h | 14 +- crt/crt_mutex.h | 1 - crt/crt_sha1.h | 11 +- crt/crt_sjson.h | 58 +- crt/crt_sock.h | 5 +- crt/crt_var.h | 8 +- crt/posixosdef.h | 1 - crt/unixosdef.h | 10 +- crt/winosdef.h | 2 - extensions/include/db/idatabase.h | 1 - extensions/include/io/ioperation.h | 8 +- extensions/include/io/isocket.h | 4 +- extensions/include/io/itimer.h | 2 +- extensions/include/net/imodbus.h | 8 +- extensions/include/net/inet.h | 1 - extensions/include/runtime/iconfigure.h | 27 +- include/dlcom/comfactory.hpp | 2 - include/dlcom/id.hpp | 6 +- include/dlcom/loadcom.hpp | 25 +- include/dlcom/objectrun.hpp | 10 +- include/utilex/file.hpp | 2 +- include/utilex/json.hpp | 2 +- include/utilex/lockqueue.hpp | 6 +- include/utilex/timethread.hpp | 4 +- license/dllmain.cpp | 4 +- license/licenseimpl.h | 3 +- logs/dllmain.cpp | 4 +- logs/logdatabase.cpp | 14 +- logs/logdatabase.h | 5 +- logs/logsimpl.cpp | 28 +- logs/logsimpl.h | 7 +- logs/stdafx.h | 6 +- logs/tablestruct.cpp | 2 +- logs/tablestruct.h | 3 +- mainui/appviewimpl.cpp | 62 +- mainui/appviewimpl.h | 21 +- mainuiapp/appviewimpl.h | 4 +- mainview/dllmain.cpp | 4 +- mainview/mainviewimpl.cpp | 2 +- mainview/mainviewimpl.h | 6 +- msgbus/agent.h | 5 +- msgbus/broker.h | 6 +- msgbus/consumer.h | 5 +- msgbus/dllmain.cpp | 4 +- msgbus/msgbusimpl.h | 5 +- msgbus/producer.h | 5 +- net/dllmain.cpp | 4 +- net/dnsimpl.cpp | 2 +- net/dnsimpl.h | 4 +- net/httpimpl.h | 6 +- net/modbusimpl.cpp | 4 - net/modbusimpl.h | 3 +- net/netimpl.cpp | 5 +- net/netimpl.h | 5 +- net/protocol/dns.c | 2 +- net/protocol/modbus/config-mach.h | 35 +- net/protocol/modbus/config-posix.h | 33 +- net/protocol/modbus/modbus-config.h | 4 - net/protocol/modbus/modbus-data.c | 45 +- net/protocol/modbus/modbus-private.h | 55 +- net/protocol/modbus/modbus-rtu-private.h | 4 +- net/protocol/modbus/modbus-rtu.c | 238 ++-- net/protocol/modbus/modbus-rtu.h | 18 +- net/protocol/modbus/modbus-tcp-private.h | 4 +- net/protocol/modbus/modbus-tcp.c | 142 +- net/protocol/modbus/modbus-tcp.h | 12 +- net/protocol/modbus/modbus.c | 505 +++---- nettls/nettls/bignum.h | 4 +- nettls/nettls/ssl_internal.h | 2 - nettls/ssl/aes.c | 36 +- nettls/ssl/arc4.c | 9 +- nettls/ssl/bignum.c | 6 +- nettls/ssl/blowfish.c | 3 +- nettls/ssl/camellia.c | 61 +- nettls/ssl/ccm.c | 3 +- nettls/ssl/chacha20.c | 12 +- nettls/ssl/chachapoly.c | 30 +- nettls/ssl/cipher_wrap.c | 155 +-- nettls/ssl/cmac.c | 33 +- nettls/ssl/des.c | 39 +- nettls/ssl/ecp.c | 24 +- nettls/ssl/entropy.c | 6 +- nettls/ssl/md5.c | 3 +- nettls/ssl/nist_kw.c | 18 +- nettls/ssl/oid.c | 502 ++++--- nettls/ssl/poly1305.c | 9 +- nettls/ssl/sha1.c | 3 +- nettls/ssl/sha256.c | 15 +- nettls/ssl/sha512.c | 15 +- nettls/ssl/ssl_ciphersuites.c | 1621 +++++++++++----------- nettls/ssl/ssl_tls.c | 20 +- nettls/ssl/x509_create.c | 3 +- nettls/ssl/x509_crt.c | 43 +- nettls/ssl/xtea.c | 29 +- plugin/dllmain.cpp | 4 +- polipo/config.c | 17 +- polipo/diskcache.c | 34 +- polipo/diskcache.h | 2 +- polipo/log.c | 59 +- runtime/dllmain.cpp | 4 +- runtime/runtimeimpl.h | 4 +- stdcrt/algorithm/compat_md5.c | 379 +++-- stdcrt/algorithm/compat_sha1.c | 337 +++-- stdcrt/code/compat_endian.c | 3 +- stdcrt/code/compat_sjson.c | 1298 +++++++++-------- stdcrt/compat_error.c | 4 +- stdcrt/compat_log.c | 4 +- stdcrt/event/compat_event.c | 67 +- stdcrt/event/compat_event_epoll.c | 71 +- stdcrt/event/compat_event_epoll.h | 13 +- stdcrt/event/compat_event_iocp.c | 31 +- stdcrt/event/compat_event_iocp.h | 5 +- stdcrt/event/compat_event_kqueue.c | 478 ++++--- stdcrt/event/compat_event_kqueue.h | 10 +- stdcrt/event/compat_event_mach.c | 267 ++-- stdcrt/event/compat_event_posix.c | 14 +- stdcrt/event/compat_event_util.c | 83 +- stdcrt/event/compat_event_util.h | 65 +- stdcrt/event/compat_event_win32.c | 52 +- stdcrt/io/compat_file.c | 1 - stdcrt/io/compat_path.c | 3 - stdcrt/net/compat_sock.c | 2 +- stdcrt/net/compat_sockinet.c | 1 - stdcrt/stdlib/compat_atomic.c | 73 +- stdcrt/stdlib/compat_clock.c | 2 +- stdcrt/stdlib/compat_htable.c | 778 ++++++----- stdcrt/stdlib/compat_stdtime.c | 1 - stdcrt/stdlib/compat_str.c | 5 +- stdcrt/thread/compat_cond.c | 10 +- stdcrt/thread/compat_msgq.c | 5 +- stdcrt/thread/compat_mutex.c | 4 +- stdcrt/thread/compat_rwlock.c | 1 - stdcrt/thread/compat_sem.c | 43 +- stdcrt/thread/compat_thread.c | 1 - stdcrt_test/main.c | 8 +- stdcrt_test/test.c | 12 +- stdcrt_test/test.h | 1 - stdcrt_test/test_oper.c | 69 +- stdcrt_test/test_pipe.c | 1 - stdcrt_test/test_ssl.c | 1 - stdcrt_test/test_stdlib.c | 85 +- stdcrt_test/test_timer.c | 3 +- stdcrt_test/test_unixsock.c | 1 - testmain/appviewimpl.cpp | 8 +- testmain/appviewimpl.h | 5 +- uibase/dllmain.cpp | 4 +- uibase/uibaseimpl.h | 5 +- uibase/uicontrolimpl.cpp | 6 +- uibase/uimessageloopimpl.h | 3 +- uibase/uiwindowimpl.cpp | 1 - uibase/uiwindowimpl.h | 3 +- 200 files changed, 4779 insertions(+), 5490 deletions(-) diff --git a/access/dbimpl.h b/access/dbimpl.h index 9cfb39db..0b353183 100644 --- a/access/dbimpl.h +++ b/access/dbimpl.h @@ -16,9 +16,7 @@ enum eFIELD_ATTRIBUTE { FIELD_IS_PK = 99, }; -class CDatabaseImpl : public IDatabase, - public IPlugin, - public CUnknownImp +class CDatabaseImpl : public IDatabase, public IPlugin, public CUnknownImp { public: CDatabaseImpl(void); diff --git a/access/dllmain.cpp b/access/dllmain.cpp index ed12669f..a13eebe6 100644 --- a/access/dllmain.cpp +++ b/access/dllmain.cpp @@ -33,9 +33,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {CLSID_CDataBase, &ClassFactory::GetClass, "db.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{CLSID_CDataBase, &ClassFactory::GetClass, "db.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/access/fieldinfo.h b/access/fieldinfo.h index b5391ed2..53043f30 100644 --- a/access/fieldinfo.h +++ b/access/fieldinfo.h @@ -4,8 +4,7 @@ #include "stdafx.h" #include -class CXFieldInfo : public IFieldInfo, - public CUnknownImp +class CXFieldInfo : public IFieldInfo, public CUnknownImp { public: CXFieldInfo(void); diff --git a/access/recordset.h b/access/recordset.h index 5453d9a3..9229fb59 100644 --- a/access/recordset.h +++ b/access/recordset.h @@ -4,8 +4,7 @@ #include "stdafx.h" #include -class CRecordSet : public IRecordSet, - public CUnknownImp +class CRecordSet : public IRecordSet, public CUnknownImp { public: CRecordSet(sqlite3_stmt* pStmt3); @@ -47,9 +46,9 @@ private: unsigned int GetFieldIndex(LPCSTR lpszName); private: - ULONG m_nRowPosition; - ULONG m_nRowCount; - ULONG m_nFieldCount; + ULONG m_nRowPosition; + ULONG m_nRowCount; + ULONG m_nFieldCount; typedef std::map record; std::vector m_vRecordList; diff --git a/access/sqlite3.h b/access/sqlite3.h index 08f9709a..f4a9ed22 100644 --- a/access/sqlite3.h +++ b/access/sqlite3.h @@ -5328,17 +5328,17 @@ struct sqlite3_index_info { unsigned char op; /* Constraint operator */ unsigned char usable; /* True if this constraint is usable */ int iTermOffset; /* Used internally - xBestIndex should ignore */ - }* aConstraint; /* Table of WHERE clause constraints */ + } * aConstraint; /* Table of WHERE clause constraints */ int nOrderBy; /* Number of terms in the ORDER BY clause */ struct sqlite3_index_orderby { int iColumn; /* Column number */ unsigned char desc; /* True for DESC. False for ASC. */ - }* aOrderBy; /* The ORDER BY clause */ + } * aOrderBy; /* The ORDER BY clause */ /* Outputs */ struct sqlite3_index_constraint_usage { int argvIndex; /* if >0, constraint is part of argv to xFilter */ unsigned char omit; /* Do not code a test for this constraint */ - }* aConstraintUsage; + } * aConstraintUsage; int idxNum; /* Number used to identify the index */ char* idxStr; /* String, possibly obtained from sqlite3_malloc */ int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ diff --git a/access/statement.h b/access/statement.h index 7bab34dd..8991a47a 100644 --- a/access/statement.h +++ b/access/statement.h @@ -4,8 +4,7 @@ #include "stdafx.h" #include -class CStatementImpl : public IStatement, - public CUnknownImp +class CStatementImpl : public IStatement, public CUnknownImp { public: CStatementImpl(sqlite3* pSqlite3); diff --git a/access/tableinfo.h b/access/tableinfo.h index fc84234e..83b0f61c 100644 --- a/access/tableinfo.h +++ b/access/tableinfo.h @@ -4,8 +4,7 @@ #include "stdafx.h" #include -class CXTableInfo : public ITableInfo, - public CUnknownImp +class CXTableInfo : public ITableInfo, public CUnknownImp { public: CXTableInfo(LPCSTR lpszName); diff --git a/asynio/asynframeimpl.cpp b/asynio/asynframeimpl.cpp index b28e00ae..b3295f61 100644 --- a/asynio/asynframeimpl.cpp +++ b/asynio/asynframeimpl.cpp @@ -11,7 +11,7 @@ CAsynFrameImpl::CAsynFrameImpl(void) { - m_eventindex = 0; + m_eventindex = 0; } CAsynFrameImpl::~CAsynFrameImpl(void) @@ -24,7 +24,7 @@ static int eventloop_time_notify(ioevloop_t* evloop, int index) rc_error(evloop != NULL, S_ERROR); CAsynFrameImpl* frame = (CAsynFrameImpl*)ioevloop_getctx(evloop); rc_error(frame != NULL, S_ERROR); - logi("Send Semp"); + logi("Send Semp"); frame->PostComplete(index); return S_SUCCESS; } @@ -45,18 +45,17 @@ HRESULT CAsynFrameImpl::Init(IBase* pRot, IBase* pBase) hr = pRot->QueryInterface(IID_IRot, (void**)&m_pRot); rc_error(hr == S_OK, E_FAIL); - - InitEventLoop(); - - this->m_tpcount = 4; - this->m_evloop = (ioevloop_t*)heap_malloc(this->m_tpcount * sizeof(ioevloop_t)); - - unsigned int index = 0; - for (index = 0; index < this->m_tpcount; index++) { - ioevloop_t* ev = this->m_evloop + index; - CreateEventLoop(ev, eventloop_time_notify, this); - } - + InitEventLoop(); + + this->m_tpcount = 4; + this->m_evloop = (ioevloop_t*)heap_malloc(this->m_tpcount * sizeof(ioevloop_t)); + + unsigned int index = 0; + for (index = 0; index < this->m_tpcount; index++) { + ioevloop_t* ev = this->m_evloop + index; + CreateEventLoop(ev, eventloop_time_notify, this); + } + return S_OK; } HRESULT CAsynFrameImpl::Uninit() @@ -71,7 +70,7 @@ HRESULT CAsynFrameImpl::Start(_pid_t pid, unsigned int type) unsigned int index = 0; for (index = 0; index < this->m_tpcount; index++) { - //this->m_sem.Wait(); + // this->m_sem.Wait(); } return S_OK; @@ -108,8 +107,8 @@ HRESULT CAsynFrameImpl::CreateIo(IO_Protocol iop, IBase** pBase) return E_FAIL; else if (io_tcp_ssl_socket == iop) return CreateITcpSocketSSL(pBase); - else if(io_tcplisten_ssl_socket == iop) - return CreateITcpListenSSLSocket(pBase); + else if (io_tcplisten_ssl_socket == iop) + return CreateITcpListenSSLSocket(pBase); else if (io_timer == iop) return CreateITimer(pBase); else if (io_pipe == iop) @@ -127,12 +126,12 @@ HRESULT CAsynFrameImpl::PostIo(IBase* pOperation) HRESULT CAsynFrameImpl::ThreadPool_Run(void* user, void* ctx) { - rc_error(ctx != NULL, E_FAIL); - io_thread_t* thread = (io_thread_t*)(ctx); - rc_error(thread != NULL, E_FAIL); - ioevloop_t* ev = m_evloop + thread->id; - rc_error(ev != NULL, E_FAIL); - RunEventLoop(ev); + rc_error(ctx != NULL, E_FAIL); + io_thread_t* thread = (io_thread_t*)(ctx); + rc_error(thread != NULL, E_FAIL); + ioevloop_t* ev = m_evloop + thread->id; + rc_error(ev != NULL, E_FAIL); + RunEventLoop(ev); return S_OK; } HRESULT CAsynFrameImpl::PostComplete(int type) @@ -191,8 +190,8 @@ HRESULT CAsynFrameImpl::CreateIUdpSocket(IBase** pBase) hr = pObj->CreateIoOperation(this); rc_error(hr == S_OK, E_FAIL); - - pObj->BindEvloop(get_service()); + + pObj->BindEvloop(get_service()); return pObj->QueryInterface(IID_IUdpSocket, (void**)pBase); } @@ -210,26 +209,26 @@ HRESULT CAsynFrameImpl::CreateITcpSocketSSL(IBase** pBase) { HRESULT hr = S_OK; - CTcpSocketSslImpl* pObj = NULL; + CTcpSocketSslImpl* pObj = NULL; pObj = ALLOC_NEW CTcpSocketSslImpl; rc_error(pObj != NULL, E_FAIL); - hr = pObj->CreateIoOperation(this); - rc_error(hr == S_OK, E_FAIL); + hr = pObj->CreateIoOperation(this); + rc_error(hr == S_OK, E_FAIL); + + pObj->BindEvloop(get_service()); - pObj->BindEvloop(get_service()); - return pObj->QueryInterface(IID_ITcpSocketSsl, (void**)pBase); } HRESULT CAsynFrameImpl::CreateITcpListenSSLSocket(IBase** pBase) { - CTcpListenSocketSslImpl* pObj = NULL; - pObj = ALLOC_NEW CTcpListenSocketSslImpl; - rc_error(pObj != NULL, E_FAIL); + CTcpListenSocketSslImpl* pObj = NULL; + pObj = ALLOC_NEW CTcpListenSocketSslImpl; + rc_error(pObj != NULL, E_FAIL); - pObj->BindEvloop(get_service()); - - return pObj->QueryInterface(IID_ITcpSslListen, (void**)pBase); + pObj->BindEvloop(get_service()); + + return pObj->QueryInterface(IID_ITcpSslListen, (void**)pBase); } HRESULT CAsynFrameImpl::CreateITimer(IBase** pBase) { @@ -260,8 +259,8 @@ HRESULT CAsynFrameImpl::InitEventLoop() HRESULT CAsynFrameImpl::CreateEventLoop(ioevloop_t* ev, evloop_notify cb, void* user) { rc_error(ev != NULL, E_FAIL); - - ioevloop_setctx(ev, user); + + ioevloop_setctx(ev, user); return S_OK; } @@ -273,16 +272,16 @@ HRESULT CAsynFrameImpl::ExitEventLoop(ioevloop_t* ev) HRESULT CAsynFrameImpl::RunEventLoop(ioevloop_t* ev) { - rc_error(ev != NULL, E_FAIL); + rc_error(ev != NULL, E_FAIL); return S_OK; } ioevloop_t* CAsynFrameImpl::get_service() { { SYNC_OBJ(&m_lock) - m_eventindex++; + m_eventindex++; if (m_eventindex == m_tpcount) { - m_eventindex = 0; + m_eventindex = 0; } } return this->m_evloop + m_eventindex; diff --git a/asynio/asynframeimpl.h b/asynio/asynframeimpl.h index 06cfc321..e9b546a4 100644 --- a/asynio/asynframeimpl.h +++ b/asynio/asynframeimpl.h @@ -3,11 +3,7 @@ #include "stdafx.h" -class CAsynFrameImpl : public IAsynFrame, - public IPlugin, - public IPluginRun, - public CUnknownImp, - public CThreadPool +class CAsynFrameImpl : public IAsynFrame, public IPlugin, public IPluginRun, public CUnknownImp, public CThreadPool { public: CAsynFrameImpl(void); @@ -47,7 +43,7 @@ private: std_method(CreateIUdpSocket)(IBase** pBase); std_method(CreateITcpListenSocket)(IBase** pBase); std_method(CreateITcpSocketSSL)(IBase** pBase); - std_method(CreateITcpListenSSLSocket)(IBase** pBase); + std_method(CreateITcpListenSSLSocket)(IBase** pBase); std_method(CreateITimer)(IBase** pBase); std_method(CreateIPipe)(IBase** pBase); std_method(CreateISPipe)(IBase** pBase); diff --git a/asynio/dllmain.cpp b/asynio/dllmain.cpp index 182a3838..59574fb6 100644 --- a/asynio/dllmain.cpp +++ b/asynio/dllmain.cpp @@ -33,9 +33,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {CLSID_CAsynFrame, &ClassFactory::GetClass, "asynframe.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{CLSID_CAsynFrame, &ClassFactory::GetClass, "asynframe.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/asynio/eventwrap.cpp b/asynio/eventwrap.cpp index 3f2c84c3..24d27c96 100644 --- a/asynio/eventwrap.cpp +++ b/asynio/eventwrap.cpp @@ -2,227 +2,226 @@ /* static void on_tcperrorcb(evlistenptr listener, void* arg) { - ioevtcp_t* tcp = (ioevtcp_t*)(arg); - c_error(tcp != NULL); - c_error(tcp->event != NULL); - tcp->event(tcp, IOEVTCP_ERROR); + ioevtcp_t* tcp = (ioevtcp_t*)(arg); + c_error(tcp != NULL); + c_error(tcp->event != NULL); + tcp->event(tcp, IOEVTCP_ERROR); } static void on_tcpacceptcb(evlistenptr listen, _sock_t fd, struct sockaddr* addr, int sl, void* arg) { - ioevtcp_t* tcp = (ioevtcp_t*)(arg); - c_error(tcp != NULL); - c_error(tcp->accept != NULL); - tcp->accept(tcp, addr, sl, fd); - logi("on_tcpacceptcb"); + ioevtcp_t* tcp = (ioevtcp_t*)(arg); + c_error(tcp != NULL); + c_error(tcp->accept != NULL); + tcp->accept(tcp, addr, sl, fd); + logi("on_tcpacceptcb"); } static void on_readcb(struct bufferevent* bev, void* arg) { - ioevstream_t* stream = (ioevstream_t*)(arg); - c_error(stream != NULL); - c_error(stream->read != NULL); - + ioevstream_t* stream = (ioevstream_t*)(arg); + c_error(stream != NULL); + c_error(stream->read != NULL); + } static void on_writecb(struct bufferevent* bev, void* arg) { - ioevstream_t* stream = (ioevstream_t*)(arg); - c_error(stream != NULL); - c_error(stream->write != NULL); + ioevstream_t* stream = (ioevstream_t*)(arg); + c_error(stream != NULL); + c_error(stream->write != NULL); } static void on_eventcb(struct bufferevent* bev, short what, void* arg) { - ioevstream_t* stream = (ioevstream_t*)(arg); - c_error(stream != NULL); - c_error(stream->event != NULL); + ioevstream_t* stream = (ioevstream_t*)(arg); + c_error(stream != NULL); + c_error(stream->event != NULL); } */ static int stream_connsock(ioevstream_t* stream, SOCKADDR_PTR sa, socklen_t sl, TVL_PTR tv) { - rc_error(stream != NULL, S_ERROR); - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + return S_SUCCESS; } int ioevloop_setnotify(ioevloop_t* loop, evloop_notify cb) { - rc_error(loop != NULL, S_ERROR); - loop->notify = cb; - return S_SUCCESS; + rc_error(loop != NULL, S_ERROR); + loop->notify = cb; + return S_SUCCESS; } int ioevloop_setctx(ioevloop_t* loop, void* ctx) { - rc_error(loop != NULL, S_ERROR); - loop->ctx = ctx; - return S_SUCCESS; + rc_error(loop != NULL, S_ERROR); + loop->ctx = ctx; + return S_SUCCESS; } void* ioevloop_getctx(ioevloop_t* loop) { - rc_error(loop != NULL, NULL); - return loop->ctx; + rc_error(loop != NULL, NULL); + return loop->ctx; } int ioevtcp_init(ioevtcp_t* tcp, ioevloop_t* evloop, _sock_t sock) { - rc_error(tcp != NULL, S_ERROR); + rc_error(tcp != NULL, S_ERROR); - return S_SUCCESS; + return S_SUCCESS; } int ioevtcp_uninit(ioevtcp_t* tcp) { - rc_error(tcp != NULL, S_ERROR); - return S_SUCCESS; + rc_error(tcp != NULL, S_ERROR); + return S_SUCCESS; } int ioevtcp_setctx(ioevtcp_t* tcp, void* ctx) { - rc_error(tcp != NULL, S_ERROR); - tcp->ctx = ctx; - return S_SUCCESS; + rc_error(tcp != NULL, S_ERROR); + tcp->ctx = ctx; + return S_SUCCESS; } void* ioevtcp_getctx(ioevtcp_t* tcp) { - rc_error(tcp != NULL, NULL); - return tcp->ctx; + rc_error(tcp != NULL, NULL); + return tcp->ctx; } int ioevtcp_seteventcb(ioevtcp_t* tcp, tcp_eventcb cb) { - rc_error(tcp != NULL, S_ERROR); - tcp->event = cb; - return S_SUCCESS; + rc_error(tcp != NULL, S_ERROR); + tcp->event = cb; + return S_SUCCESS; } int ioevtcp_setacceptcb(ioevtcp_t* tcp, tcp_acceptcb cb) { - rc_error(tcp != NULL, S_ERROR); - tcp->accept = cb; - return S_SUCCESS; + rc_error(tcp != NULL, S_ERROR); + tcp->accept = cb; + return S_SUCCESS; } int ioevtcp_bind(ioevtcp_t* tcp, NET_ADDR ip, NET_ADDR_PORT port) { - rc_error(tcp != NULL, S_ERROR); - - return S_SUCCESS; + rc_error(tcp != NULL, S_ERROR); + + return S_SUCCESS; } int ioevtcp_bind6(ioevtcp_t* tcp, NET_ADDR ip, NET_ADDR_PORT port) { - rc_error(tcp != NULL, S_ERROR); - return S_SUCCESS; + rc_error(tcp != NULL, S_ERROR); + return S_SUCCESS; } int ioevtcp_enable(ioevtcp_t* tcp) { - rc_error(tcp != NULL, S_ERROR); + rc_error(tcp != NULL, S_ERROR); - return S_SUCCESS; + return S_SUCCESS; } int ioevtcp_disable(ioevtcp_t* tcp) { - rc_error(tcp != NULL, S_ERROR); + rc_error(tcp != NULL, S_ERROR); - return S_SUCCESS; + return S_SUCCESS; } int ioevstream_init(ioevstream_t* stream, ioevloop_t* evloop, _sock_t sock) { - rc_error(stream != NULL, S_ERROR); - rc_error(evloop != NULL, S_ERROR); + rc_error(stream != NULL, S_ERROR); + rc_error(evloop != NULL, S_ERROR); - return S_SUCCESS; + return S_SUCCESS; } int ioevstream_uninit(ioevstream_t* stream) { - rc_error(stream != NULL, S_ERROR); - - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + + return S_SUCCESS; } int ioevstream_assign(ioevstream_t* stream, _sock_t sock) { - rc_error(stream != NULL, S_ERROR); - - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + + return S_SUCCESS; } int ioevstream_setctx(ioevstream_t* stream, void* ctx) { - rc_error(stream != NULL, S_ERROR); - stream->ctx = ctx; - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + stream->ctx = ctx; + return S_SUCCESS; } void* ioevstream_getctx(ioevstream_t* stream) { - rc_error(stream != NULL, NULL); - return stream->ctx; + rc_error(stream != NULL, NULL); + return stream->ctx; } int ioevstream_seteventcb(ioevstream_t* stream, stream_eventcb cb) { - rc_error(stream != NULL, S_ERROR); - stream->event = cb; - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + stream->event = cb; + return S_SUCCESS; } int ioevstream_setreadcb(ioevstream_t* stream, stream_readcb cb) { - rc_error(stream != NULL, S_ERROR); - stream->read = cb; - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + stream->read = cb; + return S_SUCCESS; } int ioevstream_setwritecb(ioevstream_t* stream, stream_writecb cb) { - rc_error(stream != NULL, S_ERROR); - stream->write = cb; - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + stream->write = cb; + return S_SUCCESS; } int ioevstream_write(ioevstream_t* stream, buf_ptr ptr, buf_len len, int sec) { - struct timeval timeout; + struct timeval timeout; - rc_error(stream != NULL, S_ERROR); + rc_error(stream != NULL, S_ERROR); - timeout.tv_sec = sec; - timeout.tv_usec = 0; + timeout.tv_sec = sec; + timeout.tv_usec = 0; - return S_SUCCESS; + return S_SUCCESS; } int ioevstream_read(ioevstream_t* stream, buf_ptr ptr, buf_len len, int sec) { - struct timeval tv; + struct timeval tv; - rc_error(stream != NULL, S_ERROR); + rc_error(stream != NULL, S_ERROR); - tv.tv_sec = sec; - tv.tv_usec = 0; + tv.tv_sec = sec; + tv.tv_usec = 0; - return S_SUCCESS; + return S_SUCCESS; } int ioevstream_connectsock(ioevstream_t* stream, NET_ADDR ip, NET_ADDR_PORT port, int sec) { - struct sockaddr_in saddr; - struct timeval tv; + struct sockaddr_in saddr; + struct timeval tv; - rc_error(stream != NULL, S_ERROR); + rc_error(stream != NULL, S_ERROR); - tv.tv_sec = sec; - tv.tv_usec = 0; + tv.tv_sec = sec; + tv.tv_usec = 0; - s_memset(&saddr, 0, sizeof(struct sockaddr_in)); - saddr.sin_family = AF_INET; - saddr.sin_addr.s_addr = inet_addr(ip); - saddr.sin_port = htons(port); + s_memset(&saddr, 0, sizeof(struct sockaddr_in)); + saddr.sin_family = AF_INET; + saddr.sin_addr.s_addr = inet_addr(ip); + saddr.sin_port = htons(port); - stream_connsock(stream, (struct sockaddr*)&saddr, sizeof(saddr), &tv); + stream_connsock(stream, (struct sockaddr*)&saddr, sizeof(saddr), &tv); - return S_SUCCESS; + return S_SUCCESS; } int ioevstream_connect6sock(ioevstream_t* stream, NET_ADDR ip, NET_ADDR_PORT port, int sec) { - struct sockaddr_in6 saddr6; - struct timeval tv; + struct sockaddr_in6 saddr6; + struct timeval tv; - rc_error(stream != NULL, S_ERROR); + rc_error(stream != NULL, S_ERROR); - tv.tv_sec = sec; - tv.tv_usec = 0; + tv.tv_sec = sec; + tv.tv_usec = 0; - s_memset(&saddr6, 0, sizeof(struct sockaddr_in6)); + s_memset(&saddr6, 0, sizeof(struct sockaddr_in6)); - saddr6.sin6_family = AF_INET6; - _inet_pton(AF_INET6, ip, (char*)&saddr6.sin6_addr); - saddr6.sin6_port = htons(port); + saddr6.sin6_family = AF_INET6; + _inet_pton(AF_INET6, ip, (char*)&saddr6.sin6_addr); + saddr6.sin6_port = htons(port); - stream_connsock(stream, (struct sockaddr*)&saddr6, sizeof(saddr6), &tv); + stream_connsock(stream, (struct sockaddr*)&saddr6, sizeof(saddr6), &tv); - return S_SUCCESS; + return S_SUCCESS; } - diff --git a/asynio/eventwrap.h b/asynio/eventwrap.h index 38c3e042..3e42ef9f 100644 --- a/asynio/eventwrap.h +++ b/asynio/eventwrap.h @@ -13,8 +13,8 @@ typedef struct ioevloop_s ioevloop_t; typedef int (*evloop_notify)(ioevloop_t* evloop, int index); struct ioevloop_s { - void* ctx; - evloop_notify notify; + void* ctx; + evloop_notify notify; }; int ioevloop_setnotify(ioevloop_t* loop, evloop_notify cb); @@ -25,9 +25,9 @@ typedef struct ioevtcp_s ioevtcp_t; typedef int (*tcp_eventcb)(ioevtcp_t* tcp, short err); typedef int (*tcp_acceptcb)(ioevtcp_t* tcp, SOCKADDR_PTR sa, socklen_t sl, _sock_t sock); struct ioevtcp_s { - void* ctx; - tcp_eventcb event; - tcp_acceptcb accept; + void* ctx; + tcp_eventcb event; + tcp_acceptcb accept; }; int ioevtcp_init(ioevtcp_t* tcp, ioevloop_t* evloop, _sock_t sock); @@ -48,20 +48,20 @@ int ioevtcp_disable(ioevtcp_t* tcp); #define IOEV_STREAM_READ 0x08 #define IOEV_STREAM_TMOUT 0x10 -#define IOEVSTREAM_OPEN 0x01 -#define IOEVSSLSTREAM_OPEN 0x02 +#define IOEVSTREAM_OPEN 0x01 +#define IOEVSSLSTREAM_OPEN 0x02 -#define IOEV_STREAM_OPTIONS (BEV_OPT_DEFER_CALLBACKS | BEV_OPT_UNLOCK_CALLBACKS | BEV_OPT_THREADSAFE) +#define IOEV_STREAM_OPTIONS (BEV_OPT_DEFER_CALLBACKS | BEV_OPT_UNLOCK_CALLBACKS | BEV_OPT_THREADSAFE) typedef struct ioevstream_s ioevstream_t; typedef int (*stream_eventcb)(ioevstream_t* stream, short err, short what, _sock_t fd); typedef int (*stream_readcb)(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len); typedef int (*stream_writecb)(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len); struct ioevstream_s { - void* ctx; - stream_eventcb event; - stream_readcb read; - stream_writecb write; + void* ctx; + stream_eventcb event; + stream_readcb read; + stream_writecb write; }; int ioevstream_init(ioevstream_t* stream, ioevloop_t* evloop, _sock_t sock); @@ -77,5 +77,4 @@ int ioevstream_read(ioevstream_t* stream, buf_ptr ptr, buf_len len, int sec); int ioevstream_connectsock(ioevstream_t* stream, NET_ADDR ip, NET_ADDR_PORT port, int sec); int ioevstream_connect6sock(ioevstream_t* stream, NET_ADDR ip, NET_ADDR_PORT port, int sec); - #endif diff --git a/asynio/iooperationimpl.cpp b/asynio/iooperationimpl.cpp index 62052322..bcbc8263 100644 --- a/asynio/iooperationimpl.cpp +++ b/asynio/iooperationimpl.cpp @@ -52,7 +52,7 @@ crtid CIoOperationImpl::GetId() } HRESULT CIoOperationImpl::SetResult(crterr err, buf_len len) { - m_err = err; + m_err = err; m_pTransferedBytes = len; return S_OK; } diff --git a/asynio/iooperationimpl.h b/asynio/iooperationimpl.h index 9473f8ec..46346309 100644 --- a/asynio/iooperationimpl.h +++ b/asynio/iooperationimpl.h @@ -4,8 +4,7 @@ #include "stdafx.h" #include -class CIoOperationImpl : public IOperation, - public CUnknownImp +class CIoOperationImpl : public IOperation, public CUnknownImp { public: CIoOperationImpl(void); @@ -45,7 +44,7 @@ public: private: crterr m_err; - crtid m_cid; + crtid m_cid; buf_len m_pTransferedBytes; buf_len m_uStartPos; buf_len m_uExpectBytes; diff --git a/asynio/pipeimpl.h b/asynio/pipeimpl.h index ed82aa61..ff0ac310 100644 --- a/asynio/pipeimpl.h +++ b/asynio/pipeimpl.h @@ -2,8 +2,7 @@ #define _PIPEIMPL_H_ #include "stdafx.h" -class CPipeImpl : public IPipe, - public CUnknownImp +class CPipeImpl : public IPipe, public CUnknownImp { public: CPipeImpl(void); diff --git a/asynio/spipeimpl.h b/asynio/spipeimpl.h index 295eff30..ba77859c 100644 --- a/asynio/spipeimpl.h +++ b/asynio/spipeimpl.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CSPipeImpl : public ISPipe, - public CUnknownImp +class CSPipeImpl : public ISPipe, public CUnknownImp { public: CSPipeImpl(void); diff --git a/asynio/tcplistensocketimpl.h b/asynio/tcplistensocketimpl.h index e7be1aed..4d5b1d87 100644 --- a/asynio/tcplistensocketimpl.h +++ b/asynio/tcplistensocketimpl.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CTcpListenSocketImpl : public ITcpListen, - public CUnknownImp +class CTcpListenSocketImpl : public ITcpListen, public CUnknownImp { public: CTcpListenSocketImpl(void); @@ -14,7 +13,7 @@ public: STDCOM_INTERFACE_ENTRY(ITcpListen) STDCOM_INTERFACE_ENTRY_UNKNOWN_(ITcpListen) END_STDCOM_MAP - + public: HRESULT BindEvloop(ioevloop_t* loop); diff --git a/asynio/tcplistensocketsslimpl.cpp b/asynio/tcplistensocketsslimpl.cpp index f65f5a44..1b4e4bac 100644 --- a/asynio/tcplistensocketsslimpl.cpp +++ b/asynio/tcplistensocketsslimpl.cpp @@ -3,14 +3,14 @@ static int tcplistenssl_eventcb(ioevtcp_t* tcp, short err) { rc_error(tcp != NULL, S_ERROR); - CTcpListenSocketSslImpl* listen = (CTcpListenSocketSslImpl*)ioevtcp_getctx(tcp); + CTcpListenSocketSslImpl* listen = (CTcpListenSocketSslImpl*)ioevtcp_getctx(tcp); listen->Acceptcb(INVALID_SOCKET, NULL, 0, S_ERROR); return S_SUCCESS; } static int tcplistenssl_acceptcb(ioevtcp_t* tcp, SOCKADDR_PTR sa, socklen_t sl, _sock_t sock) { rc_error(tcp != NULL, S_ERROR); - CTcpListenSocketSslImpl* listen = (CTcpListenSocketSslImpl*)ioevtcp_getctx(tcp); + CTcpListenSocketSslImpl* listen = (CTcpListenSocketSslImpl*)ioevtcp_getctx(tcp); listen->Acceptcb(sock, sa, sl, S_SUCCESS); return S_SUCCESS; } @@ -147,8 +147,8 @@ HRESULT CTcpListenSocketSslImpl::UnBindAccpet() HRESULT CTcpListenSocketSslImpl::Acceptcb(_sock_t s, SOCKADDR_PTR sa, socklen_t sl, crtid err) { rc_error(m_accept.m_p != NULL, E_FAIL); - + m_accept->Accept(s, sa, sl, err); - + return S_OK; } diff --git a/asynio/tcplistensocketsslimpl.h b/asynio/tcplistensocketsslimpl.h index a4489811..bdec032d 100644 --- a/asynio/tcplistensocketsslimpl.h +++ b/asynio/tcplistensocketsslimpl.h @@ -3,18 +3,17 @@ #include "stdafx.h" -class CTcpListenSocketSslImpl : public ITcpSslListen, - public CUnknownImp +class CTcpListenSocketSslImpl : public ITcpSslListen, public CUnknownImp { public: - CTcpListenSocketSslImpl(void); + CTcpListenSocketSslImpl(void); virtual ~CTcpListenSocketSslImpl(void); BEGIN_STDCOM_MAP STDCOM_INTERFACE_ENTRY(ITcpSslListen) STDCOM_INTERFACE_ENTRY_UNKNOWN_(ITcpSslListen) END_STDCOM_MAP - + public: HRESULT BindEvloop(ioevloop_t* loop); diff --git a/asynio/tcpsocketimpl.cpp b/asynio/tcpsocketimpl.cpp index e50cb946..1213494b 100644 --- a/asynio/tcpsocketimpl.cpp +++ b/asynio/tcpsocketimpl.cpp @@ -2,30 +2,30 @@ int tcpsocket_eventcb(ioevstream_t* stream, short err, short what, _sock_t fd) { - rc_error(stream != NULL, S_ERROR); - CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); - + rc_error(stream != NULL, S_ERROR); + CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); + return S_SUCCESS; } int tcpsocket_opencb(ioevstream_t* stream, short err, _sock_t fd) { - rc_error(stream != NULL, S_ERROR); - CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); - + rc_error(stream != NULL, S_ERROR); + CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); + return S_SUCCESS; } int tcpsocket_readcb(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len) { - rc_error(stream != NULL, S_ERROR); - CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); - + rc_error(stream != NULL, S_ERROR); + CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); + return S_SUCCESS; } int tcpsocket_writecb(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len) { - rc_error(stream != NULL, S_ERROR); - CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); - + rc_error(stream != NULL, S_ERROR); + CTcpSocketImpl* tcpsock = (CTcpSocketImpl*)ioevstream_getctx(stream); + return S_SUCCESS; } CTcpSocketImpl::CTcpSocketImpl() @@ -116,14 +116,14 @@ HRESULT CTcpSocketImpl::AttachSock(_sock_t sock) { rc_error(sock != INVALID_SOCKET, E_FAIL); m_sock = sock; - - set_blocking(m_sock, 1); - ioevstream_assign(m_stream, m_sock); - ioevstream_setctx(m_stream, this); - ioevstream_seteventcb(m_stream, tcpsocket_eventcb); - ioevstream_setreadcb(m_stream, tcpsocket_readcb); - ioevstream_setwritecb(m_stream, tcpsocket_writecb); - + + set_blocking(m_sock, 1); + ioevstream_assign(m_stream, m_sock); + ioevstream_setctx(m_stream, this); + ioevstream_seteventcb(m_stream, tcpsocket_eventcb); + ioevstream_setreadcb(m_stream, tcpsocket_readcb); + ioevstream_setwritecb(m_stream, tcpsocket_writecb); + return S_OK; } _sock_t CTcpSocketImpl::DetachSock() @@ -176,7 +176,7 @@ HRESULT CTcpSocketImpl::WriteIo(ULONG pos, ULONG size, crtid cid, int tm) } HRESULT CTcpSocketImpl::ConnectIo(NET_ADDR addr, NET_PORT port, crtid event, int tm) { - rc_error(m_sock != INVALID_SOCKET, E_FAIL); + rc_error(m_sock != INVALID_SOCKET, E_FAIL); rc_error(addr != NULL, E_FAIL); rc_error(port != INVALID_NET_PORT, E_FAIL); rc_error(m_stream.m_p != INVALID_NET_PORT, E_FAIL); diff --git a/asynio/tcpsocketimpl.h b/asynio/tcpsocketimpl.h index bce3be5f..5ffc2b2d 100644 --- a/asynio/tcpsocketimpl.h +++ b/asynio/tcpsocketimpl.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CTcpSocketImpl : public ITcpSocket, - public CUnknownImp +class CTcpSocketImpl : public ITcpSocket, public CUnknownImp { public: CTcpSocketImpl(void); diff --git a/asynio/tcpsocketsslimpl.cpp b/asynio/tcpsocketsslimpl.cpp index e28ac682..69ce64b4 100644 --- a/asynio/tcpsocketsslimpl.cpp +++ b/asynio/tcpsocketsslimpl.cpp @@ -5,31 +5,31 @@ int tcpsocketssl_eventcb(ioevstream_t* stream, short err, short what, _sock_t fd) { - rc_error(stream != NULL, S_ERROR); - CTcpSocketSslImpl* tcpsockssl = (CTcpSocketSslImpl*)ioevstream_getctx(stream); - rc_error(tcpsockssl != NULL, S_ERROR); - tcpsockssl->OnEventcb(err, what, fd); - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + CTcpSocketSslImpl* tcpsockssl = (CTcpSocketSslImpl*)ioevstream_getctx(stream); + rc_error(tcpsockssl != NULL, S_ERROR); + tcpsockssl->OnEventcb(err, what, fd); + return S_SUCCESS; } int tcpsocketssl_readcb(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len) { - rc_error(stream != NULL, S_ERROR); - CTcpSocketSslImpl* tcpsockssl = (CTcpSocketSslImpl*)ioevstream_getctx(stream); - tcpsockssl->OnReadcb(err, ptr, len); - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + CTcpSocketSslImpl* tcpsockssl = (CTcpSocketSslImpl*)ioevstream_getctx(stream); + tcpsockssl->OnReadcb(err, ptr, len); + return S_SUCCESS; } int tcpsocketssl_writecb(ioevstream_t* stream, short err, buf_ptr ptr, buf_len len) { - rc_error(stream != NULL, S_ERROR); - CTcpSocketSslImpl* tcpsockssl = (CTcpSocketSslImpl*)ioevstream_getctx(stream); - tcpsockssl->OnWritecb(err, ptr, len); - return S_SUCCESS; + rc_error(stream != NULL, S_ERROR); + CTcpSocketSslImpl* tcpsockssl = (CTcpSocketSslImpl*)ioevstream_getctx(stream); + tcpsockssl->OnWritecb(err, ptr, len); + return S_SUCCESS; } CTcpSocketSslImpl::CTcpSocketSslImpl() { - m_sock = INVALID_SOCKET; - m_rstate = SSL_READ_HEAD; - m_stream = (ioevstream_t*)heap_malloc(sizeof(ioevstream_t)); + m_sock = INVALID_SOCKET; + m_rstate = SSL_READ_HEAD; + m_stream = (ioevstream_t*)heap_malloc(sizeof(ioevstream_t)); } CTcpSocketSslImpl::~CTcpSocketSslImpl() { @@ -39,22 +39,22 @@ HRESULT CTcpSocketSslImpl::CreateIoOperation(IAsynFrame* pIAsynFrame) { HRESULT hr = S_OK; - hr = pIAsynFrame->CreateIo(io_operation, (IBase**)&m_pReadOper); - rc_error(hr == S_OK, E_FAIL); + hr = pIAsynFrame->CreateIo(io_operation, (IBase**)&m_pReadOper); + rc_error(hr == S_OK, E_FAIL); - hr = pIAsynFrame->CreateIo(io_operation, (IBase**)&m_pWriteOper); - rc_error(hr == S_OK, E_FAIL); + hr = pIAsynFrame->CreateIo(io_operation, (IBase**)&m_pWriteOper); + rc_error(hr == S_OK, E_FAIL); - hr = pIAsynFrame->CreateIo(io_operation, (IBase**)&m_pConnectOper); - rc_error(hr == S_OK, E_FAIL); + hr = pIAsynFrame->CreateIo(io_operation, (IBase**)&m_pConnectOper); + rc_error(hr == S_OK, E_FAIL); return S_OK; } HRESULT CTcpSocketSslImpl::BindEvloop(ioevloop_t* loop) { - m_evloop = loop; - ioevstream_init(m_stream, loop, INVALID_SOCKET); - return S_OK; + m_evloop = loop; + ioevstream_init(m_stream, loop, INVALID_SOCKET); + return S_OK; } HRESULT CTcpSocketSslImpl::CloseIo(UINT rw) { @@ -71,32 +71,32 @@ HRESULT CTcpSocketSslImpl::OpenIo() } HRESULT CTcpSocketSslImpl::BindEvent(IBase* pSocketEvent) { - HRESULT hr = S_OK; - - hr = pSocketEvent->QueryInterface(IID_ISockProc, (void**)&m_pISockProc); - rc_error(hr == S_OK, E_FAIL); + HRESULT hr = S_OK; + + hr = pSocketEvent->QueryInterface(IID_ISockProc, (void**)&m_pISockProc); + rc_error(hr == S_OK, E_FAIL); return S_OK; } HRESULT CTcpSocketSslImpl::UnBindEvent() { - m_pISockProc.dispose(); + m_pISockProc.dispose(); return S_OK; } HRESULT CTcpSocketSslImpl::CreateSock() { - HRESULT hr = S_OK; - m_sock = INVALID_SOCKET; - m_sock = _createsock(PF_INET, SOCK_STREAM, IPPROTO_TCP); - rc_error(m_sock != INVALID_SOCKET, E_FAIL); - - set_blocking(m_sock, 1); - ioevstream_assign(m_stream, m_sock); - ioevstream_setctx(m_stream, this); - ioevstream_seteventcb(m_stream, tcpsocketssl_eventcb); - ioevstream_setreadcb(m_stream, tcpsocketssl_readcb); - ioevstream_setwritecb(m_stream, tcpsocketssl_writecb); - + HRESULT hr = S_OK; + m_sock = INVALID_SOCKET; + m_sock = _createsock(PF_INET, SOCK_STREAM, IPPROTO_TCP); + rc_error(m_sock != INVALID_SOCKET, E_FAIL); + + set_blocking(m_sock, 1); + ioevstream_assign(m_stream, m_sock); + ioevstream_setctx(m_stream, this); + ioevstream_seteventcb(m_stream, tcpsocketssl_eventcb); + ioevstream_setreadcb(m_stream, tcpsocketssl_readcb); + ioevstream_setwritecb(m_stream, tcpsocketssl_writecb); + return hr; } HRESULT CTcpSocketSslImpl::CloseSock() @@ -120,14 +120,14 @@ HRESULT CTcpSocketSslImpl::AttachSock(_sock_t sock) { rc_error(sock != INVALID_SOCKET, E_FAIL); m_sock = sock; - - set_blocking(m_sock, 1); - ioevstream_assign(m_stream, m_sock); - ioevstream_setctx(m_stream, this); - ioevstream_seteventcb(m_stream, tcpsocketssl_eventcb); - ioevstream_setreadcb(m_stream, tcpsocketssl_readcb); - ioevstream_setwritecb(m_stream, tcpsocketssl_writecb); - + + set_blocking(m_sock, 1); + ioevstream_assign(m_stream, m_sock); + ioevstream_setctx(m_stream, this); + ioevstream_seteventcb(m_stream, tcpsocketssl_eventcb); + ioevstream_setreadcb(m_stream, tcpsocketssl_readcb); + ioevstream_setwritecb(m_stream, tcpsocketssl_writecb); + return S_OK; } _sock_t CTcpSocketSslImpl::DetachSock() @@ -161,16 +161,16 @@ HRESULT CTcpSocketSslImpl::WriteIo(ULONG pos, ULONG size, crtid event, int tm) } HRESULT CTcpSocketSslImpl::ConnectIo(NET_ADDR addr, NET_PORT port, crtid cid, int tm) { - rc_error(m_sock != INVALID_SOCKET, E_FAIL); - rc_error(addr != NULL, E_FAIL); - rc_error(port != INVALID_NET_PORT, E_FAIL); - rc_error(m_stream.m_p != INVALID_NET_PORT, E_FAIL); + rc_error(m_sock != INVALID_SOCKET, E_FAIL); + rc_error(addr != NULL, E_FAIL); + rc_error(port != INVALID_NET_PORT, E_FAIL); + rc_error(m_stream.m_p != INVALID_NET_PORT, E_FAIL); + + int rc = S_SUCCESS; - int rc = S_SUCCESS; + rc = ioevstream_connectsock(m_stream, addr, port, tm); - rc = ioevstream_connectsock(m_stream, addr, port, tm); - - return (rc == S_SUCCESS) ? S_OK : E_FAIL; + return (rc == S_SUCCESS) ? S_OK : E_FAIL; } HRESULT CTcpSocketSslImpl::LoadCertificate(UCHAR* buf, size_t size) { @@ -184,77 +184,73 @@ HRESULT CTcpSocketSslImpl::SetSSLCtxAddress(LPCSTR hostname) } HRESULT CTcpSocketSslImpl::OnEventcb(short err, short what, _sock_t fd) { - rc_error(m_pISockProc.m_p != NULL, E_FAIL); - - /* - if (what == IOEVSTREAM_OPEN) { - - m_session.mbedNetCtx.fd = m_sock; - - int rc = open_handshake(&m_session); - - set_blocking(m_sock, 1); - - int len; - len = sprintf((char *)m_buffer, GET_REQUEST); - tls_encrypt_buf(&m_session, m_buffer, len); - - memset(m_sendbuffer, 0, sizeof(m_sendbuffer)); - - mbedtls_ssl_context* ssl = &m_session.mbedSslCtx; - - if (ssl->out_left > 0) { - memcpy(m_sendbuffer, ssl->out_hdr - ssl->out_left, ssl->out_left); - ioevstream_write(m_stream, m_sendbuffer, ssl->out_left, 30); - } - } - */ - - return S_OK; + rc_error(m_pISockProc.m_p != NULL, E_FAIL); + + /* + if (what == IOEVSTREAM_OPEN) { + + m_session.mbedNetCtx.fd = m_sock; + + int rc = open_handshake(&m_session); + + set_blocking(m_sock, 1); + + int len; + len = sprintf((char *)m_buffer, GET_REQUEST); + tls_encrypt_buf(&m_session, m_buffer, len); + + memset(m_sendbuffer, 0, sizeof(m_sendbuffer)); + + mbedtls_ssl_context* ssl = &m_session.mbedSslCtx; + + if (ssl->out_left > 0) { + memcpy(m_sendbuffer, ssl->out_hdr - ssl->out_left, ssl->out_left); + ioevstream_write(m_stream, m_sendbuffer, ssl->out_left, 30); + } + } + */ + + return S_OK; } HRESULT CTcpSocketSslImpl::OnReadcb(short err, buf_ptr ptr, buf_len len) { - rc_error(m_pISockProc.m_p != NULL, E_FAIL); - - - /* - - mbedtls_ssl_context* ssl = &m_session.mbedSslCtx; - - if (m_rstate == SSL_READ_HEAD) { - memcpy(ssl->in_hdr + ssl->in_left, ptr, len); - ssl_parse_record_header(ssl); - m_rstate = SSL_READ_BODY; - ssl->in_left = ssl->in_msglen; - ioevstream_read(m_stream, m_recvbuffer, ssl->in_msglen, 30); - return S_OK; - } - - if (m_rstate == SSL_READ_BODY) { - ssl->in_left = 5; - memcpy(ssl->in_hdr + ssl->in_left, ptr, len); - ssl_prepare_record_content(ssl); - } - */ - - - return S_OK; + rc_error(m_pISockProc.m_p != NULL, E_FAIL); + + /* + + mbedtls_ssl_context* ssl = &m_session.mbedSslCtx; + + if (m_rstate == SSL_READ_HEAD) { + memcpy(ssl->in_hdr + ssl->in_left, ptr, len); + ssl_parse_record_header(ssl); + m_rstate = SSL_READ_BODY; + ssl->in_left = ssl->in_msglen; + ioevstream_read(m_stream, m_recvbuffer, ssl->in_msglen, 30); + return S_OK; + } + + if (m_rstate == SSL_READ_BODY) { + ssl->in_left = 5; + memcpy(ssl->in_hdr + ssl->in_left, ptr, len); + ssl_prepare_record_content(ssl); + } + */ + + return S_OK; } HRESULT CTcpSocketSslImpl::OnWritecb(short err, buf_ptr ptr, buf_len len) { - rc_error(m_pISockProc.m_p != NULL, E_FAIL); - - ioevstream_read(m_stream, m_recvbuffer, 5, 30); - -/* - int ret = 0; - unsigned char buf[1024]; - int size = sizeof(buf) - 1; - memset(buf, 0, sizeof(buf)); - ret = mbedtls_ssl_read(&m_session.mbedSslCtx, buf, size); -*/ - - - - return S_OK; + rc_error(m_pISockProc.m_p != NULL, E_FAIL); + + ioevstream_read(m_stream, m_recvbuffer, 5, 30); + + /* + int ret = 0; + unsigned char buf[1024]; + int size = sizeof(buf) - 1; + memset(buf, 0, sizeof(buf)); + ret = mbedtls_ssl_read(&m_session.mbedSslCtx, buf, size); + */ + + return S_OK; } diff --git a/asynio/tcpsocketsslimpl.h b/asynio/tcpsocketsslimpl.h index a0067a59..6091b5c3 100644 --- a/asynio/tcpsocketsslimpl.h +++ b/asynio/tcpsocketsslimpl.h @@ -3,31 +3,30 @@ #include "stdafx.h" -//openssl genrsa -des3 -out server.key 1024 -//openssl req -new -key server.key -out server.csr -//openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt +// openssl genrsa -des3 -out server.key 1024 +// openssl req -new -key server.key -out server.csr +// openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt #define SSL_READ_HEAD 0 #define SSL_READ_BODY 1 -class CTcpSocketSslImpl : public ITcpSocketSsl, - public CUnknownImp +class CTcpSocketSslImpl : public ITcpSocketSsl, public CUnknownImp { public: - CTcpSocketSslImpl(void); + CTcpSocketSslImpl(void); virtual ~CTcpSocketSslImpl(void); BEGIN_STDCOM_MAP STDCOM_INTERFACE_ENTRY(ITcpSocketSsl) STDCOM_INTERFACE_ENTRY(ITcpSocket) STDCOM_INTERFACE_ENTRY_UNKNOWN_(ITcpSocketSsl) - STDCOM_INTERFACE_MEMBER_ENTRY_(m_pReadOper, IOperation, IID_IReadOperation) - STDCOM_INTERFACE_MEMBER_ENTRY_(m_pWriteOper, IOperation, IID_IWriteOperation) + STDCOM_INTERFACE_MEMBER_ENTRY_(m_pReadOper, IOperation, IID_IReadOperation) + STDCOM_INTERFACE_MEMBER_ENTRY_(m_pWriteOper, IOperation, IID_IWriteOperation) END_STDCOM_MAP public: HRESULT CreateIoOperation(IAsynFrame* pIAsynFrame); - HRESULT BindEvloop(ioevloop_t* loop); + HRESULT BindEvloop(ioevloop_t* loop); public: // IIoDevice @@ -55,25 +54,25 @@ public: // ITcpSocketSSL std_method(LoadCertificate)(UCHAR* buf, size_t size); std_method(SetSSLCtxAddress)(LPCSTR hostname); - + public: - std_method(OnEventcb)(short err, short what, _sock_t fd); - std_method(OnReadcb)(short err, buf_ptr ptr, buf_len len); - std_method(OnWritecb)(short err, buf_ptr ptr, buf_len len); - + std_method(OnEventcb)(short err, short what, _sock_t fd); + std_method(OnReadcb)(short err, buf_ptr ptr, buf_len len); + std_method(OnWritecb)(short err, buf_ptr ptr, buf_len len); + private: - _sock_t m_sock; - _lComPtr m_pReadOper; - _lComPtr m_pWriteOper; - _lComPtr m_pConnectOper; - _lComPtr m_pISockProc; - SafePtr m_stream; - ioevloop_t* m_evloop; - - unsigned char m_buffer[1024]; - unsigned char m_sendbuffer[1024]; - unsigned char m_recvbuffer[1024]; - unsigned int m_rstate; + _sock_t m_sock; + _lComPtr m_pReadOper; + _lComPtr m_pWriteOper; + _lComPtr m_pConnectOper; + _lComPtr m_pISockProc; + SafePtr m_stream; + ioevloop_t* m_evloop; + + unsigned char m_buffer[1024]; + unsigned char m_sendbuffer[1024]; + unsigned char m_recvbuffer[1024]; + unsigned int m_rstate; }; #endif diff --git a/asynio/timerimpl.cpp b/asynio/timerimpl.cpp index d8d1d423..feddc047 100644 --- a/asynio/timerimpl.cpp +++ b/asynio/timerimpl.cpp @@ -9,7 +9,7 @@ CTimerImpl::~CTimerImpl(void) } HRESULT CTimerImpl::BindEvloop(ioevloop_t* loop) { - return S_OK; + return S_OK; } HRESULT CTimerImpl::Start() { @@ -25,13 +25,13 @@ HRESULT CTimerImpl::SetSec(int isec) } HRESULT CTimerImpl::Bind(IBase* pBase) { - rc_error(pBase != NULL, E_FAIL); - return pBase->QueryInterface(IID_ITimerProc, (void**)&m_pTimerProc); + rc_error(pBase != NULL, E_FAIL); + return pBase->QueryInterface(IID_ITimerProc, (void**)&m_pTimerProc); } HRESULT CTimerImpl::UnBind() { rc_error(m_pTimerProc.m_p != NULL, E_FAIL); - m_pTimerProc.dispose(); + m_pTimerProc.dispose(); return S_OK; } crtid CTimerImpl::GetId() @@ -40,6 +40,6 @@ crtid CTimerImpl::GetId() } HRESULT CTimerImpl::SetId(crtid id) { - m_cid = id; + m_cid = id; return S_OK; } diff --git a/asynio/timerimpl.h b/asynio/timerimpl.h index a01ad5d7..362f38bc 100644 --- a/asynio/timerimpl.h +++ b/asynio/timerimpl.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CTimerImpl : public ITimer, - public CUnknownImp +class CTimerImpl : public ITimer, public CUnknownImp { public: CTimerImpl(); @@ -15,20 +14,20 @@ public: STDCOM_INTERFACE_ENTRY_UNKNOWN_(ITimer) END_STDCOM_MAP public: - HRESULT BindEvloop(ioevloop_t* loop); - + HRESULT BindEvloop(ioevloop_t* loop); + public: // ITimer std_method(Start)(); std_method(Stop)(); std_method(SetSec)(int isec); - std_method(Bind)(IBase* pBase); + std_method(Bind)(IBase* pBase); std_method(UnBind)(); std_method_(crtid, GetId)(); std_method(SetId)(crtid id); private: - crtid m_cid; + crtid m_cid; _lComPtr m_pTimerProc; }; #endif diff --git a/asynio/tlswrap.cpp b/asynio/tlswrap.cpp index efb257e9..97aab355 100644 --- a/asynio/tlswrap.cpp +++ b/asynio/tlswrap.cpp @@ -3,191 +3,191 @@ /* static void my_debug(void *ctx, int level, - const char *file, int line, - const char *str) + const char *file, int line, + const char *str) { - ((void)level); + ((void)level); - printf("%s\n", str); + printf("%s\n", str); } #define _SRV_KEY_RSA_PEM \ - "-----BEGIN RSA PRIVATE KEY-----\r\n" \ - "MIIEpAIBAAKCAQEAwU2j3efNHdEE10lyuJmsDnjkOjxKzzoTFtBa5M2jAIin7h5r\r\n" \ - "lqdStJD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W7b\r\n" \ + "vDrEnocJbqCm7IukhXHOBK8CgYEAwqdHB0hqyNSzIOGY7v9abzB6pUdA3BZiQvEs\r\n" \ + "3LjHVd4HPJ2x0N8CgrBIWOE0q8+0hSMmeE96WW/7jD3fPWwCR5zlXknxBQsfv0gP\r\n" \ + "3BC5PR0Qdypz+d+9zfMf625kyit4T/hzwhDveZUzHnk1Cf+IG7Q+TOEnLnWAWBED\r\n" \ + "ISOWmrUCgYAFEmRxgwAc/u+D6t0syCwAYh6POtscq9Y0i9GyWk89NzgC4NdwwbBH\r\n" \ + "4AgahOxIxXx2gxJnq3yfkJfIjwf0s2DyP0kY2y6Ua1OeomPeY9mrIS4tCuDQ6LrE\r\n" \ + "TB6l9VGoxJL4fyHnZb8L5gGvnB1bbD8cL6YPaDiOhcRseC9vBiEuVg==\r\n" \ + "-----END RSA PRIVATE KEY-----\r\n" #define tls_debug_level 2 int s_tls_init_bio(mbedtls_session_t* session, void *entropy, size_t len) { - mbedtls_net_init(&session->mbedNetCtx); - mbedtls_ssl_init(&session->mbedSslCtx); - mbedtls_ssl_config_init(&session->mbedSslConf); - mbedtls_ctr_drbg_init(&session->mbedDrbgCtx); - mbedtls_x509_crt_init(&session->mbedX509Crt); - mbedtls_entropy_init(&(session->mbedEtpyCtx)); - mbedtls_ssl_conf_dbg(&session->mbedSslConf, my_debug, stdout); - mbedtls_ctr_drbg_seed(&session->mbedDrbgCtx, - mbedtls_entropy_func, - &session->mbedEtpyCtx, - (unsigned char *)entropy, - len); - - mbedtls_pk_parse_key(&session->mbedPkey, (const unsigned char *) mbedtls_test_srv_key, - mbedtls_test_srv_key_len, NULL, 0 ); - - mbedtls_x509_crt_parse(&session->mbedX509Crt, - (const unsigned char*) mbedtls_test_srv_crt, mbedtls_test_srv_crt_len ); - - mbedtls_ssl_config_defaults(&session->mbedSslConf, - MBEDTLS_SSL_IS_SERVER, - MBEDTLS_SSL_TRANSPORT_STREAM, - MBEDTLS_SSL_PRESET_DEFAULT); - - mbedtls_ssl_conf_authmode(&session->mbedSslConf, MBEDTLS_SSL_VERIFY_OPTIONAL); - mbedtls_ssl_conf_ca_chain(&session->mbedSslConf, &session->mbedX509Crt, NULL); - - mbedtls_ssl_conf_rng(&session->mbedSslConf, mbedtls_ctr_drbg_random, &session->mbedDrbgCtx); - mbedtls_ssl_conf_dbg(&session->mbedSslConf, my_debug, stdout); - - - mbedtls_ssl_set_bio(&session->mbedSslCtx, - &session->mbedNetCtx, mbedtls_net_send, mbedtls_net_recv, NULL); - - - mbedtls_ssl_conf_ca_chain( &session->mbedSslConf, session->mbedX509Crt.next, NULL ); - mbedtls_ssl_conf_own_cert( &session->mbedSslConf, - &session->mbedX509Crt, &session->mbedPkey); - - - mbedtls_ssl_conf_read_timeout(&session->mbedSslConf, 30000); - - mbedtls_ssl_setup(&session->mbedSslCtx, &session->mbedSslConf); - - mbedtls_debug_set_threshold(tls_debug_level); - return 0; + mbedtls_net_init(&session->mbedNetCtx); + mbedtls_ssl_init(&session->mbedSslCtx); + mbedtls_ssl_config_init(&session->mbedSslConf); + mbedtls_ctr_drbg_init(&session->mbedDrbgCtx); + mbedtls_x509_crt_init(&session->mbedX509Crt); + mbedtls_entropy_init(&(session->mbedEtpyCtx)); + mbedtls_ssl_conf_dbg(&session->mbedSslConf, my_debug, stdout); + mbedtls_ctr_drbg_seed(&session->mbedDrbgCtx, + mbedtls_entropy_func, + &session->mbedEtpyCtx, + (unsigned char *)entropy, + len); + + mbedtls_pk_parse_key(&session->mbedPkey, (const unsigned char *) mbedtls_test_srv_key, + mbedtls_test_srv_key_len, NULL, 0 ); + + mbedtls_x509_crt_parse(&session->mbedX509Crt, + (const unsigned char*) mbedtls_test_srv_crt, mbedtls_test_srv_crt_len ); + + mbedtls_ssl_config_defaults(&session->mbedSslConf, + MBEDTLS_SSL_IS_SERVER, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT); + + mbedtls_ssl_conf_authmode(&session->mbedSslConf, MBEDTLS_SSL_VERIFY_OPTIONAL); + mbedtls_ssl_conf_ca_chain(&session->mbedSslConf, &session->mbedX509Crt, NULL); + + mbedtls_ssl_conf_rng(&session->mbedSslConf, mbedtls_ctr_drbg_random, &session->mbedDrbgCtx); + mbedtls_ssl_conf_dbg(&session->mbedSslConf, my_debug, stdout); + + + mbedtls_ssl_set_bio(&session->mbedSslCtx, + &session->mbedNetCtx, mbedtls_net_send, mbedtls_net_recv, NULL); + + + mbedtls_ssl_conf_ca_chain( &session->mbedSslConf, session->mbedX509Crt.next, NULL ); + mbedtls_ssl_conf_own_cert( &session->mbedSslConf, + &session->mbedX509Crt, &session->mbedPkey); + + + mbedtls_ssl_conf_read_timeout(&session->mbedSslConf, 30000); + + mbedtls_ssl_setup(&session->mbedSslCtx, &session->mbedSslConf); + + mbedtls_debug_set_threshold(tls_debug_level); + return 0; } int c_tls_init_bio(mbedtls_session_t* session, void *entropy, size_t len) { - mbedtls_net_init(&session->mbedNetCtx); - mbedtls_ssl_init(&session->mbedSslCtx); - mbedtls_ssl_config_init(&session->mbedSslConf); - mbedtls_ctr_drbg_init(&session->mbedDrbgCtx); - mbedtls_x509_crt_init(&session->mbedX509Crt); - mbedtls_entropy_init(&(session->mbedEtpyCtx)); - //mbedtls_ssl_conf_dbg(&session->mbedSslConf, my_debug, stdout); - mbedtls_ctr_drbg_seed(&session->mbedDrbgCtx, - mbedtls_entropy_func, - &session->mbedEtpyCtx, - (unsigned char *)entropy, - len); - - mbedtls_ssl_config_defaults(&session->mbedSslConf, - MBEDTLS_SSL_IS_CLIENT, - MBEDTLS_SSL_TRANSPORT_STREAM, - MBEDTLS_SSL_PRESET_DEFAULT); - - mbedtls_ssl_conf_authmode(&session->mbedSslConf, MBEDTLS_SSL_VERIFY_OPTIONAL); - mbedtls_ssl_conf_ca_chain(&session->mbedSslConf, &session->mbedX509Crt, NULL); - mbedtls_ssl_conf_rng(&session->mbedSslConf, mbedtls_ctr_drbg_random, &session->mbedDrbgCtx); - mbedtls_ssl_conf_dbg(&session->mbedSslConf, my_debug, stdout); - mbedtls_ssl_setup(&session->mbedSslCtx, &session->mbedSslConf); - - mbedtls_ssl_conf_read_timeout(&session->mbedSslConf, 30000); - - mbedtls_ssl_set_bio(&session->mbedSslCtx,&session->mbedNetCtx, mbedtls_net_send, mbedtls_net_recv, NULL); - - mbedtls_debug_set_threshold(tls_debug_level); - - return 0; + mbedtls_net_init(&session->mbedNetCtx); + mbedtls_ssl_init(&session->mbedSslCtx); + mbedtls_ssl_config_init(&session->mbedSslConf); + mbedtls_ctr_drbg_init(&session->mbedDrbgCtx); + mbedtls_x509_crt_init(&session->mbedX509Crt); + mbedtls_entropy_init(&(session->mbedEtpyCtx)); + //mbedtls_ssl_conf_dbg(&session->mbedSslConf, my_debug, stdout); + mbedtls_ctr_drbg_seed(&session->mbedDrbgCtx, + mbedtls_entropy_func, + &session->mbedEtpyCtx, + (unsigned char *)entropy, + len); + + mbedtls_ssl_config_defaults(&session->mbedSslConf, + MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT); + + mbedtls_ssl_conf_authmode(&session->mbedSslConf, MBEDTLS_SSL_VERIFY_OPTIONAL); + mbedtls_ssl_conf_ca_chain(&session->mbedSslConf, &session->mbedX509Crt, NULL); + mbedtls_ssl_conf_rng(&session->mbedSslConf, mbedtls_ctr_drbg_random, &session->mbedDrbgCtx); + mbedtls_ssl_conf_dbg(&session->mbedSslConf, my_debug, stdout); + mbedtls_ssl_setup(&session->mbedSslCtx, &session->mbedSslConf); + + mbedtls_ssl_conf_read_timeout(&session->mbedSslConf, 30000); + + mbedtls_ssl_set_bio(&session->mbedSslCtx,&session->mbedNetCtx, mbedtls_net_send, mbedtls_net_recv, NULL); + + mbedtls_debug_set_threshold(tls_debug_level); + + return 0; } int open_handshake(mbedtls_session_t* session) { - int open = 0; - int rc = 0; - while ((rc = mbedtls_ssl_handshake(&session->mbedSslCtx)) != 0) - { - if (rc != MBEDTLS_ERR_SSL_WANT_READ && rc != MBEDTLS_ERR_SSL_WANT_WRITE) { - break; - } - - } - - open = session->mbedSslCtx.state == MBEDTLS_SSL_HANDSHAKE_OVER; - return open; + int open = 0; + int rc = 0; + while ((rc = mbedtls_ssl_handshake(&session->mbedSslCtx)) != 0) + { + if (rc != MBEDTLS_ERR_SSL_WANT_READ && rc != MBEDTLS_ERR_SSL_WANT_WRITE) { + break; + } + + } + + open = session->mbedSslCtx.state == MBEDTLS_SSL_HANDSHAKE_OVER; + return open; } int get_verify_result(mbedtls_session_t* session, char* buf, size_t size) { - int open = 1; - uint32_t flags; - - if ((flags = mbedtls_ssl_get_verify_result(&session->mbedSslCtx)) != 0) - { - open = 0; - char vrfy_buf[512]; - mbedtls_x509_crt_verify_info(vrfy_buf, sizeof(vrfy_buf), "!", flags); - } - return open; + int open = 1; + uint32_t flags; + + if ((flags = mbedtls_ssl_get_verify_result(&session->mbedSslCtx)) != 0) + { + open = 0; + char vrfy_buf[512]; + mbedtls_x509_crt_verify_info(vrfy_buf, sizeof(vrfy_buf), "!", flags); + } + return open; } static inline size_t iossl_ep_len(const mbedtls_ssl_context* ssl) { #if defined(MBEDTLS_SSL_PROTO_DTLS) - if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) - return (2); + if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) + return (2); #else - ((void)ssl); + ((void)ssl); #endif - return (0); + return (0); } static void iossl_update_out_pointers(mbedtls_ssl_context* ssl, mbedtls_ssl_transform* transform) { #if defined(MBEDTLS_SSL_PROTO_DTLS) - if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { - ssl->out_ctr = ssl->out_hdr + 3; - ssl->out_len = ssl->out_hdr + 11; - ssl->out_iv = ssl->out_hdr + 13; - } else + if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { + ssl->out_ctr = ssl->out_hdr + 3; + ssl->out_len = ssl->out_hdr + 11; + ssl->out_iv = ssl->out_hdr + 13; + } else #endif - { - ssl->out_ctr = ssl->out_hdr - 8; - ssl->out_len = ssl->out_hdr + 3; - ssl->out_iv = ssl->out_hdr + 5; - } - - if (transform != NULL && ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2) { - ssl->out_msg = ssl->out_iv + transform->ivlen - transform->fixed_ivlen; - } else - ssl->out_msg = ssl->out_iv; + { + ssl->out_ctr = ssl->out_hdr - 8; + ssl->out_len = ssl->out_hdr + 3; + ssl->out_iv = ssl->out_hdr + 5; + } + + if (transform != NULL && ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2) { + ssl->out_msg = ssl->out_iv + transform->ivlen - transform->fixed_ivlen; + } else + ssl->out_msg = ssl->out_iv; } #define SSL_DONT_FORCE_FLUSH 0 @@ -195,83 +195,82 @@ static void iossl_update_out_pointers(mbedtls_ssl_context* ssl, mbedtls_ssl_tran int tls_encrypt_buf(mbedtls_session_t* session, unsigned char* ptr, size_t size) { - unsigned i; - int ret, done = 0; - uint8_t flush = SSL_FORCE_FLUSH; - - size_t protected_record_size; - mbedtls_ssl_context* ssl = &session->mbedSslCtx; - - ssl->out_msglen = size; - ssl->out_msgtype = MBEDTLS_SSL_MSG_APPLICATION_DATA; - memcpy(ssl->out_msg, ptr, size); - - - size_t len = ssl->out_msglen; - ssl->out_hdr[0] = (unsigned char)ssl->out_msgtype; - mbedtls_ssl_write_version(ssl->major_ver, ssl->minor_ver,ssl->conf->transport, ssl->out_hdr + 1); - memcpy(ssl->out_ctr, ssl->cur_out_ctr, 8); - ssl->out_len[0] = (unsigned char)(len >> 8); - ssl->out_len[1] = (unsigned char)(len); - - if (ssl->transform_out != NULL) { - if ((ret = ssl_encrypt_buf(ssl)) != 0) { - return (ret); - } - - len = ssl->out_msglen; - ssl->out_len[0] = (unsigned char)(len >> 8); - ssl->out_len[1] = (unsigned char)(len); - } - protected_record_size = len + mbedtls_ssl_hdr_len(ssl); - - + unsigned i; + int ret, done = 0; + uint8_t flush = SSL_FORCE_FLUSH; + + size_t protected_record_size; + mbedtls_ssl_context* ssl = &session->mbedSslCtx; + + ssl->out_msglen = size; + ssl->out_msgtype = MBEDTLS_SSL_MSG_APPLICATION_DATA; + memcpy(ssl->out_msg, ptr, size); + + + size_t len = ssl->out_msglen; + ssl->out_hdr[0] = (unsigned char)ssl->out_msgtype; + mbedtls_ssl_write_version(ssl->major_ver, ssl->minor_ver,ssl->conf->transport, ssl->out_hdr + 1); + memcpy(ssl->out_ctr, ssl->cur_out_ctr, 8); + ssl->out_len[0] = (unsigned char)(len >> 8); + ssl->out_len[1] = (unsigned char)(len); + + if (ssl->transform_out != NULL) { + if ((ret = ssl_encrypt_buf(ssl)) != 0) { + return (ret); + } + + len = ssl->out_msglen; + ssl->out_len[0] = (unsigned char)(len >> 8); + ssl->out_len[1] = (unsigned char)(len); + } + protected_record_size = len + mbedtls_ssl_hdr_len(ssl); + + #if defined(MBEDTLS_SSL_PROTO_DTLS) - if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { - ret = ssl_get_remaining_space_in_datagram(ssl); - if (ret < 0) - return (ret); - - if (protected_record_size > (size_t)ret) { - return (MBEDTLS_ERR_SSL_INTERNAL_ERROR); - } - } -#endif - - - ssl->out_left += protected_record_size; - ssl->out_hdr += protected_record_size; - iossl_update_out_pointers(ssl, ssl->transform_out); - - for (i = 8; i > iossl_ep_len(ssl); i--) - if (++ssl->cur_out_ctr[i - 1] != 0) - break; - + if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { + ret = ssl_get_remaining_space_in_datagram(ssl); + if (ret < 0) + return (ret); + + if (protected_record_size > (size_t)ret) { + return (MBEDTLS_ERR_SSL_INTERNAL_ERROR); + } + } +#endif + + + ssl->out_left += protected_record_size; + ssl->out_hdr += protected_record_size; + iossl_update_out_pointers(ssl, ssl->transform_out); + + for (i = 8; i > iossl_ep_len(ssl); i--) + if (++ssl->cur_out_ctr[i - 1] != 0) + break; + #if defined(MBEDTLS_SSL_PROTO_DTLS) - if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && flush == SSL_DONT_FORCE_FLUSH) { - - size_t remaining; - ret = ssl_get_remaining_payload_in_datagram(ssl); - if (ret < 0) { - MBEDTLS_SSL_DEBUG_RET(1, "ssl_get_remaining_payload_in_datagram", ret); - return (ret); - } - - remaining = (size_t)ret; - if (remaining == 0) { - flush = SSL_FORCE_FLUSH; - } else { - MBEDTLS_SSL_DEBUG_MSG(2, ("Still %u bytes available in current datagram", (unsigned)remaining)); - } - - } -#endif - - return 0; + if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && flush == SSL_DONT_FORCE_FLUSH) { + + size_t remaining; + ret = ssl_get_remaining_payload_in_datagram(ssl); + if (ret < 0) { + MBEDTLS_SSL_DEBUG_RET(1, "ssl_get_remaining_payload_in_datagram", ret); + return (ret); + } + + remaining = (size_t)ret; + if (remaining == 0) { + flush = SSL_FORCE_FLUSH; + } else { + MBEDTLS_SSL_DEBUG_MSG(2, ("Still %u bytes available in current datagram", (unsigned)remaining)); + } + + } +#endif + + return 0; } int tls_decryption_buf(mbedtls_session_t* session, unsigned char* ptr, size_t size) { - return 0; + return 0; } */ - diff --git a/asynio/tlswrap.h b/asynio/tlswrap.h index d1cd24f2..8815521e 100644 --- a/asynio/tlswrap.h +++ b/asynio/tlswrap.h @@ -23,10 +23,10 @@ #endif #if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \ - !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \ - !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \ - !defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C) || \ - !defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) + !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \ + !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \ + !defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C) || \ + !defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) #else @@ -46,14 +46,14 @@ typedef struct mbedtls_session_s mbedtls_session_t; struct mbedtls_session_s { - mbedtls_entropy_context mbedEntropy; - mbedtls_net_context mbedNetCtx; - mbedtls_ssl_context mbedSslCtx; - mbedtls_ssl_config mbedSslConf; - mbedtls_ctr_drbg_context mbedDrbgCtx; - mbedtls_entropy_context mbedEtpyCtx; - mbedtls_x509_crt mbedX509Crt; - mbedtls_pk_context mbedPkey; + mbedtls_entropy_context mbedEntropy; + mbedtls_net_context mbedNetCtx; + mbedtls_ssl_context mbedSslCtx; + mbedtls_ssl_config mbedSslConf; + mbedtls_ctr_drbg_context mbedDrbgCtx; + mbedtls_entropy_context mbedEtpyCtx; + mbedtls_x509_crt mbedX509Crt; + mbedtls_pk_context mbedPkey; }; int s_tls_init_bio(mbedtls_session_t* session, void *entropy, size_t len); diff --git a/asynio/udpsocketimpl.cpp b/asynio/udpsocketimpl.cpp index 22b3c404..8da869c9 100644 --- a/asynio/udpsocketimpl.cpp +++ b/asynio/udpsocketimpl.cpp @@ -22,7 +22,7 @@ HRESULT CUdpSocketImpl::CreateIoOperation(IAsynFrame* pIAsynFrame) } HRESULT CUdpSocketImpl::BindEvloop(ioevloop_t* loop) { - return S_OK; + return S_OK; } HRESULT CUdpSocketImpl::CloseIo(UINT rw) diff --git a/asynio/udpsocketimpl.h b/asynio/udpsocketimpl.h index 5edcf4fb..61c6df37 100644 --- a/asynio/udpsocketimpl.h +++ b/asynio/udpsocketimpl.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CUdpSocketImpl : public IUdpSocket, - public CUnknownImp +class CUdpSocketImpl : public IUdpSocket, public CUnknownImp { public: CUdpSocketImpl(void); @@ -17,7 +16,7 @@ public: public: HRESULT CreateIoOperation(IAsynFrame* pIAsynFrame); - HRESULT BindEvloop(ioevloop_t* loop); + HRESULT BindEvloop(ioevloop_t* loop); public: // IIoDevice diff --git a/container/dllmain.cpp b/container/dllmain.cpp index 305f2cd7..c9b2d8ae 100644 --- a/container/dllmain.cpp +++ b/container/dllmain.cpp @@ -35,9 +35,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {CLSID_CMainRun, &ClassFactory::GetClass, "MainRun.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{CLSID_CMainRun, &ClassFactory::GetClass, "MainRun.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/container/mainrun.h b/container/mainrun.h index 4d1d55d6..b55ed332 100644 --- a/container/mainrun.h +++ b/container/mainrun.h @@ -5,8 +5,7 @@ #include "objectrun.h" #include "plugins.h" -class CMainRunImpl : public IMainRun, - public CUnknownImp +class CMainRunImpl : public IMainRun, public CUnknownImp { public: CMainRunImpl(void); @@ -31,7 +30,7 @@ public: private: typedef struct ObjectRunItem { ObjectRunPtr m_ptr; - }* pObjectRunItemPtr; + } * pObjectRunItemPtr; typedef std::map ObjectStruct; typedef ObjectStruct::iterator ObjectStructIterator; diff --git a/container/msg.h b/container/msg.h index 9b4cdcd7..cd3be03b 100644 --- a/container/msg.h +++ b/container/msg.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CMsgImpl : public IMsg, - public CUnknownImp +class CMsgImpl : public IMsg, public CUnknownImp { public: CMsgImpl(void); diff --git a/container/objectloader.h b/container/objectloader.h index 358d175b..57140be5 100644 --- a/container/objectloader.h +++ b/container/objectloader.h @@ -3,9 +3,7 @@ #include "stdafx.h" -class CObjectLoader : public ICreator, - public ILibManager, - public CUnknownImp +class CObjectLoader : public ICreator, public ILibManager, public CUnknownImp { public: CObjectLoader(void); diff --git a/container/objectrun.cpp b/container/objectrun.cpp index c87fd48d..b0c98d5c 100644 --- a/container/objectrun.cpp +++ b/container/objectrun.cpp @@ -450,9 +450,9 @@ HRESULT CObjectRunImpl::UninitAllPlugins() pPlugin->Uninit(); } else { char guid[GUIDStringLength] = {0x00}; - - CLSID id = m_PluginsClsid[index].GetClsid(); - + + CLSID id = m_PluginsClsid[index].GetClsid(); + GUIDToString(&id, guid); logi("uinit_plugin_error==>guid:%s", guid); } @@ -567,9 +567,9 @@ HRESULT CObjectRunImpl::DoPluginsStartFunc(UINT uType) rc_error_continue(hr == S_OK); char guid[GUIDStringLength] = {0x00}; - - CLSID id = m_PluginsClsid[uloop].GetClsid(); - + + CLSID id = m_PluginsClsid[uloop].GetClsid(); + GUIDToString(&id, guid); m_RunPlugin = m_PluginsClsid[uloop].GetClsid(); @@ -601,9 +601,9 @@ HRESULT CObjectRunImpl::DoPluginsStopFunc(UINT uType, UINT uExit) rc_error_continue(hr == S_OK); char guid[GUIDStringLength] = {0x00}; - - CLSID id = m_PluginsClsid[uloop].GetClsid(); - + + CLSID id = m_PluginsClsid[uloop].GetClsid(); + GUIDToString(&id, guid); RunPlugin_Stop(pUnknown, uExit); @@ -698,7 +698,7 @@ HRESULT CObjectRunImpl::Reset() path_string CObjectRunImpl::ContainerPath(LPCSTR ComponentName) { - path_string stringpath; + path_string stringpath; stringpath.clear(); stringpath.append(m_strRunPath); stringpath.append(path_slash); diff --git a/container/objectrun.h b/container/objectrun.h index 96479776..cf9c5522 100644 --- a/container/objectrun.h +++ b/container/objectrun.h @@ -4,9 +4,7 @@ #include "stdafx.h" #include "plugins.h" -class CObjectRunImpl : public IObjectRun, - public IMsgPlugin, - public CUnknownImp +class CObjectRunImpl : public IObjectRun, public IMsgPlugin, public CUnknownImp { public: CObjectRunImpl(); @@ -104,14 +102,14 @@ private: LibManagerPtr m_pILibManager; private: - path_string m_strRunPath; + path_string m_strRunPath; string m_strRegisterCode; private: CPlugins m_Plugins; PluginVector m_PluginsClsid; CLSID m_RunPlugin; - path_string m_strContainer; + path_string m_strContainer; basic_tchar** m_argv; UINT m_argc; diff --git a/container/plugins.cpp b/container/plugins.cpp index 9ed36db1..e0843a09 100644 --- a/container/plugins.cpp +++ b/container/plugins.cpp @@ -25,7 +25,7 @@ HRESULT CPlugins::Clear() HRESULT CPlugins::LoadMemory(LPCSTR buf, ULONG len) { rc_error(buf != NULL, E_FAIL); - + m_pJson = sjson_parse(buf, 0, 0); rc_error(m_pJson.m_p != NULL, E_FAIL); return LoadPluginModule(m_pJson); @@ -78,12 +78,12 @@ HRESULT CPlugins::LoadPluginModule(sjsoncptr JsRoot) rc_error(JsRoot != NULL, E_FAIL); if (sjson_is_obj(JsRoot) == sjson_true) { - sjsonptr JsModule = sjson_get_obj(JsRoot, JSON_COMPONENTS_PATH); + sjsonptr JsModule = sjson_get_obj(JsRoot, JSON_COMPONENTS_PATH); if (sjson_is_array(JsModule) == sjson_true) { int iloop = 0; for (iloop = 0; iloop < sjson_get_array_size(JsModule); iloop++) { - sjsonptr JsItem = NULL; + sjsonptr JsItem = NULL; JsItem = sjson_get_array_item(JsModule, iloop); LoadPluginItem(JsItem); } @@ -97,7 +97,7 @@ HRESULT CPlugins::LoadPluginItem(sjsoncptr JsRoot) { HRESULT hr = S_OK; - if (sjson_is_string(JsRoot) == sjson_true ) { + if (sjson_is_string(JsRoot) == sjson_true) { CharArrayPtr item; item.dispose(); item = ALLOC_NEW char[JSON_ITEM + 1](); @@ -138,7 +138,7 @@ HRESULT CPlugins::GetItemString(sjsoncptr JsRoot, const char* id, char** pItem) HRESULT hr = E_FAIL; if (sjson_is_obj(JsRoot)) { - sjsonptr JsItem = sjson_get_obj(JsRoot, id); + sjsonptr JsItem = sjson_get_obj(JsRoot, id); if (sjson_is_array(JsItem)) { *pItem = JsItem->valuestring; diff --git a/container/rot.h b/container/rot.h index b2f93bb4..ce1fe5e9 100644 --- a/container/rot.h +++ b/container/rot.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CRotImpl : public IRot, - public CUnknownImp +class CRotImpl : public IRot, public CUnknownImp { public: CRotImpl(void); diff --git a/container/stdafx.h b/container/stdafx.h index 57997867..0351fb50 100644 --- a/container/stdafx.h +++ b/container/stdafx.h @@ -88,32 +88,23 @@ public: string strComponent; ~Com_Plugin() { - loop = 0; - strComponent.clear(); + loop = 0; + strComponent.clear(); } Com_Plugin(CLSID id, ULONG index, const char* component) { - clsid = id; - loop = index; - strComponent = component; + clsid = id; + loop = index; + strComponent = component; } - - CLSID GetClsid() const - { - return clsid; - } - - unsigned long GetIndex() const - { - return loop; - } - - string GetComponent() const - { - return strComponent; - } - + + CLSID GetClsid() const { return clsid; } + + unsigned long GetIndex() const { return loop; } + + string GetComponent() const { return strComponent; } + bool operator>(const Com_Plugin& it) const { return GetIndex() > (it.GetIndex()); } bool operator<(const Com_Plugin& it) const { return !(operator>(it)); } diff --git a/crt/crt_aes.h b/crt/crt_aes.h index 5a791ec2..efb57266 100644 --- a/crt/crt_aes.h +++ b/crt/crt_aes.h @@ -28,7 +28,7 @@ struct aes_ctx_s { int _aes_set_encrypt_key(const aes_byte_t* userKey, const aes_size_t bits, aes_ctx_t* key); int _aes_set_decrypt_key(const aes_byte_t* userKey, const aes_size_t bits, aes_ctx_t* key); -//len => 16 error +// len => 16 error int _aes_encrypt(const aes_byte_t* in, aes_byte_t* out, const aes_ctx_t* key); int _aes_decrypt(const aes_byte_t* in, aes_byte_t* out, const aes_ctx_t* key); diff --git a/crt/crt_barrier.h b/crt/crt_barrier.h index c7ff85b9..4e0dd8eb 100644 --- a/crt/crt_barrier.h +++ b/crt/crt_barrier.h @@ -8,7 +8,6 @@ extern "C" { #endif - #if (TARGET_OS == OS_WIN) typedef struct { @@ -27,7 +26,7 @@ typedef struct { unsigned out; pthread_mutex_t mutex; pthread_cond_t cond; -}_barrier_t; +} _barrier_t; #elif (TARGET_OS == OS_MACH) @@ -37,7 +36,7 @@ typedef struct { // mach .....no found ==> myself devlop unsigned out; pthread_mutex_t mutex; pthread_cond_t cond; -}_barrier_t; +} _barrier_t; #elif (TARGET_OS == OS_UNIX) @@ -47,7 +46,7 @@ typedef struct { // unix .....no found ==> myself devlop unsigned out; pthread_mutex_t mutex; pthread_cond_t cond; -}_barrier_t; +} _barrier_t; #endif diff --git a/crt/crt_common.hpp b/crt/crt_common.hpp index 9ee12078..626a9236 100644 --- a/crt/crt_common.hpp +++ b/crt/crt_common.hpp @@ -91,9 +91,9 @@ typedef long _off_t; #define CONST_VTBL #endif -#define bool _Bool +#define bool _Bool #define false 0 -#define true 1 +#define true 1 #endif /* __cplusplus */ @@ -170,8 +170,6 @@ typedef uint64_t uint64; #define fmt_i64d "%lld" #define fmt_i64u "%llu" - - #elif (TARGET_OS == OS_UNIX) typedef int8_t int8; diff --git a/crt/crt_cond.h b/crt/crt_cond.h index e78d9e2d..020c8a56 100644 --- a/crt/crt_cond.h +++ b/crt/crt_cond.h @@ -25,7 +25,7 @@ typedef struct { _sem_t wait_sem; _sem_t wait_done; _mutex_t lock; -}_cond_t; +} _cond_t; #elif (TARGET_OS == OS_POSIX) @@ -57,7 +57,6 @@ typedef struct { pthread_mutex_t mutex; } _cond_t; - #endif /* Wait on the condition variable for at most 'ms' milliseconds. diff --git a/crt/crt_core.hpp b/crt/crt_core.hpp index 09ad75a9..8b5eecd9 100644 --- a/crt/crt_core.hpp +++ b/crt/crt_core.hpp @@ -67,36 +67,35 @@ #include #include -typedef unsigned int crtid; -typedef unsigned int crtop; +typedef unsigned int crtid; +typedef unsigned int crtop; -typedef intptr_t crt_int_t; -typedef uintptr_t crt_uint_t; -typedef intptr_t crt_flag_t; +typedef intptr_t crt_int_t; +typedef uintptr_t crt_uint_t; +typedef intptr_t crt_flag_t; -#define CRT_INT32_LEN (sizeof("-2147483648") - 1) -#define CRT_INT64_LEN (sizeof("-9223372036854775808") - 1) +#define CRT_INT32_LEN (sizeof("-2147483648") - 1) +#define CRT_INT64_LEN (sizeof("-9223372036854775808") - 1) #if (TARGET_BITS == ARCH_32BIT) -#define CRT_INT_T_LEN NGX_INT32_LEN -#define CRT_MAX_INT_T_VALUE 2147483647 +#define CRT_INT_T_LEN NGX_INT32_LEN +#define CRT_MAX_INT_T_VALUE 2147483647 #else -#define CRT_INT_T_LEN NGX_INT64_LEN -#define CRT_MAX_INT_T_VALUE 9223372036854775807 +#define CRT_INT_T_LEN NGX_INT64_LEN +#define CRT_MAX_INT_T_VALUE 9223372036854775807 #endif // 2147483647:seconds = 68.0962597:years typedef long crt_msec; -#define CRT_UNSET -1 -#define CRT_UNSET_UINT (crt_int_t) - 1 -#define CRT_UNSET_PTR (void *) -1 -#define CRT_UNSET_SIZE (size_t) -1 -#define CRT_UNSET_MSEC (crt_msec) - 1 - +#define CRT_UNSET -1 +#define CRT_UNSET_UINT (crt_int_t) - 1 +#define CRT_UNSET_PTR (void*)-1 +#define CRT_UNSET_SIZE (size_t) - 1 +#define CRT_UNSET_MSEC (crt_msec) - 1 #ifndef CRT_ALIGNMENT -#define CRT_ALIGNMENT sizeof(unsigned long) /* platform word */ +#define CRT_ALIGNMENT sizeof(unsigned long) /* platform word */ #endif #endif diff --git a/crt/crt_def.h b/crt/crt_def.h index ecb2de6d..6874e402 100644 --- a/crt/crt_def.h +++ b/crt/crt_def.h @@ -8,84 +8,83 @@ extern "C" { #endif #ifndef S_SUCCESS -#define S_SUCCESS 0 +#define S_SUCCESS 0 #endif // !S_SUCCESS #ifndef S_ERROR -#define S_ERROR 1 +#define S_ERROR 1 #endif // !S_ERROR #ifndef S_FAILD -#define S_FAILD 2 +#define S_FAILD 2 #endif // !S_FAILD #ifndef S_FDERROR -#define S_FDERROR 3 +#define S_FDERROR 3 #endif // !S_FDERROR #ifndef S_READERROR -#define S_READERROR 4 +#define S_READERROR 4 #endif // !S_READERROR #ifndef S_WRITEERROR -#define S_WRITEERROR 5 +#define S_WRITEERROR 5 #endif // !S_WRITEERROR #ifndef S_OPENERROR -#define S_OPENERROR 6 +#define S_OPENERROR 6 #endif // !S_OPENERROR #ifndef S_CONNERROR -#define S_CONNERROR 7 +#define S_CONNERROR 7 #endif // !S_CONNERROR #ifndef S_POLLERROR -#define S_POLLERROR 8 +#define S_POLLERROR 8 #endif // !S_POLLERROR - + #ifndef S_SUPORTERROR -#define S_SUPORTERROR 9 +#define S_SUPORTERROR 9 #endif // !S_SUPORTERROR #ifndef S_MEMERROR -#define S_MEMERROR 80 +#define S_MEMERROR 80 #endif // !S_MEMERROR #ifndef S_CLOSE -#define S_CLOSE 90 +#define S_CLOSE 90 #endif // !S_CLOSE #ifndef S_PENDING -#define S_PENDING 101 +#define S_PENDING 101 #endif // !S_PENDING #ifndef S_TIMEOUT -#define S_TIMEOUT 102 +#define S_TIMEOUT 102 #endif // !S_TIMEOUT #ifndef S_COMPLETED -#define S_COMPLETED 103 +#define S_COMPLETED 103 #endif // !S_COMPLETED #ifndef S_FOUND -#define S_FOUND 301 +#define S_FOUND 301 #endif // !S_FOUND #ifndef S_NOFOUND -#define S_NOFOUND 302 +#define S_NOFOUND 302 #endif // !S_FOUND #ifndef S_AGAIN -#define S_AGAIN 303 +#define S_AGAIN 303 #endif // !S_AGAIN #ifndef S_EXIT -#define S_EXIT 304 +#define S_EXIT 304 #endif // !S_EXIT - #ifndef S_RELOAD -#define S_RELOAD 305 +#define S_RELOAD 305 #endif // !S_RELOAD #pragma pack(push, 1) @@ -131,7 +130,7 @@ typedef const SafeMemoryPtr* SafeMemoryConstPtr; #endif #ifndef buf_ptr -typedef unsigned char* buf_ptr; +typedef unsigned char* buf_ptr; #endif #ifndef buf_len @@ -190,9 +189,6 @@ typedef size_t buf_len; (type*)((char*)__mptr - offsetof(type, member)); \ }) - - - #elif (TARGET_OS == OS_UNIX) #if defined __GNUC__ || defined __llvm__ diff --git a/crt/crt_event.h b/crt/crt_event.h index 7c73b94e..1e3e98b2 100644 --- a/crt/crt_event.h +++ b/crt/crt_event.h @@ -9,10 +9,9 @@ extern "C" { #endif - -//evoper is an action +// evoper is an action typedef const struct timeval* ev_time_t; -//evoper_s->sock use windows WSASocket must IOCP +// evoper_s->sock use windows WSASocket must IOCP typedef struct evoper_s evoper_t; typedef struct evsysop_s evsysop_t; typedef struct evloop_s evloop_t; @@ -25,7 +24,6 @@ typedef int (*evmem_free)(evloop_t* loop, void* ptr); typedef int (*evloop_handler)(evloop_t* loop, short event, void* ctx); typedef int (*ev_handler)(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event); - #ifndef _evaddrptr_ #define _evaddrptr_ struct evaddr_s { @@ -35,70 +33,69 @@ struct evaddr_s { }; #endif // !_evaddrptr_ -#define ev_none_type 0x00 +#define ev_none_type 0x00 // write,read,send,recv -#define ev_sock 0xE1 // tcp_sock_c -#define ev_sockpoll 0xE2 // tcp_sock_s +#define ev_sock 0xE1 // tcp_sock_c +#define ev_sockpoll 0xE2 // tcp_sock_s // recvfrom,sendto -#define ev_rsock 0xE3 // raw_sock_c -#define ev_rsockpoll 0xE4 // raw_sock_s +#define ev_rsock 0xE3 // raw_sock_c +#define ev_rsockpoll 0xE4 // raw_sock_s // recvfrom,sendto -#define ev_usock 0xE5 // udp_sock_c -#define ev_usockpoll 0xE6 // udp_sock_s -//system -#define ev_thread 0xA1 -#define ev_signal 0xA2 -#define ev_child 0xA3 -#define ev_time 0xA4 +#define ev_usock 0xE5 // udp_sock_c +#define ev_usockpoll 0xE6 // udp_sock_s +// system +#define ev_thread 0xA1 +#define ev_signal 0xA2 +#define ev_child 0xA3 +#define ev_time 0xA4 #ifndef op_ev_none -#define op_ev_none 0x00 +#define op_ev_none 0x00 #endif // !op_ev_none #ifndef op_ev_read -#define op_ev_read 0x10 +#define op_ev_read 0x10 #endif // !op_ev_read #ifndef op_ev_write -#define op_ev_write 0x20 +#define op_ev_write 0x20 #endif // !op_ev_write #ifndef op_ev_timer -#define op_ev_timer 0x30 +#define op_ev_timer 0x30 #endif // !op_ev_timer #ifndef op_ev_open -#define op_ev_open 0x40 +#define op_ev_open 0x40 #endif // !op_ev_open #ifndef op_ev_connect -#define op_ev_connect 0x50 +#define op_ev_connect 0x50 #endif // !op_ev_connect #ifndef op_ev_accept -#define op_ev_accept 0x60 +#define op_ev_accept 0x60 #endif // !op_ev_accept #ifndef op_ev_close -#define op_ev_close 0x70 +#define op_ev_close 0x70 #endif // !op_ev_close - #ifndef op_ev_active -#define op_ev_active 0x10 +#define op_ev_active 0x10 #endif // !op_ev_active #ifndef op_ev_oneshot -#define op_ev_oneshot 0x20 +#define op_ev_oneshot 0x20 #endif // !op_ev_oneshot /////////////////////////////////// #ifndef op_ev_success -#define op_ev_success 0x00 +#define op_ev_success 0x00 #endif // !op_ev_success #ifndef op_ev_faild -#define op_ev_faild 0x01 +#define op_ev_faild 0x01 #endif // !op_ev_faild /////////////////////////////////// diff --git a/crt/crt_file.h b/crt/crt_file.h index 3d22fe2a..a0e810d7 100644 --- a/crt/crt_file.h +++ b/crt/crt_file.h @@ -50,7 +50,6 @@ typedef ssize_t _fd_len; #define FILE_INVALID (int)(-1) #define FILE_INVALID_VALUE -1 - #endif _fd_t _file_snamepipe(const char* name, long rsize, long wsize, int timeout, int flags, int mode); diff --git a/crt/crt_heap.h b/crt/crt_heap.h index d64549a0..4c774376 100644 --- a/crt/crt_heap.h +++ b/crt/crt_heap.h @@ -5,7 +5,6 @@ extern "C" { #endif - // libuv typedef struct heap_node _heap_node_t; typedef struct heap _heap_t; diff --git a/crt/crt_htable.h b/crt/crt_htable.h index 95b14df8..e3156177 100644 --- a/crt/crt_htable.h +++ b/crt/crt_htable.h @@ -7,64 +7,63 @@ extern "C" { #endif -typedef struct _htable_s _htable_t; -typedef struct _htable_info_s _htable_info_t; +typedef struct _htable_s _htable_t; +typedef struct _htable_info_s _htable_info_t; struct _htable_s { - int size; - int init_size; - int used; - _htable_info_t **data; - int status; - void *(*iter_head)(ITER*, struct _htable_s*); - void *(*iter_next)(ITER*, struct _htable_s*); - void *(*iter_tail)(ITER*, struct _htable_s*); - void *(*iter_prev)(ITER*, struct _htable_s*); - _htable_info_t *(*iter_info)(ITER*, struct _htable_s*); + int size; + int init_size; + int used; + _htable_info_t** data; + int status; + void* (*iter_head)(ITER*, struct _htable_s*); + void* (*iter_next)(ITER*, struct _htable_s*); + void* (*iter_tail)(ITER*, struct _htable_s*); + void* (*iter_prev)(ITER*, struct _htable_s*); + _htable_info_t* (*iter_info)(ITER*, struct _htable_s*); }; struct _htable_info_s { - char* key; - void* value; - unsigned hash; - struct _htable_info_s *next; - struct _htable_info_s *prev; + char* key; + void* value; + unsigned hash; + struct _htable_info_s* next; + struct _htable_info_s* prev; }; _htable_t* htable_create(int size); -int htable_errno(_htable_t *table); +int htable_errno(_htable_t* table); -#define HTABLE_STAT_OK 0 -#define HTABLE_STAT_INVAL 1 -#define HTABLE_STAT_DUPLEX_KEY 2 +#define HTABLE_STAT_OK 0 +#define HTABLE_STAT_INVAL 1 +#define HTABLE_STAT_DUPLEX_KEY 2 void htable_set_errno(_htable_t* table, int error); -_htable_info_t* htable_enter(_htable_t* table, const char *key, void *value); -_htable_info_t* htable_locate(_htable_t* table, const char *key); -void* htable_find(_htable_t* table, const char *key); -int htable_delete(_htable_t* table, const char *key, void (*free_fn) (void *)); -void htable_delete_entry(_htable_t* table, _htable_info_t* ht, void (*free_fn) (void *)); -void htable_free(_htable_t* table, void (*free_fn) (void *)); -int htable_reset(_htable_t* table, void (*free_fn) (void *)); -void htable_walk(_htable_t* table, void (*walk_fn) (_htable_info_t*, void *), void *arg); +_htable_info_t* htable_enter(_htable_t* table, const char* key, void* value); +_htable_info_t* htable_locate(_htable_t* table, const char* key); +void* htable_find(_htable_t* table, const char* key); +int htable_delete(_htable_t* table, const char* key, void (*free_fn)(void*)); +void htable_delete_entry(_htable_t* table, _htable_info_t* ht, void (*free_fn)(void*)); +void htable_free(_htable_t* table, void (*free_fn)(void*)); +int htable_reset(_htable_t* table, void (*free_fn)(void*)); +void htable_walk(_htable_t* table, void (*walk_fn)(_htable_info_t*, void*), void* arg); int htable_size(const _htable_t* table); int htable_used(const _htable_t* table); _htable_info_t** htable_list(const _htable_t* table); void htable_stat(const _htable_t* table); -#define htable_stat_r htable_stat +#define htable_stat_r htable_stat -#define HTABLE_ITER_KEY(iter) ((iter).ptr->key.c_key) +#define HTABLE_ITER_KEY(iter) ((iter).ptr->key.c_key) -#define htable_iter_key HTABLE_ITER_KEY +#define htable_iter_key HTABLE_ITER_KEY -#define HTABLE_ITER_VALUE(iter) ((iter).ptr->value) +#define HTABLE_ITER_VALUE(iter) ((iter).ptr->value) -#define htable_iter_value HTABLE_ITER_VALUE +#define htable_iter_value HTABLE_ITER_VALUE #ifdef __cplusplus } #endif #endif - diff --git a/crt/crt_log.h b/crt/crt_log.h index ba0f5135..06f794d6 100644 --- a/crt/crt_log.h +++ b/crt/crt_log.h @@ -46,14 +46,11 @@ int log_print(int proi, const char* tag, int line, const char* func, const char* #endif - - -#define loge(...) log_print(SYS_LOG_ERROR, log_error_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) +#define loge(...) log_print(SYS_LOG_ERROR, log_error_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) #define logw(...) log_print(SYS_LOG_WARN, log_warning_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) -#define logi(...) log_print(SYS_LOG_INFO, log_info_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) +#define logi(...) log_print(SYS_LOG_INFO, log_info_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) #define logd(...) log_print(SYS_LOG_DEBUG, log_debug_tag, __LINE__, _LOG_FUNCTION_, __VA_ARGS__) - #ifdef __cplusplus } #endif diff --git a/crt/crt_md5.h b/crt/crt_md5.h index 6e896110..f65f38d5 100644 --- a/crt/crt_md5.h +++ b/crt/crt_md5.h @@ -7,23 +7,21 @@ extern "C" { #endif - -#define BUFFER_SIZE 0x1000 +#define BUFFER_SIZE 0x1000 #define MD5_STRING_SIZE 0x10 -typedef unsigned char md5_byte_t; +typedef unsigned char md5_byte_t; typedef unsigned int md5_word_t; typedef struct md5_state_s { md5_word_t count[2]; md5_word_t abcd[4]; md5_byte_t buf[64]; -} md5_state_t; - -void md5_init(md5_state_t *pms); -void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); -void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); +} md5_state_t; +void md5_init(md5_state_t* pms); +void md5_append(md5_state_t* pms, const md5_byte_t* data, int nbytes); +void md5_finish(md5_state_t* pms, md5_byte_t digest[16]); #ifdef __cplusplus } diff --git a/crt/crt_mutex.h b/crt/crt_mutex.h index e1d2cd56..6dec105e 100644 --- a/crt/crt_mutex.h +++ b/crt/crt_mutex.h @@ -32,7 +32,6 @@ typedef struct { pthread_mutex_t mutex; } _mutex_t; - #elif (TARGET_OS == OS_UNIX) typedef struct { diff --git a/crt/crt_sha1.h b/crt/crt_sha1.h index 34190897..34fb16d1 100644 --- a/crt/crt_sha1.h +++ b/crt/crt_sha1.h @@ -7,10 +7,9 @@ extern "C" { #endif -#define POLARSSL_ERR_SHA1_FILE_IO_ERROR -0x0076 +#define POLARSSL_ERR_SHA1_FILE_IO_ERROR -0x0076 -typedef struct -{ +typedef struct { unsigned long total[2]; unsigned long state[5]; unsigned char buffer[64]; @@ -19,9 +18,9 @@ typedef struct unsigned char opad[64]; } sha1_context; -void sha1_starts( sha1_context *ctx ); -void sha1_update( sha1_context *ctx, const unsigned char *input, size_t ilen ); -void sha1_finish( sha1_context *ctx, unsigned char output[20] ); +void sha1_starts(sha1_context* ctx); +void sha1_update(sha1_context* ctx, const unsigned char* input, size_t ilen); +void sha1_finish(sha1_context* ctx, unsigned char output[20]); #ifdef __cplusplus } diff --git a/crt/crt_sjson.h b/crt/crt_sjson.h index b8418c46..01c2d36e 100644 --- a/crt/crt_sjson.h +++ b/crt/crt_sjson.h @@ -7,39 +7,31 @@ extern "C" { #endif -#define sjson_false S_ERROR -#define sjson_true S_SUCCESS +#define sjson_false S_ERROR +#define sjson_true S_SUCCESS -#define sjson_invalid (0) -#define sjson_raw (1 << 0) -#define sjson_int64 (1 << 1) -#define sjson_int (1 << 2) -#define sjson_double (1 << 3) -#define sjson_string (1 << 4) -#define sjson_array (1 << 5) -#define sjson_obj (1 << 6) +#define sjson_invalid (0) +#define sjson_raw (1 << 0) +#define sjson_int64 (1 << 1) +#define sjson_int (1 << 2) +#define sjson_double (1 << 3) +#define sjson_string (1 << 4) +#define sjson_array (1 << 5) +#define sjson_obj (1 << 6) -#define sjson_is_invalid(m) \ - ((m->type & 0xFF) == sjson_invalid ? sjson_true : sjson_false) +#define sjson_is_invalid(m) ((m->type & 0xFF) == sjson_invalid ? sjson_true : sjson_false) -#define sjson_is_raw(m) \ - ((m->type & 0xFF) == sjson_raw ? sjson_true : sjson_false) +#define sjson_is_raw(m) ((m->type & 0xFF) == sjson_raw ? sjson_true : sjson_false) -#define sjson_is_int(m) \ - ((m->type & 0xFF) == sjson_int ? sjson_true : sjson_false) +#define sjson_is_int(m) ((m->type & 0xFF) == sjson_int ? sjson_true : sjson_false) -#define sjson_is_double(m) \ - ((m->type & 0xFF) == sjson_double ? sjson_true : sjson_false) +#define sjson_is_double(m) ((m->type & 0xFF) == sjson_double ? sjson_true : sjson_false) -#define sjson_is_string(m) \ - ((m->type & 0xFF) == sjson_string ? sjson_true : sjson_false) +#define sjson_is_string(m) ((m->type & 0xFF) == sjson_string ? sjson_true : sjson_false) -#define sjson_is_array(m) \ - ((m->type & 0xFF) == sjson_array ? sjson_true : sjson_false) - -#define sjson_is_obj(m) \ - ((m->type & 0xFF) == sjson_obj ? sjson_true : sjson_false) +#define sjson_is_array(m) ((m->type & 0xFF) == sjson_array ? sjson_true : sjson_false) +#define sjson_is_obj(m) ((m->type & 0xFF) == sjson_obj ? sjson_true : sjson_false) #ifndef sjson_nesting_limit #define sjson_nesting_limit 10240 @@ -47,23 +39,21 @@ extern "C" { #pragma pack(push, 4) - typedef struct sjson sjon; typedef struct sjson { - struct sjson* next; struct sjson* prev; struct sjson* child; - + int type; - char* key; - - int64 valueint64; - int valueint; + char* key; + + int64 valueint64; + int valueint; double valuedouble; - char* valuestring; - + char* valuestring; + } sjson; typedef sjson* sjsonptr; diff --git a/crt/crt_sock.h b/crt/crt_sock.h index f4f67df4..b7790ebf 100644 --- a/crt/crt_sock.h +++ b/crt/crt_sock.h @@ -13,7 +13,7 @@ extern "C" { #include #elif (TARGET_OS == OS_MACH) #include - #elif (TARGET_OS == OS_UNIX) +#elif (TARGET_OS == OS_UNIX) #include #endif @@ -218,7 +218,6 @@ typedef int sock_size; #endif typedef union { - struct sockaddr_storage ss; struct sockaddr_in6 in6; struct sockaddr_in in; @@ -230,8 +229,6 @@ typedef union { struct sockaddr sa; } sock_addr; - - int _bind_unixsock(_sock_t s, const char* name, size_t len, int af, int scount); int _bind_stcpsockv4(_sock_t s, const char* name, size_t len, int scount, unsigned short port); int _bind_stcpsockv6(_sock_t s, const char* name, size_t len, int scount, unsigned short port); diff --git a/crt/crt_var.h b/crt/crt_var.h index fdd29f3d..32002d60 100644 --- a/crt/crt_var.h +++ b/crt/crt_var.h @@ -66,15 +66,15 @@ typedef struct tag_varaint_t { provarv3 v3; size_t len; union { - char cVal; // VET_I1 - short iVal; // VET_I2 - long lVal; // VET_I4 + char cVal; // VET_I1 + short iVal; // VET_I2 + long lVal; // VET_I4 int64 llVal; // VET_I8 unsigned char uVal; // VET_UI1 unsigned short uiVal; // VET_UI2 unsigned long ulVal; // VET_UI4 - uint64 ullVal; // VET_UI8 + uint64 ullVal; // VET_UI8 float fltVal; // VET_R4 double dblVal; // VET_R8 diff --git a/crt/posixosdef.h b/crt/posixosdef.h index 2478b19d..adda8dd0 100644 --- a/crt/posixosdef.h +++ b/crt/posixosdef.h @@ -13,7 +13,6 @@ #include #include - #define CALLBACK #define WINAPI #define WINAPIV diff --git a/crt/unixosdef.h b/crt/unixosdef.h index a1ba6d99..b80e8918 100644 --- a/crt/unixosdef.h +++ b/crt/unixosdef.h @@ -10,21 +10,19 @@ #include #include -//socket +// socket #include #include - -//thread +// thread #include // getpagesize #include -//error +// error #include - // thread stack size #include @@ -34,7 +32,7 @@ // atomic #include -//semp +// semp #include #include diff --git a/crt/winosdef.h b/crt/winosdef.h index b92c8ad9..cf101bfb 100644 --- a/crt/winosdef.h +++ b/crt/winosdef.h @@ -9,8 +9,6 @@ #include #include - - #ifndef _SSIZE_T_ #define _SSIZE_T_ typedef SSIZE_T ssize_t; diff --git a/extensions/include/db/idatabase.h b/extensions/include/db/idatabase.h index e95c0de9..2df2f4ca 100644 --- a/extensions/include/db/idatabase.h +++ b/extensions/include/db/idatabase.h @@ -177,7 +177,6 @@ interface IStatement : public IBase // {717B694C-8DA0-4C6E-BEEF-CB091AD2338E} _DEF_IID(IID_IStatement, 0x717b694c, 0x8da0, 0x4c6e, 0xbe, 0xef, 0xcb, 0x9, 0x1a, 0xd2, 0x33, 0x8e); - interface IDatabase : public IBase { std_method(SetOption)(LPCWSTR lpszName, LPCWSTR lpszValue) PURE; diff --git a/extensions/include/io/ioperation.h b/extensions/include/io/ioperation.h index d6718dc8..6caa2925 100644 --- a/extensions/include/io/ioperation.h +++ b/extensions/include/io/ioperation.h @@ -28,15 +28,15 @@ interface IOperation : public IBase std_method(SetId)(crtid id) PURE; std_method_(crtid, GetId)() PURE; std_method(SetResult)(crterr err, buf_len len) PURE; - std_method(GetResult)(crterr * err, buf_len * len) PURE; + std_method(GetResult)(crterr* err, buf_len* len) PURE; std_method(SetIoParam)(buf_len pos, buf_len len) PURE; - std_method(GetIoParam)(buf_len * pos, buf_len * len) PURE; + std_method(GetIoParam)(buf_len* pos, buf_len* len) PURE; std_method(SetExpect)(buf_len len) PURE; - std_method(GetExpect)(buf_len * len) PURE; + std_method(GetExpect)(buf_len* len) PURE; std_method(SetPos)(buf_len pos) PURE; std_method(GetPos)(buf_len* pos) PURE; std_method(SetTransfered)(buf_len len) PURE; - std_method(GetTransfered)(buf_len * len) PURE; + std_method(GetTransfered)(buf_len* len) PURE; std_method(Attach)(buf_ptr ptr, buf_len pos, buf_len size) PURE; std_method(Alloc)(buf_len size) PURE; std_method(GetLen)(buf_len* len) PURE; diff --git a/extensions/include/io/isocket.h b/extensions/include/io/isocket.h index 6cd12447..c6934451 100644 --- a/extensions/include/io/isocket.h +++ b/extensions/include/io/isocket.h @@ -6,7 +6,7 @@ interface ISockProc : public IBase std_method(OnSockSend)(crtid cid, crterr err, buf_ptr buf, buf_len size) PURE; std_method(OnSockRecv)(crtid cid, crterr err, buf_ptr buf, buf_len size) PURE; std_method(OnSockConnect)(crtid cid, crterr err, _sock_t fd) PURE; - std_method(OnSockEvent)(crtid cid, crtop op, crterr err, _sock_t fd) PURE; + std_method(OnSockEvent)(crtid cid, crtop op, crterr err, _sock_t fd) PURE; }; // {9C926805-64F5-4728-86A4-AB0208AA1487} @@ -126,11 +126,9 @@ _DEF_IID(IID_ITcpListen, 0x829c3a23, 0x4d1c, 0x420a, 0xbf, 0xad, 0x64, 0x6a, 0x1 interface ITcpSslListen : public ITcpListen { - }; // {829C3A23-4D1C-420A-BFAD-646A1924AA16} _DEF_IID(IID_ITcpSslListen, 0x829c3a23, 0x4d1c, 0x420a, 0xbf, 0xad, 0x64, 0x6a, 0x19, 0x24, 0xaa, 0x16); - #endif diff --git a/extensions/include/io/itimer.h b/extensions/include/io/itimer.h index 1517e5cc..fa05fb4e 100644 --- a/extensions/include/io/itimer.h +++ b/extensions/include/io/itimer.h @@ -14,7 +14,7 @@ interface ITimer : public IBase std_method(Start)() PURE; std_method(Stop)() PURE; std_method(SetSec)(int sec) PURE; - std_method(Bind)(IBase* pBase) PURE; + std_method(Bind)(IBase* pBase) PURE; std_method(UnBind)() PURE; std_method_(crtid, GetId)() PURE; std_method(SetId)(crtid cid) PURE; diff --git a/extensions/include/net/imodbus.h b/extensions/include/net/imodbus.h index fb2646a3..f876feca 100644 --- a/extensions/include/net/imodbus.h +++ b/extensions/include/net/imodbus.h @@ -1,17 +1,15 @@ #ifndef _IMODBUS_H_ #define _IMODBUS_H_ - interface IModBusProc : public IBase { - }; // {9A102441-E383-4B3C-8CC8-7C8E0B0162FF} _DEF_IID(IID_IModBusProc, 0x9a102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); -interface IModBus : public IBase{ - +interface IModBus : public IBase +{ }; // {9b102441-E383-4B3C-8CC8-7C8E0B0162FF} @@ -22,13 +20,11 @@ interface IModBusSrvProc : public IBase std_method(OnAccept)(int error, LPCSTR hostname, LPCSTR host) PURE; }; - // {9b102441-E383-4B3C-8CC8-7C8E0B0162FF} _DEF_IID(IID_IModBusSrvProc, 0x9c102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); interface IID_IModBusSrv : public IBase { - }; // {9d102441-E383-4B3C-8CC8-7C8E0B0162FF} diff --git a/extensions/include/net/inet.h b/extensions/include/net/inet.h index 5e3d5c43..1827d966 100644 --- a/extensions/include/net/inet.h +++ b/extensions/include/net/inet.h @@ -15,7 +15,6 @@ typedef enum TagNetProtocol { protocol_https = 110, protocol_https_s = 111, protocol_websocket = 150 - } Net_Protocol; diff --git a/extensions/include/runtime/iconfigure.h b/extensions/include/runtime/iconfigure.h index dac4ce02..19d9a027 100644 --- a/extensions/include/runtime/iconfigure.h +++ b/extensions/include/runtime/iconfigure.h @@ -17,24 +17,23 @@ _DEF_IID(IID_IConfigureProc, 0xE9CEF9E4, 0xA28D, 0x4AC5, 0x99, 0xC5, 0xA0, 0x6D, #define configure_name_len 32 #define configure_type_len 16 -typedef enum _UPDATE_SOURCE -{ - eUS_NONE = 0, - eUS_TEMPLATE = 1, - eUS_USM = 2, - eUS_CLIENT = 3, +typedef enum _UPDATE_SOURCE { + eUS_NONE = 0, + eUS_TEMPLATE = 1, + eUS_USM = 2, + eUS_CLIENT = 3, } UPDATE_SOURCE; interface IConfigure : public IBase { - std_method(OnRegister)(LPCSTR name, LPCSTR type, IBase* pBase) PURE; - std_method(OnUnRegister)(LPCSTR name, LPCSTR type) PURE; - std_method(SetStorePath)(LPSTRING path) PURE; - std_method_(LPSTRING, GetStorePath)() PURE; - std_method(RefreshResource)(int nclass) PURE; - std_method(GetResource)(int nclass) PURE; - std_method(UpdateSource)(int source, int type, LPCSTR buf, int size) PURE; - std_method(UpdateSource)(int source, int type, LPSTRING path) PURE; + std_method(OnRegister)(LPCSTR name, LPCSTR type, IBase* pBase) PURE; + std_method(OnUnRegister)(LPCSTR name, LPCSTR type) PURE; + std_method(SetStorePath)(LPSTRING path) PURE; + std_method_(LPSTRING, GetStorePath)() PURE; + std_method(RefreshResource)(int nclass) PURE; + std_method(GetResource)(int nclass) PURE; + std_method(UpdateSource)(int source, int type, LPCSTR buf, int size) PURE; + std_method(UpdateSource)(int source, int type, LPSTRING path) PURE; }; //{736b6e66-93be-478b-bed4-e11fcd97ca83} diff --git a/include/dlcom/comfactory.hpp b/include/dlcom/comfactory.hpp index 1639f6c9..01f3b1c0 100644 --- a/include/dlcom/comfactory.hpp +++ b/include/dlcom/comfactory.hpp @@ -8,7 +8,6 @@ namespace StdCom { - class CUnknownImp { public: @@ -18,7 +17,6 @@ public: virtual ~CUnknownImp() { ref.value = 0; } }; - typedef struct stdcom_entry_s stdcom_entry_t; struct stdcom_entry_s { diff --git a/include/dlcom/id.hpp b/include/dlcom/id.hpp index bc551484..47feb203 100644 --- a/include/dlcom/id.hpp +++ b/include/dlcom/id.hpp @@ -7,10 +7,8 @@ #define _uuidof(iface) (IID_##iface) -#define _DEF_IID_IMPL(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - const IID name = { l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}; +#define _DEF_IID_IMPL(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const IID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}; -#define _DEF_CLSID_IMPL(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - const GUID name = { l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}; +#define _DEF_CLSID_IMPL(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}; #endif diff --git a/include/dlcom/loadcom.hpp b/include/dlcom/loadcom.hpp index b4dab040..38048955 100644 --- a/include/dlcom/loadcom.hpp +++ b/include/dlcom/loadcom.hpp @@ -24,19 +24,18 @@ public: virtual STFunDesc* GetFunDefs() { static STFunDesc s_FunDefs[] = { - {(char*)DllGetClassObjectFuncName, 0 }, - {(char*)DllGetAtFuncName, 1 }, - {(char*)DllGetCountFuncName, 2 }, - {(char*)DllProgIDFromCLSIDFuncName, 3 }, - {(char*)DllCanUnloadNowFuncName, 4 }, - {(char*)DllRegisterServerFuncName, 5 }, - {(char*)DllUnregisterServerFuncName, 6 }, - {(char*)DllStartFuncName, 7 }, - {(char*)DllStopFuncName, 8 }, - {(char*)DllSetupFuncName, 9 }, - {(char*)DllGetVersionFuncName, 10}, - {(char*)NULLFuncName, 11} - }; + {(char*)DllGetClassObjectFuncName, 0}, + {(char*)DllGetAtFuncName, 1}, + {(char*)DllGetCountFuncName, 2}, + {(char*)DllProgIDFromCLSIDFuncName, 3}, + {(char*)DllCanUnloadNowFuncName, 4}, + {(char*)DllRegisterServerFuncName, 5}, + {(char*)DllUnregisterServerFuncName, 6}, + {(char*)DllStartFuncName, 7}, + {(char*)DllStopFuncName, 8}, + {(char*)DllSetupFuncName, 9}, + {(char*)DllGetVersionFuncName, 10}, + {(char*)NULLFuncName, 11}}; return s_FunDefs; } virtual bool SetFuncAddress(size_t i, void* p) diff --git a/include/dlcom/objectrun.hpp b/include/dlcom/objectrun.hpp index 745da6bb..d1158714 100644 --- a/include/dlcom/objectrun.hpp +++ b/include/dlcom/objectrun.hpp @@ -30,10 +30,10 @@ public: basic_tchar szContainerName[DYNAMIC_NAME_LEN + 1] = {0x00}; get_dynamicname(_T("container"), szContainerName, DYNAMIC_NAME_LEN); - m_strContainerPath.clear(); - m_strContainerPath.append(path->ptr); - m_strContainerPath.append(path_slash); - m_strContainerPath.append(szContainerName); + m_strContainerPath.clear(); + m_strContainerPath.append(path->ptr); + m_strContainerPath.append(path_slash); + m_strContainerPath.append(szContainerName); hr = m_loader.LoadCom(m_strContainerPath.c_str()); rc_error(hr == S_OK, E_FAIL); @@ -139,7 +139,7 @@ public: UINT code = OBJECT_RUN_RET_SUCCESS; - //logi("m_pIObjectRun->Start==>%u", type); + // logi("m_pIObjectRun->Start==>%u", type); hr = pIObjectRun->Start(type); rc_error(hr == S_OK, E_FAIL); diff --git a/include/utilex/file.hpp b/include/utilex/file.hpp index a786de53..a93ff801 100644 --- a/include/utilex/file.hpp +++ b/include/utilex/file.hpp @@ -9,7 +9,7 @@ static_inline path_string GetExePathString() { basic_tchar szPath[MAX_PATH + 1] = {0x00}; get_executepath(pid_null, szPath, MAX_PATH); - path_string strPath(szPath); + path_string strPath(szPath); return strPath; } diff --git a/include/utilex/json.hpp b/include/utilex/json.hpp index 6b73318e..da582bfb 100644 --- a/include/utilex/json.hpp +++ b/include/utilex/json.hpp @@ -11,7 +11,7 @@ struct json_sentry { template static void destroy(_Ptr p) { if (p != NULL) - sjson_delete(p); + sjson_delete(p); } }; diff --git a/include/utilex/lockqueue.hpp b/include/utilex/lockqueue.hpp index a9280f53..1fb27081 100644 --- a/include/utilex/lockqueue.hpp +++ b/include/utilex/lockqueue.hpp @@ -3,9 +3,7 @@ #include -template -class CLockQueue : protected std::queue<_Ty>, - public CAutoLock +template class CLockQueue : protected std::queue<_Ty>, public CAutoLock { typedef std::queue<_Ty> _base; @@ -60,7 +58,7 @@ public: _Ty pNode = this->_base::front(); this->_base::pop(); m_tr.destroy(pNode); - loop = this->_base::size(); + loop = this->_base::size(); } return S_SUCCESS; diff --git a/include/utilex/timethread.hpp b/include/utilex/timethread.hpp index 269c23e1..294a0567 100644 --- a/include/utilex/timethread.hpp +++ b/include/utilex/timethread.hpp @@ -61,10 +61,10 @@ public: int Jointhread() { rc_error(m_Thread != INVALID_HANDLE_VALUE, S_ERROR); - + Exit_Thread(); PostBroadcast(); - + // deadlock _thread_join(&m_Thread); return S_SUCCESS; diff --git a/license/dllmain.cpp b/license/dllmain.cpp index ebdaa79d..9ba52aa5 100644 --- a/license/dllmain.cpp +++ b/license/dllmain.cpp @@ -34,9 +34,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {CLSID_CLicense, &ClassFactory::GetClass, "license.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{CLSID_CLicense, &ClassFactory::GetClass, "license.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/license/licenseimpl.h b/license/licenseimpl.h index 08cd3e78..e2a3e27a 100644 --- a/license/licenseimpl.h +++ b/license/licenseimpl.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CLicenseImpl : public ILicense, - public IPlugin +class CLicenseImpl : public ILicense, public IPlugin { public: CLicenseImpl(void); diff --git a/logs/dllmain.cpp b/logs/dllmain.cpp index f0ef2cd7..4b06d601 100644 --- a/logs/dllmain.cpp +++ b/logs/dllmain.cpp @@ -35,9 +35,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif static_const stdcom_entry_t clsobject[] = { - {CLSID_CLogs, &ClassFactory::GetClass, "logs.V1" }, - {CLSID_CLogDataBase, &ClassFactory::GetClass, "logdatabase.V1"} -}; + {CLSID_CLogs, &ClassFactory::GetClass, "logs.V1"}, {CLSID_CLogDataBase, &ClassFactory::GetClass, "logdatabase.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/logs/logdatabase.cpp b/logs/logdatabase.cpp index 4f43059b..69bcf2e7 100644 --- a/logs/logdatabase.cpp +++ b/logs/logdatabase.cpp @@ -17,7 +17,7 @@ HRESULT CLogDataBaseImpl::Init(IBase* pRot, IBase* pBase) hr = pRot->QueryInterface(IID_IRot, (void**)&m_pRot); rc_error(hr == S_OK, E_FAIL); - path_string strDBPath = GetExePathString(); + path_string strDBPath = GetExePathString(); strDBPath += DB_NAME; // logi("db_name %s", strDBPath.c_str()); @@ -67,7 +67,7 @@ HRESULT CLogDataBaseImpl::InsertTable(UCHAR* pBuf, ULONG uSize) JsonSafePtr pJsonRoot = sjson_parse((char*)pBuf, 0, 0); rc_error(IsJsonObject(pJsonRoot.m_p), E_FAIL); - sjsonptr pJsonTable = sjson_get_obj(pJsonRoot, Rule_Table); + sjsonptr pJsonTable = sjson_get_obj(pJsonRoot, Rule_Table); rc_error(IsJsonString(pJsonTable), E_FAIL); _lComPtr pTableStruct; @@ -104,7 +104,7 @@ HRESULT CLogDataBaseImpl::CreateTable(LPCSTR name, ITableStruct* pITableStruct) HRESULT hr = S_OK; Table table; - ULONG uFieldCount = 0; + ULONG uFieldCount = 0; pITableStruct->GetFieldsCount(uFieldCount); rc_error(uFieldCount > 0, E_FAIL); @@ -185,7 +185,7 @@ HRESULT CLogDataBaseImpl::Update(LPCSTR name, sjsonptr pRoot, ITableStruct* pITa UINT uloop = 0; for (uloop = 0; uloop < uFieldCount; uloop++) { - sjsonptr pJsonItem = sjson_get_obj(pRoot, table[uloop].name); + sjsonptr pJsonItem = sjson_get_obj(pRoot, table[uloop].name); rc_error_continue(table[uloop].index == 0); @@ -213,7 +213,7 @@ HRESULT CLogDataBaseImpl::Update(LPCSTR name, sjsonptr pRoot, ITableStruct* pITa strSql += " WHERE "; for (uloop = 0; uloop < uFieldCount; uloop++) { - sjsonptr pJsonItem = sjson_get_obj(pRoot, table[uloop].name); + sjsonptr pJsonItem = sjson_get_obj(pRoot, table[uloop].name); rc_error_continue(table[uloop].index == 1); @@ -236,7 +236,7 @@ HRESULT CLogDataBaseImpl::Update(LPCSTR name, sjsonptr pRoot, ITableStruct* pITa size_t pos = strSql.find_last_of(" AND "); if (pos) { - size_t len = strSql.length(); + size_t len = strSql.length(); len = len - s_strlen(" AND "); strSql = strSql.substr(0, len); } @@ -266,7 +266,7 @@ HRESULT CLogDataBaseImpl::GetTableFields(Table& table, ITableStruct* pITableStru { HRESULT hr = S_OK; - ULONG uFieldCount = 0; + ULONG uFieldCount = 0; pITableStruct->GetFieldsCount(uFieldCount); rc_error(uFieldCount > 0, E_FAIL); diff --git a/logs/logdatabase.h b/logs/logdatabase.h index 12d43f98..5848f5a5 100644 --- a/logs/logdatabase.h +++ b/logs/logdatabase.h @@ -3,10 +3,7 @@ #include "stdafx.h" -class CLogDataBaseImpl : public ILogDataBase, - public IPlugin, - public IPluginRun, - public CUnknownImp +class CLogDataBaseImpl : public ILogDataBase, public IPlugin, public IPluginRun, public CUnknownImp { public: CLogDataBaseImpl(); diff --git a/logs/logsimpl.cpp b/logs/logsimpl.cpp index 2abf6c43..47d65d91 100644 --- a/logs/logsimpl.cpp +++ b/logs/logsimpl.cpp @@ -106,7 +106,7 @@ void get_file_cb_func(const basic_tchar* szPath, void* context) rc_return(szPath != NULL); rc_return(context != NULL); - path_string strPath(szPath); + path_string strPath(szPath); size_t index = strPath.find(_T(".xdt")); if (index == path_string::npos) { } else { @@ -173,17 +173,17 @@ HRESULT CLogsImpl::ReadRuleFile(const path_string& file) rc_error(pJsonRoot.m_p != NULL, E_FAIL); rc_error(IsJsonObject(pJsonRoot.m_p), E_FAIL); - sjsonptr pJsonLogs = sjson_get_obj(pJsonRoot, Rule_log); + sjsonptr pJsonLogs = sjson_get_obj(pJsonRoot, Rule_log); rc_error(pJsonLogs != NULL, E_FAIL); rc_error(IsJsonObject(pJsonLogs), E_FAIL); - sjsonptr pJsonTables = sjson_get_obj(pJsonLogs, Rule_Tables); + sjsonptr pJsonTables = sjson_get_obj(pJsonLogs, Rule_Tables); rc_error(pJsonTables != NULL, E_FAIL); rc_error(IsJsonArray(pJsonTables), E_FAIL); int iloop = 0; for (iloop = 0; iloop < sjson_get_array_size(pJsonTables); iloop++) { - sjsonptr JsItem = sjson_get_array_item(pJsonTables, iloop); + sjsonptr JsItem = sjson_get_array_item(pJsonTables, iloop); if (IsJsonObject(JsItem)) { SyncTable(JsItem); @@ -196,7 +196,7 @@ HRESULT CLogsImpl::SyncTable(sjsoncptr JsRoot) { rc_error(JsRoot != NULL, E_FAIL); HRESULT hr = S_OK; - ULONG uFieldCount = 0; + ULONG uFieldCount = 0; CTableStruct* pTable = new CTableStruct(); rc_error(pTable != NULL, E_FAIL); @@ -204,7 +204,7 @@ HRESULT CLogsImpl::SyncTable(sjsoncptr JsRoot) hr = pTable->QueryInterface(IID_ITableStruct, (void**)&pITableStruct); rc_error(hr == S_OK, E_FAIL); - sjsonptr pJsonTable = sjson_get_obj(JsRoot, Rule_Table); + sjsonptr pJsonTable = sjson_get_obj(JsRoot, Rule_Table); rc_error(IsJsonString(pJsonTable), E_FAIL); // pTable->SetTableName(pJsonTable->valuestring); @@ -213,40 +213,40 @@ HRESULT CLogsImpl::SyncTable(sjsoncptr JsRoot) // hr = m_pILogDataBase->IsTableExist(pJsonTable->valuestring); // rc_error_log(hr == S_OK, E_FAIL, "Fields_Table_Exist_Faild") - sjsonptr pJsonOp = sjson_get_obj(JsRoot, Rule_Op); + sjsonptr pJsonOp = sjson_get_obj(JsRoot, Rule_Op); rc_error(IsJsonNumber(pJsonOp), E_FAIL); // pTable->SetKeyValue(Rule_Op, pJsonOp->valueint); - sjsonptr pJsonSave = sjson_get_obj(JsRoot, Rule_Save); + sjsonptr pJsonSave = sjson_get_obj(JsRoot, Rule_Save); if (IsJsonNumber(pJsonSave)) { // pTable->SetKeyValue(Rule_Op, pJsonSave->valueint); } - sjsonptr pJsonFields = sjson_get_obj(JsRoot, Rule_Fields); + sjsonptr pJsonFields = sjson_get_obj(JsRoot, Rule_Fields); rc_error(IsJsonArray(pJsonFields), E_FAIL); int iloop = 0; FieldSturct field; for (iloop = 0; iloop < sjson_get_array_size(pJsonFields); iloop++) { - sjsonptr JsItem = sjson_get_array_item(pJsonFields, iloop); + sjsonptr JsItem = sjson_get_array_item(pJsonFields, iloop); if (IsJsonObject(JsItem)) { s_memset(&field, 0, sizeof(FieldSturct)); - sjsonptr pJsonFieldsName = sjson_get_obj(JsItem, Rule_Fields_Name); + sjsonptr pJsonFieldsName = sjson_get_obj(JsItem, Rule_Fields_Name); rc_error_continue(IsJsonString(pJsonFieldsName)); s_memcpy(&field.name, pJsonFieldsName->valuestring, LOG_FIELD_NAME_LEN); - sjsonptr pJsonFieldsType = sjson_get_obj(JsItem, Rule_Fields_Type); + sjsonptr pJsonFieldsType = sjson_get_obj(JsItem, Rule_Fields_Type); rc_error_continue(IsJsonString(pJsonFieldsType)); s_memcpy(&field.type, pJsonFieldsType->valuestring, LOG_FIELD_TYPE_LEN); - sjsonptr pJsonFieldsSize = sjson_get_obj(JsItem, Rule_Fields_Size); + sjsonptr pJsonFieldsSize = sjson_get_obj(JsItem, Rule_Fields_Size); if (IsJsonNumber(pJsonFieldsSize)) { field.size = pJsonFieldsSize->valueint; } - sjsonptr pJsonFieldsIndex = sjson_get_obj(JsItem, Rule_Fields_Index); + sjsonptr pJsonFieldsIndex = sjson_get_obj(JsItem, Rule_Fields_Index); if (IsJsonNumber(pJsonFieldsIndex)) { field.index = pJsonFieldsIndex->valueint; } diff --git a/logs/logsimpl.h b/logs/logsimpl.h index 5f7774f2..9505b498 100644 --- a/logs/logsimpl.h +++ b/logs/logsimpl.h @@ -3,12 +3,7 @@ #include "stdafx.h" -class CLogsImpl : public ILogs, - public IPlugin, - public IPluginRun, - public CUnknownImp, - public CSemThread, - public CTimeThread +class CLogsImpl : public ILogs, public IPlugin, public IPluginRun, public CUnknownImp, public CSemThread, public CTimeThread { public: CLogsImpl(void); diff --git a/logs/stdafx.h b/logs/stdafx.h index 6983707e..1c51c0ce 100644 --- a/logs/stdafx.h +++ b/logs/stdafx.h @@ -72,8 +72,8 @@ typedef MapTableStruct::iterator MapTableStructIterator; typedef vector Table; #define IsJsonString(x) (sjson_is_string(x) == sjson_true) -#define IsJsonNumber(x) (sjson_is_double(x)== sjson_true) -#define IsJsonArray(x) (sjson_is_array(x)== sjson_true) -#define IsJsonObject(x) (sjson_is_obj(x)== sjson_true) +#define IsJsonNumber(x) (sjson_is_double(x) == sjson_true) +#define IsJsonArray(x) (sjson_is_array(x) == sjson_true) +#define IsJsonObject(x) (sjson_is_obj(x) == sjson_true) #endif diff --git a/logs/tablestruct.cpp b/logs/tablestruct.cpp index 479eebf5..988005b2 100644 --- a/logs/tablestruct.cpp +++ b/logs/tablestruct.cpp @@ -33,7 +33,7 @@ HRESULT CTableStruct::GetTableRecord(FieldSturct* field, ULONG loop) } HRESULT CTableStruct::GetTableRecords(FieldSturct fields[], ULONG count) { - ULONG uloop = 0; + ULONG uloop = 0; for (uloop = 0; uloop < count; uloop++) { s_strcpy(fields[uloop].name, LOG_FIELD_NAME_LEN, m_vecTableFields[uloop].name); s_strcpy(fields[uloop].type, LOG_FIELD_TYPE_LEN, m_vecTableFields[uloop].type); diff --git a/logs/tablestruct.h b/logs/tablestruct.h index 038805a4..6398bc1d 100644 --- a/logs/tablestruct.h +++ b/logs/tablestruct.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CTableStruct : public ITableStruct, - public CUnknownImp +class CTableStruct : public ITableStruct, public CUnknownImp { public: CTableStruct(); diff --git a/mainui/appviewimpl.cpp b/mainui/appviewimpl.cpp index a247d414..7c8f582e 100644 --- a/mainui/appviewimpl.cpp +++ b/mainui/appviewimpl.cpp @@ -30,8 +30,7 @@ HRESULT CAppViewImpl::Start(_pid_t pid, unsigned int type) { HRESULT hr = S_OK; - - //InitBus(); + // InitBus(); return hr; } @@ -45,19 +44,19 @@ HRESULT CAppViewImpl::Stop(unsigned int exit) } HRESULT CAppViewImpl::OnSockSend(crtid id, crterr error_code, buf_ptr buf, buf_len size) { - return S_OK; + return S_OK; } HRESULT CAppViewImpl::OnSockRecv(crtid id, crterr error_code, buf_ptr buf, buf_len size) { - return S_OK; + return S_OK; } HRESULT CAppViewImpl::OnSockConnect(crtid id, crterr error_code, _sock_t fd) { - return S_OK; + return S_OK; } HRESULT CAppViewImpl::OnSockEvent(crtid id, crtid event, crterr error_code, _sock_t fd) { - return S_OK; + return S_OK; } HRESULT CAppViewImpl::InitBus() { @@ -65,52 +64,51 @@ HRESULT CAppViewImpl::InitBus() hr = m_pRot->GetObject(CLSID_CMsgBus, IID_IMsgBus, (IBase**)&m_pIMsgBus); rc_error(hr == S_OK, E_FAIL); - - hr = m_pRot->GetObject(CLSID_CAsynFrame, IID_IAsynFrame, (IBase**)&m_pIAsynFrame); - rc_error(hr == S_OK, E_FAIL); - + + hr = m_pRot->GetObject(CLSID_CAsynFrame, IID_IAsynFrame, (IBase**)&m_pIAsynFrame); + rc_error(hr == S_OK, E_FAIL); + hr = m_pIMsgBus->CreateNode(NDC_BROKER, (IBase**)&m_pIBroker); rc_error(hr == S_OK, E_FAIL); m_pIBroker->Listen("127.0.0.1:8080", s_strlen("127.0.0.1:8080"), 5); - //sleep_time(300); - - + // sleep_time(300); + hr = m_pIMsgBus->CreateNode(NDC_CONSUMER, (IBase**)&m_pIConsumer); rc_error(hr == S_OK, E_FAIL); - _lComPtr m_pITcpSocketSSL; - hr = m_pIAsynFrame->CreateIo(io_tcp_ssl_socket, (IBase**)&m_pITcpSocketSSL); - rc_error(hr == S_OK, E_FAIL); - - m_pITcpSocketSSL->CreateSock(); - - _lComPtr pBase; - hr = this->QueryInterface(IID_IBase, (void**)&pBase); - rc_error(hr == S_OK, E_FAIL); - - m_pITcpSocketSSL->BindEvent(pBase); - - //10.242.68.4 - //172.16.123.131 - m_pITcpSocketSSL->ConnectIo("127.0.0.1", 8080, 5, 5); + _lComPtr m_pITcpSocketSSL; + hr = m_pIAsynFrame->CreateIo(io_tcp_ssl_socket, (IBase**)&m_pITcpSocketSSL); + rc_error(hr == S_OK, E_FAIL); + + m_pITcpSocketSSL->CreateSock(); + + _lComPtr pBase; + hr = this->QueryInterface(IID_IBase, (void**)&pBase); + rc_error(hr == S_OK, E_FAIL); + + m_pITcpSocketSSL->BindEvent(pBase); + + // 10.242.68.4 + // 172.16.123.131 + m_pITcpSocketSSL->ConnectIo("127.0.0.1", 8080, 5, 5); sleep_time(300); - //m_pIConsumer->SetId(_inet_addr_v4("255.254.253.252")); - //m_pIConsumer->Bind("127.0.0.1:8080", s_strlen("127.0.0.1:8080")); + // m_pIConsumer->SetId(_inet_addr_v4("255.254.253.252")); + // m_pIConsumer->Bind("127.0.0.1:8080", s_strlen("127.0.0.1:8080")); hr = m_pIMsgBus->CreateNode(NDC_PRODUCER, (IBase**)&m_pIProducer); rc_error(hr == S_OK, E_FAIL); m_pIProducer->SetId(_inet_addr_v4("255.254.253.251")); - //m_pIProducer->Bind("127.0.0.1:8080", s_strlen("127.0.0.1:8080")); + // m_pIProducer->Bind("127.0.0.1:8080", s_strlen("127.0.0.1:8080")); hr = m_pIMsgBus->CreateNode(NDC_AGENT, (IBase**)&m_pIAgent); rc_error(hr == S_OK, E_FAIL); m_pIAgent->SetId(_inet_addr_v4("255.254.253.250")); - //m_pIAgent->Bind("127.0.0.1:8080", s_strlen("127.0.0.1:8080")); + // m_pIAgent->Bind("127.0.0.1:8080", s_strlen("127.0.0.1:8080")); int sec = 0; sec = 30; diff --git a/mainui/appviewimpl.h b/mainui/appviewimpl.h index 1d1eeaf8..45530fc1 100644 --- a/mainui/appviewimpl.h +++ b/mainui/appviewimpl.h @@ -18,10 +18,7 @@ //{a7957a54-37cb-42a4-9ee8-599168c2a3d1} _DEF_CLSID(CLSID_AppView, 0xA7957A54, 0x37CB, 0x42A4, 0x9E, 0xE8, 0x59, 0x91, 0x68, 0xC2, 0xA3, 0xD1); -class CAppViewImpl : public IPlugin, - public IPluginRun, - public ISockProc, - public CUnknownImp +class CAppViewImpl : public IPlugin, public IPluginRun, public ISockProc, public CUnknownImp { public: CAppViewImpl(void); @@ -32,7 +29,7 @@ public: STDCOM_INTERFACE_ENTRY_UNKNOWN_(IPlugin) STDCOM_INTERFACE_ENTRY(IPlugin) STDCOM_INTERFACE_ENTRY(IPluginRun) - STDCOM_INTERFACE_ENTRY(ISockProc) + STDCOM_INTERFACE_ENTRY(ISockProc) END_STDCOM_MAP // IPlugin @@ -42,13 +39,13 @@ public: // IPluginRun std_method(Start)(_pid_t pid, unsigned int type); std_method(Stop)(unsigned int exit); - - // ISockProc - std_method(OnSockSend)(crtid id, crterr error_code, buf_ptr buf, buf_len size); - std_method(OnSockRecv)(crtid id, crterr error_code, buf_ptr buf, buf_len size); - std_method(OnSockConnect)(crtid id, crterr error_code, _sock_t fd); - std_method(OnSockEvent)(crtid id, crtid event, crterr error_code, _sock_t fd); - + + // ISockProc + std_method(OnSockSend)(crtid id, crterr error_code, buf_ptr buf, buf_len size); + std_method(OnSockRecv)(crtid id, crterr error_code, buf_ptr buf, buf_len size); + std_method(OnSockConnect)(crtid id, crterr error_code, _sock_t fd); + std_method(OnSockEvent)(crtid id, crtid event, crterr error_code, _sock_t fd); + HRESULT InitBus(); HRESULT UnInitBus(); diff --git a/mainuiapp/appviewimpl.h b/mainuiapp/appviewimpl.h index 0c4276ad..63b3e2c9 100644 --- a/mainuiapp/appviewimpl.h +++ b/mainuiapp/appviewimpl.h @@ -10,9 +10,7 @@ //{a7957a54-37cb-42a4-9ee8-599168c2a3d1} _DEF_CLSID_IMPL(CLSID_AppView, 0xA7957A54, 0x37CB, 0x42A4, 0x9E, 0xE8, 0x59, 0x91, 0x68, 0xC2, 0xA3, 0xD1) -class CAppViewImpl : public IPlugin, - public IPluginRun, - public CUnknownImp +class CAppViewImpl : public IPlugin, public IPluginRun, public CUnknownImp { public: CAppViewImpl(void); diff --git a/mainview/dllmain.cpp b/mainview/dllmain.cpp index 897059e0..68b0c464 100644 --- a/mainview/dllmain.cpp +++ b/mainview/dllmain.cpp @@ -33,9 +33,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {CLSID_IMainViewImpl, &ClassFactory::GetClass, "mainview.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{CLSID_IMainViewImpl, &ClassFactory::GetClass, "mainview.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/mainview/mainviewimpl.cpp b/mainview/mainviewimpl.cpp index 222577a1..fc3b9b25 100644 --- a/mainview/mainviewimpl.cpp +++ b/mainview/mainviewimpl.cpp @@ -46,7 +46,7 @@ HRESULT CMainViewImpl::Start(_pid_t pid, unsigned int type) basic_tchar szPath[MAX_PATH + 1] = {0x00}; get_executepath(pid_null, szPath, MAX_PATH); - path_string strResFile(szPath); + path_string strResFile(szPath); // strResFile = _T("C:\\app\\duilib\\bin\\"); strResFile += _T("//res"); diff --git a/mainview/mainviewimpl.h b/mainview/mainviewimpl.h index 4bc53c04..16e345e0 100644 --- a/mainview/mainviewimpl.h +++ b/mainview/mainviewimpl.h @@ -6,11 +6,7 @@ // {51FA8DE1-216F-4A76-B4F4-B986E9F54C27} _DEF_CLSID_IMPL(CLSID_IMainViewImpl, 0x51fa8de1, 0x216f, 0x4a76, 0xb4, 0xf4, 0xb9, 0x86, 0xe9, 0xf5, 0x4c, 0x27); -class CMainViewImpl : public IPlugin, - public IPluginRun, - public IMsgPlugin, - public IUIEvent, - public CUnknownImp +class CMainViewImpl : public IPlugin, public IPluginRun, public IMsgPlugin, public IUIEvent, public CUnknownImp { public: CMainViewImpl(void); diff --git a/msgbus/agent.h b/msgbus/agent.h index 2436b978..71cc3b5f 100644 --- a/msgbus/agent.h +++ b/msgbus/agent.h @@ -5,10 +5,7 @@ #include "auth.hpp" #include "msgbuschannel.hpp" -class CAgentImpl : public IAgent, - public IOperationProc, - public CMsgbusChannel, - public CUnknownImp +class CAgentImpl : public IAgent, public IOperationProc, public CMsgbusChannel, public CUnknownImp { public: diff --git a/msgbus/broker.h b/msgbus/broker.h index ff907e3a..826bb712 100644 --- a/msgbus/broker.h +++ b/msgbus/broker.h @@ -4,11 +4,7 @@ #include "stdafx.h" #include "node.h" -class CBrokerImpl : public IBroker, - public IOperationProc, - public IAcceptListen, - public ITimerProc, - public CUnknownImp +class CBrokerImpl : public IBroker, public IOperationProc, public IAcceptListen, public ITimerProc, public CUnknownImp { public: diff --git a/msgbus/consumer.h b/msgbus/consumer.h index bad7fe4d..c826f6a1 100644 --- a/msgbus/consumer.h +++ b/msgbus/consumer.h @@ -5,10 +5,7 @@ #include "auth.hpp" #include "msgbuschannel.hpp" -class CConsumerImpl : public IConsumer, - public IOperationProc, - public CMsgbusChannel, - public CUnknownImp +class CConsumerImpl : public IConsumer, public IOperationProc, public CMsgbusChannel, public CUnknownImp { public: diff --git a/msgbus/dllmain.cpp b/msgbus/dllmain.cpp index 50990e66..bd368405 100644 --- a/msgbus/dllmain.cpp +++ b/msgbus/dllmain.cpp @@ -33,9 +33,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {CLSID_CMsgBus, &ClassFactory::GetClass, "msgbus.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{CLSID_CMsgBus, &ClassFactory::GetClass, "msgbus.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/msgbus/msgbusimpl.h b/msgbus/msgbusimpl.h index e9e912f8..448030f5 100644 --- a/msgbus/msgbusimpl.h +++ b/msgbus/msgbusimpl.h @@ -3,10 +3,7 @@ #include "stdafx.h" -class CMsgBusImpl : public IMsgBus, - public IPlugin, - public IPluginRun, - public CUnknownImp +class CMsgBusImpl : public IMsgBus, public IPlugin, public IPluginRun, public CUnknownImp { public: CMsgBusImpl(void); diff --git a/msgbus/producer.h b/msgbus/producer.h index 3999a418..3598abfe 100644 --- a/msgbus/producer.h +++ b/msgbus/producer.h @@ -7,10 +7,7 @@ #define TCP_CONSUMER_CONNECT 100 -class CProducerImpl : public IProducer, - public IOperationProc, - public CMsgbusChannel, - public CUnknownImp +class CProducerImpl : public IProducer, public IOperationProc, public CMsgbusChannel, public CUnknownImp { public: diff --git a/net/dllmain.cpp b/net/dllmain.cpp index a55729ff..4a033c2d 100644 --- a/net/dllmain.cpp +++ b/net/dllmain.cpp @@ -33,9 +33,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {CLSID_INet, &ClassFactory::GetClass, "net.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{CLSID_INet, &ClassFactory::GetClass, "net.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/net/dnsimpl.cpp b/net/dnsimpl.cpp index 64e63251..56179206 100644 --- a/net/dnsimpl.cpp +++ b/net/dnsimpl.cpp @@ -106,7 +106,7 @@ HRESULT CDnsImpl::OnComplete(IBase* pOperation, crtid cid, crterr err) _lComPtr pOper; pOperation->QueryInterface(IID_IOperation, (void**)&pOper); - crterr error = 0; + crterr error = 0; buf_len size = 0; pOper->GetResult(&error, &size); diff --git a/net/dnsimpl.h b/net/dnsimpl.h index 42c9edcc..47f9ac14 100644 --- a/net/dnsimpl.h +++ b/net/dnsimpl.h @@ -3,9 +3,7 @@ #include "stdafx.h" -class CDnsImpl : public IDns, - public IOperationProc, - public CUnknownImp +class CDnsImpl : public IDns, public IOperationProc, public CUnknownImp { public: CDnsImpl(); diff --git a/net/httpimpl.h b/net/httpimpl.h index 895acfa9..8b4b08fc 100644 --- a/net/httpimpl.h +++ b/net/httpimpl.h @@ -4,11 +4,7 @@ #include "stdafx.h" #include "http_protocol/chttpparser.h" -class CHttpIImpl : public IHttp, - public IOperationProc, - public IDnsProc, - public CUnknownImp, - public CHttpParser +class CHttpIImpl : public IHttp, public IOperationProc, public IDnsProc, public CUnknownImp, public CHttpParser { public: CHttpIImpl(); diff --git a/net/modbusimpl.cpp b/net/modbusimpl.cpp index 72ac784d..b2f3f62f 100644 --- a/net/modbusimpl.cpp +++ b/net/modbusimpl.cpp @@ -2,12 +2,8 @@ CModBusIImpl::CModBusIImpl() { - } CModBusIImpl::~CModBusIImpl(void) { - } - - diff --git a/net/modbusimpl.h b/net/modbusimpl.h index 60e08115..b099ae4b 100644 --- a/net/modbusimpl.h +++ b/net/modbusimpl.h @@ -3,14 +3,13 @@ #include "stdafx.h" -class CModBusIImpl : public CUnknownImp +class CModBusIImpl : public CUnknownImp { public: CModBusIImpl(); virtual ~CModBusIImpl(void); public: - }; #endif diff --git a/net/netimpl.cpp b/net/netimpl.cpp index 5a9d9727..f54b10e1 100644 --- a/net/netimpl.cpp +++ b/net/netimpl.cpp @@ -63,13 +63,10 @@ HRESULT CNetImpl::CreateProtocol(Net_Protocol netp, IBase** pBase) CWebSocketImpl* pWebSocket = ALLOC_NEW CWebSocketImpl(); rc_error(pWebSocket != NULL, E_FAIL); - } else if (protocol_modbus == netp) { - return E_FAIL; - - } else if (protocol_http == netp || protocol_https == netp) { + } else if (protocol_http == netp || protocol_https == netp) { CHttpIImpl* pObj = ALLOC_NEW CHttpIImpl(); rc_error(pObj != NULL, E_FAIL); pObj->AddRef(); diff --git a/net/netimpl.h b/net/netimpl.h index 6d495e68..c5dbf0da 100644 --- a/net/netimpl.h +++ b/net/netimpl.h @@ -3,10 +3,7 @@ #include "stdafx.h" -class CNetImpl : public INet, - public IPlugin, - public IPluginRun, - public CUnknownImp +class CNetImpl : public INet, public IPlugin, public IPluginRun, public CUnknownImp { public: CNetImpl(void); diff --git a/net/protocol/dns.c b/net/protocol/dns.c index d6f2ea5a..23246636 100644 --- a/net/protocol/dns.c +++ b/net/protocol/dns.c @@ -37,7 +37,7 @@ #define SAFE_DELETE_ARRAY(p) \ do { \ if (p) { \ - delete[] (p); \ + delete[](p); \ (p) = NULL; \ } \ } while (0) diff --git a/net/protocol/modbus/config-mach.h b/net/protocol/modbus/config-mach.h index e6aee197..4f3085c4 100644 --- a/net/protocol/modbus/config-mach.h +++ b/net/protocol/modbus/config-mach.h @@ -8,35 +8,35 @@ /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE -# define _ALL_SOURCE 1 +#define _ALL_SOURCE 1 #endif /* Enable general extensions on macOS. */ #ifndef _DARWIN_C_SOURCE -# define _DARWIN_C_SOURCE 1 +#define _DARWIN_C_SOURCE 1 #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 +#define __EXTENSIONS__ 1 #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 +#define _GNU_SOURCE 1 #endif /* Enable X/Open compliant socket functions that do not require linking with -lxnet on HP-UX 11.11. */ #ifndef _HPUX_ALT_XOPEN_SOCKET_API -# define _HPUX_ALT_XOPEN_SOCKET_API 1 +#define _HPUX_ALT_XOPEN_SOCKET_API 1 #endif /* Enable general extensions on NetBSD. Enable NetBSD compatibility extensions on Minix. */ #ifndef _NETBSD_SOURCE -# define _NETBSD_SOURCE 1 +#define _NETBSD_SOURCE 1 #endif /* Enable OpenBSD compatibility extensions on NetBSD. Oddly enough, this does nothing on OpenBSD. */ #ifndef _OPENBSD_SOURCE -# define _OPENBSD_SOURCE 1 +#define _OPENBSD_SOURCE 1 #endif /* Define to 1 if needed for POSIX-compatible behavior. */ #ifndef _POSIX_SOURCE @@ -48,42 +48,39 @@ #endif /* Enable POSIX-compatible threading on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS -# define _POSIX_PTHREAD_SEMANTICS 1 +#define _POSIX_PTHREAD_SEMANTICS 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ #ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ -# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 +#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ #ifndef __STDC_WANT_IEC_60559_BFP_EXT__ -# define __STDC_WANT_IEC_60559_BFP_EXT__ 1 +#define __STDC_WANT_IEC_60559_BFP_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ #ifndef __STDC_WANT_IEC_60559_DFP_EXT__ -# define __STDC_WANT_IEC_60559_DFP_EXT__ 1 +#define __STDC_WANT_IEC_60559_DFP_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ #ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ -# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 +#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ -# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 +#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ #ifndef __STDC_WANT_LIB_EXT2__ -# define __STDC_WANT_LIB_EXT2__ 1 +#define __STDC_WANT_LIB_EXT2__ 1 #endif /* Enable extensions specified by ISO/IEC 24747:2009. */ #ifndef __STDC_WANT_MATH_SPEC_FUNCS__ -# define __STDC_WANT_MATH_SPEC_FUNCS__ 1 +#define __STDC_WANT_MATH_SPEC_FUNCS__ 1 #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE -# define _TANDEM_SOURCE 1 +#define _TANDEM_SOURCE 1 #endif #define WINVER 0x0501 - - - diff --git a/net/protocol/modbus/config-posix.h b/net/protocol/modbus/config-posix.h index a0545784..6d5adff8 100644 --- a/net/protocol/modbus/config-posix.h +++ b/net/protocol/modbus/config-posix.h @@ -14,24 +14,24 @@ /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE -# define _ALL_SOURCE 1 +#define _ALL_SOURCE 1 #endif /* Enable general extensions on macOS. */ #ifndef _DARWIN_C_SOURCE -# define _DARWIN_C_SOURCE 1 +#define _DARWIN_C_SOURCE 1 #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 +#define __EXTENSIONS__ 1 #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 +#define _GNU_SOURCE 1 #endif /* Enable X/Open compliant socket functions that do not require linking with -lxnet on HP-UX 11.11. */ #ifndef _HPUX_ALT_XOPEN_SOCKET_API -# define _HPUX_ALT_XOPEN_SOCKET_API 1 +#define _HPUX_ALT_XOPEN_SOCKET_API 1 #endif /* Identify the host operating system as Minix. This macro does not affect the system headers' behavior. @@ -42,12 +42,12 @@ /* Enable general extensions on NetBSD. Enable NetBSD compatibility extensions on Minix. */ #ifndef _NETBSD_SOURCE -# define _NETBSD_SOURCE 1 +#define _NETBSD_SOURCE 1 #endif /* Enable OpenBSD compatibility extensions on NetBSD. Oddly enough, this does nothing on OpenBSD. */ #ifndef _OPENBSD_SOURCE -# define _OPENBSD_SOURCE 1 +#define _OPENBSD_SOURCE 1 #endif /* Define to 1 if needed for POSIX-compatible behavior. */ #ifndef _POSIX_SOURCE @@ -59,40 +59,39 @@ #endif /* Enable POSIX-compatible threading on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS -# define _POSIX_PTHREAD_SEMANTICS 1 +#define _POSIX_PTHREAD_SEMANTICS 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ #ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ -# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 +#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ #ifndef __STDC_WANT_IEC_60559_BFP_EXT__ -# define __STDC_WANT_IEC_60559_BFP_EXT__ 1 +#define __STDC_WANT_IEC_60559_BFP_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ #ifndef __STDC_WANT_IEC_60559_DFP_EXT__ -# define __STDC_WANT_IEC_60559_DFP_EXT__ 1 +#define __STDC_WANT_IEC_60559_DFP_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ #ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ -# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 +#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ -# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 +#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1 #endif /* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ #ifndef __STDC_WANT_LIB_EXT2__ -# define __STDC_WANT_LIB_EXT2__ 1 +#define __STDC_WANT_LIB_EXT2__ 1 #endif /* Enable extensions specified by ISO/IEC 24747:2009. */ #ifndef __STDC_WANT_MATH_SPEC_FUNCS__ -# define __STDC_WANT_MATH_SPEC_FUNCS__ 1 +#define __STDC_WANT_MATH_SPEC_FUNCS__ 1 #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE -# define _TANDEM_SOURCE 1 +#define _TANDEM_SOURCE 1 #endif #define WINVER 0x0501 - diff --git a/net/protocol/modbus/modbus-config.h b/net/protocol/modbus/modbus-config.h index b1743498..4758b575 100644 --- a/net/protocol/modbus/modbus-config.h +++ b/net/protocol/modbus/modbus-config.h @@ -5,7 +5,6 @@ #if (TARGET_OS == OS_WIN) - #elif (TARGET_OS == OS_POSIX) #include "config-posix.h" @@ -16,7 +15,6 @@ #endif - #if defined(HAVE_BYTESWAP_H) #include #endif @@ -61,7 +59,6 @@ static inline uint32_t bswap_32(uint32_t x) } #endif - #if defined(_WIN32) #include #else @@ -76,7 +73,6 @@ static inline uint32_t bswap_32(uint32_t x) #include #endif - #if !defined(MSG_NOSIGNAL) #define MSG_NOSIGNAL 0 #endif diff --git a/net/protocol/modbus/modbus-data.c b/net/protocol/modbus/modbus-data.c index 9c4ec50c..2ffa7b87 100644 --- a/net/protocol/modbus/modbus-data.c +++ b/net/protocol/modbus/modbus-data.c @@ -21,7 +21,7 @@ /* Sets many bits from a single byte value (all 8 bits of the byte value are set) */ -void modbus_set_bits_from_byte(uint8_t *dest, int idx, const uint8_t value) +void modbus_set_bits_from_byte(uint8_t* dest, int idx, const uint8_t value) { int i; @@ -32,10 +32,7 @@ void modbus_set_bits_from_byte(uint8_t *dest, int idx, const uint8_t value) /* Sets many bits from a table of bytes (only the bits between idx and idx + nb_bits are set) */ -void modbus_set_bits_from_bytes(uint8_t *dest, - int idx, - unsigned int nb_bits, - const uint8_t *tab_byte) +void modbus_set_bits_from_bytes(uint8_t* dest, int idx, unsigned int nb_bits, const uint8_t* tab_byte) { unsigned int i; int shift = 0; @@ -50,14 +47,14 @@ void modbus_set_bits_from_bytes(uint8_t *dest, /* Gets the byte value from many bits. To obtain a full byte, set nb_bits to 8. */ -uint8_t modbus_get_byte_from_bits(const uint8_t *src, int idx, unsigned int nb_bits) +uint8_t modbus_get_byte_from_bits(const uint8_t* src, int idx, unsigned int nb_bits) { unsigned int i; uint8_t value = 0; if (nb_bits > 8) { /* Assert is ignored if NDEBUG is set */ - // assert(nb_bits < 8); + // assert(nb_bits < 8); nb_bits = 8; } @@ -69,7 +66,7 @@ uint8_t modbus_get_byte_from_bits(const uint8_t *src, int idx, unsigned int nb_b } /* Get a float from 4 bytes (Modbus) without any conversion (ABCD) */ -float modbus_get_float_abcd(const uint16_t *src) +float modbus_get_float_abcd(const uint16_t* src) { float f; uint32_t i; @@ -87,7 +84,7 @@ float modbus_get_float_abcd(const uint16_t *src) } /* Get a float from 4 bytes (Modbus) in inversed format (DCBA) */ -float modbus_get_float_dcba(const uint16_t *src) +float modbus_get_float_dcba(const uint16_t* src) { float f; uint32_t i; @@ -105,7 +102,7 @@ float modbus_get_float_dcba(const uint16_t *src) } /* Get a float from 4 bytes (Modbus) with swapped bytes (BADC) */ -float modbus_get_float_badc(const uint16_t *src) +float modbus_get_float_badc(const uint16_t* src) { float f; uint32_t i; @@ -123,7 +120,7 @@ float modbus_get_float_badc(const uint16_t *src) } /* Get a float from 4 bytes (Modbus) with swapped words (CDAB) */ -float modbus_get_float_cdab(const uint16_t *src) +float modbus_get_float_cdab(const uint16_t* src) { float f; uint32_t i; @@ -141,22 +138,22 @@ float modbus_get_float_cdab(const uint16_t *src) } /* DEPRECATED - Get a float from 4 bytes in sort of Modbus format */ -float modbus_get_float(const uint16_t *src) +float modbus_get_float(const uint16_t* src) { float f; uint32_t i; - i = (((uint32_t) src[1]) << 16) + src[0]; + i = (((uint32_t)src[1]) << 16) + src[0]; memcpy(&f, &i, sizeof(float)); return f; } /* Set a float to 4 bytes for Modbus w/o any conversion (ABCD) */ -void modbus_set_float_abcd(float f, uint16_t *dest) +void modbus_set_float_abcd(float f, uint16_t* dest) { uint32_t i; - uint8_t *out = (uint8_t *) dest; + uint8_t* out = (uint8_t*)dest; uint8_t a, b, c, d; memcpy(&i, &f, sizeof(uint32_t)); @@ -172,10 +169,10 @@ void modbus_set_float_abcd(float f, uint16_t *dest) } /* Set a float to 4 bytes for Modbus with byte and word swap conversion (DCBA) */ -void modbus_set_float_dcba(float f, uint16_t *dest) +void modbus_set_float_dcba(float f, uint16_t* dest) { uint32_t i; - uint8_t *out = (uint8_t *) dest; + uint8_t* out = (uint8_t*)dest; uint8_t a, b, c, d; memcpy(&i, &f, sizeof(uint32_t)); @@ -191,10 +188,10 @@ void modbus_set_float_dcba(float f, uint16_t *dest) } /* Set a float to 4 bytes for Modbus with byte swap conversion (BADC) */ -void modbus_set_float_badc(float f, uint16_t *dest) +void modbus_set_float_badc(float f, uint16_t* dest) { uint32_t i; - uint8_t *out = (uint8_t *) dest; + uint8_t* out = (uint8_t*)dest; uint8_t a, b, c, d; memcpy(&i, &f, sizeof(uint32_t)); @@ -210,10 +207,10 @@ void modbus_set_float_badc(float f, uint16_t *dest) } /* Set a float to 4 bytes for Modbus with word swap conversion (CDAB) */ -void modbus_set_float_cdab(float f, uint16_t *dest) +void modbus_set_float_cdab(float f, uint16_t* dest) { uint32_t i; - uint8_t *out = (uint8_t *) dest; + uint8_t* out = (uint8_t*)dest; uint8_t a, b, c, d; memcpy(&i, &f, sizeof(uint32_t)); @@ -229,11 +226,11 @@ void modbus_set_float_cdab(float f, uint16_t *dest) } /* DEPRECATED - Set a float to 4 bytes in a sort of Modbus format! */ -void modbus_set_float(float f, uint16_t *dest) +void modbus_set_float(float f, uint16_t* dest) { uint32_t i; memcpy(&i, &f, sizeof(uint32_t)); - dest[0] = (uint16_t) i; - dest[1] = (uint16_t) (i >> 16); + dest[0] = (uint16_t)i; + dest[1] = (uint16_t)(i >> 16); } diff --git a/net/protocol/modbus/modbus-private.h b/net/protocol/modbus/modbus-private.h index c8c22f7b..64dbdf6e 100644 --- a/net/protocol/modbus/modbus-private.h +++ b/net/protocol/modbus/modbus-private.h @@ -7,12 +7,9 @@ #ifndef MODBUS_PRIVATE_H #define MODBUS_PRIVATE_H - - // clang-format on #include "modbus-config.h" - #include "modbus.h" #ifdef __cplusplus @@ -36,10 +33,7 @@ extern "C" { #define _RESPONSE_TIMEOUT 500000 #define _BYTE_TIMEOUT 500000 -typedef enum { - _MODBUS_BACKEND_TYPE_RTU = 0, - _MODBUS_BACKEND_TYPE_TCP -} modbus_backend_type_t; +typedef enum { _MODBUS_BACKEND_TYPE_RTU = 0, _MODBUS_BACKEND_TYPE_TCP } modbus_backend_type_t; /* * ---------- Request Indication ---------- @@ -66,26 +60,22 @@ typedef struct _modbus_backend { unsigned int header_length; unsigned int checksum_length; unsigned int max_adu_length; - int (*set_slave)(modbus_t *ctx, int slave); - int (*build_request_basis)( - modbus_t *ctx, int function, int addr, int nb, uint8_t *req); - int (*build_response_basis)(sft_t *sft, uint8_t *rsp); - int (*prepare_response_tid)(const uint8_t *req, int *req_length); - int (*send_msg_pre)(uint8_t *req, int req_length); - ssize_t (*send)(modbus_t *ctx, const uint8_t *req, int req_length); - int (*receive)(modbus_t *ctx, uint8_t *req); - ssize_t (*recv)(modbus_t *ctx, uint8_t *rsp, int rsp_length); - int (*check_integrity)(modbus_t *ctx, uint8_t *msg, const int msg_length); - int (*pre_check_confirmation)(modbus_t *ctx, - const uint8_t *req, - const uint8_t *rsp, - int rsp_length); - int (*connect)(modbus_t *ctx); - unsigned int (*is_connected)(modbus_t *ctx); - void (*close)(modbus_t *ctx); - int (*flush)(modbus_t *ctx); - int (*select)(modbus_t *ctx, fd_set *rset, struct timeval *tv, int msg_length); - void (*free)(modbus_t *ctx); + int (*set_slave)(modbus_t* ctx, int slave); + int (*build_request_basis)(modbus_t* ctx, int function, int addr, int nb, uint8_t* req); + int (*build_response_basis)(sft_t* sft, uint8_t* rsp); + int (*prepare_response_tid)(const uint8_t* req, int* req_length); + int (*send_msg_pre)(uint8_t* req, int req_length); + ssize_t (*send)(modbus_t* ctx, const uint8_t* req, int req_length); + int (*receive)(modbus_t* ctx, uint8_t* req); + ssize_t (*recv)(modbus_t* ctx, uint8_t* rsp, int rsp_length); + int (*check_integrity)(modbus_t* ctx, uint8_t* msg, const int msg_length); + int (*pre_check_confirmation)(modbus_t* ctx, const uint8_t* req, const uint8_t* rsp, int rsp_length); + int (*connect)(modbus_t* ctx); + unsigned int (*is_connected)(modbus_t* ctx); + void (*close)(modbus_t* ctx); + int (*flush)(modbus_t* ctx); + int (*select)(modbus_t* ctx, fd_set* rset, struct timeval* tv, int msg_length); + void (*free)(modbus_t* ctx); } modbus_backend_t; struct _modbus { @@ -99,14 +89,13 @@ struct _modbus { struct timeval response_timeout; struct timeval byte_timeout; struct timeval indication_timeout; - const modbus_backend_t *backend; - void *backend_data; + const modbus_backend_t* backend; + void* backend_data; }; -void _modbus_init_common(modbus_t *ctx); -void _error_print(modbus_t *ctx, const char *context); -int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type); - +void _modbus_init_common(modbus_t* ctx); +void _error_print(modbus_t* ctx, const char* context); +int _modbus_receive_msg(modbus_t* ctx, uint8_t* msg, msg_type_t msg_type); #ifdef __cplusplus } diff --git a/net/protocol/modbus/modbus-rtu-private.h b/net/protocol/modbus/modbus-rtu-private.h index 652ebf00..938bdb22 100644 --- a/net/protocol/modbus/modbus-rtu-private.h +++ b/net/protocol/modbus/modbus-rtu-private.h @@ -35,7 +35,7 @@ struct win32_ser { typedef struct _modbus_rtu { /* Device: "/dev/ttyS0", "/dev/ttyUSB0" or "/dev/tty.USA19*" on Mac OS X. */ - char *device; + char* device; /* Bauds: 9600, 19200, 57600, 115200, etc */ int baud; /* Data bit */ @@ -58,7 +58,7 @@ typedef struct _modbus_rtu { int rts; int rts_delay; int onebyte_time; - void (*set_rts)(modbus_t *ctx, int on); + void (*set_rts)(modbus_t* ctx, int on); #endif /* To handle many slaves on the same link */ int confirmation_to_ignore; diff --git a/net/protocol/modbus/modbus-rtu.c b/net/protocol/modbus/modbus-rtu.c index f951bbce..46dec2a2 100644 --- a/net/protocol/modbus/modbus-rtu.c +++ b/net/protocol/modbus/modbus-rtu.c @@ -20,55 +20,37 @@ #include "modbus-rtu-private.h" #include "modbus-rtu.h" - - /* Table of CRC values for high-order byte */ static const uint8_t table_crc_hi[] = { - 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, - 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, - 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, - 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, - 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, - 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, - 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, - 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, - 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, - 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, - 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, - 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, - 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, - 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, - 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, - 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, - 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, - 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, - 0x00, 0xC1, 0x81, 0x40}; + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40}; /* Table of CRC values for low-order byte */ static const uint8_t table_crc_lo[] = { - 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, - 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, - 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, - 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, - 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, - 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, - 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, - 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, - 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, - 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, - 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, - 0x6B, 0xAB, 0x69, 0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0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, + 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, + 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, + 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, + 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, + 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, + 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, + 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, 0x40}; /* Define the slave ID of the remote device to talk in master mode or set the * internal slave ID in slave mode */ -static int _modbus_set_slave(modbus_t *ctx, int slave) +static int _modbus_set_slave(modbus_t* ctx, int slave) { int max_slave = (ctx->quirks & MODBUS_QUIRK_MAX_SLAVE) ? 255 : 247; @@ -84,8 +66,7 @@ static int _modbus_set_slave(modbus_t *ctx, int slave) } /* Builds a RTU request header */ -static int _modbus_rtu_build_request_basis( - modbus_t *ctx, int function, int addr, int nb, uint8_t *req) +static int _modbus_rtu_build_request_basis(modbus_t* ctx, int function, int addr, int nb, uint8_t* req) { assert(ctx->slave != -1); req[0] = ctx->slave; @@ -99,7 +80,7 @@ static int _modbus_rtu_build_request_basis( } /* Builds a RTU response header */ -static int _modbus_rtu_build_response_basis(sft_t *sft, uint8_t *rsp) +static int _modbus_rtu_build_response_basis(sft_t* sft, uint8_t* rsp) { /* In this case, the slave is certainly valid because a check is already * done in _modbus_rtu_listen */ @@ -109,7 +90,7 @@ static int _modbus_rtu_build_response_basis(sft_t *sft, uint8_t *rsp) return _MODBUS_RTU_PRESET_RSP_LENGTH; } -static uint16_t crc16(uint8_t *buffer, uint16_t buffer_length) +static uint16_t crc16(uint8_t* buffer, uint16_t buffer_length) { uint8_t crc_hi = 0xFF; /* high CRC byte initialized */ uint8_t crc_lo = 0xFF; /* low CRC byte initialized */ @@ -125,14 +106,14 @@ static uint16_t crc16(uint8_t *buffer, uint16_t buffer_length) return (crc_hi << 8 | crc_lo); } -static int _modbus_rtu_prepare_response_tid(const uint8_t *req, int *req_length) +static int _modbus_rtu_prepare_response_tid(const uint8_t* req, int* req_length) { (*req_length) -= _MODBUS_RTU_CHECKSUM_LENGTH; /* No TID */ return 0; } -static int _modbus_rtu_send_msg_pre(uint8_t *req, int req_length) +static int _modbus_rtu_send_msg_pre(uint8_t* req, int req_length) { uint16_t crc = crc16(req, req_length); @@ -154,7 +135,7 @@ static int _modbus_rtu_send_msg_pre(uint8_t *req, int req_length) * while win32_ser_read() only consumes the receive buffer. */ -static void win32_ser_init(struct win32_ser *ws) +static void win32_ser_init(struct win32_ser* ws) { /* Clear everything */ memset(ws, 0x00, sizeof(struct win32_ser)); @@ -164,7 +145,7 @@ static void win32_ser_init(struct win32_ser *ws) } /* FIXME Try to remove length_to_read -> max_len argument, only used by win32 */ -static int win32_ser_select(struct win32_ser *ws, int max_len, const struct timeval *tv) +static int win32_ser_select(struct win32_ser* ws, int max_len, const struct timeval* tv) { COMMTIMEOUTS comm_to; unsigned int msec = 0; @@ -214,7 +195,7 @@ static int win32_ser_select(struct win32_ser *ws, int max_len, const struct time } } -static int win32_ser_read(struct win32_ser *ws, uint8_t *p_msg, unsigned int max_len) +static int win32_ser_read(struct win32_ser* ws, uint8_t* p_msg, unsigned int max_len) { unsigned int n = ws->n_bytes; @@ -233,7 +214,7 @@ static int win32_ser_read(struct win32_ser *ws, uint8_t *p_msg, unsigned int max #endif #if HAVE_DECL_TIOCM_RTS -static void _modbus_rtu_ioctl_rts(modbus_t *ctx, int on) +static void _modbus_rtu_ioctl_rts(modbus_t* ctx, int on) { int fd = ctx->s; int flags; @@ -248,17 +229,15 @@ static void _modbus_rtu_ioctl_rts(modbus_t *ctx, int on) } #endif -static ssize_t _modbus_rtu_send(modbus_t *ctx, const uint8_t *req, int req_length) +static ssize_t _modbus_rtu_send(modbus_t* ctx, const uint8_t* req, int req_length) { #if defined(_WIN32) - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; DWORD n_bytes = 0; - return (WriteFile(ctx_rtu->w_ser.fd, req, req_length, &n_bytes, NULL)) - ? (ssize_t) n_bytes - : -1; + return (WriteFile(ctx_rtu->w_ser.fd, req, req_length, &n_bytes, NULL)) ? (ssize_t)n_bytes : -1; #else #if HAVE_DECL_TIOCM_RTS - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; if (ctx_rtu->rts != MODBUS_RTU_RTS_NONE) { ssize_t size; @@ -284,10 +263,10 @@ static ssize_t _modbus_rtu_send(modbus_t *ctx, const uint8_t *req, int req_lengt #endif } -static int _modbus_rtu_receive(modbus_t *ctx, uint8_t *req) +static int _modbus_rtu_receive(modbus_t* ctx, uint8_t* req) { int rc; - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; if (ctx_rtu->confirmation_to_ignore) { _modbus_receive_msg(ctx, req, MSG_CONFIRMATION); @@ -307,30 +286,24 @@ static int _modbus_rtu_receive(modbus_t *ctx, uint8_t *req) return rc; } -static ssize_t _modbus_rtu_recv(modbus_t *ctx, uint8_t *rsp, int rsp_length) +static ssize_t _modbus_rtu_recv(modbus_t* ctx, uint8_t* rsp, int rsp_length) { #if defined(_WIN32) - return win32_ser_read(&((modbus_rtu_t *) ctx->backend_data)->w_ser, rsp, rsp_length); + return win32_ser_read(&((modbus_rtu_t*)ctx->backend_data)->w_ser, rsp, rsp_length); #else return read(ctx->s, rsp, rsp_length); #endif } -static int _modbus_rtu_flush(modbus_t *); +static int _modbus_rtu_flush(modbus_t*); -static int _modbus_rtu_pre_check_confirmation(modbus_t *ctx, - const uint8_t *req, - const uint8_t *rsp, - int rsp_length) +static int _modbus_rtu_pre_check_confirmation(modbus_t* ctx, const uint8_t* req, const uint8_t* rsp, int rsp_length) { /* Check responding slave is the slave we requested (except for broacast * request) */ if (req[0] != rsp[0] && req[0] != MODBUS_BROADCAST_ADDRESS) { if (ctx->debug) { - fprintf(stderr, - "The responding slave %d isn't the requested slave %d\n", - rsp[0], - req[0]); + fprintf(stderr, "The responding slave %d isn't the requested slave %d\n", rsp[0], req[0]); } errno = EMBBADSLAVE; return -1; @@ -342,7 +315,7 @@ static int _modbus_rtu_pre_check_confirmation(modbus_t *ctx, /* The check_crc16 function shall return 0 if the message is ignored and the message length if the CRC is valid. Otherwise it shall return -1 and set errno to EMBBADCRC. */ -static int _modbus_rtu_check_integrity(modbus_t *ctx, uint8_t *msg, const int msg_length) +static int _modbus_rtu_check_integrity(modbus_t* ctx, uint8_t* msg, const int msg_length) { uint16_t crc_calculated; uint16_t crc_received; @@ -366,10 +339,7 @@ static int _modbus_rtu_check_integrity(modbus_t *ctx, uint8_t *msg, const int ms return msg_length; } else { if (ctx->debug) { - fprintf(stderr, - "ERROR CRC received 0x%0X != CRC calculated 0x%0X\n", - crc_received, - crc_calculated); + fprintf(stderr, "ERROR CRC received 0x%0X != CRC calculated 0x%0X\n", crc_received, crc_calculated); } if (ctx->error_recovery & MODBUS_ERROR_RECOVERY_PROTOCOL) { @@ -381,7 +351,7 @@ static int _modbus_rtu_check_integrity(modbus_t *ctx, uint8_t *msg, const int ms } /* Sets up a serial port for RTU communications */ -static int _modbus_rtu_connect(modbus_t *ctx) +static int _modbus_rtu_connect(modbus_t* ctx) { #if defined(_WIN32) DCB dcb; @@ -389,15 +359,10 @@ static int _modbus_rtu_connect(modbus_t *ctx) struct termios tios; int flags; #endif - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; if (ctx->debug) { - printf("Opening %s at %d bauds (%c, %d, %d)\n", - ctx_rtu->device, - ctx_rtu->baud, - ctx_rtu->parity, - ctx_rtu->data_bit, - ctx_rtu->stop_bit); + printf("Opening %s at %d bauds (%c, %d, %d)\n", ctx_rtu->device, ctx_rtu->baud, ctx_rtu->parity, ctx_rtu->data_bit, ctx_rtu->stop_bit); } #if defined(_WIN32) @@ -408,16 +373,12 @@ static int _modbus_rtu_connect(modbus_t *ctx) /* ctx_rtu->device should contain a string like "COMxx:" xx being a decimal * number */ - ctx_rtu->w_ser.fd = CreateFileA( - ctx_rtu->device, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + ctx_rtu->w_ser.fd = CreateFileA(ctx_rtu->device, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); /* Error checking */ if (ctx_rtu->w_ser.fd == INVALID_HANDLE_VALUE) { if (ctx->debug) { - fprintf(stderr, - "ERROR Can't open the device %s (LastError %d)\n", - ctx_rtu->device, - (int) GetLastError()); + fprintf(stderr, "ERROR Can't open the device %s (LastError %d)\n", ctx_rtu->device, (int)GetLastError()); } return -1; } @@ -426,9 +387,7 @@ static int _modbus_rtu_connect(modbus_t *ctx) ctx_rtu->old_dcb.DCBlength = sizeof(DCB); if (!GetCommState(ctx_rtu->w_ser.fd, &ctx_rtu->old_dcb)) { if (ctx->debug) { - fprintf(stderr, - "ERROR Error getting configuration (LastError %d)\n", - (int) GetLastError()); + fprintf(stderr, "ERROR Error getting configuration (LastError %d)\n", (int)GetLastError()); } CloseHandle(ctx_rtu->w_ser.fd); ctx_rtu->w_ser.fd = INVALID_HANDLE_VALUE; @@ -493,9 +452,7 @@ static int _modbus_rtu_connect(modbus_t *ctx) /* Setup port */ if (!SetCommState(ctx_rtu->w_ser.fd, &dcb)) { if (ctx->debug) { - fprintf(stderr, - "ERROR Error setting new configuration (LastError %d)\n", - (int) GetLastError()); + fprintf(stderr, "ERROR Error setting new configuration (LastError %d)\n", (int)GetLastError()); } CloseHandle(ctx_rtu->w_ser.fd); ctx_rtu->w_ser.fd = INVALID_HANDLE_VALUE; @@ -517,10 +474,7 @@ static int _modbus_rtu_connect(modbus_t *ctx) ctx->s = open(ctx_rtu->device, flags); if (ctx->s < 0) { if (ctx->debug) { - fprintf(stderr, - "ERROR Can't open the device %s (%s)\n", - ctx_rtu->device, - strerror(errno)); + fprintf(stderr, "ERROR Can't open the device %s (%s)\n", ctx_rtu->device, strerror(errno)); } return -1; } @@ -535,8 +489,7 @@ static int _modbus_rtu_connect(modbus_t *ctx) */ /* Set the baud rate */ - if ((cfsetispeed(&tios, ctx_rtu->baud) < 0) || - (cfsetospeed(&tios, ctx_rtu->baud) < 0)) { + if ((cfsetispeed(&tios, ctx_rtu->baud) < 0) || (cfsetospeed(&tios, ctx_rtu->baud) < 0)) { close(ctx->s); ctx->s = -1; return -1; @@ -721,10 +674,10 @@ static int _modbus_rtu_connect(modbus_t *ctx) } // FIXME Temporary solution before rewriting Windows RTU backend -static unsigned int _modbus_rtu_is_connected(modbus_t *ctx) +static unsigned int _modbus_rtu_is_connected(modbus_t* ctx) { #if defined(_WIN32) - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; /* Check if file handle is valid */ return ctx_rtu->w_ser.fd != INVALID_HANDLE_VALUE; @@ -733,7 +686,7 @@ static unsigned int _modbus_rtu_is_connected(modbus_t *ctx) #endif } -int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode) +int modbus_rtu_set_serial_mode(modbus_t* ctx, int mode) { if (ctx == NULL) { errno = EINVAL; @@ -742,7 +695,7 @@ int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode) if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) { #if HAVE_DECL_TIOCSRS485 - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; struct serial_rs485 rs485conf; if (mode == MODBUS_RTU_RS485) { @@ -787,7 +740,7 @@ int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode) return -1; } -int modbus_rtu_get_serial_mode(modbus_t *ctx) +int modbus_rtu_get_serial_mode(modbus_t* ctx) { if (ctx == NULL) { errno = EINVAL; @@ -796,7 +749,7 @@ int modbus_rtu_get_serial_mode(modbus_t *ctx) if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) { #if HAVE_DECL_TIOCSRS485 - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; return ctx_rtu->serial_mode; #else if (ctx->debug) { @@ -811,7 +764,7 @@ int modbus_rtu_get_serial_mode(modbus_t *ctx) } } -int modbus_rtu_get_rts(modbus_t *ctx) +int modbus_rtu_get_rts(modbus_t* ctx) { if (ctx == NULL) { errno = EINVAL; @@ -820,7 +773,7 @@ int modbus_rtu_get_rts(modbus_t *ctx) if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) { #if HAVE_DECL_TIOCM_RTS - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; return ctx_rtu->rts; #else if (ctx->debug) { @@ -835,7 +788,7 @@ int modbus_rtu_get_rts(modbus_t *ctx) } } -int modbus_rtu_set_rts(modbus_t *ctx, int mode) +int modbus_rtu_set_rts(modbus_t* ctx, int mode) { if (ctx == NULL) { errno = EINVAL; @@ -844,10 +797,9 @@ int modbus_rtu_set_rts(modbus_t *ctx, int mode) if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) { #if HAVE_DECL_TIOCM_RTS - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; - if (mode == MODBUS_RTU_RTS_NONE || mode == MODBUS_RTU_RTS_UP || - mode == MODBUS_RTU_RTS_DOWN) { + if (mode == MODBUS_RTU_RTS_NONE || mode == MODBUS_RTU_RTS_UP || mode == MODBUS_RTU_RTS_DOWN) { ctx_rtu->rts = mode; /* Set the RTS bit in order to not reserve the RS485 bus */ @@ -871,7 +823,7 @@ int modbus_rtu_set_rts(modbus_t *ctx, int mode) return -1; } -int modbus_rtu_set_custom_rts(modbus_t *ctx, void (*set_rts)(modbus_t *ctx, int on)) +int modbus_rtu_set_custom_rts(modbus_t* ctx, void (*set_rts)(modbus_t* ctx, int on)) { if (ctx == NULL) { errno = EINVAL; @@ -880,7 +832,7 @@ int modbus_rtu_set_custom_rts(modbus_t *ctx, void (*set_rts)(modbus_t *ctx, int if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) { #if HAVE_DECL_TIOCM_RTS - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; ctx_rtu->set_rts = set_rts; return 0; #else @@ -896,7 +848,7 @@ int modbus_rtu_set_custom_rts(modbus_t *ctx, void (*set_rts)(modbus_t *ctx, int } } -int modbus_rtu_get_rts_delay(modbus_t *ctx) +int modbus_rtu_get_rts_delay(modbus_t* ctx) { if (ctx == NULL) { errno = EINVAL; @@ -905,8 +857,8 @@ int modbus_rtu_get_rts_delay(modbus_t *ctx) if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) { #if HAVE_DECL_TIOCM_RTS - modbus_rtu_t *ctx_rtu; - ctx_rtu = (modbus_rtu_t *) ctx->backend_data; + modbus_rtu_t* ctx_rtu; + ctx_rtu = (modbus_rtu_t*)ctx->backend_data; return ctx_rtu->rts_delay; #else if (ctx->debug) { @@ -921,7 +873,7 @@ int modbus_rtu_get_rts_delay(modbus_t *ctx) } } -int modbus_rtu_set_rts_delay(modbus_t *ctx, int us) +int modbus_rtu_set_rts_delay(modbus_t* ctx, int us) { if (ctx == NULL || us < 0) { errno = EINVAL; @@ -930,8 +882,8 @@ int modbus_rtu_set_rts_delay(modbus_t *ctx, int us) if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) { #if HAVE_DECL_TIOCM_RTS - modbus_rtu_t *ctx_rtu; - ctx_rtu = (modbus_rtu_t *) ctx->backend_data; + modbus_rtu_t* ctx_rtu; + ctx_rtu = (modbus_rtu_t*)ctx->backend_data; ctx_rtu->rts_delay = us; return 0; #else @@ -947,23 +899,19 @@ int modbus_rtu_set_rts_delay(modbus_t *ctx, int us) } } -static void _modbus_rtu_close(modbus_t *ctx) +static void _modbus_rtu_close(modbus_t* ctx) { /* Restore line settings and close file descriptor in RTU mode */ - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; #if defined(_WIN32) /* Revert settings */ if (!SetCommState(ctx_rtu->w_ser.fd, &ctx_rtu->old_dcb) && ctx->debug) { - fprintf(stderr, - "ERROR Couldn't revert to configuration (LastError %d)\n", - (int) GetLastError()); + fprintf(stderr, "ERROR Couldn't revert to configuration (LastError %d)\n", (int)GetLastError()); } if (!CloseHandle(ctx_rtu->w_ser.fd) && ctx->debug) { - fprintf(stderr, - "ERROR Error while closing handle (LastError %d)\n", - (int) GetLastError()); + fprintf(stderr, "ERROR Error while closing handle (LastError %d)\n", (int)GetLastError()); } #else if (ctx->s >= 0) { @@ -974,10 +922,10 @@ static void _modbus_rtu_close(modbus_t *ctx) #endif } -static int _modbus_rtu_flush(modbus_t *ctx) +static int _modbus_rtu_flush(modbus_t* ctx) { #if defined(_WIN32) - modbus_rtu_t *ctx_rtu = ctx->backend_data; + modbus_rtu_t* ctx_rtu = ctx->backend_data; ctx_rtu->w_ser.n_bytes = 0; return (PurgeComm(ctx_rtu->w_ser.fd, PURGE_RXCLEAR) == FALSE); #else @@ -985,13 +933,11 @@ static int _modbus_rtu_flush(modbus_t *ctx) #endif } -static int -_modbus_rtu_select(modbus_t *ctx, fd_set *rset, struct timeval *tv, int length_to_read) +static int _modbus_rtu_select(modbus_t* ctx, fd_set* rset, struct timeval* tv, int length_to_read) { int s_rc; #if defined(_WIN32) - s_rc = win32_ser_select( - &((modbus_rtu_t *) ctx->backend_data)->w_ser, length_to_read, tv); + s_rc = win32_ser_select(&((modbus_rtu_t*)ctx->backend_data)->w_ser, length_to_read, tv); if (s_rc == 0) { errno = ETIMEDOUT; return -1; @@ -1024,10 +970,10 @@ _modbus_rtu_select(modbus_t *ctx, fd_set *rset, struct timeval *tv, int length_t return s_rc; } -static void _modbus_rtu_free(modbus_t *ctx) +static void _modbus_rtu_free(modbus_t* ctx) { if (ctx->backend_data) { - free(((modbus_rtu_t *) ctx->backend_data)->device); + free(((modbus_rtu_t*)ctx->backend_data)->device); free(ctx->backend_data); } @@ -1060,11 +1006,10 @@ const modbus_backend_t _modbus_rtu_backend = { // clang-format on -modbus_t * -modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop_bit) +modbus_t* modbus_new_rtu(const char* device, int baud, char parity, int data_bit, int stop_bit) { - modbus_t *ctx; - modbus_rtu_t *ctx_rtu; + modbus_t* ctx; + modbus_rtu_t* ctx_rtu; /* Check device argument */ if (device == NULL || *device == 0) { @@ -1080,23 +1025,23 @@ modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop return NULL; } - ctx = (modbus_t *) malloc(sizeof(modbus_t)); + ctx = (modbus_t*)malloc(sizeof(modbus_t)); if (ctx == NULL) { return NULL; } _modbus_init_common(ctx); ctx->backend = &_modbus_rtu_backend; - ctx->backend_data = (modbus_rtu_t *) malloc(sizeof(modbus_rtu_t)); + ctx->backend_data = (modbus_rtu_t*)malloc(sizeof(modbus_rtu_t)); if (ctx->backend_data == NULL) { modbus_free(ctx); errno = ENOMEM; return NULL; } - ctx_rtu = (modbus_rtu_t *) ctx->backend_data; + ctx_rtu = (modbus_rtu_t*)ctx->backend_data; /* Device name and \0 */ - ctx_rtu->device = (char *) malloc((strlen(device) + 1) * sizeof(char)); + ctx_rtu->device = (char*)malloc((strlen(device) + 1) * sizeof(char)); if (ctx_rtu->device == NULL) { modbus_free(ctx); errno = ENOMEM; @@ -1130,8 +1075,7 @@ modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop ctx_rtu->rts = MODBUS_RTU_RTS_NONE; /* Calculate estimated time in micro second to send one byte */ - ctx_rtu->onebyte_time = - 1000000 * (1 + data_bit + (parity == 'N' ? 0 : 1) + stop_bit) / baud; + ctx_rtu->onebyte_time = 1000000 * (1 + data_bit + (parity == 'N' ? 0 : 1) + stop_bit) / baud; /* The internal function is used by default to set RTS */ ctx_rtu->set_rts = _modbus_rtu_ioctl_rts; diff --git a/net/protocol/modbus/modbus-rtu.h b/net/protocol/modbus/modbus-rtu.h index c7dbd54e..24e952d9 100644 --- a/net/protocol/modbus/modbus-rtu.h +++ b/net/protocol/modbus/modbus-rtu.h @@ -18,27 +18,25 @@ extern "C" { */ #define MODBUS_RTU_MAX_ADU_LENGTH 256 -modbus_t * -modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop_bit); +modbus_t* modbus_new_rtu(const char* device, int baud, char parity, int data_bit, int stop_bit); #define MODBUS_RTU_RS232 0 #define MODBUS_RTU_RS485 1 -int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode); -int modbus_rtu_get_serial_mode(modbus_t *ctx); +int modbus_rtu_set_serial_mode(modbus_t* ctx, int mode); +int modbus_rtu_get_serial_mode(modbus_t* ctx); #define MODBUS_RTU_RTS_NONE 0 #define MODBUS_RTU_RTS_UP 1 #define MODBUS_RTU_RTS_DOWN 2 -int modbus_rtu_set_rts(modbus_t *ctx, int mode); -int modbus_rtu_get_rts(modbus_t *ctx); +int modbus_rtu_set_rts(modbus_t* ctx, int mode); +int modbus_rtu_get_rts(modbus_t* ctx); -int modbus_rtu_set_custom_rts(modbus_t *ctx, - void (*set_rts)(modbus_t *ctx, int on)); +int modbus_rtu_set_custom_rts(modbus_t* ctx, void (*set_rts)(modbus_t* ctx, int on)); -int modbus_rtu_set_rts_delay(modbus_t *ctx, int us); -int modbus_rtu_get_rts_delay(modbus_t *ctx); +int modbus_rtu_set_rts_delay(modbus_t* ctx, int us); +int modbus_rtu_get_rts_delay(modbus_t* ctx); #ifdef __cplusplus } diff --git a/net/protocol/modbus/modbus-tcp-private.h b/net/protocol/modbus/modbus-tcp-private.h index a4c77941..51665bcd 100644 --- a/net/protocol/modbus/modbus-tcp-private.h +++ b/net/protocol/modbus/modbus-tcp-private.h @@ -25,9 +25,9 @@ typedef struct _modbus_tcp_pi { /* TCP port */ int port; /* Node */ - char *node; + char* node; /* Service */ - char *service; + char* service; } modbus_tcp_pi_t; #endif /* MODBUS_TCP_PRIVATE_H */ diff --git a/net/protocol/modbus/modbus-tcp.c b/net/protocol/modbus/modbus-tcp.c index 2b18d126..0e97440b 100644 --- a/net/protocol/modbus/modbus-tcp.c +++ b/net/protocol/modbus/modbus-tcp.c @@ -4,8 +4,6 @@ * SPDX-License-Identifier: LGPL-2.1-or-later */ - - // clang-format on #include "modbus-private.h" @@ -20,9 +18,7 @@ static int _modbus_tcp_init_win32(void) WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { - fprintf(stderr, - "WSAStartup() returned error code %d\n", - (unsigned int) GetLastError()); + fprintf(stderr, "WSAStartup() returned error code %d\n", (unsigned int)GetLastError()); errno = EIO; return -1; } @@ -30,7 +26,7 @@ static int _modbus_tcp_init_win32(void) } #endif -static int _modbus_set_slave(modbus_t *ctx, int slave) +static int _modbus_set_slave(modbus_t* ctx, int slave) { int max_slave = (ctx->quirks & MODBUS_QUIRK_MAX_SLAVE) ? 255 : 247; @@ -50,10 +46,9 @@ static int _modbus_set_slave(modbus_t *ctx, int slave) } /* Builds a TCP request header */ -static int _modbus_tcp_build_request_basis( - modbus_t *ctx, int function, int addr, int nb, uint8_t *req) +static int _modbus_tcp_build_request_basis(modbus_t* ctx, int function, int addr, int nb, uint8_t* req) { - modbus_tcp_t *ctx_tcp = ctx->backend_data; + modbus_tcp_t* ctx_tcp = ctx->backend_data; /* Increase transaction ID */ if (ctx_tcp->t_id < UINT16_MAX) @@ -81,7 +76,7 @@ static int _modbus_tcp_build_request_basis( } /* Builds a TCP response header */ -static int _modbus_tcp_build_response_basis(sft_t *sft, uint8_t *rsp) +static int _modbus_tcp_build_response_basis(sft_t* sft, uint8_t* rsp) { /* Extract from MODBUS Messaging on TCP/IP Implementation Guide V1.0b (page 23/46): @@ -103,12 +98,12 @@ static int _modbus_tcp_build_response_basis(sft_t *sft, uint8_t *rsp) return _MODBUS_TCP_PRESET_RSP_LENGTH; } -static int _modbus_tcp_prepare_response_tid(const uint8_t *req, int *req_length) +static int _modbus_tcp_prepare_response_tid(const uint8_t* req, int* req_length) { return (req[0] << 8) + req[1]; } -static int _modbus_tcp_send_msg_pre(uint8_t *req, int req_length) +static int _modbus_tcp_send_msg_pre(uint8_t* req, int req_length) { /* Subtract the header length to the message length */ int mbap_length = req_length - 6; @@ -119,43 +114,37 @@ static int _modbus_tcp_send_msg_pre(uint8_t *req, int req_length) return req_length; } -static ssize_t _modbus_tcp_send(modbus_t *ctx, const uint8_t *req, int req_length) +static ssize_t _modbus_tcp_send(modbus_t* ctx, const uint8_t* req, int req_length) { /* MSG_NOSIGNAL Requests not to send SIGPIPE on errors on stream oriented sockets when the other end breaks the connection. The EPIPE error is still returned. */ - return send(ctx->s, (const char *) req, req_length, MSG_NOSIGNAL); + return send(ctx->s, (const char*)req, req_length, MSG_NOSIGNAL); } -static int _modbus_tcp_receive(modbus_t *ctx, uint8_t *req) +static int _modbus_tcp_receive(modbus_t* ctx, uint8_t* req) { return _modbus_receive_msg(ctx, req, MSG_INDICATION); } -static ssize_t _modbus_tcp_recv(modbus_t *ctx, uint8_t *rsp, int rsp_length) +static ssize_t _modbus_tcp_recv(modbus_t* ctx, uint8_t* rsp, int rsp_length) { - return recv(ctx->s, (char *) rsp, rsp_length, 0); + return recv(ctx->s, (char*)rsp, rsp_length, 0); } -static int _modbus_tcp_check_integrity(modbus_t *ctx, uint8_t *msg, const int msg_length) +static int _modbus_tcp_check_integrity(modbus_t* ctx, uint8_t* msg, const int msg_length) { return msg_length; } -static int _modbus_tcp_pre_check_confirmation(modbus_t *ctx, - const uint8_t *req, - const uint8_t *rsp, - int rsp_length) +static int _modbus_tcp_pre_check_confirmation(modbus_t* ctx, const uint8_t* req, const uint8_t* rsp, int rsp_length) { unsigned int protocol_id; /* Check transaction ID */ if (req[0] != rsp[0] || req[1] != rsp[1]) { if (ctx->debug) { - fprintf(stderr, - "Invalid transaction ID received 0x%X (not 0x%X)\n", - (rsp[0] << 8) + rsp[1], - (req[0] << 8) + req[1]); + fprintf(stderr, "Invalid transaction ID received 0x%X (not 0x%X)\n", (rsp[0] << 8) + rsp[1], (req[0] << 8) + req[1]); } errno = EMBBADDATA; return -1; @@ -182,7 +171,7 @@ static int _modbus_tcp_set_ipv4_options(int s) /* Set the TCP no delay flag */ /* SOL_TCP = IPPROTO_TCP */ option = 1; - rc = setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const void *) &option, sizeof(int)); + rc = setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const void*)&option, sizeof(int)); if (rc == -1) { return -1; } @@ -210,7 +199,7 @@ static int _modbus_tcp_set_ipv4_options(int s) **/ /* Set the IP low delay option */ option = IPTOS_LOWDELAY; - rc = setsockopt(s, IPPROTO_IP, IP_TOS, (const void *) &option, sizeof(int)); + rc = setsockopt(s, IPPROTO_IP, IP_TOS, (const void*)&option, sizeof(int)); if (rc == -1) { return -1; } @@ -219,10 +208,7 @@ static int _modbus_tcp_set_ipv4_options(int s) return 0; } -static int _connect(int sockfd, - const struct sockaddr *addr, - socklen_t addrlen, - const struct timeval *ro_tv) +static int _connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen, const struct timeval* ro_tv) { int rc = connect(sockfd, addr, addrlen); @@ -251,7 +237,7 @@ static int _connect(int sockfd, } /* The connection is established if SO_ERROR and optval are set to 0 */ - rc = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *) &optval, &optlen); + rc = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void*)&optval, &optlen); if (rc == 0 && optval == 0) { return 0; } else { @@ -263,12 +249,12 @@ static int _connect(int sockfd, } /* Establishes a modbus TCP connection with a Modbus server. */ -static int _modbus_tcp_connect(modbus_t *ctx) +static int _modbus_tcp_connect(modbus_t* ctx) { int rc; /* Specialized version of sockaddr for Internet socket address (same size) */ struct sockaddr_in addr; - modbus_tcp_t *ctx_tcp = ctx->backend_data; + modbus_tcp_t* ctx_tcp = ctx->backend_data; int flags = SOCK_STREAM; #ifdef OS_WIN32 @@ -313,8 +299,7 @@ static int _modbus_tcp_connect(modbus_t *ctx) return -1; } - rc = - _connect(ctx->s, (struct sockaddr *) &addr, sizeof(addr), &ctx->response_timeout); + rc = _connect(ctx->s, (struct sockaddr*)&addr, sizeof(addr), &ctx->response_timeout); if (rc == -1) { close(ctx->s); ctx->s = -1; @@ -325,13 +310,13 @@ static int _modbus_tcp_connect(modbus_t *ctx) } /* Establishes a modbus TCP PI connection with a Modbus server. */ -static int _modbus_tcp_pi_connect(modbus_t *ctx) +static int _modbus_tcp_pi_connect(modbus_t* ctx) { int rc; - struct addrinfo *ai_list; - struct addrinfo *ai_ptr; + struct addrinfo* ai_list; + struct addrinfo* ai_ptr; struct addrinfo ai_hints; - modbus_tcp_pi_t *ctx_tcp_pi = ctx->backend_data; + modbus_tcp_pi_t* ctx_tcp_pi = ctx->backend_data; #ifdef OS_WIN32 if (_modbus_tcp_init_win32() == -1) { @@ -398,13 +383,13 @@ static int _modbus_tcp_pi_connect(modbus_t *ctx) return 0; } -static unsigned int _modbus_tcp_is_connected(modbus_t *ctx) +static unsigned int _modbus_tcp_is_connected(modbus_t* ctx) { return ctx->s >= 0; } /* Closes the network connection and socket in TCP mode */ -static void _modbus_tcp_close(modbus_t *ctx) +static void _modbus_tcp_close(modbus_t* ctx) { if (ctx->s >= 0) { shutdown(ctx->s, SHUT_RDWR); @@ -413,7 +398,7 @@ static void _modbus_tcp_close(modbus_t *ctx) } } -static int _modbus_tcp_flush(modbus_t *ctx) +static int _modbus_tcp_flush(modbus_t* ctx) { int rc; int rc_sum = 0; @@ -451,13 +436,13 @@ static int _modbus_tcp_flush(modbus_t *ctx) } /* Listens for any request from one or many modbus masters in TCP */ -int modbus_tcp_listen(modbus_t *ctx, int nb_connection) +int modbus_tcp_listen(modbus_t* ctx, int nb_connection) { int new_s; int enable; int flags; struct sockaddr_in addr; - modbus_tcp_t *ctx_tcp; + modbus_tcp_t* ctx_tcp; int rc; if (ctx == NULL) { @@ -485,8 +470,7 @@ int modbus_tcp_listen(modbus_t *ctx, int nb_connection) } enable = 1; - if (setsockopt(new_s, SOL_SOCKET, SO_REUSEADDR, (char *) &enable, sizeof(enable)) == - -1) { + if (setsockopt(new_s, SOL_SOCKET, SO_REUSEADDR, (char*)&enable, sizeof(enable)) == -1) { close(new_s); return -1; } @@ -510,7 +494,7 @@ int modbus_tcp_listen(modbus_t *ctx, int nb_connection) } } - if (bind(new_s, (struct sockaddr *) &addr, sizeof(addr)) == -1) { + if (bind(new_s, (struct sockaddr*)&addr, sizeof(addr)) == -1) { close(new_s); return -1; } @@ -523,16 +507,16 @@ int modbus_tcp_listen(modbus_t *ctx, int nb_connection) return new_s; } -int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection) +int modbus_tcp_pi_listen(modbus_t* ctx, int nb_connection) { int rc; - struct addrinfo *ai_list; - struct addrinfo *ai_ptr; + struct addrinfo* ai_list; + struct addrinfo* ai_ptr; struct addrinfo ai_hints; - const char *node; - const char *service; + const char* node; + const char* service; int new_s; - modbus_tcp_pi_t *ctx_tcp_pi; + modbus_tcp_pi_t* ctx_tcp_pi; if (ctx == NULL) { errno = EINVAL; @@ -595,8 +579,7 @@ int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection) continue; } else { int enable = 1; - rc = - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void *) &enable, sizeof(enable)); + rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*)&enable, sizeof(enable)); if (rc != 0) { close(s); if (ctx->debug) { @@ -636,7 +619,7 @@ int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection) return new_s; } -int modbus_tcp_accept(modbus_t *ctx, int *s) +int modbus_tcp_accept(modbus_t* ctx, int* s) { struct sockaddr_in addr; socklen_t addrlen; @@ -649,9 +632,9 @@ int modbus_tcp_accept(modbus_t *ctx, int *s) addrlen = sizeof(addr); #ifdef HAVE_ACCEPT4 /* Inherit socket flags and use accept4 call */ - ctx->s = accept4(*s, (struct sockaddr *) &addr, &addrlen, SOCK_CLOEXEC); + ctx->s = accept4(*s, (struct sockaddr*)&addr, &addrlen, SOCK_CLOEXEC); #else - ctx->s = accept(*s, (struct sockaddr *) &addr, &addrlen); + ctx->s = accept(*s, (struct sockaddr*)&addr, &addrlen); #endif if (ctx->s < 0) { @@ -670,7 +653,7 @@ int modbus_tcp_accept(modbus_t *ctx, int *s) return ctx->s; } -int modbus_tcp_pi_accept(modbus_t *ctx, int *s) +int modbus_tcp_pi_accept(modbus_t* ctx, int* s) { struct sockaddr_in6 addr; socklen_t addrlen; @@ -683,9 +666,9 @@ int modbus_tcp_pi_accept(modbus_t *ctx, int *s) addrlen = sizeof(addr); #ifdef HAVE_ACCEPT4 /* Inherit socket flags and use accept4 call */ - ctx->s = accept4(*s, (struct sockaddr *) &addr, &addrlen, SOCK_CLOEXEC); + ctx->s = accept4(*s, (struct sockaddr*)&addr, &addrlen, SOCK_CLOEXEC); #else - ctx->s = accept(*s, (struct sockaddr *) &addr, &addrlen); + ctx->s = accept(*s, (struct sockaddr*)&addr, &addrlen); #endif if (ctx->s < 0) { @@ -704,8 +687,7 @@ int modbus_tcp_pi_accept(modbus_t *ctx, int *s) return ctx->s; } -static int -_modbus_tcp_select(modbus_t *ctx, fd_set *rset, struct timeval *tv, int length_to_read) +static int _modbus_tcp_select(modbus_t* ctx, fd_set* rset, struct timeval* tv, int length_to_read) { int s_rc; while ((s_rc = select(ctx->s + 1, rset, NULL, NULL, tv)) == -1) { @@ -729,7 +711,7 @@ _modbus_tcp_select(modbus_t *ctx, fd_set *rset, struct timeval *tv, int length_t return s_rc; } -static void _modbus_tcp_free(modbus_t *ctx) +static void _modbus_tcp_free(modbus_t* ctx) { if (ctx->backend_data) { free(ctx->backend_data); @@ -737,10 +719,10 @@ static void _modbus_tcp_free(modbus_t *ctx) free(ctx); } -static void _modbus_tcp_pi_free(modbus_t *ctx) +static void _modbus_tcp_pi_free(modbus_t* ctx) { if (ctx->backend_data) { - modbus_tcp_pi_t *ctx_tcp_pi = ctx->backend_data; + modbus_tcp_pi_t* ctx_tcp_pi = ctx->backend_data; free(ctx_tcp_pi->node); free(ctx_tcp_pi->service); free(ctx->backend_data); @@ -798,10 +780,10 @@ const modbus_backend_t _modbus_tcp_pi_backend = { // clang-format on -modbus_t *modbus_new_tcp(const char *ip, int port) +modbus_t* modbus_new_tcp(const char* ip, int port) { - modbus_t *ctx; - modbus_tcp_t *ctx_tcp; + modbus_t* ctx; + modbus_tcp_t* ctx_tcp; size_t dest_size; size_t ret_size; @@ -818,7 +800,7 @@ modbus_t *modbus_new_tcp(const char *ip, int port) } #endif - ctx = (modbus_t *) malloc(sizeof(modbus_t)); + ctx = (modbus_t*)malloc(sizeof(modbus_t)); if (ctx == NULL) { return NULL; } @@ -829,13 +811,13 @@ modbus_t *modbus_new_tcp(const char *ip, int port) ctx->backend = &_modbus_tcp_backend; - ctx->backend_data = (modbus_tcp_t *) malloc(sizeof(modbus_tcp_t)); + ctx->backend_data = (modbus_tcp_t*)malloc(sizeof(modbus_tcp_t)); if (ctx->backend_data == NULL) { modbus_free(ctx); errno = ENOMEM; return NULL; } - ctx_tcp = (modbus_tcp_t *) ctx->backend_data; + ctx_tcp = (modbus_tcp_t*)ctx->backend_data; if (ip != NULL) { dest_size = sizeof(char) * 16; @@ -862,12 +844,12 @@ modbus_t *modbus_new_tcp(const char *ip, int port) return ctx; } -modbus_t *modbus_new_tcp_pi(const char *node, const char *service) +modbus_t* modbus_new_tcp_pi(const char* node, const char* service) { - modbus_t *ctx; - modbus_tcp_pi_t *ctx_tcp_pi; + modbus_t* ctx; + modbus_tcp_pi_t* ctx_tcp_pi; - ctx = (modbus_t *) malloc(sizeof(modbus_t)); + ctx = (modbus_t*)malloc(sizeof(modbus_t)); if (ctx == NULL) { return NULL; } @@ -878,13 +860,13 @@ modbus_t *modbus_new_tcp_pi(const char *node, const char *service) ctx->backend = &_modbus_tcp_pi_backend; - ctx->backend_data = (modbus_tcp_pi_t *) malloc(sizeof(modbus_tcp_pi_t)); + ctx->backend_data = (modbus_tcp_pi_t*)malloc(sizeof(modbus_tcp_pi_t)); if (ctx->backend_data == NULL) { modbus_free(ctx); errno = ENOMEM; return NULL; } - ctx_tcp_pi = (modbus_tcp_pi_t *) ctx->backend_data; + ctx_tcp_pi = (modbus_tcp_pi_t*)ctx->backend_data; ctx_tcp_pi->node = NULL; ctx_tcp_pi->service = NULL; diff --git a/net/protocol/modbus/modbus-tcp.h b/net/protocol/modbus/modbus-tcp.h index 3b63a77a..16b63f99 100644 --- a/net/protocol/modbus/modbus-tcp.h +++ b/net/protocol/modbus/modbus-tcp.h @@ -21,13 +21,13 @@ extern "C" { */ #define MODBUS_TCP_MAX_ADU_LENGTH 260 -modbus_t *modbus_new_tcp(const char *ip_address, int port); -int modbus_tcp_listen(modbus_t *ctx, int nb_connection); -int modbus_tcp_accept(modbus_t *ctx, int *s); +modbus_t* modbus_new_tcp(const char* ip_address, int port); +int modbus_tcp_listen(modbus_t* ctx, int nb_connection); +int modbus_tcp_accept(modbus_t* ctx, int* s); -modbus_t *modbus_new_tcp_pi(const char *node, const char *service); -int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection); -int modbus_tcp_pi_accept(modbus_t *ctx, int *s); +modbus_t* modbus_new_tcp_pi(const char* node, const char* service); +int modbus_tcp_pi_listen(modbus_t* ctx, int nb_connection); +int modbus_tcp_pi_accept(modbus_t* ctx, int* s); #ifdef __cplusplus } diff --git a/net/protocol/modbus/modbus.c b/net/protocol/modbus/modbus.c index dc473361..f25f6c79 100644 --- a/net/protocol/modbus/modbus.c +++ b/net/protocol/modbus/modbus.c @@ -21,13 +21,9 @@ #define MAX_MESSAGE_LENGTH 260 /* 3 steps are used to parse the query */ -typedef enum { - _STEP_FUNCTION, - _STEP_META, - _STEP_DATA -} _step_t; +typedef enum { _STEP_FUNCTION, _STEP_META, _STEP_DATA } _step_t; -const char *modbus_strerror(int errnum) +const char* modbus_strerror(int errnum) { switch (errnum) { case EMBXILFUN: @@ -65,7 +61,7 @@ const char *modbus_strerror(int errnum) } } -void _error_print(modbus_t *ctx, const char *context) +void _error_print(modbus_t* ctx, const char* context) { if (ctx->debug) { fprintf(stderr, "ERROR %s", modbus_strerror(errno)); @@ -77,7 +73,7 @@ void _error_print(modbus_t *ctx, const char *context) } } -static void _sleep_response_timeout(modbus_t *ctx) +static void _sleep_response_timeout(modbus_t* ctx) { /* Response timeout is always positive */ #ifdef _WIN32 @@ -87,14 +83,14 @@ static void _sleep_response_timeout(modbus_t *ctx) /* usleep source code */ struct timespec request, remaining; request.tv_sec = ctx->response_timeout.tv_sec; - request.tv_nsec = ((long int) ctx->response_timeout.tv_usec) * 1000; + request.tv_nsec = ((long int)ctx->response_timeout.tv_usec) * 1000; while (nanosleep(&request, &remaining) == -1 && errno == EINTR) { request = remaining; } #endif } -int modbus_flush(modbus_t *ctx) +int modbus_flush(modbus_t* ctx) { int rc; @@ -112,7 +108,7 @@ int modbus_flush(modbus_t *ctx) } /* Computes the length of the expected response */ -static unsigned int compute_response_length_from_request(modbus_t *ctx, uint8_t *req) +static unsigned int compute_response_length_from_request(modbus_t* ctx, uint8_t* req) { int length; const int offset = ctx->backend->header_length; @@ -148,7 +144,7 @@ static unsigned int compute_response_length_from_request(modbus_t *ctx, uint8_t } /* Sends a request/response */ -static int send_msg(modbus_t *ctx, uint8_t *msg, int msg_length) +static int send_msg(modbus_t* ctx, uint8_t* msg, int msg_length) { int rc; int i; @@ -170,10 +166,8 @@ static int send_msg(modbus_t *ctx, uint8_t *msg, int msg_length) if (ctx->error_recovery & MODBUS_ERROR_RECOVERY_LINK) { #ifdef _WIN32 const int wsa_err = WSAGetLastError(); - if (wsa_err == WSAENETRESET || wsa_err == WSAENOTCONN || - wsa_err == WSAENOTSOCK || wsa_err == WSAESHUTDOWN || - wsa_err == WSAEHOSTUNREACH || wsa_err == WSAECONNABORTED || - wsa_err == WSAECONNRESET || wsa_err == WSAETIMEDOUT) { + if (wsa_err == WSAENETRESET || wsa_err == WSAENOTCONN || wsa_err == WSAENOTSOCK || wsa_err == WSAESHUTDOWN + || wsa_err == WSAEHOSTUNREACH || wsa_err == WSAECONNABORTED || wsa_err == WSAECONNRESET || wsa_err == WSAETIMEDOUT) { modbus_close(ctx); _sleep_response_timeout(ctx); modbus_connect(ctx); @@ -206,7 +200,7 @@ static int send_msg(modbus_t *ctx, uint8_t *msg, int msg_length) return rc; } -int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length) +int modbus_send_raw_request(modbus_t* ctx, const uint8_t* raw_req, int raw_req_length) { sft_t sft; uint8_t req[MAX_MESSAGE_LENGTH]; @@ -255,8 +249,7 @@ static uint8_t compute_meta_length_after_function(int function, msg_type_t msg_t if (msg_type == MSG_INDICATION) { if (function <= MODBUS_FC_WRITE_SINGLE_REGISTER) { length = 4; - } else if (function == MODBUS_FC_WRITE_MULTIPLE_COILS || - function == MODBUS_FC_WRITE_MULTIPLE_REGISTERS) { + } else if (function == MODBUS_FC_WRITE_MULTIPLE_COILS || function == MODBUS_FC_WRITE_MULTIPLE_REGISTERS) { length = 5; } else if (function == MODBUS_FC_MASK_WRITE_REGISTER) { length = 6; @@ -287,8 +280,7 @@ static uint8_t compute_meta_length_after_function(int function, msg_type_t msg_t } /* Computes the length to read after the meta information (address, count, etc) */ -static int -compute_data_length_after_meta(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) +static int compute_data_length_after_meta(modbus_t* ctx, uint8_t* msg, msg_type_t msg_type) { int function = msg[ctx->backend->header_length]; int length; @@ -307,9 +299,7 @@ compute_data_length_after_meta(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) } } else { /* MSG_CONFIRMATION */ - if (function <= MODBUS_FC_READ_INPUT_REGISTERS || - function == MODBUS_FC_REPORT_SLAVE_ID || - function == MODBUS_FC_WRITE_AND_READ_REGISTERS) { + if (function <= MODBUS_FC_READ_INPUT_REGISTERS || function == MODBUS_FC_REPORT_SLAVE_ID || function == MODBUS_FC_WRITE_AND_READ_REGISTERS) { length = msg[ctx->backend->header_length + 1]; } else { length = 0; @@ -333,12 +323,12 @@ compute_data_length_after_meta(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) - read() or recv() error codes */ -int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) +int _modbus_receive_msg(modbus_t* ctx, uint8_t* msg, msg_type_t msg_type) { int rc; fd_set rset; struct timeval tv; - struct timeval *p_tv; + struct timeval* p_tv; unsigned int length_to_read; int msg_length = 0; _step_t step; @@ -429,19 +419,15 @@ int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) _error_print(ctx, "read"); #ifdef _WIN32 wsa_err = WSAGetLastError(); - if ((ctx->error_recovery & MODBUS_ERROR_RECOVERY_LINK) && - (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_TCP) && - (wsa_err == WSAENOTCONN || wsa_err == WSAENETRESET || - wsa_err == WSAENOTSOCK || wsa_err == WSAESHUTDOWN || - wsa_err == WSAECONNABORTED || wsa_err == WSAETIMEDOUT || - wsa_err == WSAECONNRESET)) { + if ((ctx->error_recovery & MODBUS_ERROR_RECOVERY_LINK) && (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_TCP) + && (wsa_err == WSAENOTCONN || wsa_err == WSAENETRESET || wsa_err == WSAENOTSOCK || wsa_err == WSAESHUTDOWN + || wsa_err == WSAECONNABORTED || wsa_err == WSAETIMEDOUT || wsa_err == WSAECONNRESET)) { modbus_close(ctx); modbus_connect(ctx); } #else - if ((ctx->error_recovery & MODBUS_ERROR_RECOVERY_LINK) && - (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_TCP) && - (errno == ECONNRESET || errno == ECONNREFUSED || errno == EBADF)) { + if ((ctx->error_recovery & MODBUS_ERROR_RECOVERY_LINK) && (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_TCP) + && (errno == ECONNRESET || errno == ECONNREFUSED || errno == EBADF)) { int saved_errno = errno; modbus_close(ctx); modbus_connect(ctx); @@ -468,8 +454,7 @@ int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) switch (step) { case _STEP_FUNCTION: /* Function code position */ - length_to_read = compute_meta_length_after_function( - msg[ctx->backend->header_length], msg_type); + length_to_read = compute_meta_length_after_function(msg[ctx->backend->header_length], msg_type); if (length_to_read != 0) { step = _STEP_META; break; @@ -488,8 +473,7 @@ int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) } } - if (length_to_read > 0 && - (ctx->byte_timeout.tv_sec > 0 || ctx->byte_timeout.tv_usec > 0)) { + if (length_to_read > 0 && (ctx->byte_timeout.tv_sec > 0 || ctx->byte_timeout.tv_usec > 0)) { /* If there is no character in the buffer, the allowed timeout interval between two consecutive bytes is defined by byte_timeout */ @@ -508,7 +492,7 @@ int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) } /* Receive the request from a modbus master */ -int modbus_receive(modbus_t *ctx, uint8_t *req) +int modbus_receive(modbus_t* ctx, uint8_t* req) { if (ctx == NULL) { errno = EINVAL; @@ -526,7 +510,7 @@ int modbus_receive(modbus_t *ctx, uint8_t *req) The function doesn't check the confirmation is the expected response to the initial request. */ -int modbus_receive_confirmation(modbus_t *ctx, uint8_t *rsp) +int modbus_receive_confirmation(modbus_t* ctx, uint8_t* rsp) { if (ctx == NULL) { errno = EINVAL; @@ -536,7 +520,7 @@ int modbus_receive_confirmation(modbus_t *ctx, uint8_t *rsp) return _modbus_receive_msg(ctx, rsp, MSG_CONFIRMATION); } -static int check_confirmation(modbus_t *ctx, uint8_t *req, uint8_t *rsp, int rsp_length) +static int check_confirmation(modbus_t* ctx, uint8_t* req, uint8_t* rsp, int rsp_length) { int rc; int rsp_length_computed; @@ -558,8 +542,7 @@ static int check_confirmation(modbus_t *ctx, uint8_t *req, uint8_t *rsp, int rsp /* Exception code */ if (function >= 0x80) { - if (rsp_length == (int) (offset + 2 + ctx->backend->checksum_length) && - req[offset] == (rsp[offset] - 0x80)) { + if (rsp_length == (int)(offset + 2 + ctx->backend->checksum_length) && req[offset] == (rsp[offset] - 0x80)) { /* Valid exception code received */ int exception_code = rsp[offset + 1]; @@ -578,9 +561,7 @@ static int check_confirmation(modbus_t *ctx, uint8_t *req, uint8_t *rsp, int rsp } /* Check length */ - if ((rsp_length == rsp_length_computed || - rsp_length_computed == MSG_LENGTH_UNDEFINED) && - function < 0x80) { + if ((rsp_length == rsp_length_computed || rsp_length_computed == MSG_LENGTH_UNDEFINED) && function < 0x80) { int req_nb_value; int rsp_nb_value; int resp_addr_ok = TRUE; @@ -589,11 +570,7 @@ static int check_confirmation(modbus_t *ctx, uint8_t *req, uint8_t *rsp, int rsp /* Check function code */ if (function != req[offset]) { if (ctx->debug) { - fprintf( - stderr, - "Received function not corresponding to the request (0x%X != 0x%X)\n", - function, - req[offset]); + fprintf(stderr, "Received function not corresponding to the request (0x%X != 0x%X)\n", function, req[offset]); } if (ctx->error_recovery & MODBUS_ERROR_RECOVERY_PROTOCOL) { _sleep_response_timeout(ctx); @@ -624,8 +601,7 @@ static int check_confirmation(modbus_t *ctx, uint8_t *req, uint8_t *rsp, int rsp case MODBUS_FC_WRITE_MULTIPLE_COILS: case MODBUS_FC_WRITE_MULTIPLE_REGISTERS: /* address in request and response must be equal */ - if ((req[offset + 1] != rsp[offset + 1]) || - (req[offset + 2] != rsp[offset + 2])) { + if ((req[offset + 1] != rsp[offset + 1]) || (req[offset + 2] != rsp[offset + 2])) { resp_addr_ok = FALSE; } /* N Write functions */ @@ -639,13 +615,11 @@ static int check_confirmation(modbus_t *ctx, uint8_t *req, uint8_t *rsp, int rsp case MODBUS_FC_WRITE_SINGLE_COIL: case MODBUS_FC_WRITE_SINGLE_REGISTER: /* address in request and response must be equal */ - if ((req[offset + 1] != rsp[offset + 1]) || - (req[offset + 2] != rsp[offset + 2])) { + if ((req[offset + 1] != rsp[offset + 1]) || (req[offset + 2] != rsp[offset + 2])) { resp_addr_ok = FALSE; } /* data in request and response must be equal */ - if ((req[offset + 3] != rsp[offset + 3]) || - (req[offset + 4] != rsp[offset + 4])) { + if ((req[offset + 3] != rsp[offset + 3]) || (req[offset + 4] != rsp[offset + 4])) { resp_data_ok = FALSE; } /* 1 Write functions & others */ @@ -657,15 +631,11 @@ static int check_confirmation(modbus_t *ctx, uint8_t *req, uint8_t *rsp, int rsp break; } - if ((req_nb_value == rsp_nb_value) && (resp_addr_ok == TRUE) && - (resp_data_ok == TRUE)) { + if ((req_nb_value == rsp_nb_value) && (resp_addr_ok == TRUE) && (resp_data_ok == TRUE)) { rc = rsp_nb_value; } else { if (ctx->debug) { - fprintf(stderr, - "Received data not corresponding to the request (%d != %d)\n", - rsp_nb_value, - req_nb_value); + fprintf(stderr, "Received data not corresponding to the request (%d != %d)\n", rsp_nb_value, req_nb_value); } if (ctx->error_recovery & MODBUS_ERROR_RECOVERY_PROTOCOL) { @@ -678,11 +648,7 @@ static int check_confirmation(modbus_t *ctx, uint8_t *req, uint8_t *rsp, int rsp } } else { if (ctx->debug) { - fprintf( - stderr, - "Message length not corresponding to the computed length (%d != %d)\n", - rsp_length, - rsp_length_computed); + fprintf(stderr, "Message length not corresponding to the computed length (%d != %d)\n", rsp_length, rsp_length_computed); } if (ctx->error_recovery & MODBUS_ERROR_RECOVERY_PROTOCOL) { _sleep_response_timeout(ctx); @@ -695,8 +661,7 @@ static int check_confirmation(modbus_t *ctx, uint8_t *req, uint8_t *rsp, int rsp return rc; } -static int -response_io_status(uint8_t *tab_io_status, int address, int nb, uint8_t *rsp, int offset) +static int response_io_status(uint8_t* tab_io_status, int address, int nb, uint8_t* rsp, int offset) { int shift = 0; /* Instead of byte (not allowed in Win32) */ @@ -721,13 +686,7 @@ response_io_status(uint8_t *tab_io_status, int address, int nb, uint8_t *rsp, in } /* Build the exception response */ -static int response_exception(modbus_t *ctx, - sft_t *sft, - int exception_code, - uint8_t *rsp, - unsigned int to_flush, - const char *template, - ...) +static int response_exception(modbus_t* ctx, sft_t* sft, int exception_code, uint8_t* rsp, unsigned int to_flush, const char* template, ...) { int rsp_length; @@ -760,10 +719,7 @@ static int response_exception(modbus_t *ctx, If an error occurs, this function construct the response accordingly. */ -int modbus_reply(modbus_t *ctx, - const uint8_t *req, - int req_length, - modbus_mapping_t *mb_mapping) +int modbus_reply(modbus_t* ctx, const uint8_t* req, int req_length, modbus_mapping_t* mb_mapping) { unsigned int offset; int slave; @@ -794,73 +750,47 @@ int modbus_reply(modbus_t *ctx, unsigned int is_input = (function == MODBUS_FC_READ_DISCRETE_INPUTS); int start_bits = is_input ? mb_mapping->start_input_bits : mb_mapping->start_bits; int nb_bits = is_input ? mb_mapping->nb_input_bits : mb_mapping->nb_bits; - uint8_t *tab_bits = is_input ? mb_mapping->tab_input_bits : mb_mapping->tab_bits; - const char *const name = is_input ? "read_input_bits" : "read_bits"; + uint8_t* tab_bits = is_input ? mb_mapping->tab_input_bits : mb_mapping->tab_bits; + const char* const name = is_input ? "read_input_bits" : "read_bits"; int nb = (req[offset + 3] << 8) + req[offset + 4]; /* The mapping can be shifted to reduce memory consumption and it doesn't always start at address zero. */ int mapping_address = address - start_bits; if (nb < 1 || MODBUS_MAX_READ_BITS < nb) { - rsp_length = response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, - rsp, - TRUE, - "Illegal nb of values %d in %s (max %d)\n", - nb, - name, - MODBUS_MAX_READ_BITS); + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp, TRUE, "Illegal nb of values %d in %s (max %d)\n", nb, name, + MODBUS_MAX_READ_BITS); } else if (mapping_address < 0 || (mapping_address + nb) > nb_bits) { - rsp_length = response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, - rsp, - FALSE, - "Illegal data address 0x%0X in %s\n", - mapping_address < 0 ? address : address + nb, - name); + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE, "Illegal data address 0x%0X in %s\n", + mapping_address < 0 ? address : address + nb, name); } else { rsp_length = ctx->backend->build_response_basis(&sft, rsp); rsp[rsp_length++] = (nb / 8) + ((nb % 8) ? 1 : 0); - rsp_length = - response_io_status(tab_bits, mapping_address, nb, rsp, rsp_length); + rsp_length = response_io_status(tab_bits, mapping_address, nb, rsp, rsp_length); } } break; case MODBUS_FC_READ_HOLDING_REGISTERS: case MODBUS_FC_READ_INPUT_REGISTERS: { unsigned int is_input = (function == MODBUS_FC_READ_INPUT_REGISTERS); - int start_registers = - is_input ? mb_mapping->start_input_registers : mb_mapping->start_registers; - int nb_registers = - is_input ? mb_mapping->nb_input_registers : mb_mapping->nb_registers; - uint16_t *tab_registers = - is_input ? mb_mapping->tab_input_registers : mb_mapping->tab_registers; - const char *const name = is_input ? "read_input_registers" : "read_registers"; + int start_registers = is_input ? mb_mapping->start_input_registers : mb_mapping->start_registers; + int nb_registers = is_input ? mb_mapping->nb_input_registers : mb_mapping->nb_registers; + uint16_t* tab_registers = is_input ? mb_mapping->tab_input_registers : mb_mapping->tab_registers; + const char* const name = is_input ? "read_input_registers" : "read_registers"; int nb = (req[offset + 3] << 8) + req[offset + 4]; /* The mapping can be shifted to reduce memory consumption and it doesn't always start at address zero. */ int mapping_address = address - start_registers; if (nb < 1 || MODBUS_MAX_READ_REGISTERS < nb) { - rsp_length = response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, - rsp, - TRUE, - "Illegal nb of values %d in %s (max %d)\n", - nb, - name, - MODBUS_MAX_READ_REGISTERS); + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp, TRUE, "Illegal nb of values %d in %s (max %d)\n", nb, name, + MODBUS_MAX_READ_REGISTERS); } else if (mapping_address < 0 || (mapping_address + nb) > nb_registers) { - rsp_length = response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, - rsp, - FALSE, - "Illegal data address 0x%0X in %s\n", - mapping_address < 0 ? address : address + nb, - name); + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE, "Illegal data address 0x%0X in %s\n", + mapping_address < 0 ? address : address + nb, name); } else { int i; @@ -876,13 +806,8 @@ int modbus_reply(modbus_t *ctx, int mapping_address = address - mb_mapping->start_bits; if (mapping_address < 0 || mapping_address >= mb_mapping->nb_bits) { - rsp_length = response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, - rsp, - FALSE, - "Illegal data address 0x%0X in write_bit\n", - address); + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE, "Illegal data address 0x%0X in write_bit\n", address); } else { int data = (req[offset + 3] << 8) + req[offset + 4]; @@ -892,14 +817,8 @@ int modbus_reply(modbus_t *ctx, rsp_length = req_length; } else { rsp_length = response_exception( - ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, - rsp, - FALSE, - "Illegal data value 0x%0X in write_bit request at address %0X\n", - data, - address); + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp, FALSE, "Illegal data value 0x%0X in write_bit request at address %0X\n", + data, address); } } } break; @@ -907,14 +826,8 @@ int modbus_reply(modbus_t *ctx, int mapping_address = address - mb_mapping->start_registers; if (mapping_address < 0 || mapping_address >= mb_mapping->nb_registers) { - rsp_length = - response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, - rsp, - FALSE, - "Illegal data address 0x%0X in write_register\n", - address); + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE, "Illegal data address 0x%0X in write_register\n", address); } else { int data = (req[offset + 3] << 8) + req[offset + 4]; @@ -932,27 +845,16 @@ int modbus_reply(modbus_t *ctx, /* May be the indication has been truncated on reading because of * invalid address (eg. nb is 0 but the request contains values to * write) so it's necessary to flush. */ - rsp_length = - response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, - rsp, - TRUE, - "Illegal number of values %d in write_bits (max %d)\n", - nb, - MODBUS_MAX_WRITE_BITS); + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp, TRUE, "Illegal number of values %d in write_bits (max %d)\n", nb, + MODBUS_MAX_WRITE_BITS); } else if (mapping_address < 0 || (mapping_address + nb) > mb_mapping->nb_bits) { - rsp_length = response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, - rsp, - FALSE, - "Illegal data address 0x%0X in write_bits\n", - mapping_address < 0 ? address : address + nb); + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE, "Illegal data address 0x%0X in write_bits\n", + mapping_address < 0 ? address : address + nb); } else { /* 6 = byte count */ - modbus_set_bits_from_bytes( - mb_mapping->tab_bits, mapping_address, nb, &req[offset + 6]); + modbus_set_bits_from_bytes(mb_mapping->tab_bits, mapping_address, nb, &req[offset + 6]); rsp_length = ctx->backend->build_response_basis(&sft, rsp); /* 4 to copy the bit address (2) and the quantity of bits */ @@ -967,30 +869,17 @@ int modbus_reply(modbus_t *ctx, if (nb < 1 || MODBUS_MAX_WRITE_REGISTERS < nb || nb_bytes != nb * 2) { rsp_length = response_exception( - ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, - rsp, - TRUE, - "Illegal number of values %d in write_registers (max %d)\n", - nb, + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp, TRUE, "Illegal number of values %d in write_registers (max %d)\n", nb, MODBUS_MAX_WRITE_REGISTERS); - } else if (mapping_address < 0 || - (mapping_address + nb) > mb_mapping->nb_registers) { - rsp_length = - response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, - rsp, - FALSE, - "Illegal data address 0x%0X in write_registers\n", - mapping_address < 0 ? address : address + nb); + } else if (mapping_address < 0 || (mapping_address + nb) > mb_mapping->nb_registers) { + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE, "Illegal data address 0x%0X in write_registers\n", + mapping_address < 0 ? address : address + nb); } else { int i, j; for (i = mapping_address, j = 6; i < mapping_address + nb; i++, j += 2) { /* 6 and 7 = first value */ - mb_mapping->tab_registers[i] = - (req[offset + j] << 8) + req[offset + j + 1]; + mb_mapping->tab_registers[i] = (req[offset + j] << 8) + req[offset + j + 1]; } rsp_length = ctx->backend->build_response_basis(&sft, rsp); @@ -1026,14 +915,8 @@ int modbus_reply(modbus_t *ctx, int mapping_address = address - mb_mapping->start_registers; if (mapping_address < 0 || mapping_address >= mb_mapping->nb_registers) { - rsp_length = - response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, - rsp, - FALSE, - "Illegal data address 0x%0X in write_register\n", - address); + rsp_length = response_exception( + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE, "Illegal data address 0x%0X in write_register\n", address); } else { uint16_t data = mb_mapping->tab_registers[mapping_address]; uint16_t and = (req[offset + 3] << 8) + req[offset + 4]; @@ -1053,34 +936,21 @@ int modbus_reply(modbus_t *ctx, int mapping_address = address - mb_mapping->start_registers; int mapping_address_write = address_write - mb_mapping->start_registers; - if (nb_write < 1 || MODBUS_MAX_WR_WRITE_REGISTERS < nb_write || nb < 1 || - MODBUS_MAX_WR_READ_REGISTERS < nb || nb_write_bytes != nb_write * 2) { + if (nb_write < 1 || MODBUS_MAX_WR_WRITE_REGISTERS < nb_write || nb < 1 || MODBUS_MAX_WR_READ_REGISTERS < nb + || nb_write_bytes != nb_write * 2) { rsp_length = response_exception( - ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, - rsp, - TRUE, + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp, TRUE, "Illegal nb of values (W%d, R%d) in write_and_read_registers (max W%d, " "R%d)\n", - nb_write, - nb, - MODBUS_MAX_WR_WRITE_REGISTERS, - MODBUS_MAX_WR_READ_REGISTERS); - } else if (mapping_address < 0 || - (mapping_address + nb) > mb_mapping->nb_registers || - mapping_address_write < 0 || - (mapping_address_write + nb_write) > mb_mapping->nb_registers) { + nb_write, nb, MODBUS_MAX_WR_WRITE_REGISTERS, MODBUS_MAX_WR_READ_REGISTERS); + } else if ( + mapping_address < 0 || (mapping_address + nb) > mb_mapping->nb_registers || mapping_address_write < 0 + || (mapping_address_write + nb_write) > mb_mapping->nb_registers) { rsp_length = response_exception( - ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, - rsp, - FALSE, + ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, rsp, FALSE, "Illegal data read address 0x%0X or write address 0x%0X " "write_and_read_registers\n", - mapping_address < 0 ? address : address + nb, - mapping_address_write < 0 ? address_write : address_write + nb_write); + mapping_address < 0 ? address : address + nb, mapping_address_write < 0 ? address_write : address_write + nb_write); } else { int i, j; rsp_length = ctx->backend->build_response_basis(&sft, rsp); @@ -1088,10 +958,8 @@ int modbus_reply(modbus_t *ctx, /* Write first. 10 and 11 are the offset of the first values to write */ - for (i = mapping_address_write, j = 10; i < mapping_address_write + nb_write; - i++, j += 2) { - mb_mapping->tab_registers[i] = - (req[offset + j] << 8) + req[offset + j + 1]; + for (i = mapping_address_write, j = 10; i < mapping_address_write + nb_write; i++, j += 2) { + mb_mapping->tab_registers[i] = (req[offset + j] << 8) + req[offset + j + 1]; } /* and read the data for the response */ @@ -1103,27 +971,20 @@ int modbus_reply(modbus_t *ctx, } break; default: - rsp_length = response_exception(ctx, - &sft, - MODBUS_EXCEPTION_ILLEGAL_FUNCTION, - rsp, - TRUE, - "Unknown Modbus function code: 0x%0X\n", - function); + rsp_length = response_exception(ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_FUNCTION, rsp, TRUE, "Unknown Modbus function code: 0x%0X\n", function); break; } /* Suppress any responses in RTU when the request was a broadcast, excepted when quirk * is enabled. */ - if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU && - slave == MODBUS_BROADCAST_ADDRESS && - !(ctx->quirks & MODBUS_QUIRK_REPLY_TO_BROADCAST)) { + if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU && slave == MODBUS_BROADCAST_ADDRESS + && !(ctx->quirks & MODBUS_QUIRK_REPLY_TO_BROADCAST)) { return 0; } return send_msg(ctx, rsp, rsp_length); } -int modbus_reply_exception(modbus_t *ctx, const uint8_t *req, unsigned int exception_code) +int modbus_reply_exception(modbus_t* ctx, const uint8_t* req, unsigned int exception_code) { unsigned int offset; int slave; @@ -1158,7 +1019,7 @@ int modbus_reply_exception(modbus_t *ctx, const uint8_t *req, unsigned int excep } /* Reads IO status */ -static int read_io_status(modbus_t *ctx, int function, int addr, int nb, uint8_t *dest) +static int read_io_status(modbus_t* ctx, int function, int addr, int nb, uint8_t* dest) { int rc; int req_length; @@ -1201,7 +1062,7 @@ static int read_io_status(modbus_t *ctx, int function, int addr, int nb, uint8_t /* Reads the boolean status of bits and sets the array elements in the destination to TRUE or FALSE (single bits). */ -int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest) +int modbus_read_bits(modbus_t* ctx, int addr, int nb, uint8_t* dest) { int rc; @@ -1212,10 +1073,7 @@ int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest) if (nb > MODBUS_MAX_READ_BITS) { if (ctx->debug) { - fprintf(stderr, - "ERROR Too many bits requested (%d > %d)\n", - nb, - MODBUS_MAX_READ_BITS); + fprintf(stderr, "ERROR Too many bits requested (%d > %d)\n", nb, MODBUS_MAX_READ_BITS); } errno = EMBMDATA; return -1; @@ -1230,7 +1088,7 @@ int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest) } /* Same as modbus_read_bits but reads the remote device input table */ -int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest) +int modbus_read_input_bits(modbus_t* ctx, int addr, int nb, uint8_t* dest) { int rc; @@ -1241,10 +1099,7 @@ int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest) if (nb > MODBUS_MAX_READ_BITS) { if (ctx->debug) { - fprintf(stderr, - "ERROR Too many discrete inputs requested (%d > %d)\n", - nb, - MODBUS_MAX_READ_BITS); + fprintf(stderr, "ERROR Too many discrete inputs requested (%d > %d)\n", nb, MODBUS_MAX_READ_BITS); } errno = EMBMDATA; return -1; @@ -1259,7 +1114,7 @@ int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest) } /* Reads the data from a remote device and put that data into an array */ -static int read_registers(modbus_t *ctx, int function, int addr, int nb, uint16_t *dest) +static int read_registers(modbus_t* ctx, int function, int addr, int nb, uint16_t* dest) { int rc; int req_length; @@ -1268,10 +1123,7 @@ static int read_registers(modbus_t *ctx, int function, int addr, int nb, uint16_ if (nb > MODBUS_MAX_READ_REGISTERS) { if (ctx->debug) { - fprintf(stderr, - "ERROR Too many registers requested (%d > %d)\n", - nb, - MODBUS_MAX_READ_REGISTERS); + fprintf(stderr, "ERROR Too many registers requested (%d > %d)\n", nb, MODBUS_MAX_READ_REGISTERS); } errno = EMBMDATA; return -1; @@ -1305,7 +1157,7 @@ static int read_registers(modbus_t *ctx, int function, int addr, int nb, uint16_ /* Reads the holding registers of remote device and put the data into an array */ -int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest) +int modbus_read_registers(modbus_t* ctx, int addr, int nb, uint16_t* dest) { int status; @@ -1316,10 +1168,7 @@ int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest) if (nb > MODBUS_MAX_READ_REGISTERS) { if (ctx->debug) { - fprintf(stderr, - "ERROR Too many registers requested (%d > %d)\n", - nb, - MODBUS_MAX_READ_REGISTERS); + fprintf(stderr, "ERROR Too many registers requested (%d > %d)\n", nb, MODBUS_MAX_READ_REGISTERS); } errno = EMBMDATA; return -1; @@ -1330,7 +1179,7 @@ int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest) } /* Reads the input registers of remote device and put the data into an array */ -int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest) +int modbus_read_input_registers(modbus_t* ctx, int addr, int nb, uint16_t* dest) { int status; @@ -1340,10 +1189,7 @@ int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest) } if (nb > MODBUS_MAX_READ_REGISTERS) { - fprintf(stderr, - "ERROR Too many input registers requested (%d > %d)\n", - nb, - MODBUS_MAX_READ_REGISTERS); + fprintf(stderr, "ERROR Too many input registers requested (%d > %d)\n", nb, MODBUS_MAX_READ_REGISTERS); errno = EMBMDATA; return -1; } @@ -1355,7 +1201,7 @@ int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest) /* Write a value to the specified register of the remote device. Used by write_bit and write_register */ -static int write_single(modbus_t *ctx, int function, int addr, const uint16_t value) +static int write_single(modbus_t* ctx, int function, int addr, const uint16_t value) { int rc; int req_length; @@ -1366,7 +1212,7 @@ static int write_single(modbus_t *ctx, int function, int addr, const uint16_t va return -1; } - req_length = ctx->backend->build_request_basis(ctx, function, addr, (int) value, req); + req_length = ctx->backend->build_request_basis(ctx, function, addr, (int)value, req); rc = send_msg(ctx, req, req_length); if (rc > 0) { @@ -1384,7 +1230,7 @@ static int write_single(modbus_t *ctx, int function, int addr, const uint16_t va } /* Turns ON or OFF a single bit of the remote device */ -int modbus_write_bit(modbus_t *ctx, int addr, int status) +int modbus_write_bit(modbus_t* ctx, int addr, int status) { if (ctx == NULL) { errno = EINVAL; @@ -1395,7 +1241,7 @@ int modbus_write_bit(modbus_t *ctx, int addr, int status) } /* Writes a value in one register of the remote device */ -int modbus_write_register(modbus_t *ctx, int addr, const uint16_t value) +int modbus_write_register(modbus_t* ctx, int addr, const uint16_t value) { if (ctx == NULL) { errno = EINVAL; @@ -1406,7 +1252,7 @@ int modbus_write_register(modbus_t *ctx, int addr, const uint16_t value) } /* Write the bits of the array in the remote device */ -int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *src) +int modbus_write_bits(modbus_t* ctx, int addr, int nb, const uint8_t* src) { int rc; int i; @@ -1423,17 +1269,13 @@ int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *src) if (nb > MODBUS_MAX_WRITE_BITS) { if (ctx->debug) { - fprintf(stderr, - "ERROR Writing too many bits (%d > %d)\n", - nb, - MODBUS_MAX_WRITE_BITS); + fprintf(stderr, "ERROR Writing too many bits (%d > %d)\n", nb, MODBUS_MAX_WRITE_BITS); } errno = EMBMDATA; return -1; } - req_length = ctx->backend->build_request_basis( - ctx, MODBUS_FC_WRITE_MULTIPLE_COILS, addr, nb, req); + req_length = ctx->backend->build_request_basis(ctx, MODBUS_FC_WRITE_MULTIPLE_COILS, addr, nb, req); byte_count = (nb / 8) + ((nb % 8) ? 1 : 0); req[req_length++] = byte_count; @@ -1469,7 +1311,7 @@ int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *src) } /* Write the values from the array to the registers of the remote device */ -int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *src) +int modbus_write_registers(modbus_t* ctx, int addr, int nb, const uint16_t* src) { int rc; int i; @@ -1484,17 +1326,13 @@ int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *src) if (nb > MODBUS_MAX_WRITE_REGISTERS) { if (ctx->debug) { - fprintf(stderr, - "ERROR Trying to write to too many registers (%d > %d)\n", - nb, - MODBUS_MAX_WRITE_REGISTERS); + fprintf(stderr, "ERROR Trying to write to too many registers (%d > %d)\n", nb, MODBUS_MAX_WRITE_REGISTERS); } errno = EMBMDATA; return -1; } - req_length = ctx->backend->build_request_basis( - ctx, MODBUS_FC_WRITE_MULTIPLE_REGISTERS, addr, nb, req); + req_length = ctx->backend->build_request_basis(ctx, MODBUS_FC_WRITE_MULTIPLE_REGISTERS, addr, nb, req); byte_count = nb * 2; req[req_length++] = byte_count; @@ -1517,10 +1355,7 @@ int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *src) return rc; } -int modbus_mask_write_register(modbus_t *ctx, - int addr, - uint16_t and_mask, - uint16_t or_mask) +int modbus_mask_write_register(modbus_t* ctx, int addr, uint16_t and_mask, uint16_t or_mask) { int rc; int req_length; @@ -1529,8 +1364,7 @@ int modbus_mask_write_register(modbus_t *ctx, * (2 bytes) which is not used. */ uint8_t req[_MIN_REQ_LENGTH + 2]; - req_length = ctx->backend->build_request_basis( - ctx, MODBUS_FC_MASK_WRITE_REGISTER, addr, 0, req); + req_length = ctx->backend->build_request_basis(ctx, MODBUS_FC_MASK_WRITE_REGISTER, addr, 0, req); /* HACKISH, count is not used */ req_length -= 2; @@ -1557,13 +1391,7 @@ int modbus_mask_write_register(modbus_t *ctx, /* Write multiple registers from src array to remote device and read multiple registers from remote device to dest array. */ -int modbus_write_and_read_registers(modbus_t *ctx, - int write_addr, - int write_nb, - const uint16_t *src, - int read_addr, - int read_nb, - uint16_t *dest) +int modbus_write_and_read_registers(modbus_t* ctx, int write_addr, int write_nb, const uint16_t* src, int read_addr, int read_nb, uint16_t* dest) { int rc; @@ -1580,10 +1408,7 @@ int modbus_write_and_read_registers(modbus_t *ctx, if (write_nb > MODBUS_MAX_WR_WRITE_REGISTERS) { if (ctx->debug) { - fprintf(stderr, - "ERROR Too many registers to write (%d > %d)\n", - write_nb, - MODBUS_MAX_WR_WRITE_REGISTERS); + fprintf(stderr, "ERROR Too many registers to write (%d > %d)\n", write_nb, MODBUS_MAX_WR_WRITE_REGISTERS); } errno = EMBMDATA; return -1; @@ -1591,16 +1416,12 @@ int modbus_write_and_read_registers(modbus_t *ctx, if (read_nb > MODBUS_MAX_WR_READ_REGISTERS) { if (ctx->debug) { - fprintf(stderr, - "ERROR Too many registers requested (%d > %d)\n", - read_nb, - MODBUS_MAX_WR_READ_REGISTERS); + fprintf(stderr, "ERROR Too many registers requested (%d > %d)\n", read_nb, MODBUS_MAX_WR_READ_REGISTERS); } errno = EMBMDATA; return -1; } - req_length = ctx->backend->build_request_basis( - ctx, MODBUS_FC_WRITE_AND_READ_REGISTERS, read_addr, read_nb, req); + req_length = ctx->backend->build_request_basis(ctx, MODBUS_FC_WRITE_AND_READ_REGISTERS, read_addr, read_nb, req); req[req_length++] = write_addr >> 8; req[req_length++] = write_addr & 0x00ff; @@ -1638,7 +1459,7 @@ int modbus_write_and_read_registers(modbus_t *ctx, /* Send a request to get the slave ID of the device (only available in serial communication). */ -int modbus_report_slave_id(modbus_t *ctx, int max_dest, uint8_t *dest) +int modbus_report_slave_id(modbus_t* ctx, int max_dest, uint8_t* dest) { int rc; int req_length; @@ -1649,8 +1470,7 @@ int modbus_report_slave_id(modbus_t *ctx, int max_dest, uint8_t *dest) return -1; } - req_length = - ctx->backend->build_request_basis(ctx, MODBUS_FC_REPORT_SLAVE_ID, 0, 0, req); + req_length = ctx->backend->build_request_basis(ctx, MODBUS_FC_REPORT_SLAVE_ID, 0, 0, req); /* HACKISH, addr and count are not used */ req_length -= 4; @@ -1681,7 +1501,7 @@ int modbus_report_slave_id(modbus_t *ctx, int max_dest, uint8_t *dest) return rc; } -void _modbus_init_common(modbus_t *ctx) +void _modbus_init_common(modbus_t* ctx) { /* Slave and socket are initialized to -1 */ ctx->slave = -1; @@ -1702,7 +1522,7 @@ void _modbus_init_common(modbus_t *ctx) } /* Define the slave number */ -int modbus_set_slave(modbus_t *ctx, int slave) +int modbus_set_slave(modbus_t* ctx, int slave) { if (ctx == NULL) { errno = EINVAL; @@ -1712,7 +1532,7 @@ int modbus_set_slave(modbus_t *ctx, int slave) return ctx->backend->set_slave(ctx, slave); } -int modbus_get_slave(modbus_t *ctx) +int modbus_get_slave(modbus_t* ctx) { if (ctx == NULL) { errno = EINVAL; @@ -1722,7 +1542,7 @@ int modbus_get_slave(modbus_t *ctx) return ctx->slave; } -int modbus_set_error_recovery(modbus_t *ctx, modbus_error_recovery_mode error_recovery) +int modbus_set_error_recovery(modbus_t* ctx, modbus_error_recovery_mode error_recovery) { if (ctx == NULL) { errno = EINVAL; @@ -1730,12 +1550,12 @@ int modbus_set_error_recovery(modbus_t *ctx, modbus_error_recovery_mode error_re } /* The type of modbus_error_recovery_mode is unsigned enum */ - ctx->error_recovery = (uint8_t) error_recovery; + ctx->error_recovery = (uint8_t)error_recovery; return 0; } // FIXME Doesn't work under Windows RTU -int modbus_set_socket(modbus_t *ctx, int s) +int modbus_set_socket(modbus_t* ctx, int s) { if (ctx == NULL) { errno = EINVAL; @@ -1746,7 +1566,7 @@ int modbus_set_socket(modbus_t *ctx, int s) return 0; } -int modbus_get_socket(modbus_t *ctx) +int modbus_get_socket(modbus_t* ctx) { if (ctx == NULL) { errno = EINVAL; @@ -1757,7 +1577,7 @@ int modbus_get_socket(modbus_t *ctx) } /* Get the timeout interval used to wait for a response */ -int modbus_get_response_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec) +int modbus_get_response_timeout(modbus_t* ctx, uint32_t* to_sec, uint32_t* to_usec) { if (ctx == NULL) { errno = EINVAL; @@ -1769,7 +1589,7 @@ int modbus_get_response_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_us return 0; } -int modbus_set_response_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec) +int modbus_set_response_timeout(modbus_t* ctx, uint32_t to_sec, uint32_t to_usec) { if (ctx == NULL || (to_sec == 0 && to_usec == 0) || to_usec > 999999) { errno = EINVAL; @@ -1782,7 +1602,7 @@ int modbus_set_response_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec } /* Get the timeout interval between two consecutive bytes of a message */ -int modbus_get_byte_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec) +int modbus_get_byte_timeout(modbus_t* ctx, uint32_t* to_sec, uint32_t* to_usec) { if (ctx == NULL) { errno = EINVAL; @@ -1794,7 +1614,7 @@ int modbus_get_byte_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec) return 0; } -int modbus_set_byte_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec) +int modbus_set_byte_timeout(modbus_t* ctx, uint32_t to_sec, uint32_t to_usec) { /* Byte timeout can be disabled when both values are zero */ if (ctx == NULL || to_usec > 999999) { @@ -1808,7 +1628,7 @@ int modbus_set_byte_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec) } /* Get the timeout interval used by the server to wait for an indication from a client */ -int modbus_get_indication_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec) +int modbus_get_indication_timeout(modbus_t* ctx, uint32_t* to_sec, uint32_t* to_usec) { if (ctx == NULL) { errno = EINVAL; @@ -1820,7 +1640,7 @@ int modbus_get_indication_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_ return 0; } -int modbus_set_indication_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec) +int modbus_set_indication_timeout(modbus_t* ctx, uint32_t to_sec, uint32_t to_usec) { /* Indication timeout can be disabled when both values are zero */ if (ctx == NULL || to_usec > 999999) { @@ -1833,7 +1653,7 @@ int modbus_set_indication_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_us return 0; } -int modbus_get_header_length(modbus_t *ctx) +int modbus_get_header_length(modbus_t* ctx) { if (ctx == NULL) { errno = EINVAL; @@ -1843,7 +1663,7 @@ int modbus_get_header_length(modbus_t *ctx) return ctx->backend->header_length; } -int modbus_enable_quirks(modbus_t *ctx, uint32_t quirks_mask) +int modbus_enable_quirks(modbus_t* ctx, uint32_t quirks_mask) { if (ctx == NULL) { errno = EINVAL; @@ -1855,7 +1675,7 @@ int modbus_enable_quirks(modbus_t *ctx, uint32_t quirks_mask) return 0; } -int modbus_disable_quirks(modbus_t *ctx, uint32_t quirks_mask) +int modbus_disable_quirks(modbus_t* ctx, uint32_t quirks_mask) { if (ctx == NULL) { errno = EINVAL; @@ -1867,7 +1687,7 @@ int modbus_disable_quirks(modbus_t *ctx, uint32_t quirks_mask) return 0; } -int modbus_connect(modbus_t *ctx) +int modbus_connect(modbus_t* ctx) { if (ctx == NULL) { errno = EINVAL; @@ -1877,7 +1697,7 @@ int modbus_connect(modbus_t *ctx) return ctx->backend->connect(ctx); } -void modbus_close(modbus_t *ctx) +void modbus_close(modbus_t* ctx) { if (ctx == NULL) return; @@ -1885,7 +1705,7 @@ void modbus_close(modbus_t *ctx) ctx->backend->close(ctx); } -void modbus_free(modbus_t *ctx) +void modbus_free(modbus_t* ctx) { if (ctx == NULL) return; @@ -1893,7 +1713,7 @@ void modbus_free(modbus_t *ctx) ctx->backend->free(ctx); } -int modbus_set_debug(modbus_t *ctx, int flag) +int modbus_set_debug(modbus_t* ctx, int flag) { if (ctx == NULL) { errno = EINVAL; @@ -1910,18 +1730,19 @@ int modbus_set_debug(modbus_t *ctx, int flag) The modbus_mapping_new_start_address() function shall return the new allocated structure if successful. Otherwise it shall return NULL and set errno to ENOMEM. */ -modbus_mapping_t *modbus_mapping_new_start_address(unsigned int start_bits, - unsigned int nb_bits, - unsigned int start_input_bits, - unsigned int nb_input_bits, - unsigned int start_registers, - unsigned int nb_registers, - unsigned int start_input_registers, - unsigned int nb_input_registers) +modbus_mapping_t* modbus_mapping_new_start_address( + unsigned int start_bits, + unsigned int nb_bits, + unsigned int start_input_bits, + unsigned int nb_input_bits, + unsigned int start_registers, + unsigned int nb_registers, + unsigned int start_input_registers, + unsigned int nb_input_registers) { - modbus_mapping_t *mb_mapping; + modbus_mapping_t* mb_mapping; - mb_mapping = (modbus_mapping_t *) malloc(sizeof(modbus_mapping_t)); + mb_mapping = (modbus_mapping_t*)malloc(sizeof(modbus_mapping_t)); if (mb_mapping == NULL) { return NULL; } @@ -1933,7 +1754,7 @@ modbus_mapping_t *modbus_mapping_new_start_address(unsigned int start_bits, mb_mapping->tab_bits = NULL; } else { /* Negative number raises a POSIX error */ - mb_mapping->tab_bits = (uint8_t *) malloc(nb_bits * sizeof(uint8_t)); + mb_mapping->tab_bits = (uint8_t*)malloc(nb_bits * sizeof(uint8_t)); if (mb_mapping->tab_bits == NULL) { free(mb_mapping); return NULL; @@ -1947,7 +1768,7 @@ modbus_mapping_t *modbus_mapping_new_start_address(unsigned int start_bits, if (nb_input_bits == 0) { mb_mapping->tab_input_bits = NULL; } else { - mb_mapping->tab_input_bits = (uint8_t *) malloc(nb_input_bits * sizeof(uint8_t)); + mb_mapping->tab_input_bits = (uint8_t*)malloc(nb_input_bits * sizeof(uint8_t)); if (mb_mapping->tab_input_bits == NULL) { free(mb_mapping->tab_bits); free(mb_mapping); @@ -1962,7 +1783,7 @@ modbus_mapping_t *modbus_mapping_new_start_address(unsigned int start_bits, if (nb_registers == 0) { mb_mapping->tab_registers = NULL; } else { - mb_mapping->tab_registers = (uint16_t *) malloc(nb_registers * sizeof(uint16_t)); + mb_mapping->tab_registers = (uint16_t*)malloc(nb_registers * sizeof(uint16_t)); if (mb_mapping->tab_registers == NULL) { free(mb_mapping->tab_input_bits); free(mb_mapping->tab_bits); @@ -1978,8 +1799,7 @@ modbus_mapping_t *modbus_mapping_new_start_address(unsigned int start_bits, if (nb_input_registers == 0) { mb_mapping->tab_input_registers = NULL; } else { - mb_mapping->tab_input_registers = - (uint16_t *) malloc(nb_input_registers * sizeof(uint16_t)); + mb_mapping->tab_input_registers = (uint16_t*)malloc(nb_input_registers * sizeof(uint16_t)); if (mb_mapping->tab_input_registers == NULL) { free(mb_mapping->tab_registers); free(mb_mapping->tab_input_bits); @@ -1993,17 +1813,13 @@ modbus_mapping_t *modbus_mapping_new_start_address(unsigned int start_bits, return mb_mapping; } -modbus_mapping_t *modbus_mapping_new(int nb_bits, - int nb_input_bits, - int nb_registers, - int nb_input_registers) +modbus_mapping_t* modbus_mapping_new(int nb_bits, int nb_input_bits, int nb_registers, int nb_input_registers) { - return modbus_mapping_new_start_address( - 0, nb_bits, 0, nb_input_bits, 0, nb_registers, 0, nb_input_registers); + return modbus_mapping_new_start_address(0, nb_bits, 0, nb_input_bits, 0, nb_registers, 0, nb_input_registers); } /* Frees the 4 arrays */ -void modbus_mapping_free(modbus_mapping_t *mb_mapping) +void modbus_mapping_free(modbus_mapping_t* mb_mapping) { if (mb_mapping == NULL) { return; @@ -2015,4 +1831,3 @@ void modbus_mapping_free(modbus_mapping_t *mb_mapping) free(mb_mapping->tab_bits); free(mb_mapping); } - diff --git a/nettls/nettls/bignum.h b/nettls/nettls/bignum.h index 4664619a..fd0813a5 100644 --- a/nettls/nettls/bignum.h +++ b/nettls/nettls/bignum.h @@ -68,8 +68,8 @@ #define MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL -0x0008 /**< The buffer is too small to write to. */ #define MBEDTLS_ERR_MPI_NEGATIVE_VALUE -0x000A /**< The input arguments are negative or result in illegal output. */ #define MBEDTLS_ERR_MPI_DIVISION_BY_ZERO -0x000C /**< The input argument for division is zero, which is not allowed.*/ -#define MBEDTLS_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< The input arguments are not acceptable. */ -#define MBEDTLS_ERR_MPI_ALLOC_FAILED -0x0010 /**< Memory allocation failed. */ +#define MBEDTLS_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< The input arguments are not acceptable. */ +#define MBEDTLS_ERR_MPI_ALLOC_FAILED -0x0010 /**< Memory allocation failed. */ #define MBEDTLS_MPI_CHK(f) \ do { \ diff --git a/nettls/nettls/ssl_internal.h b/nettls/nettls/ssl_internal.h index 8b91d3b7..f1cf511e 100644 --- a/nettls/nettls/ssl_internal.h +++ b/nettls/nettls/ssl_internal.h @@ -654,7 +654,6 @@ int mbedtls_ssl_write_handshake_msg(mbedtls_ssl_context* ssl); int mbedtls_ssl_write_record(mbedtls_ssl_context* ssl, uint8_t force_flush); int mbedtls_ssl_flush_output(mbedtls_ssl_context* ssl); - int ssl_parse_record_header(mbedtls_ssl_context* ssl); int ssl_encrypt_buf(mbedtls_ssl_context* ssl); int ssl_prepare_record_content(mbedtls_ssl_context* ssl); @@ -662,7 +661,6 @@ int ssl_decrypt_buf(mbedtls_ssl_context* ssl); int ssl_get_remaining_space_in_datagram(mbedtls_ssl_context const* ssl); int ssl_get_remaining_payload_in_datagram(mbedtls_ssl_context const* ssl); - int mbedtls_ssl_parse_certificate(mbedtls_ssl_context* ssl); int mbedtls_ssl_write_certificate(mbedtls_ssl_context* ssl); diff --git a/nettls/ssl/aes.c b/nettls/ssl/aes.c index f4a03884..6c92fd38 100644 --- a/nettls/ssl/aes.c +++ b/nettls/ssl/aes.c @@ -1200,27 +1200,23 @@ int mbedtls_aes_crypt_ctr( static const unsigned char aes_test_ecb_dec[3][16] = { {0x44, 0x41, 0x6A, 0xC2, 0xD1, 0xF5, 0x3C, 0x58, 0x33, 0x03, 0x91, 0x7E, 0x6B, 0xE9, 0xEB, 0xE0}, {0x48, 0xE3, 0x1E, 0x9E, 0x25, 0x67, 0x18, 0xF2, 0x92, 0x29, 0x31, 0x9C, 0x19, 0xF1, 0x5B, 0xA4}, - {0x05, 0x8C, 0xCF, 0xFD, 0xBB, 0xCB, 0x38, 0x2D, 0x1F, 0x6F, 0x56, 0x58, 0x5D, 0x8A, 0x4A, 0xDE} -}; + {0x05, 0x8C, 0xCF, 0xFD, 0xBB, 0xCB, 0x38, 0x2D, 0x1F, 0x6F, 0x56, 0x58, 0x5D, 0x8A, 0x4A, 0xDE}}; static const unsigned char aes_test_ecb_enc[3][16] = { {0xC3, 0x4C, 0x05, 0x2C, 0xC0, 0xDA, 0x8D, 0x73, 0x45, 0x1A, 0xFE, 0x5F, 0x03, 0xBE, 0x29, 0x7F}, {0xF3, 0xF6, 0x75, 0x2A, 0xE8, 0xD7, 0x83, 0x11, 0x38, 0xF0, 0x41, 0x56, 0x06, 0x31, 0xB1, 0x14}, - {0x8B, 0x79, 0xEE, 0xCC, 0x93, 0xA0, 0xEE, 0x5D, 0xFF, 0x30, 0xB4, 0xEA, 0x21, 0x63, 0x6D, 0xA4} -}; + {0x8B, 0x79, 0xEE, 0xCC, 0x93, 0xA0, 0xEE, 0x5D, 0xFF, 0x30, 0xB4, 0xEA, 0x21, 0x63, 0x6D, 0xA4}}; #if defined(MBEDTLS_CIPHER_MODE_CBC) static const unsigned char aes_test_cbc_dec[3][16] = { {0xFA, 0xCA, 0x37, 0xE0, 0xB0, 0xC8, 0x53, 0x73, 0xDF, 0x70, 0x6E, 0x73, 0xF7, 0xC9, 0xAF, 0x86}, {0x5D, 0xF6, 0x78, 0xDD, 0x17, 0xBA, 0x4E, 0x75, 0xB6, 0x17, 0x68, 0xC6, 0xAD, 0xEF, 0x7C, 0x7B}, - {0x48, 0x04, 0xE1, 0x81, 0x8F, 0xE6, 0x29, 0x75, 0x19, 0xA3, 0xE8, 0x8C, 0x57, 0x31, 0x04, 0x13} -}; + {0x48, 0x04, 0xE1, 0x81, 0x8F, 0xE6, 0x29, 0x75, 0x19, 0xA3, 0xE8, 0x8C, 0x57, 0x31, 0x04, 0x13}}; static const unsigned char aes_test_cbc_enc[3][16] = { {0x8A, 0x05, 0xFC, 0x5E, 0x09, 0x5A, 0xF4, 0x84, 0x8A, 0x08, 0xD3, 0x28, 0xD3, 0x68, 0x8E, 0x3D}, {0x7B, 0xD9, 0x66, 0xD5, 0x3A, 0xD8, 0xC1, 0xBB, 0x85, 0xD2, 0xAD, 0xFA, 0xE8, 0x7B, 0xB1, 0x04}, - {0xFE, 0x3C, 0x53, 0x65, 0x3E, 0x2F, 0x45, 0xB5, 0x6F, 0xCD, 0x88, 0xB2, 0xCC, 0x89, 0x8F, 0xF0} -}; + {0xFE, 0x3C, 0x53, 0x65, 0x3E, 0x2F, 0x45, 0xB5, 0x6F, 0xCD, 0x88, 0xB2, 0xCC, 0x89, 0x8F, 0xF0}}; #endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_CIPHER_MODE_CFB) @@ -1233,8 +1229,7 @@ static const unsigned char aes_test_cfb128_key[3][32] = { {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C}, {0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B}, {0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, - 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4} -}; + 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4}}; static const unsigned char aes_test_cfb128_iv[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; @@ -1252,8 +1247,7 @@ static const unsigned char aes_test_cfb128_ct[3][64] = { 0x1E, 0xFA, 0xC4, 0xC9, 0xC0, 0x5F, 0x9F, 0x9C, 0xA9, 0x83, 0x4F, 0xA0, 0x42, 0xAE, 0x8F, 0xBA, 0x58, 0x4B, 0x09, 0xFF}, {0xDC, 0x7E, 0x84, 0xBF, 0xDA, 0x79, 0x16, 0x4B, 0x7E, 0xCD, 0x84, 0x86, 0x98, 0x5D, 0x38, 0x60, 0x39, 0xFF, 0xED, 0x14, 0x3B, 0x28, 0xB1, 0xC8, 0x32, 0x11, 0x3C, 0x63, 0x31, 0xE5, 0x40, 0x7B, 0xDF, 0x10, 0x13, 0x24, 0x15, 0xE5, 0x4B, 0x92, 0xA1, 0x3E, 0xD0, 0xA8, - 0x26, 0x7A, 0xE2, 0xF9, 0x75, 0xA3, 0x85, 0x74, 0x1A, 0xB9, 0xCE, 0xF8, 0x20, 0x31, 0x62, 0x3D, 0x55, 0xB1, 0xE4, 0x71} -}; + 0x26, 0x7A, 0xE2, 0xF9, 0x75, 0xA3, 0x85, 0x74, 0x1A, 0xB9, 0xCE, 0xF8, 0x20, 0x31, 0x62, 0x3D, 0x55, 0xB1, 0xE4, 0x71}}; #endif /* MBEDTLS_CIPHER_MODE_CFB */ #if defined(MBEDTLS_CIPHER_MODE_OFB) @@ -1266,8 +1260,7 @@ static const unsigned char aes_test_ofb_key[3][32] = { {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C}, {0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B}, {0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, - 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4} -}; + 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4}}; static const unsigned char aes_test_ofb_iv[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; @@ -1285,8 +1278,7 @@ static const unsigned char aes_test_ofb_ct[3][64] = { 0xaf, 0x59, 0xa5, 0xf2, 0x6d, 0x9f, 0x20, 0x08, 0x57, 0xca, 0x6c, 0x3e, 0x9c, 0xac, 0x52, 0x4b, 0xd9, 0xac, 0xc9, 0x2a}, {0xDC, 0x7E, 0x84, 0xBF, 0xDA, 0x79, 0x16, 0x4B, 0x7E, 0xCD, 0x84, 0x86, 0x98, 0x5D, 0x38, 0x60, 0x4f, 0xeb, 0xdc, 0x67, 0x40, 0xd2, 0x0b, 0x3a, 0xc8, 0x8f, 0x6a, 0xd8, 0x2a, 0x4f, 0xb0, 0x8d, 0x71, 0xab, 0x47, 0xa0, 0x86, 0xe8, 0x6e, 0xed, 0xf3, 0x9d, 0x1c, 0x5b, - 0xba, 0x97, 0xc4, 0x08, 0x01, 0x26, 0x14, 0x1d, 0x67, 0xf3, 0x7b, 0xe8, 0x53, 0x8f, 0x5a, 0x8b, 0xe7, 0x40, 0xe4, 0x84} -}; + 0xba, 0x97, 0xc4, 0x08, 0x01, 0x26, 0x14, 0x1d, 0x67, 0xf3, 0x7b, 0xe8, 0x53, 0x8f, 0x5a, 0x8b, 0xe7, 0x40, 0xe4, 0x84}}; #endif /* MBEDTLS_CIPHER_MODE_OFB */ #if defined(MBEDTLS_CIPHER_MODE_CTR) @@ -1299,14 +1291,12 @@ static const unsigned char aes_test_ofb_ct[3][64] = { static const unsigned char aes_test_ctr_key[3][16] = { {0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E}, {0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63}, - {0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC} -}; + {0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC}}; static const unsigned char aes_test_ctr_nonce_counter[3][16] = { {0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, {0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59, 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01}, - {0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01} -}; + {0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01}}; static const unsigned char aes_test_ctr_pt[3][48] = { {0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67}, @@ -1315,16 +1305,14 @@ static const unsigned char aes_test_ctr_pt[3][48] = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, - 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23} -}; + 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23}}; static const unsigned char aes_test_ctr_ct[3][48] = { {0xE4, 0x09, 0x5D, 0x4F, 0xB7, 0xA7, 0xB3, 0x79, 0x2D, 0x61, 0x75, 0xA3, 0x26, 0x13, 0x11, 0xB8}, {0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9, 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88, 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8, 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28}, {0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9, 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7, 0x45, 0x40, - 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36, 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53, 0x25, 0xB2, 0x07, 0x2F} -}; + 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36, 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53, 0x25, 0xB2, 0x07, 0x2F}}; static const int aes_test_ctr_len[3] = {16, 32, 36}; #endif /* MBEDTLS_CIPHER_MODE_CTR */ diff --git a/nettls/ssl/arc4.c b/nettls/ssl/arc4.c index 12217fb3..afd171b5 100644 --- a/nettls/ssl/arc4.c +++ b/nettls/ssl/arc4.c @@ -157,20 +157,17 @@ int mbedtls_arc4_crypt(mbedtls_arc4_context* ctx, size_t length, const unsigned static const unsigned char arc4_test_key[3][8] = { {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}, {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} -}; + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; static const unsigned char arc4_test_pt[3][8] = { {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} -}; + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; static const unsigned char arc4_test_ct[3][8] = { {0x75, 0xB7, 0x87, 0x80, 0x99, 0xE0, 0xC5, 0x96}, {0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79}, - {0xDE, 0x18, 0x89, 0x41, 0xA3, 0x37, 0x5D, 0x3A} -}; + {0xDE, 0x18, 0x89, 0x41, 0xA3, 0x37, 0x5D, 0x3A}}; /* * Checkup routine diff --git a/nettls/ssl/bignum.c b/nettls/ssl/bignum.c index cebd1d96..ad49fde5 100644 --- a/nettls/ssl/bignum.c +++ b/nettls/ssl/bignum.c @@ -2678,11 +2678,7 @@ cleanup: #define GCD_PAIR_COUNT 3 -static const int gcd_pairs[GCD_PAIR_COUNT][3] = { - {693, 609, 21}, - {1764, 868, 28}, - {768454923, 542167814, 1 } -}; +static const int gcd_pairs[GCD_PAIR_COUNT][3] = {{693, 609, 21}, {1764, 868, 28}, {768454923, 542167814, 1}}; /* * Checkup routine diff --git a/nettls/ssl/blowfish.c b/nettls/ssl/blowfish.c index 49007945..91455d6d 100644 --- a/nettls/ssl/blowfish.c +++ b/nettls/ssl/blowfish.c @@ -516,8 +516,7 @@ static const uint32_t S[4][256] = { 0xE6C6C7BDL, 0x327A140AL, 0x45E1D006L, 0xC3F27B9AL, 0xC9AA53FDL, 0x62A80F00L, 0xBB25BFE2L, 0x35BDD2F6L, 0x71126905L, 0xB2040222L, 0xB6CBCF7CL, 0xCD769C2BL, 0x53113EC0L, 0x1640E3D3L, 0x38ABBD60L, 0x2547ADF0L, 0xBA38209CL, 0xF746CE76L, 0x77AFA1C5L, 0x20756060L, 0x85CBFE4EL, 0x8AE88DD8L, 0x7AAAF9B0L, 0x4CF9AA7EL, 0x1948C25CL, 0x02FB8A8CL, 0x01C36AE4L, 0xD6EBE1F9L, 0x90D4F869L, 0xA65CDEA0L, 0x3F09252DL, 0xC208E69FL, 0xB74E6132L, - 0xCE77E25BL, 0x578FDFE3L, 0x3AC372E6L} -}; + 0xCE77E25BL, 0x578FDFE3L, 0x3AC372E6L}}; #endif /* !MBEDTLS_BLOWFISH_ALT */ #endif /* MBEDTLS_BLOWFISH_C */ diff --git a/nettls/ssl/camellia.c b/nettls/ssl/camellia.c index ff9d3e61..6c1294fd 100644 --- a/nettls/ssl/camellia.c +++ b/nettls/ssl/camellia.c @@ -98,14 +98,9 @@ } #endif -static const unsigned char SIGMA_CHARS[6][8] = { - {0xa0, 0x9e, 0x66, 0x7f, 0x3b, 0xcc, 0x90, 0x8b}, - {0xb6, 0x7a, 0xe8, 0x58, 0x4c, 0xaa, 0x73, 0xb2}, - {0xc6, 0xef, 0x37, 0x2f, 0xe9, 0x4f, 0x82, 0xbe}, - {0x54, 0xff, 0x53, 0xa5, 0xf1, 0xd3, 0x6f, 0x1c}, - {0x10, 0xe5, 0x27, 0xfa, 0xde, 0x68, 0x2d, 0x1d}, - {0xb0, 0x56, 0x88, 0xc2, 0xb3, 0xe6, 0xc1, 0xfd} -}; +static const unsigned char SIGMA_CHARS[6][8] = {{0xa0, 0x9e, 0x66, 0x7f, 0x3b, 0xcc, 0x90, 0x8b}, {0xb6, 0x7a, 0xe8, 0x58, 0x4c, 0xaa, 0x73, 0xb2}, + {0xc6, 0xef, 0x37, 0x2f, 0xe9, 0x4f, 0x82, 0xbe}, {0x54, 0xff, 0x53, 0xa5, 0xf1, 0xd3, 0x6f, 0x1c}, + {0x10, 0xe5, 0x27, 0xfa, 0xde, 0x68, 0x2d, 0x1d}, {0xb0, 0x56, 0x88, 0xc2, 0xb3, 0xe6, 0xc1, 0xfd}}; #if defined(MBEDTLS_CAMELLIA_SMALL_MEMORY) @@ -180,38 +175,35 @@ static const unsigned char FSb4[256] = { static const unsigned char shifts[2][4][4] = { { - {1, 1, 1, 1}, /* KL */ + {1, 1, 1, 1}, /* KL */ {0, 0, 0, 0}, /* KR */ {1, 1, 1, 1}, /* KA */ {0, 0, 0, 0} /* KB */ }, { - {1, 0, 1, 1}, /* KL */ + {1, 0, 1, 1}, /* KL */ {1, 1, 0, 1}, /* KR */ {1, 1, 1, 0}, /* KA */ {1, 1, 0, 1} /* KB */ - } -}; + }}; static const signed char indexes[2][4][20] = { { - {0, 1, 2, 3, 8, 9, 10, 11, 38, 39, 36, 37, 23, 20, 21, 22, 27, -1, -1, 26}, /* KL -> RK */ + {0, 1, 2, 3, 8, 9, 10, 11, 38, 39, 36, 37, 23, 20, 21, 22, 27, -1, -1, 26}, /* KL -> RK */ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* KR -> RK */ {4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 18, 19, -1, 24, 25, -1, 31, 28, 29, 30}, /* KA -> RK */ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} /* KB -> RK */ }, { - {0, 1, 2, 3, 61, 62, 63, 60, -1, -1, -1, -1, 27, 24, 25, 26, 35, 32, 33, 34}, /* KL -> RK */ - {-1, -1, -1, -1, 8, 9, 10, 11, 16, 17, 18, 19, -1, -1, -1, -1, 39, 36, 37, 38}, /* KR -> RK */ + {0, 1, 2, 3, 61, 62, 63, 60, -1, -1, -1, -1, 27, 24, 25, 26, 35, 32, 33, 34}, /* KL -> RK */ + {-1, -1, -1, -1, 8, 9, 10, 11, 16, 17, 18, 19, -1, -1, -1, -1, 39, 36, 37, 38}, /* KR -> RK */ {-1, -1, -1, -1, 12, 13, 14, 15, 58, 59, 56, 57, 31, 28, 29, 30, -1, -1, -1, -1}, /* KA -> RK */ {4, 5, 6, 7, 65, 66, 67, 64, 20, 21, 22, 23, -1, -1, -1, -1, 43, 40, 41, 42} /* KB -> RK */ - } -}; + }}; static const signed char transposes[2][20] = { - {21, 22, 23, 20, -1, -1, -1, -1, 18, 19, 16, 17, 11, 8, 9, 10, 15, 12, 13, 14}, - {25, 26, 27, 24, 29, 30, 31, 28, 18, 19, 16, 17, -1, -1, -1, -1, -1, -1, -1, -1} -}; + {21, 22, 23, 20, -1, -1, -1, -1, 18, 19, 16, 17, 11, 8, 9, 10, 15, 12, 13, 14}, + {25, 26, 27, 24, 29, 30, 31, 28, 18, 19, 16, 17, -1, -1, -1, -1, -1, -1, -1, -1}}; /* Shift macro for 128 bit strings with rotation smaller than 32 bits (!) */ #define ROTL(DEST, SRC, SHIFT) \ @@ -671,7 +663,7 @@ static const unsigned char camellia_test_ecb_key[3][CAMELLIA_TESTS_ECB][32] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -680,8 +672,7 @@ static const unsigned char camellia_test_ecb_key[3][CAMELLIA_TESTS_ECB][32] = { static const unsigned char camellia_test_ecb_plain[CAMELLIA_TESTS_ECB][16] = { {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}, - {0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} -}; + {0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; static const unsigned char camellia_test_ecb_cipher[3][CAMELLIA_TESTS_ECB][16] = { {{0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73, 0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43}, @@ -689,8 +680,7 @@ static const unsigned char camellia_test_ecb_cipher[3][CAMELLIA_TESTS_ECB][16] = {{0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8, 0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9}, {0xD1, 0x76, 0x3F, 0xC0, 0x19, 0xD7, 0x7C, 0xC9, 0x30, 0xBF, 0xF2, 0xA5, 0x6F, 0x7C, 0x93, 0x64}}, {{0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c, 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09}, - {0x05, 0x03, 0xFB, 0x10, 0xAB, 0x24, 0x1E, 0x7C, 0xF4, 0x5D, 0x8C, 0xDE, 0xEE, 0x47, 0x43, 0x35}} -}; + {0x05, 0x03, 0xFB, 0x10, 0xAB, 0x24, 0x1E, 0x7C, 0xF4, 0x5D, 0x8C, 0xDE, 0xEE, 0x47, 0x43, 0x35}}}; #if defined(MBEDTLS_CIPHER_MODE_CBC) #define CAMELLIA_TESTS_CBC 3 @@ -699,8 +689,7 @@ static const unsigned char camellia_test_cbc_key[3][32] = { {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C}, {0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B}, {0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, - 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4} -}; + 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4}}; static const unsigned char camellia_test_cbc_iv[16] = @@ -709,8 +698,7 @@ static const unsigned char camellia_test_cbc_iv[16] = static const unsigned char camellia_test_cbc_plain[CAMELLIA_TESTS_CBC][16] = { {0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A}, {0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51}, - {0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF} -}; + {0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF}}; static const unsigned char camellia_test_cbc_cipher[3][CAMELLIA_TESTS_CBC][16] = { {{0x16, 0x07, 0xCF, 0x49, 0x4B, 0x36, 0xBB, 0xF0, 0x0D, 0xAE, 0xB0, 0xB5, 0x03, 0xC8, 0x31, 0xAB}, @@ -721,8 +709,7 @@ static const unsigned char camellia_test_cbc_cipher[3][CAMELLIA_TESTS_CBC][16] = {0x37, 0xD3, 0x59, 0xC3, 0x34, 0x98, 0x36, 0xD8, 0x84, 0xE3, 0x10, 0xAD, 0xDF, 0x68, 0xC4, 0x49}}, {{0xE6, 0xCF, 0xA3, 0x5F, 0xC0, 0x2B, 0x13, 0x4A, 0x4D, 0x2C, 0x0B, 0x67, 0x37, 0xAC, 0x3E, 0xDA}, {0x36, 0xCB, 0xEB, 0x73, 0xBD, 0x50, 0x4B, 0x40, 0x70, 0xB1, 0xB7, 0xDE, 0x2B, 0x21, 0xEB, 0x50}, - {0xE3, 0x1A, 0x60, 0x55, 0x29, 0x7D, 0x96, 0xCA, 0x33, 0x30, 0xCD, 0xF1, 0xB1, 0x86, 0x0A, 0x83}} -}; + {0xE3, 0x1A, 0x60, 0x55, 0x29, 0x7D, 0x96, 0xCA, 0x33, 0x30, 0xCD, 0xF1, 0xB1, 0x86, 0x0A, 0x83}}}; #endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_CIPHER_MODE_CTR) @@ -735,14 +722,12 @@ static const unsigned char camellia_test_cbc_cipher[3][CAMELLIA_TESTS_CBC][16] = static const unsigned char camellia_test_ctr_key[3][16] = { {0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E}, {0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63}, - {0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC} -}; + {0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC}}; static const unsigned char camellia_test_ctr_nonce_counter[3][16] = { {0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, {0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59, 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01}, - {0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01} -}; + {0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01}}; static const unsigned char camellia_test_ctr_pt[3][48] = { {0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67}, @@ -751,16 +736,14 @@ static const unsigned char camellia_test_ctr_pt[3][48] = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}, {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, - 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23} -}; + 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23}}; static const unsigned char camellia_test_ctr_ct[3][48] = { {0xD0, 0x9D, 0xC2, 0x9A, 0x82, 0x14, 0x61, 0x9A, 0x20, 0x87, 0x7C, 0x76, 0xDB, 0x1F, 0x0B, 0x3F}, {0xDB, 0xF3, 0xC7, 0x8D, 0xC0, 0x83, 0x96, 0xD4, 0xDA, 0x7C, 0x90, 0x77, 0x65, 0xBB, 0xCB, 0x44, 0x2B, 0x8E, 0x8E, 0x0F, 0x31, 0xF0, 0xDC, 0xA7, 0x2C, 0x74, 0x17, 0xE3, 0x53, 0x60, 0xE0, 0x48}, {0xB1, 0x9D, 0x1F, 0xCD, 0xCB, 0x75, 0xEB, 0x88, 0x2F, 0x84, 0x9C, 0xE2, 0x4D, 0x85, 0xCF, 0x73, 0x9C, 0xE6, - 0x4B, 0x2B, 0x5C, 0x9D, 0x73, 0xF1, 0x4F, 0x2D, 0x5D, 0x9D, 0xCE, 0x98, 0x89, 0xCD, 0xDF, 0x50, 0x86, 0x96} -}; + 0x4B, 0x2B, 0x5C, 0x9D, 0x73, 0xF1, 0x4F, 0x2D, 0x5D, 0x9D, 0xCE, 0x98, 0x89, 0xCD, 0xDF, 0x50, 0x86, 0x96}}; static const int camellia_test_ctr_len[3] = {16, 32, 36}; #endif /* MBEDTLS_CIPHER_MODE_CTR */ diff --git a/nettls/ssl/ccm.c b/nettls/ssl/ccm.c index 594584d9..f18ebaf8 100644 --- a/nettls/ssl/ccm.c +++ b/nettls/ssl/ccm.c @@ -482,8 +482,7 @@ static const unsigned char res[NB_TESTS][CCM_SELFTEST_CT_MAX_LEN] = { {0x71, 0x62, 0x01, 0x5b, 0x4d, 0xac, 0x25, 0x5d}, {0xd2, 0xa1, 0xf0, 0xe0, 0x51, 0xea, 0x5f, 0x62, 0x08, 0x1a, 0x77, 0x92, 0x07, 0x3d, 0x59, 0x3d, 0x1f, 0xc6, 0x4f, 0xbf, 0xac, 0xcd}, {0xe3, 0xb2, 0x01, 0xa9, 0xf5, 0xb7, 0x1a, 0x7a, 0x9b, 0x1c, 0xea, 0xec, 0xcd, 0x97, 0xe7, 0x0b, - 0x61, 0x76, 0xaa, 0xd9, 0xa4, 0x42, 0x8a, 0xa5, 0x48, 0x43, 0x92, 0xfb, 0xc1, 0xb0, 0x99, 0x51} -}; + 0x61, 0x76, 0xaa, 0xd9, 0xa4, 0x42, 0x8a, 0xa5, 0x48, 0x43, 0x92, 0xfb, 0xc1, 0xb0, 0x99, 0x51}}; int mbedtls_ccm_self_test(int verbose) { diff --git a/nettls/ssl/chacha20.c b/nettls/ssl/chacha20.c index 328d3449..ba06c3b4 100644 --- a/nettls/ssl/chacha20.c +++ b/nettls/ssl/chacha20.c @@ -349,13 +349,11 @@ static const unsigned char test_keys[2][32] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}; static const unsigned char test_nonces[2][12] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02} -}; + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}; static const uint32_t test_counters[2] = {0U, 1U}; @@ -378,8 +376,7 @@ static const unsigned char test_input[2][375] = { 0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x72, 0x6f, 0x6e, 0x69, 0x63, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6d, 0x61, 0x64, 0x65, 0x20, 0x61, 0x74, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x6f, 0x72, 0x20, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2c, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x61, - 0x72, 0x65, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x6f} -}; + 0x72, 0x65, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x6f}}; static const unsigned char test_output[2][375] = { {0x76, 0xb8, 0xe0, 0xad, 0xa0, 0xf1, 0x3d, 0x90, 0x40, 0x5d, 0x6a, 0xe5, 0x53, 0x86, 0xbd, 0x28, 0xbd, 0xd2, 0x19, 0xb8, 0xa0, 0x8d, @@ -400,8 +397,7 @@ static const unsigned char test_output[2][375] = { 0x58, 0x69, 0xca, 0x52, 0xc5, 0xb8, 0x3f, 0xa3, 0x6f, 0xf2, 0x16, 0xb9, 0xc1, 0xd3, 0x00, 0x62, 0xbe, 0xbc, 0xfd, 0x2d, 0xc5, 0xbc, 0xe0, 0x91, 0x19, 0x34, 0xfd, 0xa7, 0x9a, 0x86, 0xf6, 0xe6, 0x98, 0xce, 0xd7, 0x59, 0xc3, 0xff, 0x9b, 0x64, 0x77, 0x33, 0x8f, 0x3d, 0xa4, 0xf9, 0xcd, 0x85, 0x14, 0xea, 0x99, 0x82, 0xcc, 0xaf, 0xb3, 0x41, 0xb2, 0x38, 0x4d, 0xd9, 0x02, 0xf3, 0xd1, 0xab, 0x7a, 0xc6, 0x1d, 0xd2, 0x9c, 0x6f, 0x21, 0xba, - 0x5b, 0x86, 0x2f, 0x37, 0x30, 0xe3, 0x7c, 0xfd, 0xc4, 0xfd, 0x80, 0x6c, 0x22, 0xf2, 0x21} -}; + 0x5b, 0x86, 0x2f, 0x37, 0x30, 0xe3, 0x7c, 0xfd, 0xc4, 0xfd, 0x80, 0x6c, 0x22, 0xf2, 0x21}}; static const size_t test_lengths[2] = {64U, 375U}; diff --git a/nettls/ssl/chachapoly.c b/nettls/ssl/chachapoly.c index b4b9c160..61565f10 100644 --- a/nettls/ssl/chachapoly.c +++ b/nettls/ssl/chachapoly.c @@ -385,21 +385,15 @@ int mbedtls_chachapoly_auth_decrypt( #if defined(MBEDTLS_SELF_TEST) -static const unsigned char test_key[1][32] = { - {0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f} -}; +static const unsigned char test_key[1][32] = {{0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f}}; -static const unsigned char test_nonce[1][12] = { - { - 0x07, 0x00, 0x00, 0x00, /* 32-bit common part */ - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 /* 64-bit IV */ - } -}; +static const unsigned char test_nonce[1][12] = {{ + 0x07, 0x00, 0x00, 0x00, /* 32-bit common part */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 /* 64-bit IV */ +}}; -static const unsigned char test_aad[1][12] = { - {0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7} -}; +static const unsigned char test_aad[1][12] = {{0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7}}; static const size_t test_aad_len[1] = {12U}; @@ -408,22 +402,18 @@ static const unsigned char test_input[1][114] = { 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x27, 0x39, 0x39, 0x3a, 0x20, 0x49, 0x66, 0x20, 0x49, 0x20, 0x63, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x6f, 0x6e, 0x65, 0x20, 0x74, 0x69, 0x70, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x75, 0x74, 0x75, 0x72, 0x65, 0x2c, 0x20, - 0x73, 0x75, 0x6e, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x77, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69, 0x74, 0x2e} -}; + 0x73, 0x75, 0x6e, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x77, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69, 0x74, 0x2e}}; static const unsigned char test_output[1][114] = { {0xd3, 0x1a, 0x8d, 0x34, 0x64, 0x8e, 0x60, 0xdb, 0x7b, 0x86, 0xaf, 0xbc, 0x53, 0xef, 0x7e, 0xc2, 0xa4, 0xad, 0xed, 0x51, 0x29, 0x6e, 0x08, 0xfe, 0xa9, 0xe2, 0xb5, 0xa7, 0x36, 0xee, 0x62, 0xd6, 0x3d, 0xbe, 0xa4, 0x5e, 0x8c, 0xa9, 0x67, 0x12, 0x82, 0xfa, 0xfb, 0x69, 0xda, 0x92, 0x72, 0x8b, 0x1a, 0x71, 0xde, 0x0a, 0x9e, 0x06, 0x0b, 0x29, 0x05, 0xd6, 0xa5, 0xb6, 0x7e, 0xcd, 0x3b, 0x36, 0x92, 0xdd, 0xbd, 0x7f, 0x2d, 0x77, 0x8b, 0x8c, 0x98, 0x03, 0xae, 0xe3, 0x28, 0x09, 0x1b, 0x58, 0xfa, 0xb3, 0x24, 0xe4, 0xfa, 0xd6, 0x75, 0x94, 0x55, 0x85, 0x80, 0x8b, - 0x48, 0x31, 0xd7, 0xbc, 0x3f, 0xf4, 0xde, 0xf0, 0x8e, 0x4b, 0x7a, 0x9d, 0xe5, 0x76, 0xd2, 0x65, 0x86, 0xce, 0xc6, 0x4b, 0x61, 0x16} -}; + 0x48, 0x31, 0xd7, 0xbc, 0x3f, 0xf4, 0xde, 0xf0, 0x8e, 0x4b, 0x7a, 0x9d, 0xe5, 0x76, 0xd2, 0x65, 0x86, 0xce, 0xc6, 0x4b, 0x61, 0x16}}; static const size_t test_input_len[1] = {114U}; -static const unsigned char test_mac[1][16] = { - {0x1a, 0xe1, 0x0b, 0x59, 0x4f, 0x09, 0xe2, 0x6a, 0x7e, 0x90, 0x2e, 0xcb, 0xd0, 0x60, 0x06, 0x91} -}; +static const unsigned char test_mac[1][16] = {{0x1a, 0xe1, 0x0b, 0x59, 0x4f, 0x09, 0xe2, 0x6a, 0x7e, 0x90, 0x2e, 0xcb, 0xd0, 0x60, 0x06, 0x91}}; #define ASSERT(cond, args) \ do { \ diff --git a/nettls/ssl/cipher_wrap.c b/nettls/ssl/cipher_wrap.c index 057f682b..4cbe73a2 100644 --- a/nettls/ssl/cipher_wrap.c +++ b/nettls/ssl/cipher_wrap.c @@ -1467,70 +1467,70 @@ static const mbedtls_cipher_info_t null_cipher_info = {MBEDTLS_CIPHER_NULL, MBED const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = { #if defined(MBEDTLS_AES_C) - {MBEDTLS_CIPHER_AES_128_ECB, &aes_128_ecb_info }, - {MBEDTLS_CIPHER_AES_192_ECB, &aes_192_ecb_info }, - {MBEDTLS_CIPHER_AES_256_ECB, &aes_256_ecb_info }, + {MBEDTLS_CIPHER_AES_128_ECB, &aes_128_ecb_info}, + {MBEDTLS_CIPHER_AES_192_ECB, &aes_192_ecb_info}, + {MBEDTLS_CIPHER_AES_256_ECB, &aes_256_ecb_info}, #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_CIPHER_AES_128_CBC, &aes_128_cbc_info }, - {MBEDTLS_CIPHER_AES_192_CBC, &aes_192_cbc_info }, - {MBEDTLS_CIPHER_AES_256_CBC, &aes_256_cbc_info }, + {MBEDTLS_CIPHER_AES_128_CBC, &aes_128_cbc_info}, + {MBEDTLS_CIPHER_AES_192_CBC, &aes_192_cbc_info}, + {MBEDTLS_CIPHER_AES_256_CBC, &aes_256_cbc_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_CFB) - {MBEDTLS_CIPHER_AES_128_CFB128, &aes_128_cfb128_info }, - {MBEDTLS_CIPHER_AES_192_CFB128, &aes_192_cfb128_info }, - {MBEDTLS_CIPHER_AES_256_CFB128, &aes_256_cfb128_info }, + {MBEDTLS_CIPHER_AES_128_CFB128, &aes_128_cfb128_info}, + {MBEDTLS_CIPHER_AES_192_CFB128, &aes_192_cfb128_info}, + {MBEDTLS_CIPHER_AES_256_CFB128, &aes_256_cfb128_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_OFB) - {MBEDTLS_CIPHER_AES_128_OFB, &aes_128_ofb_info }, - {MBEDTLS_CIPHER_AES_192_OFB, &aes_192_ofb_info }, - {MBEDTLS_CIPHER_AES_256_OFB, &aes_256_ofb_info }, + {MBEDTLS_CIPHER_AES_128_OFB, &aes_128_ofb_info}, + {MBEDTLS_CIPHER_AES_192_OFB, &aes_192_ofb_info}, + {MBEDTLS_CIPHER_AES_256_OFB, &aes_256_ofb_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_CTR) - {MBEDTLS_CIPHER_AES_128_CTR, &aes_128_ctr_info }, - {MBEDTLS_CIPHER_AES_192_CTR, &aes_192_ctr_info }, - {MBEDTLS_CIPHER_AES_256_CTR, &aes_256_ctr_info }, + {MBEDTLS_CIPHER_AES_128_CTR, &aes_128_ctr_info}, + {MBEDTLS_CIPHER_AES_192_CTR, &aes_192_ctr_info}, + {MBEDTLS_CIPHER_AES_256_CTR, &aes_256_ctr_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_XTS) - {MBEDTLS_CIPHER_AES_128_XTS, &aes_128_xts_info }, - {MBEDTLS_CIPHER_AES_256_XTS, &aes_256_xts_info }, + {MBEDTLS_CIPHER_AES_128_XTS, &aes_128_xts_info}, + {MBEDTLS_CIPHER_AES_256_XTS, &aes_256_xts_info}, #endif #if defined(MBEDTLS_GCM_C) - {MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info }, - {MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info }, - {MBEDTLS_CIPHER_AES_256_GCM, &aes_256_gcm_info }, + {MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info}, + {MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info}, + {MBEDTLS_CIPHER_AES_256_GCM, &aes_256_gcm_info}, #endif #if defined(MBEDTLS_CCM_C) - {MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info }, - {MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info }, - {MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info }, + {MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info}, + {MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info}, + {MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info}, #endif -#endif /* MBEDTLS_AES_C */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_ARC4_C) - {MBEDTLS_CIPHER_ARC4_128, &arc4_128_info }, + {MBEDTLS_CIPHER_ARC4_128, &arc4_128_info}, #endif #if defined(MBEDTLS_BLOWFISH_C) - {MBEDTLS_CIPHER_BLOWFISH_ECB, &blowfish_ecb_info }, + {MBEDTLS_CIPHER_BLOWFISH_ECB, &blowfish_ecb_info}, #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_CIPHER_BLOWFISH_CBC, &blowfish_cbc_info }, + {MBEDTLS_CIPHER_BLOWFISH_CBC, &blowfish_cbc_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_CFB) - {MBEDTLS_CIPHER_BLOWFISH_CFB64, &blowfish_cfb64_info }, + {MBEDTLS_CIPHER_BLOWFISH_CFB64, &blowfish_cfb64_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_CTR) - {MBEDTLS_CIPHER_BLOWFISH_CTR, &blowfish_ctr_info }, + {MBEDTLS_CIPHER_BLOWFISH_CTR, &blowfish_ctr_info}, #endif -#endif /* MBEDTLS_BLOWFISH_C */ +#endif /* MBEDTLS_BLOWFISH_C */ #if defined(MBEDTLS_CAMELLIA_C) - {MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info }, - {MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info }, - {MBEDTLS_CIPHER_CAMELLIA_256_ECB, &camellia_256_ecb_info }, + {MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info}, + {MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info}, + {MBEDTLS_CIPHER_CAMELLIA_256_ECB, &camellia_256_ecb_info}, #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_CIPHER_CAMELLIA_128_CBC, &camellia_128_cbc_info }, - {MBEDTLS_CIPHER_CAMELLIA_192_CBC, &camellia_192_cbc_info }, - {MBEDTLS_CIPHER_CAMELLIA_256_CBC, &camellia_256_cbc_info }, + {MBEDTLS_CIPHER_CAMELLIA_128_CBC, &camellia_128_cbc_info}, + {MBEDTLS_CIPHER_CAMELLIA_192_CBC, &camellia_192_cbc_info}, + {MBEDTLS_CIPHER_CAMELLIA_256_CBC, &camellia_256_cbc_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_CFB) {MBEDTLS_CIPHER_CAMELLIA_128_CFB128, &camellia_128_cfb128_info}, @@ -1538,78 +1538,77 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = { {MBEDTLS_CIPHER_CAMELLIA_256_CFB128, &camellia_256_cfb128_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_CTR) - {MBEDTLS_CIPHER_CAMELLIA_128_CTR, &camellia_128_ctr_info }, - {MBEDTLS_CIPHER_CAMELLIA_192_CTR, &camellia_192_ctr_info }, - {MBEDTLS_CIPHER_CAMELLIA_256_CTR, &camellia_256_ctr_info }, + {MBEDTLS_CIPHER_CAMELLIA_128_CTR, &camellia_128_ctr_info}, + {MBEDTLS_CIPHER_CAMELLIA_192_CTR, &camellia_192_ctr_info}, + {MBEDTLS_CIPHER_CAMELLIA_256_CTR, &camellia_256_ctr_info}, #endif #if defined(MBEDTLS_GCM_C) - {MBEDTLS_CIPHER_CAMELLIA_128_GCM, &camellia_128_gcm_info }, - {MBEDTLS_CIPHER_CAMELLIA_192_GCM, &camellia_192_gcm_info }, - {MBEDTLS_CIPHER_CAMELLIA_256_GCM, &camellia_256_gcm_info }, + {MBEDTLS_CIPHER_CAMELLIA_128_GCM, &camellia_128_gcm_info}, + {MBEDTLS_CIPHER_CAMELLIA_192_GCM, &camellia_192_gcm_info}, + {MBEDTLS_CIPHER_CAMELLIA_256_GCM, &camellia_256_gcm_info}, #endif #if defined(MBEDTLS_CCM_C) - {MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info }, - {MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info }, - {MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info }, + {MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info}, + {MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info}, + {MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info}, #endif -#endif /* MBEDTLS_CAMELLIA_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_ARIA_C) - {MBEDTLS_CIPHER_ARIA_128_ECB, &aria_128_ecb_info }, - {MBEDTLS_CIPHER_ARIA_192_ECB, &aria_192_ecb_info }, - {MBEDTLS_CIPHER_ARIA_256_ECB, &aria_256_ecb_info }, + {MBEDTLS_CIPHER_ARIA_128_ECB, &aria_128_ecb_info}, + {MBEDTLS_CIPHER_ARIA_192_ECB, &aria_192_ecb_info}, + {MBEDTLS_CIPHER_ARIA_256_ECB, &aria_256_ecb_info}, #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_CIPHER_ARIA_128_CBC, &aria_128_cbc_info }, - {MBEDTLS_CIPHER_ARIA_192_CBC, &aria_192_cbc_info }, - {MBEDTLS_CIPHER_ARIA_256_CBC, &aria_256_cbc_info }, + {MBEDTLS_CIPHER_ARIA_128_CBC, &aria_128_cbc_info}, + {MBEDTLS_CIPHER_ARIA_192_CBC, &aria_192_cbc_info}, + {MBEDTLS_CIPHER_ARIA_256_CBC, &aria_256_cbc_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_CFB) - {MBEDTLS_CIPHER_ARIA_128_CFB128, &aria_128_cfb128_info }, - {MBEDTLS_CIPHER_ARIA_192_CFB128, &aria_192_cfb128_info }, - {MBEDTLS_CIPHER_ARIA_256_CFB128, &aria_256_cfb128_info }, + {MBEDTLS_CIPHER_ARIA_128_CFB128, &aria_128_cfb128_info}, + {MBEDTLS_CIPHER_ARIA_192_CFB128, &aria_192_cfb128_info}, + {MBEDTLS_CIPHER_ARIA_256_CFB128, &aria_256_cfb128_info}, #endif #if defined(MBEDTLS_CIPHER_MODE_CTR) - {MBEDTLS_CIPHER_ARIA_128_CTR, &aria_128_ctr_info }, - {MBEDTLS_CIPHER_ARIA_192_CTR, &aria_192_ctr_info }, - {MBEDTLS_CIPHER_ARIA_256_CTR, &aria_256_ctr_info }, + {MBEDTLS_CIPHER_ARIA_128_CTR, &aria_128_ctr_info}, + {MBEDTLS_CIPHER_ARIA_192_CTR, &aria_192_ctr_info}, + {MBEDTLS_CIPHER_ARIA_256_CTR, &aria_256_ctr_info}, #endif #if defined(MBEDTLS_GCM_C) - {MBEDTLS_CIPHER_ARIA_128_GCM, &aria_128_gcm_info }, - {MBEDTLS_CIPHER_ARIA_192_GCM, &aria_192_gcm_info }, - {MBEDTLS_CIPHER_ARIA_256_GCM, &aria_256_gcm_info }, + {MBEDTLS_CIPHER_ARIA_128_GCM, &aria_128_gcm_info}, + {MBEDTLS_CIPHER_ARIA_192_GCM, &aria_192_gcm_info}, + {MBEDTLS_CIPHER_ARIA_256_GCM, &aria_256_gcm_info}, #endif #if defined(MBEDTLS_CCM_C) - {MBEDTLS_CIPHER_ARIA_128_CCM, &aria_128_ccm_info }, - {MBEDTLS_CIPHER_ARIA_192_CCM, &aria_192_ccm_info }, - {MBEDTLS_CIPHER_ARIA_256_CCM, &aria_256_ccm_info }, + {MBEDTLS_CIPHER_ARIA_128_CCM, &aria_128_ccm_info}, + {MBEDTLS_CIPHER_ARIA_192_CCM, &aria_192_ccm_info}, + {MBEDTLS_CIPHER_ARIA_256_CCM, &aria_256_ccm_info}, #endif -#endif /* MBEDTLS_ARIA_C */ +#endif /* MBEDTLS_ARIA_C */ #if defined(MBEDTLS_DES_C) - {MBEDTLS_CIPHER_DES_ECB, &des_ecb_info }, - {MBEDTLS_CIPHER_DES_EDE_ECB, &des_ede_ecb_info }, - {MBEDTLS_CIPHER_DES_EDE3_ECB, &des_ede3_ecb_info }, + {MBEDTLS_CIPHER_DES_ECB, &des_ecb_info}, + {MBEDTLS_CIPHER_DES_EDE_ECB, &des_ede_ecb_info}, + {MBEDTLS_CIPHER_DES_EDE3_ECB, &des_ede3_ecb_info}, #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_CIPHER_DES_CBC, &des_cbc_info }, - {MBEDTLS_CIPHER_DES_EDE_CBC, &des_ede_cbc_info }, - {MBEDTLS_CIPHER_DES_EDE3_CBC, &des_ede3_cbc_info }, + {MBEDTLS_CIPHER_DES_CBC, &des_cbc_info}, + {MBEDTLS_CIPHER_DES_EDE_CBC, &des_ede_cbc_info}, + {MBEDTLS_CIPHER_DES_EDE3_CBC, &des_ede3_cbc_info}, #endif -#endif /* MBEDTLS_DES_C */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_CHACHA20_C) - {MBEDTLS_CIPHER_CHACHA20, &chacha20_info }, + {MBEDTLS_CIPHER_CHACHA20, &chacha20_info}, #endif #if defined(MBEDTLS_CHACHAPOLY_C) - {MBEDTLS_CIPHER_CHACHA20_POLY1305, &chachapoly_info }, + {MBEDTLS_CIPHER_CHACHA20_POLY1305, &chachapoly_info}, #endif #if defined(MBEDTLS_CIPHER_NULL_CIPHER) - {MBEDTLS_CIPHER_NULL, &null_cipher_info }, -#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ + {MBEDTLS_CIPHER_NULL, &null_cipher_info}, +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ - {MBEDTLS_CIPHER_NONE, NULL } -}; + {MBEDTLS_CIPHER_NONE, NULL}}; #define NUM_CIPHERS sizeof mbedtls_cipher_definitions / sizeof mbedtls_cipher_definitions[0] int mbedtls_cipher_supported[NUM_CIPHERS]; diff --git a/nettls/ssl/cmac.c b/nettls/ssl/cmac.c index 34c06c2c..1c2ea2c7 100644 --- a/nettls/ssl/cmac.c +++ b/nettls/ssl/cmac.c @@ -477,8 +477,7 @@ static const unsigned char aes_128_subkeys[2][MBEDTLS_AES_BLOCK_SIZE] = { {/* K1 */ 0xfb, 0xee, 0xd6, 0x18, 0x35, 0x71, 0x33, 0x66, 0x7c, 0x85, 0xe0, 0x8f, 0x72, 0x36, 0xa8, 0xde}, {/* K2 */ - 0xf7, 0xdd, 0xac, 0x30, 0x6a, 0xe2, 0x66, 0xcc, 0xf9, 0x0b, 0xc1, 0x1e, 0xe4, 0x6d, 0x51, 0x3b} -}; + 0xf7, 0xdd, 0xac, 0x30, 0x6a, 0xe2, 0x66, 0xcc, 0xf9, 0x0b, 0xc1, 0x1e, 0xe4, 0x6d, 0x51, 0x3b}}; static const unsigned char aes_128_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_AES_BLOCK_SIZE] = { {/* Example #1 */ 0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28, 0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46}, @@ -487,8 +486,7 @@ static const unsigned char aes_128_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTL {/* Example #3 */ 0x7d, 0x85, 0x44, 0x9e, 0xa6, 0xea, 0x19, 0xc8, 0x23, 0xa7, 0xbf, 0x78, 0x83, 0x7d, 0xfa, 0xde}, {/* Example #4 */ - 0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92, 0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe} -}; + 0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92, 0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe}}; /* CMAC-AES192 Test Data */ static const unsigned char aes_192_key[24] = {0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, 0x10, 0xf3, 0x2b, @@ -497,8 +495,7 @@ static const unsigned char aes_192_subkeys[2][MBEDTLS_AES_BLOCK_SIZE] = { {/* K1 */ 0x44, 0x8a, 0x5b, 0x1c, 0x93, 0x51, 0x4b, 0x27, 0x3e, 0xe6, 0x43, 0x9d, 0xd4, 0xda, 0xa2, 0x96}, {/* K2 */ - 0x89, 0x14, 0xb6, 0x39, 0x26, 0xa2, 0x96, 0x4e, 0x7d, 0xcc, 0x87, 0x3b, 0xa9, 0xb5, 0x45, 0x2c} -}; + 0x89, 0x14, 0xb6, 0x39, 0x26, 0xa2, 0x96, 0x4e, 0x7d, 0xcc, 0x87, 0x3b, 0xa9, 0xb5, 0x45, 0x2c}}; static const unsigned char aes_192_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_AES_BLOCK_SIZE] = { {/* Example #1 */ 0xd1, 0x7d, 0xdf, 0x46, 0xad, 0xaa, 0xcd, 0xe5, 0x31, 0xca, 0xc4, 0x83, 0xde, 0x7a, 0x93, 0x67}, @@ -507,8 +504,7 @@ static const unsigned char aes_192_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTL {/* Example #3 */ 0x3d, 0x75, 0xc1, 0x94, 0xed, 0x96, 0x07, 0x04, 0x44, 0xa9, 0xfa, 0x7e, 0xc7, 0x40, 0xec, 0xf8}, {/* Example #4 */ - 0xa1, 0xd5, 0xdf, 0x0e, 0xed, 0x79, 0x0f, 0x79, 0x4d, 0x77, 0x58, 0x96, 0x59, 0xf3, 0x9a, 0x11} -}; + 0xa1, 0xd5, 0xdf, 0x0e, 0xed, 0x79, 0x0f, 0x79, 0x4d, 0x77, 0x58, 0x96, 0x59, 0xf3, 0x9a, 0x11}}; /* CMAC-AES256 Test Data */ static const unsigned char aes_256_key[32] = {0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, @@ -517,8 +513,7 @@ static const unsigned char aes_256_subkeys[2][MBEDTLS_AES_BLOCK_SIZE] = { {/* K1 */ 0xca, 0xd1, 0xed, 0x03, 0x29, 0x9e, 0xed, 0xac, 0x2e, 0x9a, 0x99, 0x80, 0x86, 0x21, 0x50, 0x2f}, {/* K2 */ - 0x95, 0xa3, 0xda, 0x06, 0x53, 0x3d, 0xdb, 0x58, 0x5d, 0x35, 0x33, 0x01, 0x0c, 0x42, 0xa0, 0xd9} -}; + 0x95, 0xa3, 0xda, 0x06, 0x53, 0x3d, 0xdb, 0x58, 0x5d, 0x35, 0x33, 0x01, 0x0c, 0x42, 0xa0, 0xd9}}; static const unsigned char aes_256_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_AES_BLOCK_SIZE] = { {/* Example #1 */ 0x02, 0x89, 0x62, 0xf6, 0x1b, 0x7b, 0xf8, 0x9e, 0xfc, 0x6b, 0x55, 0x1f, 0x46, 0x67, 0xd9, 0x83}, @@ -527,8 +522,7 @@ static const unsigned char aes_256_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTL {/* Example #3 */ 0x15, 0x67, 0x27, 0xdc, 0x08, 0x78, 0x94, 0x4a, 0x02, 0x3c, 0x1f, 0xe0, 0x3b, 0xad, 0x6d, 0x93}, {/* Example #4 */ - 0xe1, 0x99, 0x21, 0x90, 0x54, 0x9f, 0x6e, 0xd5, 0x69, 0x6a, 0x2c, 0x05, 0x6c, 0x31, 0x54, 0x10} -}; + 0xe1, 0x99, 0x21, 0x90, 0x54, 0x9f, 0x6e, 0xd5, 0x69, 0x6a, 0x2c, 0x05, 0x6c, 0x31, 0x54, 0x10}}; #endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_DES_C) @@ -547,8 +541,7 @@ static const unsigned char des3_2key_subkeys[2][8] = { {/* K1 */ 0x0d, 0xd2, 0xcb, 0x7a, 0x3d, 0x88, 0x88, 0xd9}, {/* K2 */ - 0x1b, 0xa5, 0x96, 0xf4, 0x7b, 0x11, 0x11, 0xb2} -}; + 0x1b, 0xa5, 0x96, 0xf4, 0x7b, 0x11, 0x11, 0xb2}}; static const unsigned char des3_2key_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_DES3_BLOCK_SIZE] = { {/* Sample #1 */ 0x79, 0xce, 0x52, 0xa7, 0xf7, 0x86, 0xa9, 0x60}, @@ -557,8 +550,7 @@ static const unsigned char des3_2key_expected_result[NB_CMAC_TESTS_PER_KEY][MBED {/* Sample #3 */ 0xc0, 0x6d, 0x37, 0x7e, 0xcd, 0x10, 0x19, 0x69}, {/* Sample #4 */ - 0x9c, 0xd3, 0x35, 0x80, 0xf9, 0xb6, 0x4d, 0xfb} -}; + 0x9c, 0xd3, 0x35, 0x80, 0xf9, 0xb6, 0x4d, 0xfb}}; /* CMAC-TDES (Generation) - 3 Key Test Data */ static const unsigned char des3_3key_key[24] = { @@ -572,8 +564,7 @@ static const unsigned char des3_3key_subkeys[2][8] = { {/* K1 */ 0x9d, 0x74, 0xe7, 0x39, 0x33, 0x17, 0x96, 0xc0}, {/* K2 */ - 0x3a, 0xe9, 0xce, 0x72, 0x66, 0x2f, 0x2d, 0x9b} -}; + 0x3a, 0xe9, 0xce, 0x72, 0x66, 0x2f, 0x2d, 0x9b}}; static const unsigned char des3_3key_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_DES3_BLOCK_SIZE] = { {/* Sample #1 */ 0x7d, 0xb0, 0xd3, 0x7d, 0xf9, 0x36, 0xc5, 0x50}, @@ -582,8 +573,7 @@ static const unsigned char des3_3key_expected_result[NB_CMAC_TESTS_PER_KEY][MBED {/* Sample #3 */ 0x6c, 0x9f, 0x3e, 0xe4, 0x92, 0x3f, 0x6b, 0xe2}, {/* Sample #4 */ - 0x99, 0x42, 0x9b, 0xd0, 0xbF, 0x79, 0x04, 0xe5} -}; + 0x99, 0x42, 0x9b, 0xd0, 0xbF, 0x79, 0x04, 0xe5}}; #endif /* MBEDTLS_DES_C */ @@ -603,8 +593,7 @@ static const unsigned char PRFM[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0 static const unsigned char PRFT[NB_PRF_TESTS][16] = { {0x84, 0xa3, 0x48, 0xa4, 0xa4, 0x5d, 0x23, 0x5b, 0xab, 0xff, 0xfc, 0x0d, 0x2b, 0x4d, 0xa0, 0x9a}, {0x98, 0x0a, 0xe8, 0x7b, 0x5f, 0x4c, 0x9c, 0x52, 0x14, 0xf5, 0xb6, 0xa8, 0x45, 0x5e, 0x4c, 0x2d}, - {0x29, 0x0d, 0x9e, 0x11, 0x2e, 0xdb, 0x09, 0xee, 0x14, 0x1f, 0xcf, 0x64, 0xc0, 0xb7, 0x2f, 0x3d} -}; + {0x29, 0x0d, 0x9e, 0x11, 0x2e, 0xdb, 0x09, 0xee, 0x14, 0x1f, 0xcf, 0x64, 0xc0, 0xb7, 0x2f, 0x3d}}; #endif /* MBEDTLS_AES_C */ static int cmac_test_subkeys( diff --git a/nettls/ssl/des.c b/nettls/ssl/des.c index 9e435251..040ca256 100644 --- a/nettls/ssl/des.c +++ b/nettls/ssl/des.c @@ -319,24 +319,15 @@ int mbedtls_des_key_check_key_parity(const unsigned char key[MBEDTLS_DES_KEY_SIZ #define WEAK_KEY_COUNT 16 static const unsigned char weak_key_table[WEAK_KEY_COUNT][MBEDTLS_DES_KEY_SIZE] = { - {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, - {0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE}, - {0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E}, - {0xE0, 0xE0, 0xE0, 0xE0, 0xF1, 0xF1, 0xF1, 0xF1}, - - {0x01, 0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E}, - {0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E, 0x01}, - {0x01, 0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1}, - {0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1, 0x01}, - {0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE}, - {0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01}, - {0x1F, 0xE0, 0x1F, 0xE0, 0x0E, 0xF1, 0x0E, 0xF1}, - {0xE0, 0x1F, 0xE0, 0x1F, 0xF1, 0x0E, 0xF1, 0x0E}, - {0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E, 0xFE}, - {0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E}, - {0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE}, - {0xFE, 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1} -}; + {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, {0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE}, + {0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E}, {0xE0, 0xE0, 0xE0, 0xE0, 0xF1, 0xF1, 0xF1, 0xF1}, + + {0x01, 0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E}, {0x1F, 0x01, 0x1F, 0x01, 0x0E, 0x01, 0x0E, 0x01}, + {0x01, 0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1}, {0xE0, 0x01, 0xE0, 0x01, 0xF1, 0x01, 0xF1, 0x01}, + {0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE}, {0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01}, + {0x1F, 0xE0, 0x1F, 0xE0, 0x0E, 0xF1, 0x0E, 0xF1}, {0xE0, 0x1F, 0xE0, 0x1F, 0xF1, 0x0E, 0xF1, 0x0E}, + {0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E, 0xFE}, {0xFE, 0x1F, 0xFE, 0x1F, 0xFE, 0x0E, 0xFE, 0x0E}, + {0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE}, {0xFE, 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1}}; int mbedtls_des_key_check_weak(const unsigned char key[MBEDTLS_DES_KEY_SIZE]) { @@ -701,14 +692,12 @@ static const unsigned char des3_test_buf[8] = {0x4E, 0x6F, 0x77, 0x20, 0x69, 0x7 static const unsigned char des3_test_ecb_dec[3][8] = { {0xCD, 0xD6, 0x4F, 0x2F, 0x94, 0x27, 0xC1, 0x5D}, {0x69, 0x96, 0xC8, 0xFA, 0x47, 0xA2, 0xAB, 0xEB}, - {0x83, 0x25, 0x39, 0x76, 0x44, 0x09, 0x1A, 0x0A} -}; + {0x83, 0x25, 0x39, 0x76, 0x44, 0x09, 0x1A, 0x0A}}; static const unsigned char des3_test_ecb_enc[3][8] = { {0x6A, 0x2A, 0x19, 0xF4, 0x1E, 0xCA, 0x85, 0x4B}, {0x03, 0xE6, 0x9F, 0x5B, 0xFA, 0x58, 0xEB, 0x42}, - {0xDD, 0x17, 0xE8, 0xB8, 0xB4, 0x37, 0xD2, 0x32} -}; + {0xDD, 0x17, 0xE8, 0xB8, 0xB4, 0x37, 0xD2, 0x32}}; #if defined(MBEDTLS_CIPHER_MODE_CBC) static const unsigned char des3_test_iv[8] = { @@ -718,14 +707,12 @@ static const unsigned char des3_test_iv[8] = { static const unsigned char des3_test_cbc_dec[3][8] = { {0x12, 0x9F, 0x40, 0xB9, 0xD2, 0x00, 0x56, 0xB3}, {0x47, 0x0E, 0xFC, 0x9A, 0x6B, 0x8E, 0xE3, 0x93}, - {0xC5, 0xCE, 0xCF, 0x63, 0xEC, 0xEC, 0x51, 0x4C} -}; + {0xC5, 0xCE, 0xCF, 0x63, 0xEC, 0xEC, 0x51, 0x4C}}; static const unsigned char des3_test_cbc_enc[3][8] = { {0x54, 0xF1, 0x5A, 0xF6, 0xEB, 0xE3, 0xA4, 0xB4}, {0x35, 0x76, 0x11, 0x56, 0x5F, 0xA1, 0x8E, 0x4D}, - {0xCB, 0x19, 0x1F, 0x85, 0xD1, 0xED, 0x84, 0x39} -}; + {0xCB, 0x19, 0x1F, 0x85, 0xD1, 0xED, 0x84, 0x39}}; #endif /* MBEDTLS_CIPHER_MODE_CBC */ /* diff --git a/nettls/ssl/ecp.c b/nettls/ssl/ecp.c index e9f384ca..3ff2610d 100644 --- a/nettls/ssl/ecp.c +++ b/nettls/ssl/ecp.c @@ -633,39 +633,39 @@ typedef enum { */ static const mbedtls_ecp_curve_info ecp_supported_curves[] = { #if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) - {MBEDTLS_ECP_DP_SECP521R1, 25, 521, "secp521r1" }, + {MBEDTLS_ECP_DP_SECP521R1, 25, 521, "secp521r1"}, #endif #if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) - {MBEDTLS_ECP_DP_BP512R1, 28, 512, "brainpoolP512r1"}, + {MBEDTLS_ECP_DP_BP512R1, 28, 512, "brainpoolP512r1"}, #endif #if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) - {MBEDTLS_ECP_DP_SECP384R1, 24, 384, "secp384r1" }, + {MBEDTLS_ECP_DP_SECP384R1, 24, 384, "secp384r1"}, #endif #if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) - {MBEDTLS_ECP_DP_BP384R1, 27, 384, "brainpoolP384r1"}, + {MBEDTLS_ECP_DP_BP384R1, 27, 384, "brainpoolP384r1"}, #endif #if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) - {MBEDTLS_ECP_DP_SECP256R1, 23, 256, "secp256r1" }, + {MBEDTLS_ECP_DP_SECP256R1, 23, 256, "secp256r1"}, #endif #if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) - {MBEDTLS_ECP_DP_SECP256K1, 22, 256, "secp256k1" }, + {MBEDTLS_ECP_DP_SECP256K1, 22, 256, "secp256k1"}, #endif #if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) - {MBEDTLS_ECP_DP_BP256R1, 26, 256, "brainpoolP256r1"}, + {MBEDTLS_ECP_DP_BP256R1, 26, 256, "brainpoolP256r1"}, #endif #if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) - {MBEDTLS_ECP_DP_SECP224R1, 21, 224, "secp224r1" }, + {MBEDTLS_ECP_DP_SECP224R1, 21, 224, "secp224r1"}, #endif #if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) - {MBEDTLS_ECP_DP_SECP224K1, 20, 224, "secp224k1" }, + {MBEDTLS_ECP_DP_SECP224K1, 20, 224, "secp224k1"}, #endif #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) - {MBEDTLS_ECP_DP_SECP192R1, 19, 192, "secp192r1" }, + {MBEDTLS_ECP_DP_SECP192R1, 19, 192, "secp192r1"}, #endif #if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) - {MBEDTLS_ECP_DP_SECP192K1, 18, 192, "secp192k1" }, + {MBEDTLS_ECP_DP_SECP192K1, 18, 192, "secp192k1"}, #endif - {MBEDTLS_ECP_DP_NONE, 0, 0, NULL }, + {MBEDTLS_ECP_DP_NONE, 0, 0, NULL}, }; #define ECP_NB_CURVES sizeof(ecp_supported_curves) / sizeof(ecp_supported_curves[0]) diff --git a/nettls/ssl/entropy.c b/nettls/ssl/entropy.c index dd49b70a..f765be82 100644 --- a/nettls/ssl/entropy.c +++ b/nettls/ssl/entropy.c @@ -241,9 +241,9 @@ int mbedtls_entropy_update_manual(mbedtls_entropy_context* ctx, const unsigned c */ static int entropy_gather_internal(mbedtls_entropy_context* ctx) { - int ret = 0; - int i = 0; - int have_one_strong = 0; + int ret = 0; + int i = 0; + int have_one_strong = 0; unsigned char buf[MBEDTLS_ENTROPY_MAX_GATHER]; size_t olen; diff --git a/nettls/ssl/md5.c b/nettls/ssl/md5.c index 6ee59ad4..948ad1b0 100644 --- a/nettls/ssl/md5.c +++ b/nettls/ssl/md5.c @@ -443,8 +443,7 @@ static const unsigned char md5_test_sum[7][16] = { {0xF9, 0x6B, 0x69, 0x7D, 0x7C, 0xB7, 0x93, 0x8D, 0x52, 0x5A, 0x2F, 0x31, 0xAA, 0xF1, 0x61, 0xD0}, {0xC3, 0xFC, 0xD3, 0xD7, 0x61, 0x92, 0xE4, 0x00, 0x7D, 0xFB, 0x49, 0x6C, 0xCA, 0x67, 0xE1, 0x3B}, {0xD1, 0x74, 0xAB, 0x98, 0xD2, 0x77, 0xD9, 0xF5, 0xA5, 0x61, 0x1C, 0x2C, 0x9F, 0x41, 0x9D, 0x9F}, - {0x57, 0xED, 0xF4, 0xA2, 0x2B, 0xE3, 0xC9, 0x55, 0xAC, 0x49, 0xDA, 0x2E, 0x21, 0x07, 0xB6, 0x7A} -}; + {0x57, 0xED, 0xF4, 0xA2, 0x2B, 0xE3, 0xC9, 0x55, 0xAC, 0x49, 0xDA, 0x2E, 0x21, 0x07, 0xB6, 0x7A}}; /* * Checkup routine diff --git a/nettls/ssl/nist_kw.c b/nettls/ssl/nist_kw.c index 1b02fe5f..55d34228 100644 --- a/nettls/ssl/nist_kw.c +++ b/nettls/ssl/nist_kw.c @@ -528,15 +528,13 @@ static const unsigned char kw_key[KW_TESTS][32] = { {0x75, 0x75, 0xda, 0x3a, 0x93, 0x60, 0x7c, 0xc2, 0xbf, 0xd8, 0xce, 0xc7, 0xaa, 0xdf, 0xd9, 0xa6}, {0x2d, 0x85, 0x26, 0x08, 0x1d, 0x02, 0xfb, 0x5b, 0x85, 0xf6, 0x9a, 0xc2, 0x86, 0xec, 0xd5, 0x7d, 0x40, 0xdf, 0x5d, 0xf3, 0x49, 0x47, 0x44, 0xd3}, {0x11, 0x2a, 0xd4, 0x1b, 0x48, 0x56, 0xc7, 0x25, 0x4a, 0x98, 0x48, 0xd3, 0x0f, 0xdd, 0x78, 0x33, - 0x5b, 0x03, 0x9a, 0x48, 0xa8, 0x96, 0x2c, 0x4d, 0x1c, 0xb7, 0x8e, 0xab, 0xd5, 0xda, 0xd7, 0x88} -}; + 0x5b, 0x03, 0x9a, 0x48, 0xa8, 0x96, 0x2c, 0x4d, 0x1c, 0xb7, 0x8e, 0xab, 0xd5, 0xda, 0xd7, 0x88}}; static const unsigned char kw_msg[KW_TESTS][40] = { {0x42, 0x13, 0x6d, 0x3c, 0x38, 0x4a, 0x3e, 0xea, 0xc9, 0x5a, 0x06, 0x6f, 0xd2, 0x8f, 0xed, 0x3f}, {0x95, 0xc1, 0x1b, 0xf5, 0x35, 0x3a, 0xfe, 0xdb, 0x98, 0xfd, 0xd6, 0xc8, 0xca, 0x6f, 0xdb, 0x6d, 0xa5, 0x4b, 0x74, 0xb4, 0x99, 0x0f, 0xdc, 0x45, 0xc0, 0x9d, 0x15, 0x8f, 0x51, 0xce, 0x62, 0x9d, 0xe2, 0xaf, 0x26, 0xe3, 0x25, 0x0e, 0x6b, 0x4c}, - {0x1b, 0x20, 0xbf, 0x19, 0x90, 0xb0, 0x65, 0xd7, 0x98, 0xe1, 0xb3, 0x22, 0x64, 0xad, 0x50, 0xa8, 0x74, 0x74, 0x92, 0xba, 0x09, 0xa0, 0x4d, 0xd1} -}; + {0x1b, 0x20, 0xbf, 0x19, 0x90, 0xb0, 0x65, 0xd7, 0x98, 0xe1, 0xb3, 0x22, 0x64, 0xad, 0x50, 0xa8, 0x74, 0x74, 0x92, 0xba, 0x09, 0xa0, 0x4d, 0xd1}}; static const size_t kw_msg_len[KW_TESTS] = {16, 40, 24}; static const size_t kw_out_len[KW_TESTS] = {24, 48, 32}; @@ -545,30 +543,26 @@ static const unsigned char kw_res[KW_TESTS][48] = { {0x44, 0x3c, 0x6f, 0x15, 0x09, 0x83, 0x71, 0x91, 0x3e, 0x5c, 0x81, 0x4c, 0xa1, 0xa0, 0x42, 0xec, 0x68, 0x2f, 0x7b, 0x13, 0x6d, 0x24, 0x3a, 0x4d, 0x6c, 0x42, 0x6f, 0xc6, 0x97, 0x15, 0x63, 0xe8, 0xa1, 0x4a, 0x55, 0x8e, 0x09, 0x64, 0x16, 0x19, 0xbf, 0x03, 0xfc, 0xaf, 0x90, 0xb1, 0xfc, 0x2d}, {0xba, 0x8a, 0x25, 0x9a, 0x47, 0x1b, 0x78, 0x7d, 0xd5, 0xd5, 0x40, 0xec, 0x25, 0xd4, 0x3d, 0x87, - 0x20, 0x0f, 0xda, 0xdc, 0x6d, 0x1f, 0x05, 0xd9, 0x16, 0x58, 0x4f, 0xa9, 0xf6, 0xcb, 0xf5, 0x12} -}; + 0x20, 0x0f, 0xda, 0xdc, 0x6d, 0x1f, 0x05, 0xd9, 0x16, 0x58, 0x4f, 0xa9, 0xf6, 0xcb, 0xf5, 0x12}}; static const unsigned char kwp_key[KW_TESTS][32] = { {0x78, 0x65, 0xe2, 0x0f, 0x3c, 0x21, 0x65, 0x9a, 0xb4, 0x69, 0x0b, 0x62, 0x9c, 0xdf, 0x3c, 0xc4}, {0xf5, 0xf8, 0x96, 0xa3, 0xbd, 0x2f, 0x4a, 0x98, 0x23, 0xef, 0x16, 0x2b, 0x00, 0xb8, 0x05, 0xd7, 0xde, 0x1e, 0xa4, 0x66, 0x26, 0x96, 0xa2, 0x58}, {0x95, 0xda, 0x27, 0x00, 0xca, 0x6f, 0xd9, 0xa5, 0x25, 0x54, 0xee, 0x2a, 0x8d, 0xf1, 0x38, 0x6f, - 0x5b, 0x94, 0xa1, 0xa6, 0x0e, 0xd8, 0xa4, 0xae, 0xf6, 0x0a, 0x8d, 0x61, 0xab, 0x5f, 0x22, 0x5a} -}; + 0x5b, 0x94, 0xa1, 0xa6, 0x0e, 0xd8, 0xa4, 0xae, 0xf6, 0x0a, 0x8d, 0x61, 0xab, 0x5f, 0x22, 0x5a}}; static const unsigned char kwp_msg[KW_TESTS][31] = { {0xbd, 0x68, 0x43, 0xd4, 0x20, 0x37, 0x8d, 0xc8, 0x96}, {0x6c, 0xcd, 0xd5, 0x85, 0x18, 0x40, 0x97, 0xeb, 0xd5, 0xc3, 0xaf, 0x3e, 0x47, 0xd0, 0x2c, 0x19, 0x14, 0x7b, 0x4d, 0x99, 0x5f, 0x96, 0x43, 0x66, 0x91, 0x56, 0x75, 0x8c, 0x13, 0x16, 0x8f}, - {0xd1} -}; + {0xd1}}; static const size_t kwp_msg_len[KW_TESTS] = {9, 31, 1}; static const unsigned char kwp_res[KW_TESTS][48] = { {0x41, 0xec, 0xa9, 0x56, 0xd4, 0xaa, 0x04, 0x7e, 0xb5, 0xcf, 0x4e, 0xfe, 0x65, 0x96, 0x61, 0xe7, 0x4d, 0xb6, 0xf8, 0xc5, 0x64, 0xe2, 0x35, 0x00}, {0x4e, 0x9b, 0xc2, 0xbc, 0xbc, 0x6c, 0x1e, 0x13, 0xd3, 0x35, 0xbc, 0xc0, 0xf7, 0x73, 0x6a, 0x88, 0xfa, 0x87, 0x53, 0x66, 0x15, 0xbb, 0x8e, 0x63, 0x8b, 0xcc, 0x81, 0x66, 0x84, 0x68, 0x17, 0x90, 0x67, 0xcf, 0xa9, 0x8a, 0x9d, 0x0e, 0x33, 0x26}, - {0x06, 0xba, 0x7a, 0xe6, 0xf3, 0x24, 0x8c, 0xfd, 0xcf, 0x26, 0x75, 0x07, 0xfa, 0x00, 0x1b, 0xc4} -}; + {0x06, 0xba, 0x7a, 0xe6, 0xf3, 0x24, 0x8c, 0xfd, 0xcf, 0x26, 0x75, 0x07, 0xfa, 0x00, 0x1b, 0xc4}}; static const size_t kwp_out_len[KW_TESTS] = {24, 40, 16}; int mbedtls_nist_kw_self_test(int verbose) diff --git a/nettls/ssl/oid.c b/nettls/ssl/oid.c index 3b27941d..875c93e9 100644 --- a/nettls/ssl/oid.c +++ b/nettls/ssl/oid.c @@ -188,66 +188,85 @@ typedef struct { static const oid_x520_attr_t oid_x520_attr_type[] = { { - {ADD_LEN(MBEDTLS_OID_AT_CN), "id-at-commonName", "Common Name"}, - "CN", }, + {ADD_LEN(MBEDTLS_OID_AT_CN), "id-at-commonName", "Common Name"}, + "CN", + }, { - {ADD_LEN(MBEDTLS_OID_AT_COUNTRY), "id-at-countryName", "Country"}, - "C", }, + {ADD_LEN(MBEDTLS_OID_AT_COUNTRY), "id-at-countryName", "Country"}, + "C", + }, { - {ADD_LEN(MBEDTLS_OID_AT_LOCALITY), "id-at-locality", "Locality"}, - "L", }, + {ADD_LEN(MBEDTLS_OID_AT_LOCALITY), "id-at-locality", "Locality"}, + "L", + }, { - {ADD_LEN(MBEDTLS_OID_AT_STATE), "id-at-state", "State"}, - "ST", }, + {ADD_LEN(MBEDTLS_OID_AT_STATE), "id-at-state", "State"}, + "ST", + }, { - {ADD_LEN(MBEDTLS_OID_AT_ORGANIZATION), "id-at-organizationName", "Organization"}, - "O", }, + {ADD_LEN(MBEDTLS_OID_AT_ORGANIZATION), "id-at-organizationName", "Organization"}, + "O", + }, { - {ADD_LEN(MBEDTLS_OID_AT_ORG_UNIT), "id-at-organizationalUnitName", "Org Unit"}, - "OU", }, + {ADD_LEN(MBEDTLS_OID_AT_ORG_UNIT), "id-at-organizationalUnitName", "Org Unit"}, + "OU", + }, { - {ADD_LEN(MBEDTLS_OID_PKCS9_EMAIL), "emailAddress", "E-mail address"}, - "emailAddress", }, + {ADD_LEN(MBEDTLS_OID_PKCS9_EMAIL), "emailAddress", "E-mail address"}, + "emailAddress", + }, { - {ADD_LEN(MBEDTLS_OID_AT_SERIAL_NUMBER), "id-at-serialNumber", "Serial number"}, - "serialNumber", }, + {ADD_LEN(MBEDTLS_OID_AT_SERIAL_NUMBER), "id-at-serialNumber", "Serial number"}, + "serialNumber", + }, { - {ADD_LEN(MBEDTLS_OID_AT_POSTAL_ADDRESS), "id-at-postalAddress", "Postal address"}, - "postalAddress", }, + {ADD_LEN(MBEDTLS_OID_AT_POSTAL_ADDRESS), "id-at-postalAddress", "Postal address"}, + "postalAddress", + }, { - {ADD_LEN(MBEDTLS_OID_AT_POSTAL_CODE), "id-at-postalCode", "Postal code"}, - "postalCode", }, + {ADD_LEN(MBEDTLS_OID_AT_POSTAL_CODE), "id-at-postalCode", "Postal code"}, + "postalCode", + }, { - {ADD_LEN(MBEDTLS_OID_AT_SUR_NAME), "id-at-surName", "Surname"}, - "SN", }, + {ADD_LEN(MBEDTLS_OID_AT_SUR_NAME), "id-at-surName", "Surname"}, + "SN", + }, { - {ADD_LEN(MBEDTLS_OID_AT_GIVEN_NAME), "id-at-givenName", "Given name"}, - "GN", }, + {ADD_LEN(MBEDTLS_OID_AT_GIVEN_NAME), "id-at-givenName", "Given name"}, + "GN", + }, { - {ADD_LEN(MBEDTLS_OID_AT_INITIALS), "id-at-initials", "Initials"}, - "initials", }, + {ADD_LEN(MBEDTLS_OID_AT_INITIALS), "id-at-initials", "Initials"}, + "initials", + }, { - {ADD_LEN(MBEDTLS_OID_AT_GENERATION_QUALIFIER), "id-at-generationQualifier", "Generation qualifier"}, - "generationQualifier", }, + {ADD_LEN(MBEDTLS_OID_AT_GENERATION_QUALIFIER), "id-at-generationQualifier", "Generation qualifier"}, + "generationQualifier", + }, { - {ADD_LEN(MBEDTLS_OID_AT_TITLE), "id-at-title", "Title"}, - "title", }, + {ADD_LEN(MBEDTLS_OID_AT_TITLE), "id-at-title", "Title"}, + "title", + }, { - {ADD_LEN(MBEDTLS_OID_AT_DN_QUALIFIER), "id-at-dnQualifier", "Distinguished Name qualifier"}, - "dnQualifier", }, + {ADD_LEN(MBEDTLS_OID_AT_DN_QUALIFIER), "id-at-dnQualifier", "Distinguished Name qualifier"}, + "dnQualifier", + }, { - {ADD_LEN(MBEDTLS_OID_AT_PSEUDONYM), "id-at-pseudonym", "Pseudonym"}, - "pseudonym", }, + {ADD_LEN(MBEDTLS_OID_AT_PSEUDONYM), "id-at-pseudonym", "Pseudonym"}, + "pseudonym", + }, { - {ADD_LEN(MBEDTLS_OID_DOMAIN_COMPONENT), "id-domainComponent", "Domain component"}, - "DC", }, + {ADD_LEN(MBEDTLS_OID_DOMAIN_COMPONENT), "id-domainComponent", "Domain component"}, + "DC", + }, { - {ADD_LEN(MBEDTLS_OID_AT_UNIQUE_IDENTIFIER), "id-at-uniqueIdentifier", "Unique Identifier"}, - "uniqueIdentifier", }, + {ADD_LEN(MBEDTLS_OID_AT_UNIQUE_IDENTIFIER), "id-at-uniqueIdentifier", "Unique Identifier"}, + "uniqueIdentifier", + }, { - {NULL, 0, NULL, NULL}, - NULL, } -}; + {NULL, 0, NULL, NULL}, + NULL, + }}; FN_OID_TYPED_FROM_ASN1(oid_x520_attr_t, x520_attr, oid_x520_attr_type) FN_OID_GET_ATTR1(mbedtls_oid_get_attr_short_name, oid_x520_attr_t, x520_attr, const char*, short_name) @@ -262,23 +281,29 @@ typedef struct { static const oid_x509_ext_t oid_x509_ext[] = { { - {ADD_LEN(MBEDTLS_OID_BASIC_CONSTRAINTS), "id-ce-basicConstraints", "Basic Constraints"}, - MBEDTLS_X509_EXT_BASIC_CONSTRAINTS, }, + {ADD_LEN(MBEDTLS_OID_BASIC_CONSTRAINTS), "id-ce-basicConstraints", "Basic Constraints"}, + MBEDTLS_X509_EXT_BASIC_CONSTRAINTS, + }, { - {ADD_LEN(MBEDTLS_OID_KEY_USAGE), "id-ce-keyUsage", "Key Usage"}, - MBEDTLS_X509_EXT_KEY_USAGE, }, + {ADD_LEN(MBEDTLS_OID_KEY_USAGE), "id-ce-keyUsage", "Key Usage"}, + MBEDTLS_X509_EXT_KEY_USAGE, + }, { - {ADD_LEN(MBEDTLS_OID_EXTENDED_KEY_USAGE), "id-ce-extKeyUsage", "Extended Key Usage"}, - MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE, }, + {ADD_LEN(MBEDTLS_OID_EXTENDED_KEY_USAGE), "id-ce-extKeyUsage", "Extended Key Usage"}, + MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE, + }, { - {ADD_LEN(MBEDTLS_OID_SUBJECT_ALT_NAME), "id-ce-subjectAltName", "Subject Alt Name"}, - MBEDTLS_X509_EXT_SUBJECT_ALT_NAME, }, + {ADD_LEN(MBEDTLS_OID_SUBJECT_ALT_NAME), "id-ce-subjectAltName", "Subject Alt Name"}, + MBEDTLS_X509_EXT_SUBJECT_ALT_NAME, + }, { - {ADD_LEN(MBEDTLS_OID_NS_CERT_TYPE), "id-netscape-certtype", "Netscape Certificate Type"}, - MBEDTLS_X509_EXT_NS_CERT_TYPE, }, + {ADD_LEN(MBEDTLS_OID_NS_CERT_TYPE), "id-netscape-certtype", "Netscape Certificate Type"}, + MBEDTLS_X509_EXT_NS_CERT_TYPE, + }, { - {NULL, 0, NULL, NULL}, - 0, }, + {NULL, 0, NULL, NULL}, + 0, + }, }; FN_OID_TYPED_FROM_ASN1(oid_x509_ext_t, x509_ext, oid_x509_ext) @@ -312,93 +337,109 @@ static const oid_sig_alg_t oid_sig_alg[] = { #if defined(MBEDTLS_RSA_C) #if defined(MBEDTLS_MD2_C) { - {ADD_LEN(MBEDTLS_OID_PKCS1_MD2), "md2WithRSAEncryption", "RSA with MD2"}, - MBEDTLS_MD_MD2, MBEDTLS_PK_RSA, - }, -#endif /* MBEDTLS_MD2_C */ + {ADD_LEN(MBEDTLS_OID_PKCS1_MD2), "md2WithRSAEncryption", "RSA with MD2"}, + MBEDTLS_MD_MD2, + MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_MD2_C */ #if defined(MBEDTLS_MD4_C) { - {ADD_LEN(MBEDTLS_OID_PKCS1_MD4), "md4WithRSAEncryption", "RSA with MD4"}, - MBEDTLS_MD_MD4, MBEDTLS_PK_RSA, - }, -#endif /* MBEDTLS_MD4_C */ + {ADD_LEN(MBEDTLS_OID_PKCS1_MD4), "md4WithRSAEncryption", "RSA with MD4"}, + MBEDTLS_MD_MD4, + MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_MD4_C */ #if defined(MBEDTLS_MD5_C) { - {ADD_LEN(MBEDTLS_OID_PKCS1_MD5), "md5WithRSAEncryption", "RSA with MD5"}, - MBEDTLS_MD_MD5,MBEDTLS_PK_RSA, - }, -#endif /* MBEDTLS_MD5_C */ + {ADD_LEN(MBEDTLS_OID_PKCS1_MD5), "md5WithRSAEncryption", "RSA with MD5"}, + MBEDTLS_MD_MD5, + MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_MD5_C */ #if defined(MBEDTLS_SHA1_C) { - {ADD_LEN(MBEDTLS_OID_PKCS1_SHA1), "sha-1WithRSAEncryption", "RSA with SHA1"}, - MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA, - }, -#endif /* MBEDTLS_SHA1_C */ + {ADD_LEN(MBEDTLS_OID_PKCS1_SHA1), "sha-1WithRSAEncryption", "RSA with SHA1"}, + MBEDTLS_MD_SHA1, + MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) { - {ADD_LEN(MBEDTLS_OID_PKCS1_SHA224), "sha224WithRSAEncryption", "RSA with SHA-224"}, - MBEDTLS_MD_SHA224, MBEDTLS_PK_RSA, - }, + {ADD_LEN(MBEDTLS_OID_PKCS1_SHA224), "sha224WithRSAEncryption", "RSA with SHA-224"}, + MBEDTLS_MD_SHA224, + MBEDTLS_PK_RSA, + }, { - {ADD_LEN(MBEDTLS_OID_PKCS1_SHA256), "sha256WithRSAEncryption", "RSA with SHA-256"}, - MBEDTLS_MD_SHA256, MBEDTLS_PK_RSA, - }, -#endif /* MBEDTLS_SHA256_C */ + {ADD_LEN(MBEDTLS_OID_PKCS1_SHA256), "sha256WithRSAEncryption", "RSA with SHA-256"}, + MBEDTLS_MD_SHA256, + MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) { - {ADD_LEN(MBEDTLS_OID_PKCS1_SHA384), "sha384WithRSAEncryption", "RSA with SHA-384"}, - MBEDTLS_MD_SHA384, MBEDTLS_PK_RSA, - }, + {ADD_LEN(MBEDTLS_OID_PKCS1_SHA384), "sha384WithRSAEncryption", "RSA with SHA-384"}, + MBEDTLS_MD_SHA384, + MBEDTLS_PK_RSA, + }, { - {ADD_LEN(MBEDTLS_OID_PKCS1_SHA512), "sha512WithRSAEncryption", "RSA with SHA-512"}, - MBEDTLS_MD_SHA512,MBEDTLS_PK_RSA, - }, -#endif /* MBEDTLS_SHA512_C */ + {ADD_LEN(MBEDTLS_OID_PKCS1_SHA512), "sha512WithRSAEncryption", "RSA with SHA-512"}, + MBEDTLS_MD_SHA512, + MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_SHA512_C */ #if defined(MBEDTLS_SHA1_C) { - {ADD_LEN(MBEDTLS_OID_RSA_SHA_OBS), "sha-1WithRSAEncryption", "RSA with SHA1"}, - MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA, - }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_RSA_C */ + {ADD_LEN(MBEDTLS_OID_RSA_SHA_OBS), "sha-1WithRSAEncryption", "RSA with SHA1"}, + MBEDTLS_MD_SHA1, + MBEDTLS_PK_RSA, + }, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_RSA_C */ #if defined(MBEDTLS_ECDSA_C) #if defined(MBEDTLS_SHA1_C) { - {ADD_LEN(MBEDTLS_OID_ECDSA_SHA1), "ecdsa-with-SHA1", "ECDSA with SHA1"}, - MBEDTLS_MD_SHA1, MBEDTLS_PK_ECDSA, - }, -#endif /* MBEDTLS_SHA1_C */ + {ADD_LEN(MBEDTLS_OID_ECDSA_SHA1), "ecdsa-with-SHA1", "ECDSA with SHA1"}, + MBEDTLS_MD_SHA1, + MBEDTLS_PK_ECDSA, + }, +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) { - {ADD_LEN(MBEDTLS_OID_ECDSA_SHA224), "ecdsa-with-SHA224", "ECDSA with SHA224"}, - MBEDTLS_MD_SHA224, MBEDTLS_PK_ECDSA, - }, + {ADD_LEN(MBEDTLS_OID_ECDSA_SHA224), "ecdsa-with-SHA224", "ECDSA with SHA224"}, + MBEDTLS_MD_SHA224, + MBEDTLS_PK_ECDSA, + }, { - {ADD_LEN(MBEDTLS_OID_ECDSA_SHA256), "ecdsa-with-SHA256", "ECDSA with SHA256"}, - MBEDTLS_MD_SHA256, MBEDTLS_PK_ECDSA, - }, -#endif /* MBEDTLS_SHA256_C */ + {ADD_LEN(MBEDTLS_OID_ECDSA_SHA256), "ecdsa-with-SHA256", "ECDSA with SHA256"}, + MBEDTLS_MD_SHA256, + MBEDTLS_PK_ECDSA, + }, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) { - {ADD_LEN(MBEDTLS_OID_ECDSA_SHA384), "ecdsa-with-SHA384", "ECDSA with SHA384"}, - MBEDTLS_MD_SHA384, MBEDTLS_PK_ECDSA, - }, - { - {ADD_LEN(MBEDTLS_OID_ECDSA_SHA512), "ecdsa-with-SHA512", "ECDSA with SHA512"}, - MBEDTLS_MD_SHA512, MBEDTLS_PK_ECDSA, - }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_ECDSA_C */ + {ADD_LEN(MBEDTLS_OID_ECDSA_SHA384), "ecdsa-with-SHA384", "ECDSA with SHA384"}, + MBEDTLS_MD_SHA384, + MBEDTLS_PK_ECDSA, + }, + { + {ADD_LEN(MBEDTLS_OID_ECDSA_SHA512), "ecdsa-with-SHA512", "ECDSA with SHA512"}, + MBEDTLS_MD_SHA512, + MBEDTLS_PK_ECDSA, + }, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_ECDSA_C */ #if defined(MBEDTLS_RSA_C) { - {ADD_LEN(MBEDTLS_OID_RSASSA_PSS), "RSASSA-PSS", "RSASSA-PSS"}, - MBEDTLS_MD_NONE, MBEDTLS_PK_RSASSA_PSS, - }, -#endif /* MBEDTLS_RSA_C */ + {ADD_LEN(MBEDTLS_OID_RSASSA_PSS), "RSASSA-PSS", "RSASSA-PSS"}, + MBEDTLS_MD_NONE, + MBEDTLS_PK_RSASSA_PSS, + }, +#endif /* MBEDTLS_RSA_C */ { - {NULL, 0, NULL, NULL}, - MBEDTLS_MD_NONE, MBEDTLS_PK_NONE, - }, + {NULL, 0, NULL, NULL}, + MBEDTLS_MD_NONE, + MBEDTLS_PK_NONE, + }, }; FN_OID_TYPED_FROM_ASN1(oid_sig_alg_t, sig_alg, oid_sig_alg) @@ -417,17 +458,21 @@ typedef struct { static const oid_pk_alg_t oid_pk_alg[] = { { - {ADD_LEN(MBEDTLS_OID_PKCS1_RSA), "rsaEncryption", "RSA"}, - MBEDTLS_PK_RSA, }, + {ADD_LEN(MBEDTLS_OID_PKCS1_RSA), "rsaEncryption", "RSA"}, + MBEDTLS_PK_RSA, + }, { - {ADD_LEN(MBEDTLS_OID_EC_ALG_UNRESTRICTED), "id-ecPublicKey", "Generic EC key"}, - MBEDTLS_PK_ECKEY, }, + {ADD_LEN(MBEDTLS_OID_EC_ALG_UNRESTRICTED), "id-ecPublicKey", "Generic EC key"}, + MBEDTLS_PK_ECKEY, + }, { - {ADD_LEN(MBEDTLS_OID_EC_ALG_ECDH), "id-ecDH", "EC key for ECDH"}, - MBEDTLS_PK_ECKEY_DH, }, + {ADD_LEN(MBEDTLS_OID_EC_ALG_ECDH), "id-ecDH", "EC key for ECDH"}, + MBEDTLS_PK_ECKEY_DH, + }, { - {NULL, 0, NULL, NULL}, - MBEDTLS_PK_NONE, }, + {NULL, 0, NULL, NULL}, + MBEDTLS_PK_NONE, + }, }; FN_OID_TYPED_FROM_ASN1(oid_pk_alg_t, pk_alg, oid_pk_alg) @@ -446,62 +491,74 @@ typedef struct { static const oid_ecp_grp_t oid_ecp_grp[] = { #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP192R1), "secp192r1", "secp192r1"}, - MBEDTLS_ECP_DP_SECP192R1, }, -#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP192R1), "secp192r1", "secp192r1"}, + MBEDTLS_ECP_DP_SECP192R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP224R1), "secp224r1", "secp224r1"}, - MBEDTLS_ECP_DP_SECP224R1, }, -#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP224R1), "secp224r1", "secp224r1"}, + MBEDTLS_ECP_DP_SECP224R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP256R1), "secp256r1", "secp256r1"}, - MBEDTLS_ECP_DP_SECP256R1, }, -#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP256R1), "secp256r1", "secp256r1"}, + MBEDTLS_ECP_DP_SECP256R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP384R1), "secp384r1", "secp384r1"}, - MBEDTLS_ECP_DP_SECP384R1, }, -#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP384R1), "secp384r1", "secp384r1"}, + MBEDTLS_ECP_DP_SECP384R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP521R1), "secp521r1", "secp521r1"}, - MBEDTLS_ECP_DP_SECP521R1, }, -#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP521R1), "secp521r1", "secp521r1"}, + MBEDTLS_ECP_DP_SECP521R1, + }, +#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP192K1), "secp192k1", "secp192k1"}, - MBEDTLS_ECP_DP_SECP192K1, }, -#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP192K1), "secp192k1", "secp192k1"}, + MBEDTLS_ECP_DP_SECP192K1, + }, +#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP224K1), "secp224k1", "secp224k1"}, - MBEDTLS_ECP_DP_SECP224K1, }, -#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP224K1), "secp224k1", "secp224k1"}, + MBEDTLS_ECP_DP_SECP224K1, + }, +#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ #if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP256K1), "secp256k1", "secp256k1"}, - MBEDTLS_ECP_DP_SECP256K1, }, -#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_SECP256K1), "secp256k1", "secp256k1"}, + MBEDTLS_ECP_DP_SECP256K1, + }, +#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ #if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_BP256R1), "brainpoolP256r1", "brainpool256r1"}, - MBEDTLS_ECP_DP_BP256R1, }, -#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_BP256R1), "brainpoolP256r1", "brainpool256r1"}, + MBEDTLS_ECP_DP_BP256R1, + }, +#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_BP384R1), "brainpoolP384r1", "brainpool384r1"}, - MBEDTLS_ECP_DP_BP384R1, }, -#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_BP384R1), "brainpoolP384r1", "brainpool384r1"}, + MBEDTLS_ECP_DP_BP384R1, + }, +#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ #if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) { - {ADD_LEN(MBEDTLS_OID_EC_GRP_BP512R1), "brainpoolP512r1", "brainpool512r1"}, - MBEDTLS_ECP_DP_BP512R1, }, -#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ + {ADD_LEN(MBEDTLS_OID_EC_GRP_BP512R1), "brainpoolP512r1", "brainpool512r1"}, + MBEDTLS_ECP_DP_BP512R1, + }, +#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ { - {NULL, 0, NULL, NULL}, - MBEDTLS_ECP_DP_NONE, }, + {NULL, 0, NULL, NULL}, + MBEDTLS_ECP_DP_NONE, + }, }; FN_OID_TYPED_FROM_ASN1(oid_ecp_grp_t, grp_id, oid_ecp_grp) @@ -520,14 +577,17 @@ typedef struct { static const oid_cipher_alg_t oid_cipher_alg[] = { { - {ADD_LEN(MBEDTLS_OID_DES_CBC), "desCBC", "DES-CBC"}, - MBEDTLS_CIPHER_DES_CBC, }, + {ADD_LEN(MBEDTLS_OID_DES_CBC), "desCBC", "DES-CBC"}, + MBEDTLS_CIPHER_DES_CBC, + }, { - {ADD_LEN(MBEDTLS_OID_DES_EDE3_CBC), "des-ede3-cbc", "DES-EDE3-CBC"}, - MBEDTLS_CIPHER_DES_EDE3_CBC, }, + {ADD_LEN(MBEDTLS_OID_DES_EDE3_CBC), "des-ede3-cbc", "DES-EDE3-CBC"}, + MBEDTLS_CIPHER_DES_EDE3_CBC, + }, { - {NULL, 0, NULL, NULL}, - MBEDTLS_CIPHER_NONE, }, + {NULL, 0, NULL, NULL}, + MBEDTLS_CIPHER_NONE, + }, }; FN_OID_TYPED_FROM_ASN1(oid_cipher_alg_t, cipher_alg, oid_cipher_alg) @@ -546,43 +606,52 @@ typedef struct { static const oid_md_alg_t oid_md_alg[] = { #if defined(MBEDTLS_MD2_C) { - {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_MD2), "id-md2", "MD2"}, - MBEDTLS_MD_MD2, }, -#endif /* MBEDTLS_MD2_C */ + {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_MD2), "id-md2", "MD2"}, + MBEDTLS_MD_MD2, + }, +#endif /* MBEDTLS_MD2_C */ #if defined(MBEDTLS_MD4_C) { - {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_MD4), "id-md4", "MD4"}, - MBEDTLS_MD_MD4, }, -#endif /* MBEDTLS_MD4_C */ + {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_MD4), "id-md4", "MD4"}, + MBEDTLS_MD_MD4, + }, +#endif /* MBEDTLS_MD4_C */ #if defined(MBEDTLS_MD5_C) { - {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_MD5), "id-md5", "MD5"}, - MBEDTLS_MD_MD5, }, -#endif /* MBEDTLS_MD5_C */ + {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_MD5), "id-md5", "MD5"}, + MBEDTLS_MD_MD5, + }, +#endif /* MBEDTLS_MD5_C */ #if defined(MBEDTLS_SHA1_C) { - {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA1), "id-sha1", "SHA-1"}, - MBEDTLS_MD_SHA1, }, -#endif /* MBEDTLS_SHA1_C */ + {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA1), "id-sha1", "SHA-1"}, + MBEDTLS_MD_SHA1, + }, +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) { - {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA224), "id-sha224", "SHA-224"}, - MBEDTLS_MD_SHA224, }, + {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA224), "id-sha224", "SHA-224"}, + MBEDTLS_MD_SHA224, + }, { - {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA256), "id-sha256", "SHA-256"}, - MBEDTLS_MD_SHA256, }, -#endif /* MBEDTLS_SHA256_C */ + {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA256), "id-sha256", "SHA-256"}, + MBEDTLS_MD_SHA256, + }, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) { - {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA384), "id-sha384", "SHA-384"}, - MBEDTLS_MD_SHA384, }, + {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA384), "id-sha384", "SHA-384"}, + MBEDTLS_MD_SHA384, + }, { - {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA512), "id-sha512", "SHA-512"}, - MBEDTLS_MD_SHA512, }, -#endif /* MBEDTLS_SHA512_C */ + {ADD_LEN(MBEDTLS_OID_DIGEST_ALG_SHA512), "id-sha512", "SHA-512"}, + MBEDTLS_MD_SHA512, + }, +#endif /* MBEDTLS_SHA512_C */ { - {NULL, 0, NULL, NULL}, - MBEDTLS_MD_NONE, }, + {NULL, 0, NULL, NULL}, + MBEDTLS_MD_NONE, + }, }; FN_OID_TYPED_FROM_ASN1(oid_md_alg_t, md_alg, oid_md_alg) @@ -600,28 +669,34 @@ typedef struct { static const oid_md_hmac_t oid_md_hmac[] = { #if defined(MBEDTLS_SHA1_C) { - {ADD_LEN(MBEDTLS_OID_HMAC_SHA1), "hmacSHA1", "HMAC-SHA-1"}, - MBEDTLS_MD_SHA1, }, -#endif /* MBEDTLS_SHA1_C */ + {ADD_LEN(MBEDTLS_OID_HMAC_SHA1), "hmacSHA1", "HMAC-SHA-1"}, + MBEDTLS_MD_SHA1, + }, +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) { - {ADD_LEN(MBEDTLS_OID_HMAC_SHA224), "hmacSHA224", "HMAC-SHA-224"}, - MBEDTLS_MD_SHA224, }, + {ADD_LEN(MBEDTLS_OID_HMAC_SHA224), "hmacSHA224", "HMAC-SHA-224"}, + MBEDTLS_MD_SHA224, + }, { - {ADD_LEN(MBEDTLS_OID_HMAC_SHA256), "hmacSHA256", "HMAC-SHA-256"}, - MBEDTLS_MD_SHA256, }, -#endif /* MBEDTLS_SHA256_C */ + {ADD_LEN(MBEDTLS_OID_HMAC_SHA256), "hmacSHA256", "HMAC-SHA-256"}, + MBEDTLS_MD_SHA256, + }, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) { - {ADD_LEN(MBEDTLS_OID_HMAC_SHA384), "hmacSHA384", "HMAC-SHA-384"}, - MBEDTLS_MD_SHA384, }, + {ADD_LEN(MBEDTLS_OID_HMAC_SHA384), "hmacSHA384", "HMAC-SHA-384"}, + MBEDTLS_MD_SHA384, + }, { - {ADD_LEN(MBEDTLS_OID_HMAC_SHA512), "hmacSHA512", "HMAC-SHA-512"}, - MBEDTLS_MD_SHA512, }, -#endif /* MBEDTLS_SHA512_C */ + {ADD_LEN(MBEDTLS_OID_HMAC_SHA512), "hmacSHA512", "HMAC-SHA-512"}, + MBEDTLS_MD_SHA512, + }, +#endif /* MBEDTLS_SHA512_C */ { - {NULL, 0, NULL, NULL}, - MBEDTLS_MD_NONE, }, + {NULL, 0, NULL, NULL}, + MBEDTLS_MD_NONE, + }, }; FN_OID_TYPED_FROM_ASN1(oid_md_hmac_t, md_hmac, oid_md_hmac) @@ -640,17 +715,20 @@ typedef struct { static const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg[] = { { - {ADD_LEN(MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC), "pbeWithSHAAnd3-KeyTripleDES-CBC", "PBE with SHA1 and 3-Key 3DES"}, - MBEDTLS_MD_SHA1, MBEDTLS_CIPHER_DES_EDE3_CBC, - }, + {ADD_LEN(MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC), "pbeWithSHAAnd3-KeyTripleDES-CBC", "PBE with SHA1 and 3-Key 3DES"}, + MBEDTLS_MD_SHA1, + MBEDTLS_CIPHER_DES_EDE3_CBC, + }, { - {ADD_LEN(MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC), "pbeWithSHAAnd2-KeyTripleDES-CBC", "PBE with SHA1 and 2-Key 3DES"}, - MBEDTLS_MD_SHA1, MBEDTLS_CIPHER_DES_EDE_CBC, - }, + {ADD_LEN(MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC), "pbeWithSHAAnd2-KeyTripleDES-CBC", "PBE with SHA1 and 2-Key 3DES"}, + MBEDTLS_MD_SHA1, + MBEDTLS_CIPHER_DES_EDE_CBC, + }, { - {NULL, 0, NULL, NULL}, - MBEDTLS_MD_NONE,MBEDTLS_CIPHER_NONE, - }, + {NULL, 0, NULL, NULL}, + MBEDTLS_MD_NONE, + MBEDTLS_CIPHER_NONE, + }, }; FN_OID_TYPED_FROM_ASN1(oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, oid_pkcs12_pbe_alg) diff --git a/nettls/ssl/poly1305.c b/nettls/ssl/poly1305.c index 0f6cd055..30017785 100644 --- a/nettls/ssl/poly1305.c +++ b/nettls/ssl/poly1305.c @@ -432,8 +432,7 @@ static const unsigned char test_keys[2][32] = { {0x85, 0xd6, 0xbe, 0x78, 0x57, 0x55, 0x6d, 0x33, 0x7f, 0x44, 0x52, 0xfe, 0x42, 0xd5, 0x06, 0xa8, 0x01, 0x03, 0x80, 0x8a, 0xfb, 0x0d, 0xb2, 0xfd, 0x4a, 0xbf, 0xf6, 0xaf, 0x41, 0x49, 0xf5, 0x1b}, {0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a, 0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0, - 0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09, 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0} -}; + 0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09, 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0}}; static const unsigned char test_data[2][127] = { {0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x46, 0x6f, 0x72, @@ -443,15 +442,13 @@ static const unsigned char test_data[2][127] = { 0x20, 0x61, 0x6e, 0x64, 0x20, 0x67, 0x69, 0x6d, 0x62, 0x6c, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, 0x61, 0x62, 0x65, 0x3a, 0x0a, 0x41, 0x6c, 0x6c, 0x20, 0x6d, 0x69, 0x6d, 0x73, 0x79, 0x20, 0x77, 0x65, 0x72, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6f, 0x72, 0x6f, 0x67, 0x6f, 0x76, 0x65, 0x73, 0x2c, 0x0a, 0x41, 0x6e, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6d, 0x6f, 0x6d, - 0x65, 0x20, 0x72, 0x61, 0x74, 0x68, 0x73, 0x20, 0x6f, 0x75, 0x74, 0x67, 0x72, 0x61, 0x62, 0x65, 0x2e} -}; + 0x65, 0x20, 0x72, 0x61, 0x74, 0x68, 0x73, 0x20, 0x6f, 0x75, 0x74, 0x67, 0x72, 0x61, 0x62, 0x65, 0x2e}}; static const size_t test_data_len[2] = {34U, 127U}; static const unsigned char test_mac[2][16] = { {0xa8, 0x06, 0x1d, 0xc1, 0x30, 0x51, 0x36, 0xc6, 0xc2, 0x2b, 0x8b, 0xaf, 0x0c, 0x01, 0x27, 0xa9}, - {0x45, 0x41, 0x66, 0x9a, 0x7e, 0xaa, 0xee, 0x61, 0xe7, 0x08, 0xdc, 0x7c, 0xbc, 0xc5, 0xeb, 0x62} -}; + {0x45, 0x41, 0x66, 0x9a, 0x7e, 0xaa, 0xee, 0x61, 0xe7, 0x08, 0xdc, 0x7c, 0xbc, 0xc5, 0xeb, 0x62}}; #define ASSERT(cond, args) \ do { \ diff --git a/nettls/ssl/sha1.c b/nettls/ssl/sha1.c index 8a691d43..0b5d8ad4 100644 --- a/nettls/ssl/sha1.c +++ b/nettls/ssl/sha1.c @@ -486,8 +486,7 @@ static const size_t sha1_test_buflen[3] = {3, 56, 1000}; static const unsigned char sha1_test_sum[3][20] = { {0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D}, {0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1}, - {0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E, 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F} -}; + {0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E, 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F}}; /* * Checkup routine diff --git a/nettls/ssl/sha256.c b/nettls/ssl/sha256.c index d3f1d9f3..dfb73579 100644 --- a/nettls/ssl/sha256.c +++ b/nettls/ssl/sha256.c @@ -448,9 +448,9 @@ static const unsigned char sha256_test_buf[3][57] = {{"abc"}, {"abcdbcdecdefdefg static const size_t sha256_test_buflen[3] = {3, 56, 1000}; static const unsigned char sha256_test_sum[6][32] = { - /* - * SHA-224 test vectors - */ + /* + * SHA-224 test vectors + */ {0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22, 0x86, 0x42, 0xA4, 0x77, 0xBD, 0xA2, 0x55, 0xB3, 0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3, 0xF7, 0xE3, 0x6C, 0x9D, 0xA7}, {0x75, 0x38, 0x8B, 0x16, 0x51, 0x27, 0x76, 0xCC, 0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, @@ -458,16 +458,15 @@ static const unsigned char sha256_test_sum[6][32] = { {0x20, 0x79, 0x46, 0x55, 0x98, 0x0C, 0x91, 0xD8, 0xBB, 0xB4, 0xC1, 0xEA, 0x97, 0x61, 0x8A, 0x4B, 0xF0, 0x3F, 0x42, 0x58, 0x19, 0x48, 0xB2, 0xEE, 0x4E, 0xE7, 0xAD, 0x67}, - /* - * SHA-256 test vectors - */ + /* + * SHA-256 test vectors + */ {0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, 0x41, 0x41, 0x40, 0xDE, 0x5D, 0xAE, 0x22, 0x23, 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, 0x7A, 0x9C, 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD}, {0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8, 0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39, 0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67, 0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1}, {0xCD, 0xC7, 0x6E, 0x5C, 0x99, 0x14, 0xFB, 0x92, 0x81, 0xA1, 0xC7, 0xE2, 0x84, 0xD7, 0x3E, 0x67, - 0xF1, 0x80, 0x9A, 0x48, 0xA4, 0x97, 0x20, 0x0E, 0x04, 0x6D, 0x39, 0xCC, 0xC7, 0x11, 0x2C, 0xD0} -}; + 0xF1, 0x80, 0x9A, 0x48, 0xA4, 0x97, 0x20, 0x0E, 0x04, 0x6D, 0x39, 0xCC, 0xC7, 0x11, 0x2C, 0xD0}}; /* * Checkup routine diff --git a/nettls/ssl/sha512.c b/nettls/ssl/sha512.c index b4004b0a..67e301e4 100644 --- a/nettls/ssl/sha512.c +++ b/nettls/ssl/sha512.c @@ -468,9 +468,9 @@ static const unsigned char sha512_test_buf[3][113] = { static const size_t sha512_test_buflen[3] = {3, 112, 1000}; static const unsigned char sha512_test_sum[6][64] = { - /* - * SHA-384 test vectors - */ + /* + * SHA-384 test vectors + */ {0xCB, 0x00, 0x75, 0x3F, 0x45, 0xA3, 0x5E, 0x8B, 0xB5, 0xA0, 0x3D, 0x69, 0x9A, 0xC6, 0x50, 0x07, 0x27, 0x2C, 0x32, 0xAB, 0x0E, 0xDE, 0xD1, 0x63, 0x1A, 0x8B, 0x60, 0x5A, 0x43, 0xFF, 0x5B, 0xED, 0x80, 0x86, 0x07, 0x2B, 0xA1, 0xE7, 0xCC, 0x23, 0x58, 0xBA, 0xEC, 0xA1, 0x34, 0xC8, 0x25, 0xA7}, {0x09, 0x33, 0x0C, 0x33, 0xF7, 0x11, 0x47, 0xE8, 0x3D, 0x19, 0x2F, 0xC7, 0x82, 0xCD, 0x1B, 0x47, 0x53, 0x11, 0x1B, 0x17, 0x3B, 0x3B, 0x05, 0xD2, @@ -478,9 +478,9 @@ static const unsigned char sha512_test_sum[6][64] = { {0x9D, 0x0E, 0x18, 0x09, 0x71, 0x64, 0x74, 0xCB, 0x08, 0x6E, 0x83, 0x4E, 0x31, 0x0A, 0x4A, 0x1C, 0xED, 0x14, 0x9E, 0x9C, 0x00, 0xF2, 0x48, 0x52, 0x79, 0x72, 0xCE, 0xC5, 0x70, 0x4C, 0x2A, 0x5B, 0x07, 0xB8, 0xB3, 0xDC, 0x38, 0xEC, 0xC4, 0xEB, 0xAE, 0x97, 0xDD, 0xD8, 0x7F, 0x3D, 0x89, 0x85}, - /* - * SHA-512 test vectors - */ + /* + * SHA-512 test vectors + */ {0xDD, 0xAF, 0x35, 0xA1, 0x93, 0x61, 0x7A, 0xBA, 0xCC, 0x41, 0x73, 0x49, 0xAE, 0x20, 0x41, 0x31, 0x12, 0xE6, 0xFA, 0x4E, 0x89, 0xA9, 0x7E, 0xA2, 0x0A, 0x9E, 0xEE, 0xE6, 0x4B, 0x55, 0xD3, 0x9A, 0x21, 0x92, 0x99, 0x2A, 0x27, 0x4F, 0xC1, 0xA8, 0x36, 0xBA, 0x3C, 0x23, 0xA3, 0xFE, 0xEB, 0xBD, 0x45, 0x4D, 0x44, 0x23, 0x64, 0x3C, 0xE8, 0x0E, 0x2A, 0x9A, 0xC9, 0x4F, 0xA5, 0x4C, 0xA4, 0x9F}, @@ -489,8 +489,7 @@ static const unsigned char sha512_test_sum[6][64] = { 0xC4, 0xB5, 0x43, 0x3A, 0xC7, 0xD3, 0x29, 0xEE, 0xB6, 0xDD, 0x26, 0x54, 0x5E, 0x96, 0xE5, 0x5B, 0x87, 0x4B, 0xE9, 0x09}, {0xE7, 0x18, 0x48, 0x3D, 0x0C, 0xE7, 0x69, 0x64, 0x4E, 0x2E, 0x42, 0xC7, 0xBC, 0x15, 0xB4, 0x63, 0x8E, 0x1F, 0x98, 0xB1, 0x3B, 0x20, 0x44, 0x28, 0x56, 0x32, 0xA8, 0x03, 0xAF, 0xA9, 0x73, 0xEB, 0xDE, 0x0F, 0xF2, 0x44, 0x87, 0x7E, 0xA6, 0x0A, 0x4C, 0xB0, 0x43, 0x2C, - 0xE5, 0x77, 0xC3, 0x1B, 0xEB, 0x00, 0x9C, 0x5C, 0x2C, 0x49, 0xAA, 0x2E, 0x4E, 0xAD, 0xB2, 0x17, 0xAD, 0x8C, 0xC0, 0x9B} -}; + 0xE5, 0x77, 0xC3, 0x1B, 0xEB, 0x00, 0x9C, 0x5C, 0x2C, 0x49, 0xAA, 0x2E, 0x4E, 0xAD, 0xB2, 0x17, 0xAD, 0x8C, 0xC0, 0x9B}}; /* * Checkup routine diff --git a/nettls/ssl/ssl_ciphersuites.c b/nettls/ssl/ssl_ciphersuites.c index c8f492bb..78ae819e 100644 --- a/nettls/ssl/ssl_ciphersuites.c +++ b/nettls/ssl/ssl_ciphersuites.c @@ -214,1323 +214,1322 @@ static const int ciphersuite_preference[] = { static const mbedtls_ssl_ciphersuite_t ciphersuite_definitions[] = { #if defined(MBEDTLS_CHACHAPOLY_C) && defined(MBEDTLS_SHA256_C) && defined(MBEDTLS_SSL_PROTO_TLS1_2) #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) - {MBEDTLS_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) {MBEDTLS_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, "TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) - {MBEDTLS_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256, "TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256, "TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) - {MBEDTLS_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256, "TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256, "TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) - {MBEDTLS_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256, "TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256, "TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) - {MBEDTLS_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256, "TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256, "TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) - {MBEDTLS_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256, "TLS-RSA-PSK-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256, "TLS-RSA-PSK-WITH-CHACHA20-POLY1305-SHA256", MBEDTLS_CIPHER_CHACHA20_POLY1305, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif -#endif /* MBEDTLS_CHACHAPOLY_C && \ - MBEDTLS_SHA256_C && \ - MBEDTLS_SSL_PROTO_TLS1_2 */ +#endif /* MBEDTLS_CHACHAPOLY_C && \ + MBEDTLS_SHA256_C && \ + MBEDTLS_SSL_PROTO_TLS1_2 */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_SHA1_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_SHA1_C */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, "TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, "TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, "TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, "TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, "TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_SHA512_C */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, "TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA512_C */ #if defined(MBEDTLS_CCM_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM, "TLS-ECDHE-ECDSA-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8, "TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_SHORT_TAG}, - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM, "TLS-ECDHE-ECDSA-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, "TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_SHORT_TAG}, -#endif /* MBEDTLS_CCM_C */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM, "TLS-ECDHE-ECDSA-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8, "TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_SHORT_TAG}, + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM, "TLS-ECDHE-ECDSA-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, "TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_SHORT_TAG}, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, - MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, + MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, - MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, + MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDHE-ECDSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_ARC4_C) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, "TLS-ECDHE-ECDSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_ARC4_C */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, "TLS-ECDHE-ECDSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ #if defined(MBEDTLS_CIPHER_NULL_CIPHER) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA, "TLS-ECDHE-ECDSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA, "TLS-ECDHE-ECDSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_SHA1_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_SHA1_C */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, "TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, "TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, "TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, "TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, "TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, "TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, - MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDHE-RSA-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, + MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, - MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, + MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDHE-RSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_ARC4_C) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA, "TLS-ECDHE-RSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_ARC4_C */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA, "TLS-ECDHE-RSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ #if defined(MBEDTLS_CIPHER_NULL_CIPHER) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA, "TLS-ECDHE-RSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */ + {MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA, "TLS-ECDHE-RSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, "TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C && MBEDTLS_GCM_C */ + {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, "TLS-DHE-RSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C && MBEDTLS_GCM_C */ #if defined(MBEDTLS_SHA256_C) #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, "TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_GCM_C */ + {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, "TLS-DHE-RSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_GCM_C */ #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, "TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, "TLS-DHE-RSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, - {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, "TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, "TLS-DHE-RSA-WITH-AES-256-CBC-SHA256", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA, "TLS-DHE-RSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, - - {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA, "TLS-DHE-RSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA, "TLS-DHE-RSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, + + {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA, "TLS-DHE-RSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_CCM_C) - {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM, "TLS-DHE-RSA-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, - {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM_8, "TLS-DHE-RSA-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - MBEDTLS_CIPHERSUITE_SHORT_TAG }, - {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM, "TLS-DHE-RSA-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, - {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM_8, "TLS-DHE-RSA-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - MBEDTLS_CIPHERSUITE_SHORT_TAG }, -#endif /* MBEDTLS_CCM_C */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM, "TLS-DHE-RSA-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, + {MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM_8, "TLS-DHE-RSA-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG}, + {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM, "TLS-DHE-RSA-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, + {MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM_8, "TLS-DHE-RSA-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG}, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, - {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256, "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256, "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, - - {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, "TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, + + {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, "TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-DHE-RSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ -#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ + {MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-DHE-RSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_SHA512_C) && defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384, "TLS-RSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C && MBEDTLS_GCM_C */ + {MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384, "TLS-RSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C && MBEDTLS_GCM_C */ #if defined(MBEDTLS_SHA256_C) #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256, "TLS-RSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_GCM_C */ + {MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256, "TLS-RSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_GCM_C */ #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256, "TLS-RSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256, "TLS-RSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, - {MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256, "TLS-RSA-WITH-AES-256-CBC-SHA256", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256, "TLS-RSA-WITH-AES-256-CBC-SHA256", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA1_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA, "TLS-RSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA, "TLS-RSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, - {MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA, "TLS-RSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_SHA1_C */ + {MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA, "TLS-RSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_CCM_C) - {MBEDTLS_TLS_RSA_WITH_AES_256_CCM, "TLS-RSA-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_RSA_WITH_AES_256_CCM_8, "TLS-RSA-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - MBEDTLS_CIPHERSUITE_SHORT_TAG }, - {MBEDTLS_TLS_RSA_WITH_AES_128_CCM, "TLS-RSA-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_RSA_WITH_AES_128_CCM_8, "TLS-RSA-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - MBEDTLS_CIPHERSUITE_SHORT_TAG }, -#endif /* MBEDTLS_CCM_C */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_RSA_WITH_AES_256_CCM, "TLS-RSA-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_RSA_WITH_AES_256_CCM_8, "TLS-RSA-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG}, + {MBEDTLS_TLS_RSA_WITH_AES_128_CCM, "TLS-RSA-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_RSA_WITH_AES_128_CCM_8, "TLS-RSA-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG}, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, - {MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256, "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256, "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA, "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA, "TLS-RSA-WITH-CAMELLIA-128-CBC-SHA", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, - {MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA, "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA, "TLS-RSA-WITH-CAMELLIA-256-CBC-SHA", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-RSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ + {MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-RSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_ARC4_C) #if defined(MBEDTLS_MD5_C) - {MBEDTLS_TLS_RSA_WITH_RC4_128_MD5, "TLS-RSA-WITH-RC4-128-MD5", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_MD5, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, + {MBEDTLS_TLS_RSA_WITH_RC4_128_MD5, "TLS-RSA-WITH-RC4-128-MD5", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_MD5, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, #endif #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_WITH_RC4_128_SHA, "TLS-RSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, + {MBEDTLS_TLS_RSA_WITH_RC4_128_SHA, "TLS-RSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, #endif -#endif /* MBEDTLS_ARC4_C */ -#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_SHA1_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, "TLS-ECDH-RSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, "TLS-ECDH-RSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_SHA1_C */ + {MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, "TLS-ECDH-RSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, "TLS-ECDH-RSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, "TLS-ECDH-RSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, "TLS-ECDH-RSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, "TLS-ECDH-RSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, "TLS-ECDH-RSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, "TLS-ECDH-RSA-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, "TLS-ECDH-RSA-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, "TLS-ECDH-RSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, "TLS-ECDH-RSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDH-RSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDH-RSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDH-RSA-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, - MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDH-RSA-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, + MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDH-RSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDH-RSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDH-RSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, - MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDH-RSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, + MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDH-RSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ + {MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDH-RSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_ARC4_C) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA, "TLS-ECDH-RSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_ARC4_C */ + {MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA, "TLS-ECDH-RSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ #if defined(MBEDTLS_CIPHER_NULL_CIPHER) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA, "TLS-ECDH-RSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ -#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */ + {MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA, "TLS-ECDH-RSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_SHA1_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_SHA1_C */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, "TLS-ECDH-ECDSA-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, "TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, "TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, "TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, "TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, "TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDH-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDH-ECDSA-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDH-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, - MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDH-ECDSA-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, + MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDH-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, "TLS-ECDH-ECDSA-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDH-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, - MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, "TLS-ECDH-ECDSA-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, + MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, "TLS-ECDH-ECDSA-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_ARC4_C) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA, "TLS-ECDH-ECDSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_ARC4_C */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA, "TLS-ECDH-ECDSA-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ #if defined(MBEDTLS_CIPHER_NULL_CIPHER) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA, "TLS-ECDH-ECDSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ -#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + {MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA, "TLS-ECDH-ECDSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256, "TLS-PSK-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256, "TLS-PSK-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384, "TLS-PSK-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ + {MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384, "TLS-PSK-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256, "TLS-PSK-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256, "TLS-PSK-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384, "TLS-PSK-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ + {MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384, "TLS-PSK-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA, "TLS-PSK-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA, "TLS-PSK-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, - {MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA, "TLS-PSK-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA, "TLS-PSK-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_CCM_C) - {MBEDTLS_TLS_PSK_WITH_AES_256_CCM, "TLS-PSK-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8, "TLS-PSK-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - MBEDTLS_CIPHERSUITE_SHORT_TAG }, - {MBEDTLS_TLS_PSK_WITH_AES_128_CCM, "TLS-PSK-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, - {MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8, "TLS-PSK-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - MBEDTLS_CIPHERSUITE_SHORT_TAG }, -#endif /* MBEDTLS_CCM_C */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_PSK_WITH_AES_256_CCM, "TLS-PSK-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8, "TLS-PSK-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG}, + {MBEDTLS_TLS_PSK_WITH_AES_128_CCM, "TLS-PSK-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, + {MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8, "TLS-PSK-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG}, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-PSK-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-PSK-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256, "TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256, "TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384, "TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384, "TLS-PSK-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-PSK-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ + {MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-PSK-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_ARC4_C) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_PSK_WITH_RC4_128_SHA, "TLS-PSK-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_ARC4_C */ -#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ + {MBEDTLS_TLS_PSK_WITH_RC4_128_SHA, "TLS-PSK-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256, "TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256, "TLS-DHE-PSK-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384, "TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384, "TLS-DHE-PSK-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256, "TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256, "TLS-DHE-PSK-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384, "TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384, "TLS-DHE-PSK-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C */ #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA, "TLS-DHE-PSK-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, - - {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA, "TLS-DHE-PSK-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA, "TLS-DHE-PSK-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, + + {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA, "TLS-DHE-PSK-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_CCM_C) - {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM, "TLS-DHE-PSK-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, - {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8, "TLS-DHE-PSK-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - MBEDTLS_CIPHERSUITE_SHORT_TAG }, - {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM, "TLS-DHE-PSK-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, - {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8, "TLS-DHE-PSK-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - MBEDTLS_CIPHERSUITE_SHORT_TAG }, -#endif /* MBEDTLS_CCM_C */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM, "TLS-DHE-PSK-WITH-AES-256-CCM", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, + {MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8, "TLS-DHE-PSK-WITH-AES-256-CCM-8", MBEDTLS_CIPHER_AES_256_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG}, + {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM, "TLS-DHE-PSK-WITH-AES-128-CCM", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, + {MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8, "TLS-DHE-PSK-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG}, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-DHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-DHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256, "TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256, "TLS-DHE-PSK-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384, "TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384, "TLS-DHE-PSK-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-DHE-PSK-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_ARC4_C) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA, "TLS-DHE-PSK-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_ARC4_C */ -#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + {MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA, "TLS-DHE-PSK-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384, "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ + {MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384, "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, "TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, - {MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA, "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA, "TLS-ECDHE-PSK-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, - MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-ECDHE-PSK-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, + MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, - MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-ECDHE-PSK-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, + MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ + {MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-ECDHE-PSK-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_ARC4_C) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA, "TLS-ECDHE-PSK-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_ARC4_C */ -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + {MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA, "TLS-ECDHE-PSK-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256, "TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256, "TLS-RSA-PSK-WITH-AES-128-GCM-SHA256", MBEDTLS_CIPHER_AES_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384, "TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384, "TLS-RSA-PSK-WITH-AES-256-GCM-SHA384", MBEDTLS_CIPHER_AES_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256, "TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256, "TLS-RSA-PSK-WITH-AES-128-CBC-SHA256", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384, "TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384, "TLS-RSA-PSK-WITH-AES-256-CBC-SHA384", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C */ #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA, "TLS-RSA-PSK-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA, "TLS-RSA-PSK-WITH-AES-128-CBC-SHA", MBEDTLS_CIPHER_AES_128_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, - {MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA, "TLS-RSA-PSK-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_AES_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA, "TLS-RSA-PSK-WITH-AES-256-CBC-SHA", MBEDTLS_CIPHER_AES_256_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_AES_C */ #if defined(MBEDTLS_CAMELLIA_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256, "TLS-RSA-PSK-WITH-CAMELLIA-128-CBC-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ + {MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384, "TLS-RSA-PSK-WITH-CAMELLIA-256-CBC-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ #if defined(MBEDTLS_GCM_C) #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256, "TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA256_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256, "TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256", MBEDTLS_CIPHER_CAMELLIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384, "TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA512_C */ -#endif /* MBEDTLS_GCM_C */ -#endif /* MBEDTLS_CAMELLIA_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384, "TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384", MBEDTLS_CIPHER_CAMELLIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA512_C */ +#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_CAMELLIA_C */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA, "TLS-RSA-PSK-WITH-3DES-EDE-CBC-SHA", MBEDTLS_CIPHER_DES_EDE3_CBC, MBEDTLS_MD_SHA1, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ #if defined(MBEDTLS_ARC4_C) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA, "TLS-RSA-PSK-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_ARC4_C */ -#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ + {MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA, "TLS-RSA-PSK-WITH-RC4-128-SHA", MBEDTLS_CIPHER_ARC4_128, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_NODTLS}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_ARC4_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_CCM_C) - {MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8, "TLS-ECJPAKE-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECJPAKE, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - MBEDTLS_CIPHERSUITE_SHORT_TAG }, -#endif /* MBEDTLS_CCM_C */ -#endif /* MBEDTLS_AES_C */ -#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + {MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8, "TLS-ECJPAKE-WITH-AES-128-CCM-8", MBEDTLS_CIPHER_AES_128_CCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECJPAKE, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_CIPHERSUITE_SHORT_TAG}, +#endif /* MBEDTLS_CCM_C */ +#endif /* MBEDTLS_AES_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_ENABLE_WEAK_CIPHERSUITES) #if defined(MBEDTLS_CIPHER_NULL_CIPHER) #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) #if defined(MBEDTLS_MD5_C) - {MBEDTLS_TLS_RSA_WITH_NULL_MD5, "TLS-RSA-WITH-NULL-MD5", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_MD5, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_RSA_WITH_NULL_MD5, "TLS-RSA-WITH-NULL-MD5", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_MD5, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_WITH_NULL_SHA, "TLS-RSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_RSA_WITH_NULL_SHA, "TLS-RSA-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_RSA_WITH_NULL_SHA256, "TLS-RSA-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_RSA_WITH_NULL_SHA256, "TLS-RSA-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_PSK_WITH_NULL_SHA, "TLS-PSK-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ + {MBEDTLS_TLS_PSK_WITH_NULL_SHA, "TLS-PSK-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_PSK_WITH_NULL_SHA256, "TLS-PSK-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_PSK_WITH_NULL_SHA256, "TLS-PSK-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_PSK_WITH_NULL_SHA384, "TLS-PSK-WITH-NULL-SHA384", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_PSK_WITH_NULL_SHA384, "TLS-PSK-WITH-NULL-SHA384", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA, "TLS-DHE-PSK-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ + {MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA, "TLS-DHE-PSK-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256, "TLS-DHE-PSK-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256, "TLS-DHE-PSK-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384, "TLS-DHE-PSK-WITH-NULL-SHA384", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384, "TLS-DHE-PSK-WITH-NULL-SHA384", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA, "TLS-ECDHE-PSK-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ + {MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA, "TLS-ECDHE-PSK-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256, "TLS-ECDHE-PSK-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256, "TLS-ECDHE-PSK-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384, "TLS-ECDHE-PSK-WITH-NULL-SHA384", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384, "TLS-ECDHE-PSK-WITH-NULL-SHA384", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA, "TLS-RSA-PSK-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ + {MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA, "TLS-RSA-PSK-WITH-NULL-SHA", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) - {MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256, "TLS-RSA-PSK-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256, "TLS-RSA-PSK-WITH-NULL-SHA256", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif #if defined(MBEDTLS_SHA512_C) - {MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384, "TLS-RSA-PSK-WITH-NULL-SHA384", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA_PSK, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, + {MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384, "TLS-RSA-PSK-WITH-NULL-SHA384", MBEDTLS_CIPHER_NULL, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_1, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ -#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ #if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA, "TLS-DHE-RSA-WITH-DES-CBC-SHA", MBEDTLS_CIPHER_DES_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ + {MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA, "TLS-DHE-RSA-WITH-DES-CBC-SHA", MBEDTLS_CIPHER_DES_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) #if defined(MBEDTLS_SHA1_C) - {MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA, "TLS-RSA-WITH-DES-CBC-SHA", MBEDTLS_CIPHER_DES_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, - MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK }, -#endif /* MBEDTLS_SHA1_C */ -#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ -#endif /* MBEDTLS_CIPHER_MODE_CBC */ -#endif /* MBEDTLS_DES_C */ -#endif /* MBEDTLS_ENABLE_WEAK_CIPHERSUITES */ + {MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA, "TLS-RSA-WITH-DES-CBC-SHA", MBEDTLS_CIPHER_DES_CBC, MBEDTLS_MD_SHA1, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_0, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_CIPHERSUITE_WEAK}, +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ +#endif /* MBEDTLS_DES_C */ +#endif /* MBEDTLS_ENABLE_WEAK_CIPHERSUITES */ #if defined(MBEDTLS_ARIA_C) #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384, "TLS-RSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384, "TLS-RSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384, "TLS-RSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384, "TLS-RSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256, "TLS-RSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256, "TLS-RSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256, "TLS-RSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256, "TLS-RSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384, "TLS-RSA-PSK-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384, "TLS-RSA-PSK-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384, "TLS-RSA-PSK-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384, "TLS-RSA-PSK-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256, "TLS-RSA-PSK-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256, "TLS-RSA-PSK-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256, "TLS-RSA-PSK-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256, "TLS-RSA-PSK-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384, "TLS-PSK-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384, "TLS-PSK-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384, "TLS-PSK-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384, "TLS-PSK-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256, "TLS-PSK-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256, "TLS-PSK-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256, "TLS-PSK-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256, "TLS-PSK-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384, "TLS-ECDH-RSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384, "TLS-ECDH-RSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384, "TLS-ECDH-RSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384, "TLS-ECDH-RSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256, "TLS-ECDH-RSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256, "TLS-ECDH-RSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256, "TLS-ECDH-RSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256, "TLS-ECDH-RSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDH_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384, "TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384, "TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384, "TLS-ECDHE-RSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384, "TLS-ECDHE-RSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256, "TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256, "TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256, "TLS-ECDHE-RSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256, "TLS-ECDHE-RSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384, "TLS-ECDHE-PSK-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384, "TLS-ECDHE-PSK-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256, "TLS-ECDHE-PSK-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256, "TLS-ECDHE-PSK-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384, "TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384, "TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384, "TLS-ECDHE-ECDSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384, "TLS-ECDHE-ECDSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256, "TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256, "TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256, "TLS-ECDHE-ECDSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256, "TLS-ECDHE-ECDSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384, "TLS-ECDH-ECDSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384, "TLS-ECDH-ECDSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384, "TLS-ECDH-ECDSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384, "TLS-ECDH-ECDSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256, "TLS-ECDH-ECDSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256, "TLS-ECDH-ECDSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256, "TLS-ECDH-ECDSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, - MBEDTLS_SSL_MINOR_VERSION_3, 0 }, + {MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256, "TLS-ECDH-ECDSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, + MBEDTLS_SSL_MINOR_VERSION_3, 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384, "TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384, "TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384, "TLS-DHE-RSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384, "TLS-DHE-RSA-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256, "TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256, "TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256, "TLS-DHE-RSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256, "TLS-DHE-RSA-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384, "TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384, "TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) - {MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384, "TLS-DHE-PSK-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384, "TLS-DHE-PSK-WITH-ARIA-256-CBC-SHA384", MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif #if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256, "TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256, "TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif #if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) - {MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256, "TLS-DHE-PSK-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, - MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, - 0 }, + {MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256, "TLS-DHE-PSK-WITH-ARIA-128-CBC-SHA256", MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0}, #endif -#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ -#endif /* MBEDTLS_ARIA_C */ +#endif /* MBEDTLS_ARIA_C */ - {0, "", MBEDTLS_CIPHER_NONE, MBEDTLS_MD_NONE, MBEDTLS_KEY_EXCHANGE_NONE, 0, 0, 0, 0, 0 } -}; + {0, "", MBEDTLS_CIPHER_NONE, MBEDTLS_MD_NONE, MBEDTLS_KEY_EXCHANGE_NONE, 0, 0, 0, 0, 0}}; #if defined(MBEDTLS_SSL_CIPHERSUITES) const int* mbedtls_ssl_list_ciphersuites(void) diff --git a/nettls/ssl/ssl_tls.c b/nettls/ssl/ssl_tls.c index 0ae80584..cdc77374 100644 --- a/nettls/ssl/ssl_tls.c +++ b/nettls/ssl/ssl_tls.c @@ -2213,7 +2213,7 @@ int mbedtls_ssl_fetch_input(mbedtls_ssl_context* ssl, size_t nb_want) int ret; size_t len; - //MBEDTLS_SSL_DEBUG_MSG(2, ("=> fetch input")); + // MBEDTLS_SSL_DEBUG_MSG(2, ("=> fetch input")); if (ssl->f_recv == NULL && ssl->f_recv_timeout == NULL) { MBEDTLS_SSL_DEBUG_MSG( @@ -2265,13 +2265,13 @@ int mbedtls_ssl_fetch_input(mbedtls_ssl_context* ssl, size_t nb_want) ssl->next_record_offset = 0; } - //MBEDTLS_SSL_DEBUG_MSG(2, ("in_left: %d, nb_want: %d", ssl->in_left, nb_want)); + // MBEDTLS_SSL_DEBUG_MSG(2, ("in_left: %d, nb_want: %d", ssl->in_left, nb_want)); /* * Done if we already have enough data. */ if (nb_want <= ssl->in_left) { - //MBEDTLS_SSL_DEBUG_MSG(2, ("<= fetch input")); + // MBEDTLS_SSL_DEBUG_MSG(2, ("<= fetch input")); return (0); } @@ -2301,14 +2301,14 @@ int mbedtls_ssl_fetch_input(mbedtls_ssl_context* ssl, size_t nb_want) else timeout = ssl->conf->read_timeout; - //MBEDTLS_SSL_DEBUG_MSG(3, ("f_recv_timeout: %u ms", timeout)); + // MBEDTLS_SSL_DEBUG_MSG(3, ("f_recv_timeout: %u ms", timeout)); if (ssl->f_recv_timeout != NULL) ret = ssl->f_recv_timeout(ssl->p_bio, ssl->in_hdr, len, timeout); else ret = ssl->f_recv(ssl->p_bio, ssl->in_hdr, len); - //MBEDTLS_SSL_DEBUG_RET(2, "ssl->f_recv(_timeout)", ret); + // MBEDTLS_SSL_DEBUG_RET(2, "ssl->f_recv(_timeout)", ret); if (ret == 0) return (MBEDTLS_ERR_SSL_CONN_EOF); @@ -2350,7 +2350,7 @@ int mbedtls_ssl_fetch_input(mbedtls_ssl_context* ssl, size_t nb_want) } else #endif { - //MBEDTLS_SSL_DEBUG_MSG(2, ("in_left: %d, nb_want: %d", ssl->in_left, nb_want)); + // MBEDTLS_SSL_DEBUG_MSG(2, ("in_left: %d, nb_want: %d", ssl->in_left, nb_want)); while (ssl->in_left < nb_want) { len = nb_want - ssl->in_left; @@ -2365,8 +2365,8 @@ int mbedtls_ssl_fetch_input(mbedtls_ssl_context* ssl, size_t nb_want) } } - //MBEDTLS_SSL_DEBUG_MSG(2, ("in_left: %d, nb_want: %d", ssl->in_left, nb_want)); - //MBEDTLS_SSL_DEBUG_RET(2, "ssl->f_recv(_timeout)", ret); + // MBEDTLS_SSL_DEBUG_MSG(2, ("in_left: %d, nb_want: %d", ssl->in_left, nb_want)); + // MBEDTLS_SSL_DEBUG_RET(2, "ssl->f_recv(_timeout)", ret); if (ret == 0) return (MBEDTLS_ERR_SSL_CONN_EOF); @@ -2383,7 +2383,7 @@ int mbedtls_ssl_fetch_input(mbedtls_ssl_context* ssl, size_t nb_want) } } - //MBEDTLS_SSL_DEBUG_MSG(2, ("<= fetch input")); + // MBEDTLS_SSL_DEBUG_MSG(2, ("<= fetch input")); return (0); } @@ -3823,7 +3823,7 @@ int mbedtls_ssl_read_record(mbedtls_ssl_context* ssl, unsigned update_hs_digest) ssl->keep_current_message = 0; } - //MBEDTLS_SSL_DEBUG_MSG(2, ("<= read record")); + // MBEDTLS_SSL_DEBUG_MSG(2, ("<= read record")); return (0); } diff --git a/nettls/ssl/x509_create.c b/nettls/ssl/x509_create.c index cf6a8a40..be34e3d4 100644 --- a/nettls/ssl/x509_create.c +++ b/nettls/ssl/x509_create.c @@ -103,8 +103,7 @@ static const x509_attr_descriptor_t x509_attrs[] = { {ADD_STRLEN("generationQualifier"), MBEDTLS_OID_AT_GENERATION_QUALIFIER, MBEDTLS_ASN1_UTF8_STRING}, {ADD_STRLEN("domainComponent"), MBEDTLS_OID_DOMAIN_COMPONENT, MBEDTLS_ASN1_IA5_STRING}, {ADD_STRLEN("DC"), MBEDTLS_OID_DOMAIN_COMPONENT, MBEDTLS_ASN1_IA5_STRING}, - {NULL, 0, NULL, MBEDTLS_ASN1_NULL} -}; + {NULL, 0, NULL, MBEDTLS_ASN1_NULL}}; static const x509_attr_descriptor_t* x509_attr_descr_from_name(const char* name, size_t name_len) { diff --git a/nettls/ssl/x509_crt.c b/nettls/ssl/x509_crt.c index 11c73033..3efcc90d 100644 --- a/nettls/ssl/x509_crt.c +++ b/nettls/ssl/x509_crt.c @@ -1499,28 +1499,27 @@ struct x509_crt_verify_string { }; static const struct x509_crt_verify_string x509_crt_verify_strings[] = { - {MBEDTLS_X509_BADCERT_EXPIRED, "The certificate validity has expired" }, - {MBEDTLS_X509_BADCERT_REVOKED, "The certificate has been revoked (is on a CRL)" }, - {MBEDTLS_X509_BADCERT_CN_MISMATCH, "The certificate Common Name (CN) does not match with the expected CN" }, - {MBEDTLS_X509_BADCERT_NOT_TRUSTED, "The certificate is not correctly signed by the trusted CA" }, - {MBEDTLS_X509_BADCRL_NOT_TRUSTED, "The CRL is not correctly signed by the trusted CA" }, - {MBEDTLS_X509_BADCRL_EXPIRED, "The CRL is expired" }, - {MBEDTLS_X509_BADCERT_MISSING, "Certificate was missing" }, - {MBEDTLS_X509_BADCERT_SKIP_VERIFY, "Certificate verification was skipped" }, - {MBEDTLS_X509_BADCERT_OTHER, "Other reason (can be used by verify callback)" }, - {MBEDTLS_X509_BADCERT_FUTURE, "The certificate validity starts in the future" }, - {MBEDTLS_X509_BADCRL_FUTURE, "The CRL is from the future" }, - {MBEDTLS_X509_BADCERT_KEY_USAGE, "Usage does not match the keyUsage extension" }, - {MBEDTLS_X509_BADCERT_EXT_KEY_USAGE, "Usage does not match the extendedKeyUsage extension" }, - {MBEDTLS_X509_BADCERT_NS_CERT_TYPE, "Usage does not match the nsCertType extension" }, - {MBEDTLS_X509_BADCERT_BAD_MD, "The certificate is signed with an unacceptable hash." }, - {MBEDTLS_X509_BADCERT_BAD_PK, "The certificate is signed with an unacceptable PK alg (eg RSA vs ECDSA)." }, - {MBEDTLS_X509_BADCERT_BAD_KEY, "The certificate is signed with an unacceptable key (eg bad curve, RSA too short)."}, - {MBEDTLS_X509_BADCRL_BAD_MD, "The CRL is signed with an unacceptable hash." }, - {MBEDTLS_X509_BADCRL_BAD_PK, "The CRL is signed with an unacceptable PK alg (eg RSA vs ECDSA)." }, - {MBEDTLS_X509_BADCRL_BAD_KEY, "The CRL is signed with an unacceptable key (eg bad curve, RSA too short)." }, - {0, NULL } -}; + {MBEDTLS_X509_BADCERT_EXPIRED, "The certificate validity has expired"}, + {MBEDTLS_X509_BADCERT_REVOKED, "The certificate has been revoked (is on a CRL)"}, + {MBEDTLS_X509_BADCERT_CN_MISMATCH, "The certificate Common Name (CN) does not match with the expected CN"}, + {MBEDTLS_X509_BADCERT_NOT_TRUSTED, "The certificate is not correctly signed by the trusted CA"}, + {MBEDTLS_X509_BADCRL_NOT_TRUSTED, "The CRL is not correctly signed by the trusted CA"}, + {MBEDTLS_X509_BADCRL_EXPIRED, "The CRL is expired"}, + {MBEDTLS_X509_BADCERT_MISSING, "Certificate was missing"}, + {MBEDTLS_X509_BADCERT_SKIP_VERIFY, "Certificate verification was skipped"}, + {MBEDTLS_X509_BADCERT_OTHER, "Other reason (can be used by verify callback)"}, + {MBEDTLS_X509_BADCERT_FUTURE, "The certificate validity starts in the future"}, + {MBEDTLS_X509_BADCRL_FUTURE, "The CRL is from the future"}, + {MBEDTLS_X509_BADCERT_KEY_USAGE, "Usage does not match the keyUsage extension"}, + {MBEDTLS_X509_BADCERT_EXT_KEY_USAGE, "Usage does not match the extendedKeyUsage extension"}, + {MBEDTLS_X509_BADCERT_NS_CERT_TYPE, "Usage does not match the nsCertType extension"}, + {MBEDTLS_X509_BADCERT_BAD_MD, "The certificate is signed with an unacceptable hash."}, + {MBEDTLS_X509_BADCERT_BAD_PK, "The certificate is signed with an unacceptable PK alg (eg RSA vs ECDSA)."}, + {MBEDTLS_X509_BADCERT_BAD_KEY, "The certificate is signed with an unacceptable key (eg bad curve, RSA too short)."}, + {MBEDTLS_X509_BADCRL_BAD_MD, "The CRL is signed with an unacceptable hash."}, + {MBEDTLS_X509_BADCRL_BAD_PK, "The CRL is signed with an unacceptable PK alg (eg RSA vs ECDSA)."}, + {MBEDTLS_X509_BADCRL_BAD_KEY, "The CRL is signed with an unacceptable key (eg bad curve, RSA too short)."}, + {0, NULL}}; int mbedtls_x509_crt_verify_info(char* buf, size_t size, const char* prefix, uint32_t flags) { diff --git a/nettls/ssl/xtea.c b/nettls/ssl/xtea.c index 61043fa4..7bdd5cb8 100644 --- a/nettls/ssl/xtea.c +++ b/nettls/ssl/xtea.c @@ -209,26 +209,15 @@ static const unsigned char xtea_test_key[6][16] = { {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} -}; - -static const unsigned char xtea_test_pt[6][8] = { - {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48}, - {0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41}, - {0x5a, 0x5b, 0x6e, 0x27, 0x89, 0x48, 0xd7, 0x7f}, - {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48}, - {0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41}, - {0x70, 0xe1, 0x22, 0x5d, 0x6e, 0x4e, 0x76, 0x55} -}; - -static const unsigned char xtea_test_ct[6][8] = { - {0x49, 0x7d, 0xf3, 0xd0, 0x72, 0x61, 0x2c, 0xb5}, - {0xe7, 0x8f, 0x2d, 0x13, 0x74, 0x43, 0x41, 0xd8}, - {0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41}, - {0xa0, 0x39, 0x05, 0x89, 0xf8, 0xb8, 0xef, 0xa5}, - {0xed, 0x23, 0x37, 0x5a, 0x82, 0x1a, 0x8c, 0x2d}, - {0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41} -}; + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; + +static const unsigned char xtea_test_pt[6][8] = {{0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48}, {0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41}, + {0x5a, 0x5b, 0x6e, 0x27, 0x89, 0x48, 0xd7, 0x7f}, {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48}, + {0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41}, {0x70, 0xe1, 0x22, 0x5d, 0x6e, 0x4e, 0x76, 0x55}}; + +static const unsigned char xtea_test_ct[6][8] = {{0x49, 0x7d, 0xf3, 0xd0, 0x72, 0x61, 0x2c, 0xb5}, {0xe7, 0x8f, 0x2d, 0x13, 0x74, 0x43, 0x41, 0xd8}, + {0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41}, {0xa0, 0x39, 0x05, 0x89, 0xf8, 0xb8, 0xef, 0xa5}, + {0xed, 0x23, 0x37, 0x5a, 0x82, 0x1a, 0x8c, 0x2d}, {0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41}}; /* * Checkup routine diff --git a/plugin/dllmain.cpp b/plugin/dllmain.cpp index 403c8122..eb11085f 100644 --- a/plugin/dllmain.cpp +++ b/plugin/dllmain.cpp @@ -32,9 +32,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {IID_INULL, NULL, "net.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{IID_INULL, NULL, "net.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/polipo/config.c b/polipo/config.c index 676bae45..e2a0b2a5 100644 --- a/polipo/config.c +++ b/polipo/config.c @@ -555,21 +555,8 @@ static int parseInt(char* buf, int offset, int* value_return) static struct config_state { char* name; int value; -} states[] = { - {"false", 0}, - {"no", 0}, - {"reluctantly", 1}, - {"seldom", 1}, - {"rarely", 1}, - {"lazily", 1}, - {"maybe", 2}, - {"perhaps", 2}, - {"happily", 3}, - {"often", 3}, - {"eagerly", 3}, - {"true", 4}, - {"yes", 4} -}; +} states[] = {{"false", 0}, {"no", 0}, {"reluctantly", 1}, {"seldom", 1}, {"rarely", 1}, {"lazily", 1}, {"maybe", 2}, + {"perhaps", 2}, {"happily", 3}, {"often", 3}, {"eagerly", 3}, {"true", 4}, {"yes", 4}}; static int parseState(char* buf, int offset, int kind) { diff --git a/polipo/diskcache.c b/polipo/diskcache.c index cfed0846..a42e7517 100644 --- a/polipo/diskcache.c +++ b/polipo/diskcache.c @@ -683,23 +683,23 @@ typedef struct _MimeEntry { } MimeEntryRec; static const MimeEntryRec mimeEntries[] = { - {"html", "text/html" }, - {"htm", "text/html" }, - {"text", "text/plain" }, - {"txt", "text/plain" }, - {"png", "image/png" }, - {"gif", "image/gif" }, - {"jpeg", "image/jpeg" }, - {"jpg", "image/jpeg" }, - {"ico", "image/x-icon" }, - {"pdf", "application/pdf" }, - {"ps", "application/postscript" }, - {"tar", "application/x-tar" }, - {"pac", "application/x-ns-proxy-autoconfig"}, - {"css", "text/css" }, - {"js", "application/x-javascript" }, - {"xml", "text/xml" }, - {"swf", "application/x-shockwave-flash" }, + {"html", "text/html"}, + {"htm", "text/html"}, + {"text", "text/plain"}, + {"txt", "text/plain"}, + {"png", "image/png"}, + {"gif", "image/gif"}, + {"jpeg", "image/jpeg"}, + {"jpg", "image/jpeg"}, + {"ico", "image/x-icon"}, + {"pdf", "application/pdf"}, + {"ps", "application/postscript"}, + {"tar", "application/x-tar"}, + {"pac", "application/x-ns-proxy-autoconfig"}, + {"css", "text/css"}, + {"js", "application/x-javascript"}, + {"xml", "text/xml"}, + {"swf", "application/x-shockwave-flash"}, }; static char* localObjectMimeType(ObjectPtr object, char** encoding_return) diff --git a/polipo/diskcache.h b/polipo/diskcache.h index 4b6bef24..299714d2 100644 --- a/polipo/diskcache.h +++ b/polipo/diskcache.h @@ -36,7 +36,7 @@ typedef struct _DiskCacheEntry { short metadataDirty; struct _DiskCacheEntry* next; struct _DiskCacheEntry* previous; -} *DiskCacheEntryPtr, DiskCacheEntryRec; +} * DiskCacheEntryPtr, DiskCacheEntryRec; typedef struct _DiskObject { char* location; diff --git a/polipo/log.c b/polipo/log.c index b99982f4..73f4d08e 100644 --- a/polipo/log.c +++ b/polipo/log.c @@ -156,52 +156,51 @@ static int translateFacility(AtomPtr facility) This list is terminated by a NULL facility name. */ FacilitiesRec facilities[] = { - /* These are all the facilities found in glibc 2.5. */ + /* These are all the facilities found in glibc 2.5. */ #ifdef LOG_AUTH - {"auth", LOG_AUTH }, + {"auth", LOG_AUTH}, #endif #ifdef LOG_AUTHPRIV {"authpriv", LOG_AUTHPRIV}, #endif #ifdef LOG_CRON - {"cron", LOG_CRON }, + {"cron", LOG_CRON}, #endif #ifdef LOG_DAEMON - {"daemon", LOG_DAEMON }, + {"daemon", LOG_DAEMON}, #endif #ifdef LOG_FTP - {"ftp", LOG_FTP }, + {"ftp", LOG_FTP}, #endif #ifdef LOG_KERN - {"kern", LOG_KERN }, + {"kern", LOG_KERN}, #endif #ifdef LOG_LPR - {"lpr", LOG_LPR }, + {"lpr", LOG_LPR}, #endif #ifdef LOG_MAIL - {"mail", LOG_MAIL }, + {"mail", LOG_MAIL}, #endif #ifdef LOG_NEWS - {"news", LOG_NEWS }, + {"news", LOG_NEWS}, #endif #ifdef LOG_SYSLOG - {"syslog", LOG_SYSLOG }, + {"syslog", LOG_SYSLOG}, #endif #ifdef LOG_uucp - {"uucp", LOG_UUCP }, + {"uucp", LOG_UUCP}, #endif - /* These are required by POSIX. */ - {"user", LOG_USER }, - {"local0", LOG_LOCAL0 }, - {"local1", LOG_LOCAL1 }, - {"local2", LOG_LOCAL2 }, - {"local3", LOG_LOCAL3 }, - {"local4", LOG_LOCAL4 }, - {"local5", LOG_LOCAL5 }, - {"local6", LOG_LOCAL6 }, - {"local7", LOG_LOCAL7 }, - {NULL, 0 } - }; + /* These are required by POSIX. */ + {"user", LOG_USER}, + {"local0", LOG_LOCAL0}, + {"local1", LOG_LOCAL1}, + {"local2", LOG_LOCAL2}, + {"local3", LOG_LOCAL3}, + {"local4", LOG_LOCAL4}, + {"local5", LOG_LOCAL5}, + {"local6", LOG_LOCAL6}, + {"local7", LOG_LOCAL7}, + {NULL, 0}}; FacilitiesRec* current; @@ -237,17 +236,9 @@ static int translatePriority(int type) /* The list is terminated with a type of zero. */ - PrioritiesRec priorities[] = { - {L_ERROR, LOG_ERR }, - {L_WARN, LOG_WARNING}, - {L_INFO, LOG_NOTICE }, - {L_FORBIDDEN, LOG_DEBUG }, - {L_UNCACHEABLE, LOG_DEBUG }, - {L_SUPERSEDED, LOG_DEBUG }, - {L_VARY, LOG_DEBUG }, - {L_TUNNEL, LOG_NOTICE }, - {0, 0 } - }; + PrioritiesRec priorities[] = {{L_ERROR, LOG_ERR}, {L_WARN, LOG_WARNING}, {L_INFO, LOG_NOTICE}, + {L_FORBIDDEN, LOG_DEBUG}, {L_UNCACHEABLE, LOG_DEBUG}, {L_SUPERSEDED, LOG_DEBUG}, + {L_VARY, LOG_DEBUG}, {L_TUNNEL, LOG_NOTICE}, {0, 0}}; PrioritiesRec* current; current = priorities; diff --git a/runtime/dllmain.cpp b/runtime/dllmain.cpp index a4b77b1f..dd5397ff 100644 --- a/runtime/dllmain.cpp +++ b/runtime/dllmain.cpp @@ -33,9 +33,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {CLSID_CRunTime, &ClassFactory::GetClass, "runtime.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{CLSID_CRunTime, &ClassFactory::GetClass, "runtime.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/runtime/runtimeimpl.h b/runtime/runtimeimpl.h index 959fd9fa..d655385a 100644 --- a/runtime/runtimeimpl.h +++ b/runtime/runtimeimpl.h @@ -6,9 +6,7 @@ #include "threadimpl.h" #include "threadpoolimpl.h" -class CRunTimeImpl : public IRunTime, - public IPlugin, - public CUnknownImp +class CRunTimeImpl : public IRunTime, public IPlugin, public CUnknownImp { public: CRunTimeImpl(void); diff --git a/stdcrt/algorithm/compat_md5.c b/stdcrt/algorithm/compat_md5.c index fb26e544..939fd5b4 100644 --- a/stdcrt/algorithm/compat_md5.c +++ b/stdcrt/algorithm/compat_md5.c @@ -1,85 +1,81 @@ #include -#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ +#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ #ifdef ARCH_IS_BIG_ENDIAN -# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) +#define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) #else -# define BYTE_ORDER 0 +#define BYTE_ORDER 0 #endif #define T_MASK ((md5_word_t)~0) -#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) -#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) -#define T3 0x242070db -#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111) -#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050) -#define T6 0x4787c62a -#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec) -#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe) -#define T9 0x698098d8 -#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850) -#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e) -#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841) +#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) +#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) +#define T3 0x242070db +#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111) +#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050) +#define T6 0x4787c62a +#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec) +#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe) +#define T9 0x698098d8 +#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850) +#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e) +#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841) #define T13 0x6b901122 -#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c) -#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71) +#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c) +#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71) #define T16 0x49b40821 -#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d) -#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf) +#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d) +#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf) #define T19 0x265e5a51 -#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855) -#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2) +#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855) +#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2) #define T22 0x02441453 -#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e) -#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437) +#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e) +#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437) #define T25 0x21e1cde6 -#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829) -#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278) +#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829) +#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278) #define T28 0x455a14ed -#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa) -#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07) +#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa) +#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07) #define T31 0x676f02d9 -#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375) -#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd) -#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e) +#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375) +#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd) +#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e) #define T35 0x6d9d6122 -#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3) -#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb) +#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3) +#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb) #define T38 0x4bdecfa9 -#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f) -#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f) +#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f) +#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f) #define T41 0x289b7ec6 -#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805) -#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a) +#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805) +#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a) #define T44 0x04881d05 -#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6) -#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a) +#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6) +#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a) #define T47 0x1fa27cf8 -#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a) -#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb) +#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a) +#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb) #define T50 0x432aff97 -#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58) -#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6) +#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58) +#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6) #define T53 0x655b59c3 -#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d) -#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82) -#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e) +#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d) +#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82) +#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e) #define T57 0x6fa87e4f -#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f) -#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb) +#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f) +#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb) #define T60 0x4e0811a1 -#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d) -#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca) +#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d) +#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca) #define T63 0x2ad7d2bb -#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) +#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) - -static void -md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) +static void md5_process(md5_state_t* pms, const md5_byte_t* data /*[64]*/) { - md5_word_t - a = pms->abcd[0], b = pms->abcd[1], - c = pms->abcd[2], d = pms->abcd[3]; + md5_word_t a = pms->abcd[0], b = pms->abcd[1], c = pms->abcd[2], d = pms->abcd[3]; md5_word_t t; #if BYTE_ORDER > 0 /* Define storage only for big-endian CPUs. */ @@ -87,56 +83,56 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) #else /* Define storage for little-endian or both types of CPUs. */ md5_word_t xbuf[16]; - const md5_word_t *X; + const md5_word_t* X; #endif { #if BYTE_ORDER == 0 - /* - * Determine dynamically whether this is a big-endian or - * little-endian machine, since we can use a more efficient - * algorithm on the latter. - */ - static const int w = 1; + /* + * Determine dynamically whether this is a big-endian or + * little-endian machine, since we can use a more efficient + * algorithm on the latter. + */ + static const int w = 1; - if (*((const md5_byte_t *)&w)) /* dynamic little-endian */ + if (*((const md5_byte_t*)&w)) /* dynamic little-endian */ #endif -#if BYTE_ORDER <= 0 /* little-endian */ - { - /* - * On little-endian machines, we can process properly aligned - * data without copying it. - */ - if (!((data - (const md5_byte_t *)0) & 3)) { - /* data are properly aligned */ - X = (const md5_word_t *)data; - } else { - /* not aligned */ - memcpy(xbuf, data, 64); - X = xbuf; - } - } +#if BYTE_ORDER <= 0 /* little-endian */ + { + /* + * On little-endian machines, we can process properly aligned + * data without copying it. + */ + if (!((data - (const md5_byte_t*)0) & 3)) { + /* data are properly aligned */ + X = (const md5_word_t*)data; + } else { + /* not aligned */ + memcpy(xbuf, data, 64); + X = xbuf; + } + } #endif #if BYTE_ORDER == 0 - else /* dynamic big-endian */ + else /* dynamic big-endian */ #endif -#if BYTE_ORDER >= 0 /* big-endian */ - { - /* - * On big-endian machines, we must arrange the bytes in the - * right order. - */ - const md5_byte_t *xp = data; - int i; +#if BYTE_ORDER >= 0 /* big-endian */ + { + /* + * On big-endian machines, we must arrange the bytes in the + * right order. + */ + const md5_byte_t* xp = data; + int i; -# if BYTE_ORDER == 0 - X = xbuf; /* (dynamic only) */ -# else -# define xbuf X /* (static only) */ -# endif - for (i = 0; i < 16; ++i, xp += 4) - xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); - } +#if BYTE_ORDER == 0 + X = xbuf; /* (dynamic only) */ +#else +#define xbuf X /* (static only) */ +#endif + for (i = 0; i < 16; ++i, xp += 4) + xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); + } #endif } @@ -146,117 +142,116 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) /* Let [abcd k s i] denote the operation a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ #define F(x, y, z) (((x) & (y)) | (~(x) & (z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + F(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b +#define SET(a, b, c, d, k, s, Ti) \ + t = a + F(b, c, d) + X[k] + Ti; \ + a = ROTATE_LEFT(t, s) + b /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 7, T1); - SET(d, a, b, c, 1, 12, T2); - SET(c, d, a, b, 2, 17, T3); - SET(b, c, d, a, 3, 22, T4); - SET(a, b, c, d, 4, 7, T5); - SET(d, a, b, c, 5, 12, T6); - SET(c, d, a, b, 6, 17, T7); - SET(b, c, d, a, 7, 22, T8); - SET(a, b, c, d, 8, 7, T9); - SET(d, a, b, c, 9, 12, T10); + SET(a, b, c, d, 0, 7, T1); + SET(d, a, b, c, 1, 12, T2); + SET(c, d, a, b, 2, 17, T3); + SET(b, c, d, a, 3, 22, T4); + SET(a, b, c, d, 4, 7, T5); + SET(d, a, b, c, 5, 12, T6); + SET(c, d, a, b, 6, 17, T7); + SET(b, c, d, a, 7, 22, T8); + SET(a, b, c, d, 8, 7, T9); + SET(d, a, b, c, 9, 12, T10); SET(c, d, a, b, 10, 17, T11); SET(b, c, d, a, 11, 22, T12); - SET(a, b, c, d, 12, 7, T13); + SET(a, b, c, d, 12, 7, T13); SET(d, a, b, c, 13, 12, T14); SET(c, d, a, b, 14, 17, T15); SET(b, c, d, a, 15, 22, T16); #undef SET - /* Round 2. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ + /* Round 2. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ #define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + G(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 1, 5, T17); - SET(d, a, b, c, 6, 9, T18); +#define SET(a, b, c, d, k, s, Ti) \ + t = a + G(b, c, d) + X[k] + Ti; \ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 1, 5, T17); + SET(d, a, b, c, 6, 9, T18); SET(c, d, a, b, 11, 14, T19); - SET(b, c, d, a, 0, 20, T20); - SET(a, b, c, d, 5, 5, T21); - SET(d, a, b, c, 10, 9, T22); + SET(b, c, d, a, 0, 20, T20); + SET(a, b, c, d, 5, 5, T21); + SET(d, a, b, c, 10, 9, T22); SET(c, d, a, b, 15, 14, T23); - SET(b, c, d, a, 4, 20, T24); - SET(a, b, c, d, 9, 5, T25); - SET(d, a, b, c, 14, 9, T26); - SET(c, d, a, b, 3, 14, T27); - SET(b, c, d, a, 8, 20, T28); - SET(a, b, c, d, 13, 5, T29); - SET(d, a, b, c, 2, 9, T30); - SET(c, d, a, b, 7, 14, T31); + SET(b, c, d, a, 4, 20, T24); + SET(a, b, c, d, 9, 5, T25); + SET(d, a, b, c, 14, 9, T26); + SET(c, d, a, b, 3, 14, T27); + SET(b, c, d, a, 8, 20, T28); + SET(a, b, c, d, 13, 5, T29); + SET(d, a, b, c, 2, 9, T30); + SET(c, d, a, b, 7, 14, T31); SET(b, c, d, a, 12, 20, T32); #undef SET - /* Round 3. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ + /* Round 3. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ #define H(x, y, z) ((x) ^ (y) ^ (z)) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + H(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 5, 4, T33); - SET(d, a, b, c, 8, 11, T34); +#define SET(a, b, c, d, k, s, Ti) \ + t = a + H(b, c, d) + X[k] + Ti; \ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 5, 4, T33); + SET(d, a, b, c, 8, 11, T34); SET(c, d, a, b, 11, 16, T35); SET(b, c, d, a, 14, 23, T36); - SET(a, b, c, d, 1, 4, T37); - SET(d, a, b, c, 4, 11, T38); - SET(c, d, a, b, 7, 16, T39); + SET(a, b, c, d, 1, 4, T37); + SET(d, a, b, c, 4, 11, T38); + SET(c, d, a, b, 7, 16, T39); SET(b, c, d, a, 10, 23, T40); - SET(a, b, c, d, 13, 4, T41); - SET(d, a, b, c, 0, 11, T42); - SET(c, d, a, b, 3, 16, T43); - SET(b, c, d, a, 6, 23, T44); - SET(a, b, c, d, 9, 4, T45); + SET(a, b, c, d, 13, 4, T41); + SET(d, a, b, c, 0, 11, T42); + SET(c, d, a, b, 3, 16, T43); + SET(b, c, d, a, 6, 23, T44); + SET(a, b, c, d, 9, 4, T45); SET(d, a, b, c, 12, 11, T46); SET(c, d, a, b, 15, 16, T47); - SET(b, c, d, a, 2, 23, T48); + SET(b, c, d, a, 2, 23, T48); #undef SET - /* Round 4. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ + /* Round 4. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ #define I(x, y, z) ((y) ^ ((x) | ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + I(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 6, T49); - SET(d, a, b, c, 7, 10, T50); +#define SET(a, b, c, d, k, s, Ti) \ + t = a + I(b, c, d) + X[k] + Ti; \ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 0, 6, T49); + SET(d, a, b, c, 7, 10, T50); SET(c, d, a, b, 14, 15, T51); - SET(b, c, d, a, 5, 21, T52); - SET(a, b, c, d, 12, 6, T53); - SET(d, a, b, c, 3, 10, T54); + SET(b, c, d, a, 5, 21, T52); + SET(a, b, c, d, 12, 6, T53); + SET(d, a, b, c, 3, 10, T54); SET(c, d, a, b, 10, 15, T55); - SET(b, c, d, a, 1, 21, T56); - SET(a, b, c, d, 8, 6, T57); + SET(b, c, d, a, 1, 21, T56); + SET(a, b, c, d, 8, 6, T57); SET(d, a, b, c, 15, 10, T58); - SET(c, d, a, b, 6, 15, T59); + SET(c, d, a, b, 6, 15, T59); SET(b, c, d, a, 13, 21, T60); - SET(a, b, c, d, 4, 6, T61); + SET(a, b, c, d, 4, 6, T61); SET(d, a, b, c, 11, 10, T62); - SET(c, d, a, b, 2, 15, T63); - SET(b, c, d, a, 9, 21, T64); + SET(c, d, a, b, 2, 15, T63); + SET(b, c, d, a, 9, 21, T64); #undef SET - /* Then perform the following additions. (That is increment each - of the four registers by the value it had before this block - was started.) */ + /* Then perform the following additions. (That is increment each + of the four registers by the value it had before this block + was started.) */ pms->abcd[0] += a; pms->abcd[1] += b; pms->abcd[2] += c; pms->abcd[3] += d; } -void -md5_init(md5_state_t *pms) +void md5_init(md5_state_t* pms) { pms->count[0] = pms->count[1] = 0; pms->abcd[0] = 0x67452301; @@ -265,63 +260,57 @@ md5_init(md5_state_t *pms) pms->abcd[3] = 0x10325476; } -void -md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) +void md5_append(md5_state_t* pms, const md5_byte_t* data, int nbytes) { - const md5_byte_t *p = data; + const md5_byte_t* p = data; int left = nbytes; int offset = (pms->count[0] >> 3) & 63; md5_word_t nbits = (md5_word_t)(nbytes << 3); if (nbytes <= 0) - return; + return; /* Update the message length. */ pms->count[1] += nbytes >> 29; pms->count[0] += nbits; if (pms->count[0] < nbits) - pms->count[1]++; + pms->count[1]++; /* Process an initial partial block. */ if (offset) { - int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); + int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); - memcpy(pms->buf + offset, p, copy); - if (offset + copy < 64) - return; - p += copy; - left -= copy; - md5_process(pms, pms->buf); + memcpy(pms->buf + offset, p, copy); + if (offset + copy < 64) + return; + p += copy; + left -= copy; + md5_process(pms, pms->buf); } /* Process full blocks. */ for (; left >= 64; p += 64, left -= 64) - md5_process(pms, p); + md5_process(pms, p); /* Process a final partial block. */ if (left) - memcpy(pms->buf, p, left); + memcpy(pms->buf, p, left); } -void -md5_finish(md5_state_t *pms, md5_byte_t digest[16]) +void md5_finish(md5_state_t* pms, md5_byte_t digest[16]) { - static const md5_byte_t pad[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + static const md5_byte_t pad[64] = {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; md5_byte_t data[8]; int i; /* Save the length before padding. */ for (i = 0; i < 8; ++i) - data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); + data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); /* Pad to 56 bytes mod 64. */ md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); /* Append the length. */ md5_append(pms, data, 8); for (i = 0; i < 16; ++i) - digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); + digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); } diff --git a/stdcrt/algorithm/compat_sha1.c b/stdcrt/algorithm/compat_sha1.c index 1c769585..2d517acb 100644 --- a/stdcrt/algorithm/compat_sha1.c +++ b/stdcrt/algorithm/compat_sha1.c @@ -4,29 +4,27 @@ * 32-bit integer manipulation macros (big endian) */ #ifndef GET_ULONG_BE -#define GET_ULONG_BE(n,b,i) \ -{ \ - (n) = ( (unsigned long) (b)[(i) ] << 24 ) \ - | ( (unsigned long) (b)[(i) + 1] << 16 ) \ - | ( (unsigned long) (b)[(i) + 2] << 8 ) \ - | ( (unsigned long) (b)[(i) + 3] ); \ -} +#define GET_ULONG_BE(n, b, i) \ + { \ + (n) = ((unsigned long)(b)[(i)] << 24) | ((unsigned long)(b)[(i) + 1] << 16) | ((unsigned long)(b)[(i) + 2] << 8) \ + | ((unsigned long)(b)[(i) + 3]); \ + } #endif #ifndef PUT_ULONG_BE -#define PUT_ULONG_BE(n,b,i) \ -{ \ - (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ - (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ - (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ - (b)[(i) + 3] = (unsigned char) ( (n) ); \ -} +#define PUT_ULONG_BE(n, b, i) \ + { \ + (b)[(i)] = (unsigned char)((n) >> 24); \ + (b)[(i) + 1] = (unsigned char)((n) >> 16); \ + (b)[(i) + 2] = (unsigned char)((n) >> 8); \ + (b)[(i) + 3] = (unsigned char)((n)); \ + } #endif /* * SHA-1 context setup */ -void sha1_starts( sha1_context *ctx ) +void sha1_starts(sha1_context* ctx) { ctx->total[0] = 0; ctx->total[1] = 0; @@ -38,40 +36,36 @@ void sha1_starts( sha1_context *ctx ) ctx->state[4] = 0xC3D2E1F0; } -static void sha1_process( sha1_context *ctx, const unsigned char data[64] ) +static void sha1_process(sha1_context* ctx, const unsigned char data[64]) { unsigned long temp, W[16], A, B, C, D, E; - GET_ULONG_BE( W[ 0], data, 0 ); - GET_ULONG_BE( W[ 1], data, 4 ); - GET_ULONG_BE( W[ 2], data, 8 ); - GET_ULONG_BE( W[ 3], data, 12 ); - GET_ULONG_BE( W[ 4], data, 16 ); - GET_ULONG_BE( W[ 5], data, 20 ); - GET_ULONG_BE( W[ 6], data, 24 ); - GET_ULONG_BE( W[ 7], data, 28 ); - GET_ULONG_BE( W[ 8], data, 32 ); - GET_ULONG_BE( W[ 9], data, 36 ); - GET_ULONG_BE( W[10], data, 40 ); - GET_ULONG_BE( W[11], data, 44 ); - GET_ULONG_BE( W[12], data, 48 ); - GET_ULONG_BE( W[13], data, 52 ); - GET_ULONG_BE( W[14], data, 56 ); - GET_ULONG_BE( W[15], data, 60 ); - -#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) - -#define R(t) \ -( \ - temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \ - W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \ - ( W[t & 0x0F] = S(temp,1) ) \ -) - -#define P(a,b,c,d,e,x) \ -{ \ - e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \ -} + GET_ULONG_BE(W[0], data, 0); + GET_ULONG_BE(W[1], data, 4); + GET_ULONG_BE(W[2], data, 8); + GET_ULONG_BE(W[3], data, 12); + GET_ULONG_BE(W[4], data, 16); + GET_ULONG_BE(W[5], data, 20); + GET_ULONG_BE(W[6], data, 24); + GET_ULONG_BE(W[7], data, 28); + GET_ULONG_BE(W[8], data, 32); + GET_ULONG_BE(W[9], data, 36); + GET_ULONG_BE(W[10], data, 40); + GET_ULONG_BE(W[11], data, 44); + GET_ULONG_BE(W[12], data, 48); + GET_ULONG_BE(W[13], data, 52); + GET_ULONG_BE(W[14], data, 56); + GET_ULONG_BE(W[15], data, 60); + +#define S(x, n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) + +#define R(t) (temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ W[(t - 14) & 0x0F] ^ W[t & 0x0F], (W[t & 0x0F] = S(temp, 1))) + +#define P(a, b, c, d, e, x) \ + { \ + e += S(a, 5) + F(b, c, d) + K + x; \ + b = S(b, 30); \ + } A = ctx->state[0]; B = ctx->state[1]; @@ -79,110 +73,110 @@ static void sha1_process( sha1_context *ctx, const unsigned char data[64] ) D = ctx->state[3]; E = ctx->state[4]; -#define F(x,y,z) (z ^ (x & (y ^ z))) -#define K 0x5A827999 - - P( A, B, C, D, E, W[0] ); - P( E, A, B, C, D, W[1] ); - P( D, E, A, B, C, W[2] ); - P( C, D, E, A, B, W[3] ); - P( B, C, D, E, A, W[4] ); - P( A, B, C, D, E, W[5] ); - P( E, A, B, C, D, W[6] ); - P( D, E, A, B, C, W[7] ); - P( C, D, E, A, B, W[8] ); - P( B, C, D, E, A, W[9] ); - P( A, B, C, D, E, W[10] ); - P( E, A, B, C, D, W[11] ); - P( D, E, A, B, C, W[12] ); - P( C, D, E, A, B, W[13] ); - P( B, C, D, E, A, W[14] ); - P( A, B, C, D, E, W[15] ); - P( E, A, B, C, D, R(16) ); - P( D, E, A, B, C, R(17) ); - P( C, D, E, A, B, R(18) ); - P( B, C, D, E, A, R(19) ); +#define F(x, y, z) (z ^ (x & (y ^ z))) +#define K 0x5A827999 + + P(A, B, C, D, E, W[0]); + P(E, A, B, C, D, W[1]); + P(D, E, A, B, C, W[2]); + P(C, D, E, A, B, W[3]); + P(B, C, D, E, A, W[4]); + P(A, B, C, D, E, W[5]); + P(E, A, B, C, D, W[6]); + P(D, E, A, B, C, W[7]); + P(C, D, E, A, B, W[8]); + P(B, C, D, E, A, W[9]); + P(A, B, C, D, E, W[10]); + P(E, A, B, C, D, W[11]); + P(D, E, A, B, C, W[12]); + P(C, D, E, A, B, W[13]); + P(B, C, D, E, A, W[14]); + P(A, B, C, D, E, W[15]); + P(E, A, B, C, D, R(16)); + P(D, E, A, B, C, R(17)); + P(C, D, E, A, B, R(18)); + P(B, C, D, E, A, R(19)); #undef K #undef F -#define F(x,y,z) (x ^ y ^ z) -#define K 0x6ED9EBA1 - - P( A, B, C, D, E, R(20) ); - P( E, A, B, C, D, R(21) ); - P( D, E, A, B, C, R(22) ); - P( C, D, E, A, B, R(23) ); - P( B, C, D, E, A, R(24) ); - P( A, B, C, D, E, R(25) ); - P( E, A, B, C, D, R(26) ); - P( D, E, A, B, C, R(27) ); - P( C, D, E, A, B, R(28) ); - P( B, C, D, E, A, R(29) ); - P( A, B, C, D, E, R(30) ); - P( E, A, B, C, D, R(31) ); - P( D, E, A, B, C, R(32) ); - P( C, D, E, A, B, R(33) ); - P( B, C, D, E, A, R(34) ); - P( A, B, C, D, E, R(35) ); - P( E, A, B, C, D, R(36) ); - P( D, E, A, B, C, R(37) ); - P( C, D, E, A, B, R(38) ); - P( B, C, D, E, A, R(39) ); +#define F(x, y, z) (x ^ y ^ z) +#define K 0x6ED9EBA1 + + P(A, B, C, D, E, R(20)); + P(E, A, B, C, D, R(21)); + P(D, E, A, B, C, R(22)); + P(C, D, E, A, B, R(23)); + P(B, C, D, E, A, R(24)); + P(A, B, C, D, E, R(25)); + P(E, A, B, C, D, R(26)); + P(D, E, A, B, C, R(27)); + P(C, D, E, A, B, R(28)); + P(B, C, D, E, A, R(29)); + P(A, B, C, D, E, R(30)); + P(E, A, B, C, D, R(31)); + P(D, E, A, B, C, R(32)); + P(C, D, E, A, B, R(33)); + P(B, C, D, E, A, R(34)); + P(A, B, C, D, E, R(35)); + P(E, A, B, C, D, R(36)); + P(D, E, A, B, C, R(37)); + P(C, D, E, A, B, R(38)); + P(B, C, D, E, A, R(39)); #undef K #undef F -#define F(x,y,z) ((x & y) | (z & (x | y))) -#define K 0x8F1BBCDC - - P( A, B, C, D, E, R(40) ); - P( E, A, B, C, D, R(41) ); - P( D, E, A, B, C, R(42) ); - P( C, D, E, A, B, R(43) ); - P( B, C, D, E, A, R(44) ); - P( A, B, C, D, E, R(45) ); - P( E, A, B, C, D, R(46) ); - P( D, E, A, B, C, R(47) ); - P( C, D, E, A, B, R(48) ); - P( B, C, D, E, A, R(49) ); - P( A, B, C, D, E, R(50) ); - P( E, A, B, C, D, R(51) ); - P( D, E, A, B, C, R(52) ); - P( C, D, E, A, B, R(53) ); - P( B, C, D, E, A, R(54) ); - P( A, B, C, D, E, R(55) ); - P( E, A, B, C, D, R(56) ); - P( D, E, A, B, C, R(57) ); - P( C, D, E, A, B, R(58) ); - P( B, C, D, E, A, R(59) ); +#define F(x, y, z) ((x & y) | (z & (x | y))) +#define K 0x8F1BBCDC + + P(A, B, C, D, E, R(40)); + P(E, A, B, C, D, R(41)); + P(D, E, A, B, C, R(42)); + P(C, D, E, A, B, R(43)); + P(B, C, D, E, A, R(44)); + P(A, B, C, D, E, R(45)); + P(E, A, B, C, D, R(46)); + P(D, E, A, B, C, R(47)); + P(C, D, E, A, B, R(48)); + P(B, C, D, E, A, R(49)); + P(A, B, C, D, E, R(50)); + P(E, A, B, C, D, R(51)); + P(D, E, A, B, C, R(52)); + P(C, D, E, A, B, R(53)); + P(B, C, D, E, A, R(54)); + P(A, B, C, D, E, R(55)); + P(E, A, B, C, D, R(56)); + P(D, E, A, B, C, R(57)); + P(C, D, E, A, B, R(58)); + P(B, C, D, E, A, R(59)); #undef K #undef F -#define F(x,y,z) (x ^ y ^ z) -#define K 0xCA62C1D6 - - P( A, B, C, D, E, R(60) ); - P( E, A, B, C, D, R(61) ); - P( D, E, A, B, C, R(62) ); - P( C, D, E, A, B, R(63) ); - P( B, C, D, E, A, R(64) ); - P( A, B, C, D, E, R(65) ); - P( E, A, B, C, D, R(66) ); - P( D, E, A, B, C, R(67) ); - P( C, D, E, A, B, R(68) ); - P( B, C, D, E, A, R(69) ); - P( A, B, C, D, E, R(70) ); - P( E, A, B, C, D, R(71) ); - P( D, E, A, B, C, R(72) ); - P( C, D, E, A, B, R(73) ); - P( B, C, D, E, A, R(74) ); - P( A, B, C, D, E, R(75) ); - P( E, A, B, C, D, R(76) ); - P( D, E, A, B, C, R(77) ); - P( C, D, E, A, B, R(78) ); - P( B, C, D, E, A, R(79) ); +#define F(x, y, z) (x ^ y ^ z) +#define K 0xCA62C1D6 + + P(A, B, C, D, E, R(60)); + P(E, A, B, C, D, R(61)); + P(D, E, A, B, C, R(62)); + P(C, D, E, A, B, R(63)); + P(B, C, D, E, A, R(64)); + P(A, B, C, D, E, R(65)); + P(E, A, B, C, D, R(66)); + P(D, E, A, B, C, R(67)); + P(C, D, E, A, B, R(68)); + P(B, C, D, E, A, R(69)); + P(A, B, C, D, E, R(70)); + P(E, A, B, C, D, R(71)); + P(D, E, A, B, C, R(72)); + P(C, D, E, A, B, R(73)); + P(B, C, D, E, A, R(74)); + P(A, B, C, D, E, R(75)); + P(E, A, B, C, D, R(76)); + P(D, E, A, B, C, R(77)); + P(C, D, E, A, B, R(78)); + P(B, C, D, E, A, R(79)); #undef K #undef F @@ -197,80 +191,69 @@ static void sha1_process( sha1_context *ctx, const unsigned char data[64] ) /* * SHA-1 process buffer */ -void sha1_update( sha1_context *ctx, const unsigned char *input, size_t ilen ) +void sha1_update(sha1_context* ctx, const unsigned char* input, size_t ilen) { size_t fill; unsigned long left; - if( ilen <= 0 ) + if (ilen <= 0) return; left = ctx->total[0] & 0x3F; fill = 64 - left; - ctx->total[0] += (unsigned long) ilen; + ctx->total[0] += (unsigned long)ilen; ctx->total[0] &= 0xFFFFFFFF; - if( ctx->total[0] < (unsigned long) ilen ) + if (ctx->total[0] < (unsigned long)ilen) ctx->total[1]++; - if( left && ilen >= fill ) - { - memcpy( (void *) (ctx->buffer + left), - (void *) input, fill ); - sha1_process( ctx, ctx->buffer ); + if (left && ilen >= fill) { + memcpy((void*)(ctx->buffer + left), (void*)input, fill); + sha1_process(ctx, ctx->buffer); input += fill; - ilen -= fill; + ilen -= fill; left = 0; } - while( ilen >= 64 ) - { - sha1_process( ctx, input ); + while (ilen >= 64) { + sha1_process(ctx, input); input += 64; - ilen -= 64; + ilen -= 64; } - if( ilen > 0 ) - { - memcpy( (void *) (ctx->buffer + left), - (void *) input, ilen ); + if (ilen > 0) { + memcpy((void*)(ctx->buffer + left), (void*)input, ilen); } } -static const unsigned char sha1_padding[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; +static const unsigned char sha1_padding[64] = {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; /* * SHA-1 final digest */ -void sha1_finish( sha1_context *ctx, unsigned char output[20] ) +void sha1_finish(sha1_context* ctx, unsigned char output[20]) { unsigned long last, padn; unsigned long high, low; unsigned char msglen[8]; - high = ( ctx->total[0] >> 29 ) - | ( ctx->total[1] << 3 ); - low = ( ctx->total[0] << 3 ); + high = (ctx->total[0] >> 29) | (ctx->total[1] << 3); + low = (ctx->total[0] << 3); - PUT_ULONG_BE( high, msglen, 0 ); - PUT_ULONG_BE( low, msglen, 4 ); + PUT_ULONG_BE(high, msglen, 0); + PUT_ULONG_BE(low, msglen, 4); last = ctx->total[0] & 0x3F; - padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); + padn = (last < 56) ? (56 - last) : (120 - last); - sha1_update( ctx, (unsigned char *) sha1_padding, padn ); - sha1_update( ctx, msglen, 8 ); + sha1_update(ctx, (unsigned char*)sha1_padding, padn); + sha1_update(ctx, msglen, 8); - PUT_ULONG_BE( ctx->state[0], output, 0 ); - PUT_ULONG_BE( ctx->state[1], output, 4 ); - PUT_ULONG_BE( ctx->state[2], output, 8 ); - PUT_ULONG_BE( ctx->state[3], output, 12 ); - PUT_ULONG_BE( ctx->state[4], output, 16 ); + PUT_ULONG_BE(ctx->state[0], output, 0); + PUT_ULONG_BE(ctx->state[1], output, 4); + PUT_ULONG_BE(ctx->state[2], output, 8); + PUT_ULONG_BE(ctx->state[3], output, 12); + PUT_ULONG_BE(ctx->state[4], output, 16); } diff --git a/stdcrt/code/compat_endian.c b/stdcrt/code/compat_endian.c index c9c69304..b872c16f 100644 --- a/stdcrt/code/compat_endian.c +++ b/stdcrt/code/compat_endian.c @@ -25,8 +25,7 @@ uint32_t bluint32(uint32_t value) int uint64touint32(uint64_t u64value, uint32* u32value) { - rc_error(u32value != NULL, S_ERROR) - uint8_t u8value[8] = {0x00}; + rc_error(u32value != NULL, S_ERROR) uint8_t u8value[8] = {0x00}; un_putll(u8value, u64value); int rc = 0; diff --git a/stdcrt/code/compat_sjson.c b/stdcrt/code/compat_sjson.c index 4d97dcbb..9d91d92f 100644 --- a/stdcrt/code/compat_sjson.c +++ b/stdcrt/code/compat_sjson.c @@ -3,26 +3,25 @@ #define decimal_point_char '.' -#define sJSON_ArrayForEach(item, array) \ - for (item = (array != NULL) ? (array)->child : NULL; item != NULL; item = item->next) +#define sJSON_ArrayForEach(item, array) for (item = (array != NULL) ? (array)->child : NULL; item != NULL; item = item->next) #define sJson_min(a, b) ((a < b) ? a : b) static unsigned char* sjson_strdup(const unsigned char* string) { - size_t len = 0; + size_t len = 0; unsigned char* copy = NULL; if (string == NULL) { return NULL; } - len = s_strlen((const char*)string) + sizeof(""); + len = s_strlen((const char*)string) + sizeof(""); copy = (unsigned char*)sjson_allocate(len); if (copy == NULL) { return NULL; } - + s_memcpy(copy, string, len); return copy; @@ -30,7 +29,7 @@ static unsigned char* sjson_strdup(const unsigned char* string) static sjsonptr sjson_new_Item() { - sjsonptr node = (sjsonptr)sjson_allocate(sizeof(sjson)); + sjsonptr node = (sjsonptr)sjson_allocate(sizeof(sjson)); if (node) { s_memset(node, 0x00, sizeof(sjson)); } @@ -38,11 +37,11 @@ static sjsonptr sjson_new_Item() } typedef struct { - unsigned char* buffer; - size_t length; - size_t offset; - size_t depth; - int format; + unsigned char* buffer; + size_t length; + size_t offset; + size_t depth; + int format; } sjsonprint; typedef sjsonprint* sjsonprintptr; @@ -58,12 +57,11 @@ typedef struct { typedef sjsonparse* sjsonparseptr; typedef sjsonparse* const sjsonparsevptr; - /* check if the given size is left to read in a given parse buffer (starting with 1) */ #define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length)) /* check if the buffer can be accessed at the given index (starting with 0) */ -#define can_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length)) +#define can_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length)) #define cannot_index(buffer, index) (!can_index(buffer, index)) /* get a pointer to the buffer at the position */ @@ -73,46 +71,42 @@ static int parse_num(sjsonvptr item, sjsonparsevptr input_buffer) { double number = 0; unsigned char* after_end = NULL; - unsigned char number_c_string[128] = {0x00}; - unsigned char decimal_point = decimal_point_char; - - int find_decimal_point = 0; + unsigned char number_c_string[128] = {0x00}; + unsigned char decimal_point = decimal_point_char; + + int find_decimal_point = 0; size_t i = 0; - size_t len = 0; - - rc_error(input_buffer != NULL, sjson_false) - rc_error(input_buffer->content != NULL, sjson_false) - - len = (sizeof(number_c_string) - 1); - + size_t len = 0; + + rc_error(input_buffer != NULL, sjson_false) rc_error(input_buffer->content != NULL, sjson_false) + + len = (sizeof(number_c_string) - 1); + for (i = 0; (i < len) && can_index(input_buffer, i); i++) { - switch (buffer_at_offset(input_buffer)[i]) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '+': - case '-': - case 'e': - case 'E': - number_c_string[i] = buffer_at_offset(input_buffer)[i]; - break; - case '.': - { - find_decimal_point = 1; - number_c_string[i] = decimal_point; - } - break; - - default: - goto loop_end; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '+': + case '-': + case 'e': + case 'E': + number_c_string[i] = buffer_at_offset(input_buffer)[i]; + break; + case '.': { + find_decimal_point = 1; + number_c_string[i] = decimal_point; + } break; + + default: + goto loop_end; } } loop_end: @@ -123,35 +117,32 @@ loop_end: return sjson_false; } - - if (find_decimal_point) { - item->valuedouble = number; - item->type = sjson_double; - } else { - - if (number >= INT_MIN && number <= INT_MAX) { - item->valueint = (int)number; - item->type = sjson_int; - } else { + if (find_decimal_point) { + item->valuedouble = number; + item->type = sjson_double; + } else { + if (number >= INT_MIN && number <= INT_MAX) { + item->valueint = (int)number; + item->type = sjson_int; + } else { item->valueint64 = (int64)number; item->type = sjson_int64; } - } - + } input_buffer->offset += (size_t)(after_end - number_c_string); - return sjson_true; + return sjson_true; } static unsigned char* ensure(sjsonprintvptr p, size_t needed) { unsigned char* newbuffer = NULL; size_t newsize = 0; - - rc_error(p != NULL, NULL) - rc_error(p->buffer != NULL, NULL) - - if ((p->length > 0) && (p->offset >= p->length)) { + + rc_error(p != NULL, NULL) rc_error(p->buffer != NULL, NULL) + + if ((p->length > 0) && (p->offset >= p->length)) + { return NULL; } @@ -165,7 +156,6 @@ static unsigned char* ensure(sjsonprintvptr p, size_t needed) } if (needed > (INT_MAX / 2)) { - if (needed <= INT_MAX) { newsize = INT_MAX; } else { @@ -175,16 +165,15 @@ static unsigned char* ensure(sjsonprintvptr p, size_t needed) newsize = needed * 2; } - - newbuffer = (unsigned char*)sjson_reallocate(p->buffer, newsize); - - if (newbuffer == NULL) { - sjson_deallocate(p->buffer); - p->length = 0; - p->buffer = NULL; - return NULL; - } - + newbuffer = (unsigned char*)sjson_reallocate(p->buffer, newsize); + + if (newbuffer == NULL) { + sjson_deallocate(p->buffer); + p->length = 0; + p->buffer = NULL; + return NULL; + } + p->length = newsize; p->buffer = newbuffer; @@ -212,10 +201,9 @@ static int print_int64(sjsoncvptr item, sjsonprintvptr output_buffer) return sjson_false; } - #if (TARGET_OS == OS_WIN) length = sprintf((char*)number_buffer, fmt_i64d, d); -#else +#else length = sprintf((char*)number_buffer, "%" PRId64, d); #endif @@ -244,39 +232,39 @@ static int print_int64(sjsoncvptr item, sjsonprintvptr output_buffer) } static int print_int(sjsoncvptr item, sjsonprintvptr output_buffer) { - unsigned char* output_pointer = NULL; - int d = item->valueint; - int length = 0; - size_t i = 0; - unsigned char number_buffer[32] = {0x00}; - if (output_buffer == NULL) { - return sjson_false; - } - - length = sprintf((char*)number_buffer, "%d", d); - - if (length < 0) { - return sjson_false; - } - - if (length > (int)(sizeof(number_buffer) - 1)) { - return sjson_false; - } - - output_pointer = ensure(output_buffer, (size_t)length); - if (output_pointer == NULL) { - return sjson_false; - } - - for (i = 0; i < ((size_t)length); i++) { - output_pointer[i] = number_buffer[i]; - } - - output_pointer[i] = '\0'; - - output_buffer->offset += (size_t)length; - - return sjson_true; + unsigned char* output_pointer = NULL; + int d = item->valueint; + int length = 0; + size_t i = 0; + unsigned char number_buffer[32] = {0x00}; + if (output_buffer == NULL) { + return sjson_false; + } + + length = sprintf((char*)number_buffer, "%d", d); + + if (length < 0) { + return sjson_false; + } + + if (length > (int)(sizeof(number_buffer) - 1)) { + return sjson_false; + } + + output_pointer = ensure(output_buffer, (size_t)length); + if (output_pointer == NULL) { + return sjson_false; + } + + for (i = 0; i < ((size_t)length); i++) { + output_pointer[i] = number_buffer[i]; + } + + output_pointer[i] = '\0'; + + output_buffer->offset += (size_t)length; + + return sjson_true; } static int print_double(sjsoncvptr item, sjsonprintvptr output_buffer) { @@ -284,13 +272,13 @@ static int print_double(sjsoncvptr item, sjsonprintvptr output_buffer) double d = item->valuedouble; int length = 0; size_t i = 0; - unsigned char number_buffer[26] = {0x00}; - + unsigned char number_buffer[26] = {0x00}; + unsigned char decimal_point = decimal_point_char; double test; if (output_buffer == NULL) { - return sjson_false; + return sjson_false; } if ((d * 0) != 0) { @@ -304,15 +292,14 @@ static int print_double(sjsoncvptr item, sjsonprintvptr output_buffer) } if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) { - return sjson_false; + return sjson_false; } output_pointer = ensure(output_buffer, (size_t)length); if (output_pointer == NULL) { - return sjson_false; + return sjson_false; } - for (i = 0; i < ((size_t)length); i++) { if (number_buffer[i] == decimal_point) { output_pointer[i] = '.'; @@ -325,10 +312,9 @@ static int print_double(sjsoncvptr item, sjsonprintvptr output_buffer) output_buffer->offset += (size_t)length; - return sjson_true; + return sjson_true; } - static unsigned parse_hex4(const unsigned char* const input) { unsigned int h = 0; @@ -356,7 +342,6 @@ static unsigned parse_hex4(const unsigned char* const input) return h; } - static unsigned char to_utf8(const unsigned char* const input, const unsigned char* const end, unsigned char** output) { long unsigned int codepoint = 0; @@ -554,19 +539,19 @@ static int parse_string(sjsonvptr item, sjsonparsevptr input_buffer) input_buffer->offset = (size_t)(input_end - input_buffer->content); input_buffer->offset++; - - return sjson_true; + + return sjson_true; fail: if (output != NULL) { - sjson_deallocate(output); + sjson_deallocate(output); } if (input_pointer != NULL) { input_buffer->offset = (size_t)(input_pointer - input_buffer->content); } - return sjson_false; + return sjson_false; } static int print_string_ptr(const unsigned char* const input, sjsonprintvptr output_buffer) @@ -575,23 +560,23 @@ static int print_string_ptr(const unsigned char* const input, sjsonprintvptr out unsigned char* output = NULL; unsigned char* output_pointer = NULL; size_t output_length = 0; - + /* numbers of additional characters needed for escaping */ size_t escape_characters = 0; if (output_buffer == NULL) { - return sjson_false; + return sjson_false; } /* empty string */ if (input == NULL) { output = ensure(output_buffer, sizeof("\"\"")); if (output == NULL) { - return sjson_false; + return sjson_false; } s_strncpy((char*)output, "\"\"", s_strlen("\"\"")); - return sjson_true; + return sjson_true; } /* set "flag" to 1 if something needs to be escaped */ @@ -619,18 +604,17 @@ static int print_string_ptr(const unsigned char* const input, sjsonprintvptr out output = ensure(output_buffer, output_length + sizeof("\"\"")); if (output == NULL) { - return sjson_false; + return sjson_false; } /* no characters have to be escaped */ if (escape_characters == 0) { - output[0] = '\"'; memcpy(output + 1, input, output_length); output[output_length + 1] = '\"'; output[output_length + 2] = '\0'; - return sjson_true; + return sjson_true; } output[0] = '\"'; @@ -675,7 +659,7 @@ static int print_string_ptr(const unsigned char* const input, sjsonprintvptr out output[output_length + 1] = '\"'; output[output_length + 2] = '\0'; - return sjson_true; + return sjson_true; } static int print_string(sjsoncvptr item, sjsonprintvptr p) @@ -696,26 +680,24 @@ static int print_object(sjsoncvptr item, sjsonprintvptr output_buffer); static sjsonparseptr skip_utf8_bom(sjsonparsevptr buffer) { - int bom_on = 0; - rc_error(buffer != NULL, NULL) - rc_error(buffer->content != NULL, NULL) - rc_error(buffer->offset == 0, NULL) - - bom_on = (s_strncmp((const char*)buffer_at_offset(buffer), bomchar, 3) == 0); - - if (can_index(buffer, 4) && bom_on) { - buffer->offset += 3; - } - - return buffer; + int bom_on = 0; + rc_error(buffer != NULL, NULL) rc_error(buffer->content != NULL, NULL) rc_error(buffer->offset == 0, NULL) + + bom_on = (s_strncmp((const char*)buffer_at_offset(buffer), bomchar, 3) == 0); + + if (can_index(buffer, 4) && bom_on) { + buffer->offset += 3; + } + + return buffer; } static sjsonparseptr skip_character(sjsonparsevptr buffer) { - rc_error(buffer != NULL, NULL) - rc_error(buffer->content != NULL, NULL) - - while (can_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) { + rc_error(buffer != NULL, NULL) rc_error(buffer->content != NULL, NULL) + + while (can_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) + { buffer->offset++; } @@ -726,17 +708,16 @@ static sjsonparseptr skip_character(sjsonparsevptr buffer) return buffer; } - sjsonptr sjson_parse(const char* value, unsigned long len, int fmt) { sjsonparse buffer = {0, 0, 0, 0}; - sjsonptr item = NULL; - rc_error(value != NULL, NULL) + sjsonptr item = NULL; + rc_error(value != NULL, NULL) - buffer.content = (const unsigned char*)value; + buffer.content = (const unsigned char*)value; - buffer.length = (len == 0 ? s_strlen(value) : len); - buffer.length += 1; + buffer.length = (len == 0 ? s_strlen(value) : len); + buffer.length += 1; buffer.offset = 0; item = sjson_new_Item(); @@ -744,22 +725,22 @@ sjsonptr sjson_parse(const char* value, unsigned long len, int fmt) goto fail; } - skip_utf8_bom(&buffer); - skip_character(&buffer); - + skip_utf8_bom(&buffer); + skip_character(&buffer); + if (parse_value(item, &buffer) == sjson_false) { goto fail; } - - skip_character(&buffer); - if (buffer.offset >= buffer.length) { - goto fail; - } - if(buffer_at_offset(&buffer)[0] != '\0') { - goto fail; - } - + skip_character(&buffer); + if (buffer.offset >= buffer.length) { + goto fail; + } + + if (buffer_at_offset(&buffer)[0] != '\0') { + goto fail; + } + return item; fail: @@ -770,23 +751,20 @@ fail: return NULL; } - char* sjson_print(sjsoncptr item, unsigned long len, int fmt) { sjsonprint p = {0, 0, 0, 0, 0}; - rc_error(len > 0, NULL) - rc_error(sjson_is_invalid(item) != sjson_true, NULL) - p.buffer = (unsigned char*)sjson_allocate(len); - rc_error(p.buffer != NULL, NULL) + rc_error(len > 0, NULL) rc_error(sjson_is_invalid(item) != sjson_true, NULL) p.buffer = (unsigned char*)sjson_allocate(len); + rc_error(p.buffer != NULL, NULL) - p.length = (size_t)len; + p.length = (size_t)len; p.offset = 0; p.format = fmt; - + if (print_value(item, &p) == sjson_false) { - sjson_deallocate(p.buffer); - return NULL; + sjson_deallocate(p.buffer); + return NULL; } return (char*)p.buffer; @@ -794,64 +772,64 @@ char* sjson_print(sjsoncptr item, unsigned long len, int fmt) static int parse_value(sjsonvptr item, sjsonparsevptr input) { - int num_on = 0; - rc_error(input->content != NULL, sjson_false) - rc_error(input != NULL, sjson_false) - - /* string */ - if (can_index(input, 0) && (buffer_at_offset(input)[0] == '\"')) { + int num_on = 0; + rc_error(input->content != NULL, sjson_false) rc_error(input != NULL, sjson_false) + + /* string */ + if (can_index(input, 0) && (buffer_at_offset(input)[0] == '\"')) + { return parse_string(item, input); } - + /* num */ - num_on = ((buffer_at_offset(input)[0] >= '0') && (buffer_at_offset(input)[0] <= '9')); + num_on = ((buffer_at_offset(input)[0] >= '0') && (buffer_at_offset(input)[0] <= '9')); if (can_index(input, 0) && ((buffer_at_offset(input)[0] == '-') || num_on)) { return parse_num(item, input); } - + /* array */ if (can_index(input, 0) && (buffer_at_offset(input)[0] == '[')) { return parse_array(item, input); } - + /* object */ if (can_index(input, 0) && (buffer_at_offset(input)[0] == '{')) { return parse_object(item, input); } - return sjson_false; + return sjson_false; } static int print_value(sjsoncvptr item, sjsonprintvptr output_buffer) { - rc_error(output_buffer != NULL, sjson_false) - rc_error(item != NULL, sjson_false) - - switch ((item->type) & 0xFF) { - case sjson_int64: - return print_int64(item, output_buffer); - case sjson_int: - return print_int(item, output_buffer); - case sjson_double: - return print_double(item, output_buffer); - case sjson_string: - return print_string(item, output_buffer); - case sjson_array: - return print_array(item, output_buffer); - case sjson_obj: - return print_object(item, output_buffer); - default: - return sjson_false; + rc_error(output_buffer != NULL, sjson_false) rc_error(item != NULL, sjson_false) + + switch ((item->type) & 0xFF) + { + case sjson_int64: + return print_int64(item, output_buffer); + case sjson_int: + return print_int(item, output_buffer); + case sjson_double: + return print_double(item, output_buffer); + case sjson_string: + return print_string(item, output_buffer); + case sjson_array: + return print_array(item, output_buffer); + case sjson_obj: + return print_object(item, output_buffer); + default: + return sjson_false; } } static int parse_array(sjsonvptr item, sjsonparsevptr input_buffer) { - sjsonptr head = NULL; - sjsonptr cur_item = NULL; + sjsonptr head = NULL; + sjsonptr cur_item = NULL; if (input_buffer->depth >= sjson_nesting_limit) { - return sjson_false; + return sjson_false; } input_buffer->depth++; @@ -876,7 +854,7 @@ static int parse_array(sjsonvptr item, sjsonparsevptr input_buffer) /* loop through the comma separated array elements */ do { /* allocate next item */ - sjsonptr new_item = sjson_new_Item(); + sjsonptr new_item = sjson_new_Item(); if (new_item == NULL) { goto fail; /* allocation failure */ } @@ -884,12 +862,12 @@ static int parse_array(sjsonvptr item, sjsonparsevptr input_buffer) /* attach next item to list */ if (head == NULL) { /* start the linked list */ - cur_item = head = new_item; + cur_item = head = new_item; } else { /* add to the end and advance */ - cur_item->next = new_item; + cur_item->next = new_item; new_item->prev = cur_item; - cur_item = new_item; + cur_item = new_item; } /* parse next value */ @@ -913,30 +891,29 @@ success: input_buffer->offset++; - return sjson_true; + return sjson_true; fail: if (head != NULL) { sjson_delete(head); } - return sjson_false; + return sjson_false; } static int print_array(sjsoncvptr item, sjsonprintvptr output_buffer) { unsigned char* output_pointer = NULL; size_t length = 0; - sjsonptr current_element = item->child; + sjsonptr current_element = item->child; if (output_buffer == NULL) { - return sjson_false; + return sjson_false; } - output_pointer = ensure(output_buffer, 1); if (output_pointer == NULL) { - return sjson_false; + return sjson_false; } *output_pointer = '['; @@ -945,14 +922,14 @@ static int print_array(sjsoncvptr item, sjsonprintvptr output_buffer) while (current_element != NULL) { if (print_value(current_element, output_buffer) == sjson_false) { - return sjson_false; + return sjson_false; } update_offset(output_buffer); if (current_element->next) { length = (size_t)(output_buffer->format ? 2 : 1); output_pointer = ensure(output_buffer, length + 1); if (output_pointer == NULL) { - return sjson_false; + return sjson_false; } *output_pointer++ = ','; if (output_buffer->format) { @@ -966,22 +943,22 @@ static int print_array(sjsoncvptr item, sjsonprintvptr output_buffer) output_pointer = ensure(output_buffer, 2); if (output_pointer == NULL) { - return sjson_false; + return sjson_false; } *output_pointer++ = ']'; *output_pointer = '\0'; output_buffer->depth--; - return sjson_true; + return sjson_true; } static int parse_object(sjsonvptr item, sjsonparsevptr input_buffer) { - sjsonptr head = NULL; /* linked list head */ - sjsonptr cur_item = NULL; + sjsonptr head = NULL; /* linked list head */ + sjsonptr cur_item = NULL; if (input_buffer->depth >= sjson_nesting_limit) { - return sjson_false; + return sjson_false; } input_buffer->depth++; @@ -1005,7 +982,7 @@ static int parse_object(sjsonvptr item, sjsonparsevptr input_buffer) /* loop through the comma separated array elements */ do { /* allocate next item */ - sjsonptr new_item = sjson_new_Item(); + sjsonptr new_item = sjson_new_Item(); if (new_item == NULL) { goto fail; /* allocation failure */ } @@ -1013,28 +990,28 @@ static int parse_object(sjsonvptr item, sjsonparsevptr input_buffer) /* attach next item to list */ if (head == NULL) { /* start the linked list */ - cur_item = head = new_item; + cur_item = head = new_item; } else { /* add to the end and advance */ - cur_item->next = new_item; + cur_item->next = new_item; new_item->prev = cur_item; - cur_item = new_item; + cur_item = new_item; } /* parse the name of the child */ input_buffer->offset++; skip_character(input_buffer); - + if (parse_string(cur_item, input_buffer) == sjson_false) { goto fail; /* faile to parse name */ } - + skip_character(input_buffer); /* swap valuestring and string, because we parsed the name */ - cur_item->key = cur_item->valuestring; - cur_item->valuestring = NULL; - + cur_item->key = cur_item->valuestring; + cur_item->valuestring = NULL; + if (cannot_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) { goto fail; /* invalid object */ } @@ -1059,31 +1036,30 @@ success: item->child = head; input_buffer->offset++; - return sjson_true; + return sjson_true; fail: if (head != NULL) { sjson_delete(head); } - return sjson_false; + return sjson_false; } static int print_object(sjsoncvptr item, sjsonprintvptr output_buffer) { unsigned char* output_pointer = NULL; size_t length = 0; - sjsonptr cur_item = item->child; + sjsonptr cur_item = item->child; if (output_buffer == NULL) { - return sjson_false; + return sjson_false; } - length = (size_t)(output_buffer->format ? 2 : 1); /* fmt: {\n */ output_pointer = ensure(output_buffer, length + 1); if (output_pointer == NULL) { - return sjson_false; + return sjson_false; } *output_pointer++ = '{'; @@ -1098,7 +1074,7 @@ static int print_object(sjsoncvptr item, sjsonprintvptr output_buffer) size_t i; output_pointer = ensure(output_buffer, output_buffer->depth); if (output_pointer == NULL) { - return sjson_false; + return sjson_false; } for (i = 0; i < output_buffer->depth; i++) { *output_pointer++ = '\t'; @@ -1108,14 +1084,14 @@ static int print_object(sjsoncvptr item, sjsonprintvptr output_buffer) /* print key */ if (print_string_ptr((unsigned char*)cur_item->key, output_buffer) == sjson_false) { - return sjson_false; + return sjson_false; } update_offset(output_buffer); length = (size_t)(output_buffer->format ? 2 : 1); output_pointer = ensure(output_buffer, length); if (output_pointer == NULL) { - return sjson_false; + return sjson_false; } *output_pointer++ = ':'; if (output_buffer->format) { @@ -1124,15 +1100,14 @@ static int print_object(sjsoncvptr item, sjsonprintvptr output_buffer) output_buffer->offset += length; if (print_value(cur_item, output_buffer) == sjson_false) { - return sjson_false; + return sjson_false; } update_offset(output_buffer); - length = (size_t)((output_buffer->format ? 1 : 0) + (cur_item->next ? 1 : 0)); output_pointer = ensure(output_buffer, length + 1); if (output_pointer == NULL) { - return sjson_false; + return sjson_false; } if (cur_item->next) { *output_pointer++ = ','; @@ -1144,12 +1119,12 @@ static int print_object(sjsoncvptr item, sjsonprintvptr output_buffer) *output_pointer = '\0'; output_buffer->offset += length; - cur_item = cur_item->next; + cur_item = cur_item->next; } output_pointer = ensure(output_buffer, output_buffer->format ? (output_buffer->depth + 1) : 2); if (output_pointer == NULL) { - return sjson_false; + return sjson_false; } if (output_buffer->format) { size_t i; @@ -1161,12 +1136,12 @@ static int print_object(sjsoncvptr item, sjsonprintvptr output_buffer) *output_pointer = '\0'; output_buffer->depth--; - return sjson_true; + return sjson_true; } static sjsonptr get_array_item(sjsoncptr array, size_t index) { - sjsonptr current_child = NULL; + sjsonptr current_child = NULL; if (array == NULL) { return NULL; @@ -1183,7 +1158,7 @@ static sjsonptr get_array_item(sjsoncptr array, size_t index) sjsonptr sjson_get_array_item(sjsoncptr array, int index) { - sjsonptr item = NULL; + sjsonptr item = NULL; if (index < 0) { return NULL; } @@ -1200,13 +1175,13 @@ static void append_object(sjsonptr prev, sjsonptr item) int sjson_delete_item(sjsonptr parent, sjsonvptr item) { - rc_error(parent != NULL, sjson_false) - rc_error(item != NULL, sjson_false) - - if (item->prev != NULL) { + rc_error(parent != NULL, sjson_false) rc_error(item != NULL, sjson_false) + + if (item->prev != NULL) + { item->prev->next = item->next; } - + if (item->next != NULL) { item->next->prev = item->prev; } @@ -1223,45 +1198,42 @@ int sjson_delete_item(sjsonptr parent, sjsonvptr item) int sjson_delete(sjsonptr item) { - sjsonptr next = NULL; - while (item != NULL) { - next = item->next; - - if (item->child != NULL) { - sjson_delete(item->child); - } - - if ((item->valuestring != NULL) && (sjson_is_string(item) == sjson_true)) { - sjson_deallocate(item->valuestring); - } - - if (item->key != NULL) { - sjson_deallocate(item->key); - } - - sjson_deallocate(item); - - item = next; - } - - return sjson_true; -} + sjsonptr next = NULL; + while (item != NULL) { + next = item->next; + if (item->child != NULL) { + sjson_delete(item->child); + } + + if ((item->valuestring != NULL) && (sjson_is_string(item) == sjson_true)) { + sjson_deallocate(item->valuestring); + } + + if (item->key != NULL) { + sjson_deallocate(item->key); + } + + sjson_deallocate(item); + + item = next; + } + + return sjson_true; +} int sjson_replace_item(sjsonvptr parent, sjsonvptr item, sjsonptr replace) { - rc_error(parent != NULL, sjson_false) - rc_error(item != NULL, sjson_false) - rc_error(replace != NULL, sjson_false) - - replace->next = item->next; - replace->prev = item->prev; + rc_error(parent != NULL, sjson_false) rc_error(item != NULL, sjson_false) rc_error(replace != NULL, sjson_false) + + replace->next = item->next; + replace->prev = item->prev; if (replace->next != NULL) { - replace->next->prev = replace; + replace->next->prev = replace; } if (replace->prev != NULL) { - replace->prev->next = replace; + replace->prev->next = replace; } if (parent->child == item) { parent->child = replace; @@ -1269,294 +1241,282 @@ int sjson_replace_item(sjsonvptr parent, sjsonvptr item, sjsonptr replace) item->next = NULL; item->prev = NULL; - + sjson_delete(item); - - return sjson_true; + + return sjson_true; } int sjson_add_array(sjsonptr array, sjsonptr item) { - sjsonptr child = NULL; - - rc_error(array != NULL, sjson_false) - rc_error(item != NULL, sjson_false) - - child = array->child; - - if (child == NULL) { - array->child = item; - } else { - while (child->next) { - child = child->next; - } - append_object(child, item); - } - - return sjson_true; + sjsonptr child = NULL; + + rc_error(array != NULL, sjson_false) rc_error(item != NULL, sjson_false) + + child = array->child; + + if (child == NULL) { + array->child = item; + } else { + while (child->next) { + child = child->next; + } + append_object(child, item); + } + + return sjson_true; } int sjson_add_obj(sjsonptr object, const char* key, sjsonptr item) { - rc_error(key != NULL, sjson_false) - rc_error(item != NULL, sjson_false) - - item->key = (char*)sjson_strdup((const unsigned char*)key); - return sjson_add_array(object, item); -} + rc_error(key != NULL, sjson_false) rc_error(item != NULL, sjson_false) + item->key = (char*)sjson_strdup((const unsigned char*)key); + return sjson_add_array(object, item); +} int sjson_insert_array(sjsonptr array, unsigned int index, sjsonptr newitem) { - sjsonptr item = NULL; - - rc_error(index > 0, sjson_false) - - item = get_array_item(array, index); - - if (item == NULL) { - return sjson_add_array(array, newitem); - } - - newitem->next = item; - newitem->prev = item->prev; - item->prev = newitem; - - if (item == array->child) { - array->child = newitem; - } else { - newitem->prev->next = newitem; - } - - return sjson_true; + sjsonptr item = NULL; + + rc_error(index > 0, sjson_false) + + item = get_array_item(array, index); + + if (item == NULL) { + return sjson_add_array(array, newitem); + } + + newitem->next = item; + newitem->prev = item->prev; + item->prev = newitem; + + if (item == array->child) { + array->child = newitem; + } else { + newitem->prev->next = newitem; + } + + return sjson_true; } int sjson_get_array_size(sjsoncptr array) { - sjsonptr child = NULL; - size_t size = 0; + sjsonptr child = NULL; + size_t size = 0; - if (array == NULL) { - return 0; - } + if (array == NULL) { + return 0; + } - child = array->child; + child = array->child; - while (child != NULL) { - size++; - child = child->next; - } + while (child != NULL) { + size++; + child = child->next; + } - return (int)size; + return (int)size; } int sjson_compare(sjsoncvptr a, sjsoncvptr b) { + rc_error(a != NULL, sjson_false) rc_error(b != NULL, sjson_false) rc_error((a->type & 0xFF) == (b->type & 0xFF), sjson_false) + + switch (a->type & 0xFF) + { + case sjson_int64: + case sjson_int: + case sjson_double: + case sjson_string: + case sjson_array: + case sjson_obj: + break; + default: + return sjson_false; + } + + if (a == b) { + return S_SUCCESS; + } - rc_error(a != NULL, sjson_false) - rc_error(b != NULL, sjson_false) - rc_error((a->type & 0xFF) == (b->type & 0xFF), sjson_false) - - switch (a->type & 0xFF) { - case sjson_int64: - case sjson_int: - case sjson_double: - case sjson_string: - case sjson_array: - case sjson_obj: - break; - default: - return sjson_false; - } - - if (a == b) { - return S_SUCCESS; - } - - switch (a->type & 0xFF) { - case sjson_int64: - if (a->valueint64 == b->valueint64) { - return sjson_true; + switch (a->type & 0xFF) { + case sjson_int64: + if (a->valueint64 == b->valueint64) { + return sjson_true; + } + return sjson_false; + case sjson_int: + if (a->valueint == b->valueint) { + return sjson_true; + } + return sjson_false; + case sjson_double: + if (a->valuedouble == b->valuedouble) { + return S_SUCCESS; + } + return sjson_false; + case sjson_string: + if ((a->valuestring == NULL) || (b->valuestring == NULL)) { + return sjson_false; + } + if (strcmp(a->valuestring, b->valuestring) == 0) { + return sjson_true; + } + return sjson_false; + + case sjson_array: { + sjsonptr a_obj = a->child; + sjsonptr b_obj = b->child; + + for (; (a_obj != NULL) && (b_obj != NULL);) { + if (!sjson_compare(a_obj, b_obj)) { + return sjson_false; } + + a_obj = a_obj->next; + b_obj = b_obj->next; + } + + if (a_obj != b_obj) { return sjson_false; - case sjson_int: - if (a->valueint == b->valueint) { - return sjson_true; - } - return sjson_false; - case sjson_double: - if (a->valuedouble == b->valuedouble) { - return S_SUCCESS; - } - return sjson_false; - case sjson_string: - if ((a->valuestring == NULL) || (b->valuestring == NULL)) { - return sjson_false; - } - if (strcmp(a->valuestring, b->valuestring) == 0) { - return sjson_true; - } - return sjson_false; - - case sjson_array: { - - sjsonptr a_obj = a->child; - sjsonptr b_obj = b->child; - - for (; (a_obj != NULL) && (b_obj != NULL);) { - if (!sjson_compare(a_obj, b_obj)) { - return sjson_false; - } - - a_obj = a_obj->next; - b_obj = b_obj->next; - } - - if (a_obj != b_obj) { - return sjson_false; - } - - return sjson_true; - } - - case sjson_obj: { - sjsonptr a_obj = NULL; - sjsonptr b_obj = NULL; - - sJSON_ArrayForEach(a_obj, a) - { - b_obj = sjson_get_obj(b, a_obj->key); - - if (b_obj == NULL) { - return sjson_false; - } - - if (!sjson_compare(a_obj, b_obj)) { - return sjson_false; - } - - } - - sJSON_ArrayForEach(b_obj, b) - { - a_obj = sjson_get_obj(a, b_obj->key); - if (a_obj == NULL) { - return sjson_false; - } - - if (!sjson_compare(b_obj, a_obj)) { - return sjson_false; - } - } - - return sjson_true; - } - - default: - return sjson_false; - } - return sjson_false; -} + } + + return sjson_true; + } + + case sjson_obj: { + sjsonptr a_obj = NULL; + sjsonptr b_obj = NULL; + sJSON_ArrayForEach(a_obj, a) + { + b_obj = sjson_get_obj(b, a_obj->key); + + if (b_obj == NULL) { + return sjson_false; + } + + if (!sjson_compare(a_obj, b_obj)) { + return sjson_false; + } + } + + sJSON_ArrayForEach(b_obj, b) + { + a_obj = sjson_get_obj(a, b_obj->key); + if (a_obj == NULL) { + return sjson_false; + } + + if (!sjson_compare(b_obj, a_obj)) { + return sjson_false; + } + } + + return sjson_true; + } + + default: + return sjson_false; + } + return sjson_false; +} sjsonptr sjson_duplicate(sjsoncptr item) { - sjsonptr newitem = NULL; - sjsonptr child = NULL; - sjsonptr next = NULL; - sjsonptr newchild = NULL; - - if (!item) { - goto fail; - } - - newitem = sjson_new_Item(); - if (!newitem) { - goto fail; - } - - newitem->type = item->type; - newitem->valueint64 = item->valueint64; - newitem->valueint = item->valueint; - newitem->valuedouble = item->valuedouble; - - if (item->valuestring) { - newitem->valuestring = (char*)sjson_strdup((unsigned char*)item->valuestring); - if (!newitem->valuestring) { - goto fail; - } - } - - if (item->key) { - newitem->key = (char*)sjson_strdup((unsigned char*)item->key); - if (!newitem->key) { - goto fail; - } - } - - - child = item->child; - - while (child != NULL) { - newchild = sjson_duplicate(child); - if (!newchild) { - goto fail; - } - if (next != NULL) { - - next->next = newchild; - newchild->prev = next; - next = newchild; - } else { - newitem->child = newchild; - next = newchild; - } - child = child->next; - } - - return newitem; + sjsonptr newitem = NULL; + sjsonptr child = NULL; + sjsonptr next = NULL; + sjsonptr newchild = NULL; + + if (!item) { + goto fail; + } + + newitem = sjson_new_Item(); + if (!newitem) { + goto fail; + } + + newitem->type = item->type; + newitem->valueint64 = item->valueint64; + newitem->valueint = item->valueint; + newitem->valuedouble = item->valuedouble; + + if (item->valuestring) { + newitem->valuestring = (char*)sjson_strdup((unsigned char*)item->valuestring); + if (!newitem->valuestring) { + goto fail; + } + } + + if (item->key) { + newitem->key = (char*)sjson_strdup((unsigned char*)item->key); + if (!newitem->key) { + goto fail; + } + } + + child = item->child; + + while (child != NULL) { + newchild = sjson_duplicate(child); + if (!newchild) { + goto fail; + } + if (next != NULL) { + next->next = newchild; + newchild->prev = next; + next = newchild; + } else { + newitem->child = newchild; + next = newchild; + } + child = child->next; + } + + return newitem; fail: - if (newitem != NULL) { - sjson_delete(newitem); - } + if (newitem != NULL) { + sjson_delete(newitem); + } - return NULL; + return NULL; } - sjsonptr sjson_get_obj(sjsoncvptr obj, const char* const key) { - sjsonptr item = NULL; - - rc_error(obj != NULL, NULL) - rc_error(key != NULL, NULL) - - item = obj->child; - - while ((item != NULL) && (s_strcmp(key, (item->key)) != 0)) { - item = item->next; - } - - return item; + sjsonptr item = NULL; + + rc_error(obj != NULL, NULL) rc_error(key != NULL, NULL) + + item = obj->child; + + while ((item != NULL) && (s_strcmp(key, (item->key)) != 0)) { + item = item->next; + } + + return item; } sjsonptr sjson_create_array(void) { - sjsonptr item = sjson_new_Item(); - if (item) { - item->type = sjson_array; - } - return item; + sjsonptr item = sjson_new_Item(); + if (item) { + item->type = sjson_array; + } + return item; } sjsonptr sjson_create_obj(void) { - sjsonptr item = sjson_new_Item(); - if (item) { - item->type = sjson_obj; - } - return item; + sjsonptr item = sjson_new_Item(); + if (item) { + item->type = sjson_obj; + } + return item; } sjsonptr sjson_create_int64(int64 value) { @@ -1569,36 +1529,36 @@ sjsonptr sjson_create_int64(int64 value) } sjsonptr sjson_create_int(int value) { - sjsonptr item = sjson_new_Item(); - if (item) { - item->type = sjson_int; - item->valueint = value; - } - return item; + sjsonptr item = sjson_new_Item(); + if (item) { + item->type = sjson_int; + item->valueint = value; + } + return item; } sjsonptr sjson_create_double(double value) { - sjsonptr item = sjson_new_Item(); - if (item) { - item->type = sjson_double; - item->valuedouble = value; - } - return item; + sjsonptr item = sjson_new_Item(); + if (item) { + item->type = sjson_double; + item->valuedouble = value; + } + return item; } sjsonptr sjson_create_string(const char* value) { - sjsonptr item = sjson_new_Item(); - if (item) { - item->type = sjson_string; - item->valuestring = (char*)sjson_strdup((const unsigned char*)value); - if (!item->valuestring) { - sjson_delete(item); - return NULL; - } - } - - return item; + sjsonptr item = sjson_new_Item(); + if (item) { + item->type = sjson_string; + item->valuestring = (char*)sjson_strdup((const unsigned char*)value); + if (!item->valuestring) { + sjson_delete(item); + return NULL; + } + } + + return item; } sjsonptr sjson_create_int64_array(const int64* values, unsigned int count) @@ -1608,7 +1568,7 @@ sjsonptr sjson_create_int64_array(const int64* values, unsigned int count) sjsonptr p = NULL; sjsonptr a = NULL; - rc_error(count > 0, NULL); + rc_error(count > 0, NULL); rc_error(values != NULL, NULL); a = sjson_create_array(); @@ -1631,143 +1591,137 @@ sjsonptr sjson_create_int64_array(const int64* values, unsigned int count) sjsonptr sjson_create_int_array(const int* values, unsigned int count) { - size_t i = 0; - sjsonptr n = NULL; - sjsonptr p = NULL; - sjsonptr a = NULL; - - rc_error(count > 0, NULL) - rc_error(values != NULL, NULL) - - a = sjson_create_array(); - for (i = 0; a && (i < count); i++) { - n = sjson_create_int(values[i]); - if (!n) { - sjson_delete(a); - return NULL; - } - if (!i) { - a->child = n; - } else { - append_object(p, n); - } - p = n; - } - - return a; -} + size_t i = 0; + sjsonptr n = NULL; + sjsonptr p = NULL; + sjsonptr a = NULL; + + rc_error(count > 0, NULL) rc_error(values != NULL, NULL) + + a = sjson_create_array(); + for (i = 0; a && (i < count); i++) { + n = sjson_create_int(values[i]); + if (!n) { + sjson_delete(a); + return NULL; + } + if (!i) { + a->child = n; + } else { + append_object(p, n); + } + p = n; + } + return a; +} sjsonptr sjson_create_double_array(const double* values, unsigned int count) { - size_t i = 0; - sjsonptr n = NULL; - sjsonptr p = NULL; - sjsonptr a = NULL; - - rc_error(count > 0, NULL) - rc_error(values != NULL, NULL) - - a = sjson_create_array(); - - for (i = 0; a && (i < count); i++) { - n = sjson_create_double(values[i]); - if (!n) { - sjson_delete(a); - return NULL; - } - if (!i) { - a->child = n; - } else { - append_object(p, n); - } - p = n; - } - - return a; + size_t i = 0; + sjsonptr n = NULL; + sjsonptr p = NULL; + sjsonptr a = NULL; + + rc_error(count > 0, NULL) rc_error(values != NULL, NULL) + + a = sjson_create_array(); + + for (i = 0; a && (i < count); i++) { + n = sjson_create_double(values[i]); + if (!n) { + sjson_delete(a); + return NULL; + } + if (!i) { + a->child = n; + } else { + append_object(p, n); + } + p = n; + } + + return a; } sjsonptr sjson_create_string_array(const char** values, unsigned int count) { - size_t i = 0; - sjsonptr n = NULL; - sjsonptr p = NULL; - sjsonptr a = NULL; - - rc_error(count > 0, NULL) - rc_error(values != NULL, NULL) - - a = sjson_create_array(); - - for (i = 0; a && (i < count); i++) { - n = sjson_create_string(values[i]); - if (!n) { - sjson_delete(a); - return NULL; - } - if (!i) { - a->child = n; - } else { - append_object(p, n); - } - p = n; - } - - return a; + size_t i = 0; + sjsonptr n = NULL; + sjsonptr p = NULL; + sjsonptr a = NULL; + + rc_error(count > 0, NULL) rc_error(values != NULL, NULL) + + a = sjson_create_array(); + + for (i = 0; a && (i < count); i++) { + n = sjson_create_string(values[i]); + if (!n) { + sjson_delete(a); + return NULL; + } + if (!i) { + a->child = n; + } else { + append_object(p, n); + } + p = n; + } + + return a; } void* sjson_allocate(size_t size) { - return heap_malloc(size); + return heap_malloc(size); } void* sjson_reallocate(void* addr, size_t size) { - return heap_realloc(addr, size); + return heap_realloc(addr, size); } void sjson_deallocate(void* obj) { - heap_free(obj); + heap_free(obj); } void sjson_format(char* json) { - unsigned char* into = (unsigned char*)json; - - if (json == NULL) { - return; - } - - while (*json) { - if (*json == ' ') { - json++; - } else if (*json == '\t') { - json++; - } else if (*json == '\r') { - json++; - } else if (*json == '\n') { - json++; - } else if ((*json == '/') && (json[1] == '/')) { - while (*json && (*json != '\n')) { - json++; - } - } else if ((*json == '/') && (json[1] == '*')) { - while (*json && !((*json == '*') && (json[1] == '/'))) { - json++; - } - json += 2; - } else if (*json == '\"') { - *into++ = (unsigned char)*json++; - while (*json && (*json != '\"')) { - if (*json == '\\') { - *into++ = (unsigned char)*json++; - } - *into++ = (unsigned char)*json++; - } - *into++ = (unsigned char)*json++; - } else { - *into++ = (unsigned char)*json++; - } - } - *into = '\0'; + unsigned char* into = (unsigned char*)json; + + if (json == NULL) { + return; + } + + while (*json) { + if (*json == ' ') { + json++; + } else if (*json == '\t') { + json++; + } else if (*json == '\r') { + json++; + } else if (*json == '\n') { + json++; + } else if ((*json == '/') && (json[1] == '/')) { + while (*json && (*json != '\n')) { + json++; + } + } else if ((*json == '/') && (json[1] == '*')) { + while (*json && !((*json == '*') && (json[1] == '/'))) { + json++; + } + json += 2; + } else if (*json == '\"') { + *into++ = (unsigned char)*json++; + while (*json && (*json != '\"')) { + if (*json == '\\') { + *into++ = (unsigned char)*json++; + } + *into++ = (unsigned char)*json++; + } + *into++ = (unsigned char)*json++; + } else { + *into++ = (unsigned char)*json++; + } + } + *into = '\0'; } - - diff --git a/stdcrt/compat_error.c b/stdcrt/compat_error.c index e70dec4e..b5d1b452 100644 --- a/stdcrt/compat_error.c +++ b/stdcrt/compat_error.c @@ -35,8 +35,6 @@ crterr crt_geterror(void) { int error; error = ERRNO; - //crt_setfatalerror(error); + // crt_setfatalerror(error); return error; } - - diff --git a/stdcrt/compat_log.c b/stdcrt/compat_log.c index 625b3b7b..4e596c00 100644 --- a/stdcrt/compat_log.c +++ b/stdcrt/compat_log.c @@ -17,7 +17,7 @@ static int _log_print(int proi, const char* tag, int line, const char* func, con char* msg = NULL; int hmsglen = 0; int msglen = 0; - + char tm[81] = {0x00}; int rc; rc = get_time_t(tm, 80); @@ -31,7 +31,6 @@ static int _log_print(int proi, const char* tag, int line, const char* func, con #else hmsglen = snprintf(msg, LOG_PAGE_SIZE, LOG_FORMAT, tag, tm, func, line); #endif - if (hmsglen > 0 && hmsglen < LOG_PAGE_SIZE) { msglen = LOG_PAGE_SIZE - hmsglen; @@ -44,7 +43,6 @@ static int _log_print(int proi, const char* tag, int line, const char* func, con #else vsnprintf(msg + hmsglen, msglen, fmt, ap); #endif - #ifdef __ANDROID__ __android_log_write(proi, "", msg); diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index c17165d3..f857d728 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -14,8 +14,8 @@ static int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) { if (op == op_ev_connect) { - oper->handler(op_ev_success, oper, oper, op_ev_connect); - } else if(op == op_ev_open) { + oper->handler(op_ev_success, oper, oper, op_ev_connect); + } else if (op == op_ev_open) { oper->handler(op_ev_success, oper, oper, op_ev_open); } else if (op == op_ev_close) { oper->handler(op_ev_success, oper, oper, op_ev_close); @@ -24,7 +24,7 @@ static int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, e } if (op == op_ev_read) { - if (oper->bt == ev_io_complete) { + if (oper->bt == ev_io_complete) { oper->handler(op_ev_success, oper, oper, op_ev_read); } else if (oper->bt == ev_func_complete) { oper->handler(op_ev_success, oper, oper, op_ev_read); @@ -104,7 +104,7 @@ int evoper_set_msec(evoper_t* oper, crt_msec msec) int evoper_get_msec(evoper_t* oper, crt_msec* msec) { rc_error(oper != NULL, S_ERROR); - *msec = oper->msec; + *msec = oper->msec; return S_SUCCESS; } int evoper_bind_ctx(evoper_t* oper, void* ctx) @@ -116,7 +116,7 @@ int evoper_bind_ctx(evoper_t* oper, void* ctx) int evoper_get_ctx(evoper_t* oper, void** ctx) { rc_error(oper != NULL, S_ERROR); - *ctx = oper->ctx; + *ctx = oper->ctx; return S_SUCCESS; } int evoper_bind_sock(evoper_t* oper, _sock_t sock) @@ -169,7 +169,7 @@ int evoper_get_evloop(evoper_t* oper, evloop_t** evloop) return S_SUCCESS; } int evoper_sock(evoper_t* oper) -{ +{ _sock_t sock = INVALID_SOCKET; sock = _createsock(AF_INET, SOCK_STREAM, IPPROTO_TCP); rc_error(sock != INVALID_SOCKET, S_ERROR); @@ -307,7 +307,7 @@ int evloop_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t t const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_enable_write != NULL, S_ERROR); - + return evsel->op_enable_write(loop, oper, event, tv); } int evloop_disable_read(evloop_t* loop, evoper_t* oper) @@ -375,11 +375,9 @@ int evloop_poll(evoper_t* oper, unsigned int ls) rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_poll != NULL, S_ERROR); - rs_error(oper->accept == op_ev_accepting, S_COMPLETED) - rs_error(oper->accept == op_ev_accepted, S_CLOSE) - evoper_listen_size(oper, ls); - evoper_accept_op(oper, op_ev_accepting); - + rs_error(oper->accept == op_ev_accepting, S_COMPLETED) rs_error(oper->accept == op_ev_accepted, S_CLOSE) evoper_listen_size(oper, ls); + evoper_accept_op(oper, op_ev_accepting); + return evsel->op_poll(loop, oper); } int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) @@ -392,14 +390,14 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) const evsysop_t* evsel = evloop_sysop(loop); rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_add_connect != NULL, S_ERROR); - - rs_error(oper->conn == op_ev_connected, S_COMPLETED) - evoper_connect_op(oper, op_ev_connecting); - + + rs_error(oper->conn == op_ev_connected, S_COMPLETED) evoper_connect_op(oper, op_ev_connecting); + rc = evsel->op_add_connect(loop, oper, addr, tv); rs_error(rc == S_PENDING, S_SUCCESS) - if (rc == S_COMPLETED) { + if (rc == S_COMPLETED) + { complete_op(S_SUCCESS, 0, oper, oper, op_ev_connect); evoper_connect_op(oper, op_ev_connected); } @@ -524,27 +522,23 @@ static int cmd_poll_time(evloop_t* loop, evoper_t* oper) uint64_t node_count = 0; rc = evloop_nodes_count(loop->nodes, &node_count); - rc_error(rc != S_ERROR, S_ERROR) - rc_error(node_count != 0, S_ERROR); + rc_error(rc != S_ERROR, S_ERROR) rc_error(node_count != 0, S_ERROR); rc = evloop_deltime(loop->nodes, oper); - rc_error(rc != S_ERROR, S_ERROR) - rc_error(oper != NULL, S_ERROR); + rc_error(rc != S_ERROR, S_ERROR) rc_error(oper != NULL, S_ERROR); rc = evoper_get_msec(oper, &oper_msec); - rc_error(rc != S_ERROR, S_ERROR) - rc_error(oper_msec != 0, S_ERROR); + rc_error(rc != S_ERROR, S_ERROR) rc_error(oper_msec != 0, S_ERROR); rc = evloop_clock_getmsec(loop->clock, &msec); - rc_error(rc != S_ERROR, S_ERROR) - rc_error(msec != 0, S_ERROR); + rc_error(rc != S_ERROR, S_ERROR) rc_error(msec != 0, S_ERROR); ms = oper_msec - msec; if (ms > 0) op->op_dispatch(loop, op_cmd_poll, ms); - complete_op(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timer); + complete_op(ms > 0 ? S_SUCCESS : S_ERROR, 0, oper, oper, op_ev_timer); return S_SUCCESS; } @@ -565,11 +559,10 @@ int evloop_run(evloop_t* loop, crt_msec msec) rc_error(op != NULL, S_ERROR); int rc = S_ERROR; loop->status = evloop_running; - while (loop->status != evloop_close) - { + while (loop->status != evloop_close) { evoper_t* oper = NULL; int ret = S_NOFOUND; - ret = evloop_gettime(loop->nodes, &oper); + ret = evloop_gettime(loop->nodes, &oper); evloop_update_time(loop); rc = (ret == S_FOUND ? cmd_poll_time(loop, oper) : cmd_poll(loop, msec)); evloop_update_time(loop); @@ -586,23 +579,23 @@ int evloop_stop(evloop_t* loop) } int evoper_alloc(evoper_t** oper, void* ctx, void* (*alloc)(void* ctx, size_t size)) { - *oper = (alloc == NULL ? heap_malloc(sizeof(evoper_t)) : alloc(ctx, sizeof(evoper_t))); - return S_SUCCESS; + *oper = (alloc == NULL ? heap_malloc(sizeof(evoper_t)) : alloc(ctx, sizeof(evoper_t))); + return S_SUCCESS; } int evoper_free(evoper_t* oper, void* ctx, int (*free)(void* ctx, void* ptr)) { - free == NULL ? heap_free(oper) : free(ctx, oper); - return S_SUCCESS; + free == NULL ? heap_free(oper) : free(ctx, oper); + return S_SUCCESS; } int evloop_alloc(evloop_t** loop, void* ctx, void* (*alloc)(void* ctx, size_t size)) { - *loop = (alloc == NULL ? heap_malloc(sizeof(evloop_t)) : alloc(ctx, sizeof(evloop_t))); - return S_SUCCESS; + *loop = (alloc == NULL ? heap_malloc(sizeof(evloop_t)) : alloc(ctx, sizeof(evloop_t))); + return S_SUCCESS; } int evloop_free(evloop_t* loop, void* ctx, int (*free)(void* ctx, void* ptr)) { - free == NULL ? heap_free(loop) : free(ctx, loop); - return S_SUCCESS; + free == NULL ? heap_free(loop) : free(ctx, loop); + return S_SUCCESS; } int evloop_bind_memory(evloop_t* loop, evmem_malloc malloc, evmem_free free, void* mmctx) { diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index b2448eec..49e3af5c 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -3,7 +3,6 @@ #if (TARGET_OS == OS_POSIX) - /* * The first epoll version has been introduced in Linux 2.5.44. The * interface was changed several times since then and the final version @@ -38,26 +37,25 @@ #endif // !EPOLLRDHUP #ifndef is_epoll_err -#define is_epoll_err(ev) ((ev & EPOLLERR) || (ev & EPOLLHUP) || (!(ev & EPOLLIN))) +#define is_epoll_err(ev) ((ev & EPOLLERR) || (ev & EPOLLHUP) || (!(ev & EPOLLIN))) #endif -//EPOLLRDHUP +// EPOLLRDHUP -#define epoll_use 1 +#define epoll_use 1 -#define ev_base_event (EPOLLET |EPOLLERR) +#define ev_base_event (EPOLLET | EPOLLERR) #ifdef EPOLLEXCLUSIVE -#define ev_poll_event (EPOLLIN /*| EPOLLEXCLUSIVE*/) +#define ev_poll_event (EPOLLIN /*| EPOLLEXCLUSIVE*/) #else -#define ev_poll_event (EPOLLIN) +#define ev_poll_event (EPOLLIN) #endif -#define ev_conn_event (EPOLLOUT) -#define ev_read_event (EPOLLIN | EPOLLRDHUP) -#define ev_write_event (EPOLLOUT) -#define ev_clear_event (0) -#define ev_oneshot_write_event (EPOLLOUT | EPOLLONESHOT) -#define ev_oneshot_read_event (EPOLLIN | EPOLLONESHOT) - +#define ev_conn_event (EPOLLOUT) +#define ev_read_event (EPOLLIN | EPOLLRDHUP) +#define ev_write_event (EPOLLOUT) +#define ev_clear_event (0) +#define ev_oneshot_write_event (EPOLLOUT | EPOLLONESHOT) +#define ev_oneshot_read_event (EPOLLIN | EPOLLONESHOT) static int is_use_epoll_rdhup(epoll_op_t* base, int ep) { @@ -163,9 +161,8 @@ static int epoll_op(epoll_op_t* base, evoper_t* oper, epoll_event_t* ptr, int op ee.data.u64 = 0; ee.data.ptr = oper; - //ctl_mod --> EPOLLEXCLUSIVE --> 22 sys_epoll_ctl return EINVAL + // ctl_mod --> EPOLLEXCLUSIVE --> 22 sys_epoll_ctl return EINVAL if (base->sys_epoll_ctl(base->epfd, op, oper->fd, &ee) == 0) { - return S_SUCCESS; } @@ -201,7 +198,7 @@ int epoll_alloc(evloop_t* loop, int size) rc = sys_hook_api(base); if (rc != S_SUCCESS) goto err; - + base->epfd = base->sys_epoll_create(base->size); if (base->epfd == INVALID_SOCKET) goto err; @@ -210,7 +207,7 @@ int epoll_alloc(evloop_t* loop, int size) if (base->notify_fd != INVALID_SOCKET) { base->notify_handler = epoll_notify_handler; base->size += 1; - } + } base->mode = ev_base_event; @@ -219,9 +216,9 @@ int epoll_alloc(evloop_t* loop, int size) goto err; rc = socket_cloexec(base->epfd); - if (rc != S_SUCCESS) + if (rc != S_SUCCESS) goto err; - + base->poll = NULL; base->poll = loop->mm_malloc(loop, base->size, sizeof(struct epoll_event)); if (base->poll == NULL) @@ -229,7 +226,7 @@ int epoll_alloc(evloop_t* loop, int size) return evloop_bind_evbase(loop, base); err: - loop->mm_free(loop, base); + loop->mm_free(loop, base); return S_ERROR; } int epoll_dealloc(evloop_t* loop) @@ -264,7 +261,7 @@ int epoll_alloc_evoper(evloop_t* loop, evoper_t* oper) set_epoll_op(ptr, op); evoper_op_init(oper); - //https://elixir.bootlin.com/linux/v4.19.316/source/fs/eventpoll.c#L2047 + // https://elixir.bootlin.com/linux/v4.19.316/source/fs/eventpoll.c#L2047 return epoll_op(base, oper, ptr, EPOLL_CTL_ADD); } int epoll_dealloc_evoper(evloop_t* loop, evoper_t* oper) @@ -281,7 +278,7 @@ int epoll_dealloc_evoper(evloop_t* loop, evoper_t* oper) rc = epoll_op(base, oper, ptr, EPOLL_CTL_DEL); heap_free(ptr); - + return rc; } int epoll_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) @@ -296,7 +293,7 @@ int epoll_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) uint32_t op = epoll_event_add(ptr, ev_read_event); set_epoll_op(ptr, op); epoll_op(base, oper, ptr, EPOLL_CTL_MOD); - //recv + // recv rc = posix_tcpsock_recv(oper, 0); return rc; @@ -315,17 +312,17 @@ int epoll_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv set_epoll_op(ptr, op); rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); - //send + // send rc = posix_tcpsock_send(oper, 0); - return rc; + return rc; } int epoll_disable_read(evloop_t* loop, evoper_t* oper, short event) { rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - + epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); @@ -375,7 +372,7 @@ int epoll_poll(evloop_t* loop, evoper_t* oper) epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - set_epoll_op(ptr, ev_poll_event| ev_base_event); + set_epoll_op(ptr, ev_poll_event | ev_base_event); return epoll_op(base, oper, ptr, EPOLL_CTL_MOD); } @@ -414,7 +411,7 @@ int epoll_del_connect(evloop_t* loop, evoper_t* oper) return S_SUCCESS; } -//https://elixir.bootlin.com/linux/v2.6.26/source/fs/eventpoll.c#L99 +// https://elixir.bootlin.com/linux/v2.6.26/source/fs/eventpoll.c#L99 #define MAX_TIMEOUT_MSEC (35 * 60 * 1000) static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) @@ -431,7 +428,6 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) int n = 0; for (n = 0; n < fds; n++) { - evoper_t* oper = NULL; uint32_t events = 0; rc_error_break(base->ev != NULL); @@ -440,14 +436,15 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) rc_error_continue(oper != NULL); events = base->poll[n].events; rc_error_continue(oper->fd != INVALID_SOCKET) - - if (base->poll[n].data.fd == base->notify_fd) { + + if (base->poll[n].data.fd == base->notify_fd) + { if (base->notify_handler(base) == S_EXIT) { break; - } + } } - //error + // error if (events & EPOLLERR) { evoper_err_op(oper, ev_on); complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); @@ -462,7 +459,6 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) } if (events & EPOLLIN) { - if (events & EPOLLRDHUP) { evoper_close_op(oper, ev_on); complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); @@ -478,7 +474,6 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); } if (events & EPOLLOUT) { - if (oper->conn == op_ev_connecting) { complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); continue; @@ -491,7 +486,7 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) epoll_tcpsock_send(oper, S_SUCCESS, err, base->ev); } } - + return S_SUCCESS; } static int epoll_cmd_exit(const epoll_op_t* base, evloop_t* loop) @@ -533,7 +528,7 @@ int epoll_evop_t(evsysop_t* op) op->op_disable_read = epoll_disable_read; op->op_disable_write = epoll_disable_write; - op->op_cancel = epoll_cancel; + op->op_cancel = epoll_cancel; op->op_open = epoll_open; op->op_poll = epoll_poll; op->op_add_connect = epoll_add_connect; diff --git a/stdcrt/event/compat_event_epoll.h b/stdcrt/event/compat_event_epoll.h index b3f59f12..0ff42162 100644 --- a/stdcrt/event/compat_event_epoll.h +++ b/stdcrt/event/compat_event_epoll.h @@ -31,14 +31,13 @@ typedef int (*sys_eventfd_fn)(unsigned int, int); //#define TFD_NONBLOCK 00004000 //#endif // !TFD_NONBLOCK // -//typedef int (*timerfd_create_fn)(int, int); -//typedef int (*timerfd_settime_fn)(int, int, const struct itimerspec*, struct itimerspec*); -//typedef int (*timerfd_gettime_fn)(int, struct itimerspec*); +// typedef int (*timerfd_create_fn)(int, int); +// typedef int (*timerfd_settime_fn)(int, int, const struct itimerspec*, struct itimerspec*); +// typedef int (*timerfd_gettime_fn)(int, struct itimerspec*); typedef int (*base_notify_handler)(epoll_op_t* base); struct epoll_op_s { - int epfd; struct epoll_event* events; @@ -49,15 +48,15 @@ struct epoll_op_s { epoll_ctl_fn sys_epoll_ctl; sys_eventfd_fn sys_eventfd; - //notify->epoll 2.6.22 + // notify->epoll 2.6.22 int notify_fd; epoll_event_t notify_event; base_notify_handler notify_handler; - //op + // op ev_op ev; - //mode + // mode uint32_t mode; }; diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index c333b588..4ecd5e6d 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -3,11 +3,9 @@ #if (TARGET_OS == OS_WIN) - int sock_iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err, DWORD bytes); int sock_iocp_err_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err); - void _waitsem_threadProc(void* obj) { iocp_op_t* base = NULL; @@ -38,8 +36,7 @@ static void* get_mswsock_extfunc(SOCKET s, const GUID* which_fn) { void* ptr = NULL; DWORD bytes = 0; - WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, - (GUID*)which_fn, sizeof(*which_fn), &ptr, sizeof(ptr), &bytes, NULL, NULL); + WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, (GUID*)which_fn, sizeof(*which_fn), &ptr, sizeof(ptr), &bytes, NULL, NULL); return ptr; } @@ -48,8 +45,7 @@ static int iocp_hook_api(iocp_op_t* base) // process==>kernel32.dll HMODULE hModule = load_windows_system_library_(TEXT("kernel32.dll")); - rc_error(hModule != NULL, S_ERROR) - base->iocp.CancelIo = (CancelIoPtr)GetProcAddress(hModule, "CancelIo"); + rc_error(hModule != NULL, S_ERROR) base->iocp.CancelIo = (CancelIoPtr)GetProcAddress(hModule, "CancelIo"); base->iocp.CancelIoEx = (CancelIoExPtr)GetProcAddress(hModule, "CancelIoEx"); FreeLibrary(hModule); return S_SUCCESS; @@ -82,7 +78,7 @@ static int sock_hook_api(iocp_op_t* base) base->fns.GetAcceptExSockaddrs = get_mswsock_extfunc(s, &getacceptexsockaddrs); base->fns.DisconnectEx = get_mswsock_extfunc(s, &disconnectex); - + closesocket(s); return S_SUCCESS; err: @@ -119,7 +115,6 @@ err: _thread_join(&base->waitsem_thread); return S_ERROR; - } int iocp_alloc(evloop_t* loop, int size) @@ -210,7 +205,7 @@ int iocp_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) rc_error(oper != NULL, S_ERROR); iocp_op_t* base = (iocp_op_t*)evoper_evbase(oper); - if (oper->t == ev_sock) { + if (oper->t == ev_sock) { rc = win32_sock_read_op(oper); } return rc; @@ -309,7 +304,6 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWO } if (oper_ov->r == ev_on && bytes) { - oper->bt = ev_io_complete; base->ev(0, err, oper, NULL, op_ev_read); oper_ov->r = ev_off; @@ -319,7 +313,6 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWO } if (oper_ov->w == ev_on && bytes) { - oper->bt = ev_io_complete; base->ev(0, err, oper, NULL, op_ev_write); oper_ov->w = ev_off; @@ -376,8 +369,14 @@ static int sock_iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, { rc_error(oper_ov != NULL, S_ERROR) - if (key == ev_sockpoll){ poll_handle(loop, base, oper_ov, err, bytes);} - else if (key == ev_sock) { oper_handle(loop, base, oper_ov, err, bytes); } + if (key == ev_sockpoll) + { + poll_handle(loop, base, oper_ov, err, bytes); + } + else if (key == ev_sock) + { + oper_handle(loop, base, oper_ov, err, bytes); + } return S_SUCCESS; } int iocp_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) @@ -399,7 +398,7 @@ int iocp_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) crterr err = crt_geterror(); - if (err) { + if (err) { if (ovlp == NULL) { if (err != WAIT_TIMEOUT) { return NGX_ERROR; @@ -410,7 +409,7 @@ int iocp_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) if (ovlp == NULL) return S_AGAIN; - + if (HasOverlappedIoCompleted(&ovlp->overlapped) == 0) return S_SUCCESS; @@ -422,7 +421,7 @@ int iocp_cmd_poll(iocp_op_t* base, evloop_t* loop, crt_msec timer) sock_iocp_handle(loop, base, ovlp, key, err, bytes); } } - } else { + } else { if (key == ev_sock || key == ev_sockpoll) { sock_iocp_err_handle(loop, base, ovlp, key, err); } diff --git a/stdcrt/event/compat_event_iocp.h b/stdcrt/event/compat_event_iocp.h index aee9f1a7..fc028dee 100644 --- a/stdcrt/event/compat_event_iocp.h +++ b/stdcrt/event/compat_event_iocp.h @@ -89,23 +89,20 @@ struct iocp_fns_ex { #define ACCEPT_ADDRESS_LENGTH ((sizeof(struct sockaddr_in) + 16)) #endif // !ACCEPT_ADDRESS_LENGTH - typedef struct { OVERLAPPED overlapped; - void* ptr; //lpwsascok + void* ptr; // lpwsascok char addr[ACCEPT_ADDRESS_LENGTH * 2 + 20]; crterr error; evevent r; evevent w; } evoper_ov, *lpevoper_ov; - typedef struct { evoper_t* accept_oper; evoper_t* oper; } wsasock, *lpwsasock; - struct iocp_op_s { HANDLE hiocp; extension_fns fns; diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 16a336a7..5400f002 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -3,102 +3,99 @@ #if (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) -#define ev_base_event 0 +#define ev_base_event 0 -#define ev_poll_event EVFILT_READ -#define ev_conn_event EVFILT_WRITE +#define ev_poll_event EVFILT_READ +#define ev_conn_event EVFILT_WRITE -#define ev_read_event EVFILT_READ -#define ev_write_event EVFILT_WRITE +#define ev_read_event EVFILT_READ +#define ev_write_event EVFILT_WRITE -#define ev_close_event EV_EOF -#define ev_clear_event EV_CLEAR - -#define kevent_add_op EV_ADD | EV_CLEAR -#define kevent_del_op EV_DELETE | EV_CLEAR -#define kevent_op_enable EV_ENABLE | EV_CLEAR -#define kevent_op_disable EV_DISABLE| EV_CLEAR +#define ev_close_event EV_EOF +#define ev_clear_event EV_CLEAR +#define kevent_add_op EV_ADD | EV_CLEAR +#define kevent_del_op EV_DELETE | EV_CLEAR +#define kevent_op_enable EV_ENABLE | EV_CLEAR +#define kevent_op_disable EV_DISABLE | EV_CLEAR static int set_kevent_ctl(kqueue_event_t* ptr, uint32_t ctl) { - rc_error(ptr != NULL, S_ERROR); - ptr->ctl = ctl; - return S_SUCCESS; + rc_error(ptr != NULL, S_ERROR); + ptr->ctl = ctl; + return S_SUCCESS; } static uint32_t get_kevent_ctl(kqueue_event_t* ptr) { - return ptr->ctl; + return ptr->ctl; } static int kqueue_op_ctl(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr, const struct timespec* tm, int op) { - int rc = 0; - - - uint32_t flags = get_kevent_ctl(ptr); - - - if (op == ev_poll_event || op == ev_read_event) { - struct kevent event; - EV_SET(&event, oper->fd, EVFILT_READ, flags, 0, 0, oper); - rc = base->sys_kevent(base->kqfd, &event, 1, NULL, 0, tm); - } - - if (op == ev_conn_event || op == ev_write_event) { - struct kevent event; - EV_SET(&event, oper->fd, EVFILT_WRITE, flags, 0, 0, oper); - rc = base->sys_kevent(base->kqfd, &event, 1, NULL, 0, tm); - } - - if (rc == -1) { - crterr err = crt_geterror(); - if (err == EINVAL) { - loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); - } else if (err == ENOENT) { - loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); - } else if (err != EPERM) { - loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); - } - return S_ERROR; - } - - return S_SUCCESS; + int rc = 0; + + uint32_t flags = get_kevent_ctl(ptr); + + if (op == ev_poll_event || op == ev_read_event) { + struct kevent event; + EV_SET(&event, oper->fd, EVFILT_READ, flags, 0, 0, oper); + rc = base->sys_kevent(base->kqfd, &event, 1, NULL, 0, tm); + } + + if (op == ev_conn_event || op == ev_write_event) { + struct kevent event; + EV_SET(&event, oper->fd, EVFILT_WRITE, flags, 0, 0, oper); + rc = base->sys_kevent(base->kqfd, &event, 1, NULL, 0, tm); + } + + if (rc == -1) { + crterr err = crt_geterror(); + if (err == EINVAL) { + loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); + } else if (err == ENOENT) { + loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); + } else if (err != EPERM) { + loge("kqueue_op_ctl error %d, epfd=%d, fd=%d\n", errno, base->kqfd, oper->fd); + } + return S_ERROR; + } + + return S_SUCCESS; } #if (TARGET_OS == OS_MACH) static int kqueue_notify_init(kqueue_op_t* base) { - base->notify_kev.ident = 0; - base->notify_kev.filter = EVFILT_USER; - base->notify_kev.data = 0; - base->notify_kev.flags = EV_ADD | EV_CLEAR; - base->notify_kev.fflags = 0; - base->notify_kev.udata = 0; - - if (base->sys_kevent(base->kqfd, &base->notify_kev, 1, NULL, 0, NULL) == -1) { - return S_ERROR; - } - return S_SUCCESS; + base->notify_kev.ident = 0; + base->notify_kev.filter = EVFILT_USER; + base->notify_kev.data = 0; + base->notify_kev.flags = EV_ADD | EV_CLEAR; + base->notify_kev.fflags = 0; + base->notify_kev.udata = 0; + + if (base->sys_kevent(base->kqfd, &base->notify_kev, 1, NULL, 0, NULL) == -1) { + return S_ERROR; + } + return S_SUCCESS; } #endif static int kqueue_hook_api(kqueue_op_t* base) { - base->sys_kqueue = (kqueue_fn)dlsym(RTLD_NEXT, "kqueue"); - rc_error(base->sys_kqueue != NULL, S_ERROR); + base->sys_kqueue = (kqueue_fn)dlsym(RTLD_NEXT, "kqueue"); + rc_error(base->sys_kqueue != NULL, S_ERROR); - base->sys_kevent = (kevent_fn)dlsym(RTLD_NEXT, "kevent"); - rc_error(base->sys_kevent != NULL, S_ERROR); - - return S_SUCCESS; + base->sys_kevent = (kevent_fn)dlsym(RTLD_NEXT, "kevent"); + rc_error(base->sys_kevent != NULL, S_ERROR); + + return S_SUCCESS; } int kqueue_alloc(evloop_t* loop, int size) { int rc = S_ERROR; - kqueue_op_t* base = NULL; + kqueue_op_t* base = NULL; base = (kqueue_op_t*)loop->mm_malloc(loop, 1, sizeof(kqueue_op_t)); rc_error(base != NULL, S_ERROR); @@ -107,196 +104,195 @@ int kqueue_alloc(evloop_t* loop, int size) rc = kqueue_hook_api(base); if (rc != S_SUCCESS) goto err; - - base->kqfd = base->sys_kqueue(); - if (base->kqfd == 0) - goto err; - + + base->kqfd = base->sys_kqueue(); + if (base->kqfd == 0) + goto err; + #if (TARGET_OS == OS_MACH) - rc = kqueue_notify_init(base); - if(rc != S_SUCCESS) - goto err; + rc = kqueue_notify_init(base); + if (rc != S_SUCCESS) + goto err; #endif - base->poll = NULL; base->poll = loop->mm_malloc(loop, base->size, sizeof(struct kevent)); - if(base->poll == NULL) - goto err; - - base->change = NULL; - base->change = loop->mm_malloc(loop, base->size, sizeof(struct kevent)); - if(base->poll == NULL) - goto err; - + if (base->poll == NULL) + goto err; + + base->change = NULL; + base->change = loop->mm_malloc(loop, base->size, sizeof(struct kevent)); + if (base->poll == NULL) + goto err; + return evloop_bind_evbase(loop, base); err: - loop->mm_free(loop, base); + loop->mm_free(loop, base); return S_ERROR; } int kqueue_dealloc(evloop_t* loop) { - kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); - loop->mm_free(loop, base->poll); - loop->mm_free(loop, base->change); + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); + loop->mm_free(loop, base->poll); + loop->mm_free(loop, base->change); return S_SUCCESS; } int kqueue_handler(evloop_t* loop, ev_op ev) { - rc_error(loop != NULL, S_ERROR); - kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); - base->ev = ev; - return S_SUCCESS; + rc_error(loop != NULL, S_ERROR); + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); + base->ev = ev; + return S_SUCCESS; } int kqueue_alloc_evoper(evloop_t* loop, evoper_t* oper) { - rc_error(loop != NULL, S_ERROR); - kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); + rc_error(loop != NULL, S_ERROR); + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); rc_error(oper != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)loop->mm_malloc(loop, 1, sizeof(kqueue_event_t)); + kqueue_event_t* ptr = (kqueue_event_t*)loop->mm_malloc(loop, 1, sizeof(kqueue_event_t)); rc_error(ptr != NULL, S_ERROR); - + evoper_bind_private(oper, ptr); - - evoper_op_init(oper); - - //Adding kqueue causes multiple event triggers - //set_kevent_ctl(ptr, kevent_add_op); - //kqueue_op_ctl(base, oper, ptr, NULL); - - return S_SUCCESS; + + evoper_op_init(oper); + + // Adding kqueue causes multiple event triggers + // set_kevent_ctl(ptr, kevent_add_op); + // kqueue_op_ctl(base, oper, ptr, NULL); + + return S_SUCCESS; } int kqueue_dealloc_evoper(evloop_t* loop, evoper_t* oper) { rc_error(oper != NULL, S_ERROR); - kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); - rc_error(oper != NULL, S_ERROR); - - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - - set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); - kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event | ev_write_event); - - loop->mm_free(loop, evoper_private(oper)); + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); + rc_error(oper != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event | ev_write_event); + + loop->mm_free(loop, evoper_private(oper)); return S_SUCCESS; } int kqueue_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { - int rc = S_SUCCESS; - kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + int rc = S_SUCCESS; + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - - //add kqueue - set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); - kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event); - - //recv - rc = mach_tcpsock_recv(oper, 0); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + // add kqueue + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event); + + // recv + rc = mach_tcpsock_recv(oper, 0); return S_SUCCESS; } int kqueue_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) { - int rc = S_SUCCESS; - kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); - rc_error(base != NULL, S_ERROR); - - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - - //add kqueue - set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); - kqueue_op_ctl(base, oper, ptr, NULL, ev_write_event); - - //send - rc = mach_tcpsock_send(oper, 0); - - return S_SUCCESS; + int rc = S_SUCCESS; + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + // add kqueue + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_write_event); + + // send + rc = mach_tcpsock_send(oper, 0); + + return S_SUCCESS; } int kqueue_disable_read(evloop_t* loop, evoper_t* oper, short event) { - kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); - rc_error(base != NULL, S_ERROR); - - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - - evoper_read_op(oper, op_ev_readed); - - set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); - kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event); - + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + evoper_read_op(oper, op_ev_readed); + + set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event); + return S_SUCCESS; } int kqueue_disable_write(evloop_t* loop, evoper_t* oper, short event) { - kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); - rc_error(base != NULL, S_ERROR); - - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - - evoper_write_op(oper, op_ev_writed); - - set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); - kqueue_op_ctl(base, oper, ptr, NULL, ev_write_event); - - return S_SUCCESS; + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + evoper_write_op(oper, op_ev_writed); + + set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_write_event); + + return S_SUCCESS; } int kqueue_cancel(evloop_t* loop, evoper_t* oper) { - kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); - rc_error(base != NULL, S_ERROR); - return S_SUCCESS; + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); + return S_SUCCESS; } int kqueue_open(evloop_t* loop, evoper_t* oper, const evaddr_t* addr) { - kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); - rc_error(base != NULL, S_ERROR); - return S_SUCCESS; + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); + return S_SUCCESS; } int kqueue_poll(evloop_t* loop, evoper_t* oper) { - kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - - set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); - return kqueue_op_ctl(base, oper, ptr, NULL, ev_poll_event); + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + + return kqueue_op_ctl(base, oper, ptr, NULL, ev_poll_event); } int kqueue_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_time_t tv) { - int rc = S_SUCCESS; - - kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); - rc_error(base != NULL, S_ERROR); - - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); - rc_error(ptr != NULL, S_ERROR); - - rc = evoper_sock_connect(oper, addr); - - if (rc == S_PENDING) { - set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); - kqueue_op_ctl(base, oper, ptr, NULL, ev_conn_event); - } - - return S_SUCCESS; + int rc = S_SUCCESS; + + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); + + kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + rc_error(ptr != NULL, S_ERROR); + + rc = evoper_sock_connect(oper, addr); + + if (rc == S_PENDING) { + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_conn_event); + } + + return S_SUCCESS; } int kqueue_del_connect(evloop_t* loop, evoper_t* oper) { - kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); - rc_error(base != NULL, S_ERROR); + kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); + rc_error(base != NULL, S_ERROR); return S_SUCCESS; } @@ -310,49 +306,45 @@ static int kqueue_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) nfds = base->sys_kevent(base->kqfd, NULL, 0, base->poll, base->size, &timeout); - crterr err = crt_geterror(); - + crterr err = crt_geterror(); + int i = 0; for (i = 0; i < nfds; i++) { - - evoper_t* oper = base->poll[i].udata; - - if (base->poll[i].flags & EV_ERROR) { - complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); - continue; - } - - if (base->poll[i].flags & EV_EOF) { - evoper_eof_op(oper, ev_on); - } - - if(base->poll[i].filter == EVFILT_READ) { - - if (oper->accept == op_ev_accepting) { - complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); - continue; - } - - oper->bt = ev_io_complete; - complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); - continue; - } - - if (base->poll[i].filter == EVFILT_WRITE) { - - if (oper->conn == op_ev_connecting) { - complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); - continue; - } - oper->bt = ev_io_complete; - complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); - - if (evoper_writeing(oper) == S_SUCCESS) - kqueue_tcpsock_send(oper, S_SUCCESS, err, base->ev); - - continue; - } - + evoper_t* oper = base->poll[i].udata; + + if (base->poll[i].flags & EV_ERROR) { + complete_sock_close(loop, S_SUCCESS, err, oper, base->ev); + continue; + } + + if (base->poll[i].flags & EV_EOF) { + evoper_eof_op(oper, ev_on); + } + + if (base->poll[i].filter == EVFILT_READ) { + if (oper->accept == op_ev_accepting) { + complete_sock_accept(loop, S_SUCCESS, err, oper, NULL, base->ev); + continue; + } + + oper->bt = ev_io_complete; + complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); + continue; + } + + if (base->poll[i].filter == EVFILT_WRITE) { + if (oper->conn == op_ev_connecting) { + complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); + continue; + } + oper->bt = ev_io_complete; + complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); + + if (evoper_writeing(oper) == S_SUCCESS) + kqueue_tcpsock_send(oper, S_SUCCESS, err, base->ev); + + continue; + } } return S_SUCCESS; } @@ -364,7 +356,7 @@ static int kqueue_dispatch(evloop_t* loop, short event, crt_msec time) { int rc = S_SUCCESS; - kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); + kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); switch (event) { case op_cmd_poll: @@ -384,22 +376,22 @@ int kqueue_evop_t(evsysop_t* op) op->op_alloc = kqueue_alloc; op->op_dealloc = kqueue_dealloc; - op->op_handler = kqueue_handler; - + op->op_handler = kqueue_handler; + op->op_alloc_evoper = kqueue_alloc_evoper; op->op_dealloc_evoper = kqueue_dealloc_evoper; - op->op_enable_read = kqueue_enable_read; + op->op_enable_read = kqueue_enable_read; op->op_enable_write = kqueue_enable_write; op->op_disable_read = kqueue_disable_read; op->op_disable_write = kqueue_disable_write; - - op->op_cancel = kqueue_cancel; - op->op_open = kqueue_open; - op->op_poll = kqueue_poll; + + op->op_cancel = kqueue_cancel; + op->op_open = kqueue_open; + op->op_poll = kqueue_poll; op->op_add_connect = kqueue_add_connect; op->op_del_connect = kqueue_del_connect; - + op->op_dispatch = kqueue_dispatch; return S_SUCCESS; diff --git a/stdcrt/event/compat_event_kqueue.h b/stdcrt/event/compat_event_kqueue.h index 8f7b27e5..ca7ad8bf 100644 --- a/stdcrt/event/compat_event_kqueue.h +++ b/stdcrt/event/compat_event_kqueue.h @@ -10,12 +10,11 @@ extern "C" { #if (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) - typedef struct kqueue_op_s kqueue_op_t; typedef struct kevent_s kqueue_event_t; struct kevent_s { - uint32_t ctl; + uint32_t ctl; }; typedef int (*kqueue_fn)(void); @@ -27,13 +26,12 @@ struct kqueue_op_s { kqueue_fn sys_kqueue; kevent_fn sys_kevent; struct kevent* poll; - struct kevent* change; + struct kevent* change; struct kevent notify_kev; - ev_op ev; - _mutex_t lock; + ev_op ev; + _mutex_t lock; }; - int kqueue_evop_t(evsysop_t* op); #endif diff --git a/stdcrt/event/compat_event_mach.c b/stdcrt/event/compat_event_mach.c index 874f1abf..a1491748 100644 --- a/stdcrt/event/compat_event_mach.c +++ b/stdcrt/event/compat_event_mach.c @@ -6,163 +6,154 @@ #include "compat_event_kqueue.h" #include "compat_event_mach.h" - int kqueue_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func) { - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n = 0; - - - int error = 0; - buf_ptr ptr = NULL; - buf_len len = 0; - - while (n != -1) { - - rc = evbuf_get_buf(&oper->wbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->wbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - n = send(oper->fd, ptr, len, 0); - error = (n == -1) ? errno : 0; - if (n > 0) { - func(error, code, oper, NULL, op_ev_write); - } - - if (evoper_writeing(oper) == S_ERROR) - break; - } - - return rc; -} - -int kqueue_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) -{ - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n = 0; + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n = 0; - while (n != -1) { + int error = 0; + buf_ptr ptr = NULL; + buf_len len = 0; - int err = 0; - buf_ptr ptr = NULL; - buf_len len = 0; + while (n != -1) { + rc = evbuf_get_buf(&oper->wbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); - rc = evbuf_get_buf(&oper->rbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); + rc = evbuf_get_len(&oper->wbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); - rc = evbuf_get_len(&oper->rbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); + n = send(oper->fd, ptr, len, 0); + error = (n == -1) ? errno : 0; + if (n > 0) { + func(error, code, oper, NULL, op_ev_write); + } - n = recv(oper->fd, ptr, len, 0); - err = (n == -1) ? errno : 0; - if (n > 0) { - func(err, code, oper, NULL, op_ev_read); - } + if (evoper_writeing(oper) == S_ERROR) + break; + } - if (evoper_reading(oper) == S_ERROR) - break; - } - return rc; + return rc; } +int kqueue_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) +{ + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n = 0; + + while (n != -1) { + int err = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->rbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->rbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + n = recv(oper->fd, ptr, len, 0); + err = (n == -1) ? errno : 0; + if (n > 0) { + func(err, code, oper, NULL, op_ev_read); + } + + if (evoper_reading(oper) == S_ERROR) + break; + } + return rc; +} int mach_tcpsock_send(evoper_t* oper, int flags) { - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->wbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->wbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - for (;;) { - - int err = 0; - n = send(oper->fd, ptr, len, flags); - err = (n == -1) ? errno : 0; - - if (n > 0) { - evbuf_op_off(&oper->wbuf, n); - if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { - return S_COMPLETED; - } - return S_PENDING; - } - - if (err == EAGAIN) { - rc = S_PENDING; - goto end; - } else if (err == EINTR) { - // sync - } else { - rc = S_ERROR; - goto end; - } - } - return rc; + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->wbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->wbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + for (;;) { + int err = 0; + n = send(oper->fd, ptr, len, flags); + err = (n == -1) ? errno : 0; + + if (n > 0) { + evbuf_op_off(&oper->wbuf, n); + if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { + return S_COMPLETED; + } + return S_PENDING; + } + + if (err == EAGAIN) { + rc = S_PENDING; + goto end; + } else if (err == EINTR) { + // sync + } else { + rc = S_ERROR; + goto end; + } + } + return rc; end: - return rc; + return rc; } int mach_tcpsock_recv(evoper_t* oper, int flags) { - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->rbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->rbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - - for (;;) { - - int err = 0; - n = recv(oper->fd, ptr, len, flags); - err = (n == -1) ? errno : 0; - if (n > 0) { - evbuf_op_off(&oper->rbuf, n); - if (is_evbuf_compelete(&oper->rbuf) == S_SUCCESS) { - rc = S_COMPLETED; - goto end; - } - rc = S_PENDING; - goto end; - } - - if (n == 0) { - evoper_close_op(oper, ev_on); - rc = S_ERROR; - goto end; - } - - if (err == EAGAIN) { - rc = S_PENDING; - goto end; - } else if (err == EINTR) { - //sync - } else { - rc = S_ERROR; - goto end; - } - } - return rc; + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + ssize_t n; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->rbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->rbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + for (;;) { + int err = 0; + n = recv(oper->fd, ptr, len, flags); + err = (n == -1) ? errno : 0; + if (n > 0) { + evbuf_op_off(&oper->rbuf, n); + if (is_evbuf_compelete(&oper->rbuf) == S_SUCCESS) { + rc = S_COMPLETED; + goto end; + } + rc = S_PENDING; + goto end; + } + + if (n == 0) { + evoper_close_op(oper, ev_on); + rc = S_ERROR; + goto end; + } + + if (err == EAGAIN) { + rc = S_PENDING; + goto end; + } else if (err == EINTR) { + // sync + } else { + rc = S_ERROR; + goto end; + } + } + return rc; end: - return rc; + return rc; } - #endif diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index 9001983f..89dec934 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -11,14 +11,12 @@ int epoll_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func) int rc = S_SUCCESS; rc_error(oper != NULL, rc); ssize_t n = 0; - - + int error = 0; buf_ptr ptr = NULL; buf_len len = 0; while (n != -1) { - rc = evbuf_get_buf(&oper->wbuf, &ptr); rc_error(rc != S_ERROR, S_ERROR); @@ -45,7 +43,6 @@ int epoll_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) ssize_t n = 0; while (n != -1) { - int err = 0; buf_ptr ptr = NULL; buf_len len = 0; @@ -83,7 +80,6 @@ int posix_tcpsock_send(evoper_t* oper, int flags) rc_error(rc != S_ERROR, S_ERROR); for (;;) { - int err = 0; n = send(oper->fd, ptr, len, flags); err = (n == -1) ? errno : 0; @@ -119,16 +115,14 @@ int posix_tcpsock_recv(evoper_t* oper, int flags) ssize_t n; buf_ptr ptr = NULL; buf_len len = 0; - + rc = evbuf_get_buf(&oper->rbuf, &ptr); rc_error(rc != S_ERROR, S_ERROR); rc = evbuf_get_len(&oper->rbuf, &len); rc_error(rc != S_ERROR, S_ERROR); - - for (;;) { - + for (;;) { int err = 0; n = recv(oper->fd, ptr, len, flags); err = (n == -1) ? errno : 0; @@ -152,7 +146,7 @@ int posix_tcpsock_recv(evoper_t* oper, int flags) rc = S_PENDING; goto end; } else if (err == EINTR) { - //sync + // sync } else { rc = S_ERROR; goto end; diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index 9c266607..22348319 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -67,8 +67,8 @@ int evloop_nodes_uninit(evloop_nodes_t* nodes) } int evloop_nodes_count(evloop_nodes_t* nodes, uint64_t* count) { - rc_error(nodes != NULL, S_ERROR); - *count =nodes->heap.count; + rc_error(nodes != NULL, S_ERROR); + *count = nodes->heap.count; return S_SUCCESS; } int evloop_queue_init(evloop_queue_t* queue) @@ -86,7 +86,7 @@ int evloop_queue_uninit(evloop_queue_t* queue) int evloop_add_ev(evloop_queue_t* queue, evoper_queue* ev) { rc_error(queue != NULL, S_ERROR); - _queue_insert_tail(queue, ev); + _queue_insert_tail(queue, ev); return S_SUCCESS; } int evloop_del_ev(evloop_queue_t* queue, evoper_queue* ev) @@ -124,7 +124,7 @@ int evloop_clock_setmsec(evloop_clock_t* clock, crt_msec msec) int evloop_clock_getmsec(evloop_clock_t* clock, crt_msec* msec) { rc_error(clock != NULL, S_ERROR); - *msec = clock->msec; + *msec = clock->msec; return S_SUCCESS; } int evloop_bind_evbase(evloop_t* loop, void* evbase) @@ -176,7 +176,7 @@ int evoper_op_init(evoper_t* oper) oper->eof = ev_off; oper->post = ev_off; oper->err = ev_off; - oper->vnode = ev_off; + oper->vnode = ev_off; oper->pending_eof = ev_off; return S_SUCCESS; @@ -291,7 +291,7 @@ int evoper_sock_connect(evoper_t* oper, const evaddr_t* addr) } int evoper_sock_connected(evoper_t* oper) { -//win iocp https://learn.microsoft.com/zh-cn/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex + // win iocp https://learn.microsoft.com/zh-cn/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex int rc = S_ERROR; rc_error(oper != NULL, S_ERROR); @@ -310,21 +310,20 @@ int complete_sock_accept(evloop_t* loop, int err, crterr code, evoper_t* oper, e rc_error(func != NULL, S_ERROR); #if (TARGET_OS == OS_WIN) - //oper->bind = 1; + // oper->bind = 1; evoper_connect_op(oper_t, op_ev_connected); func(err == 0 ? S_SUCCESS : S_ERROR, err, oper, oper_t, op_ev_accept); #else evoper_ls ls = oper->ls; for (l = 0; l < ls; l++) { - struct sockaddr_in cliaddr; socklen_t clilen = sizeof(struct sockaddr_in); int accept_sock = -1; accept_sock = accept(oper->sock, (struct sockaddr*)&cliaddr, &clilen); rc_error_break(accept_sock != -1); - + evoper_t* oper_s = (evoper_t*)loop->mm_malloc(loop, 1, sizeof(evoper_t)); rc_error_break(oper_s != NULL); @@ -337,7 +336,7 @@ int complete_sock_accept(evloop_t* loop, int err, crterr code, evoper_t* oper, e func(S_SUCCESS, err, oper, oper_s, op_ev_accept); } -#endif +#endif return S_SUCCESS; } int complete_sock_connect(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func) @@ -368,19 +367,17 @@ int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_ rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - if(evoper_reading(oper) == S_SUCCESS) { - - #if (TARGET_OS == OS_WIN) + if (evoper_reading(oper) == S_SUCCESS) { +#if (TARGET_OS == OS_WIN) func(err, code, oper, NULL, op_ev_read); - #elif (TARGET_OS == OS_POSIX) +#elif (TARGET_OS == OS_POSIX) epoll_tcpsock_recv(oper, err, code, func); - #elif (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) - kqueue_tcpsock_recv(oper, err, code, func); - #else - - #endif - - } +#elif (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) + kqueue_tcpsock_recv(oper, err, code, func); +#else + +#endif + } return S_SUCCESS; } int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func) @@ -388,10 +385,10 @@ int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev rc_error(oper != NULL, S_ERROR); rc_error(loop != NULL, S_ERROR); rc_error(func != NULL, S_ERROR); - - if(evoper_writeing(oper) == S_SUCCESS) { - func(err, code, oper, NULL, op_ev_write); - } + + if (evoper_writeing(oper) == S_SUCCESS) { + func(err, code, oper, NULL, op_ev_write); + } return S_SUCCESS; } int evbuf_is_eof(evbuf_t* buf) @@ -448,37 +445,33 @@ int is_evbuf_compelete(evbuf_t* buf) } int evs_init(evs_t* on) { - rc_error(on != NULL, S_ERROR); - _atomic_init(&on->v); - return S_SUCCESS; + rc_error(on != NULL, S_ERROR); + _atomic_init(&on->v); + return S_SUCCESS; } int evs_uninit(evs_t* on) { - rc_error(on != NULL, S_ERROR); - _atomic_uninit(&on->v); - return S_SUCCESS; + rc_error(on != NULL, S_ERROR); + _atomic_uninit(&on->v); + return S_SUCCESS; } int evs_on(evs_t* on) { - rc_error(on != NULL, S_ERROR); - _atomic_add(&on->v); - return S_SUCCESS; + rc_error(on != NULL, S_ERROR); + _atomic_add(&on->v); + return S_SUCCESS; } int evs_off(evs_t* on) { - rc_error(on != NULL, S_ERROR); + rc_error(on != NULL, S_ERROR); _atomic_init(&on->v); - return S_SUCCESS; + return S_SUCCESS; } int is_evs_on(evs_t* on) { - rc_error(on != NULL, S_ERROR); - if (_atomic_cmp(1, &on->v)) { - return S_SUCCESS; - } - return S_ERROR; + rc_error(on != NULL, S_ERROR); + if (_atomic_cmp(1, &on->v)) { + return S_SUCCESS; + } + return S_ERROR; } - - - - diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 572a21ed..fed94e52 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -13,8 +13,8 @@ #define ev_maxsec_mesec (((LONG_MAX)-999) / evtime_sec) #endif // !ev_maxsec_mesec -#define ev_io_complete 1 -#define ev_func_complete 2 +#define ev_io_complete 1 +#define ev_func_complete 2 #ifndef op_cmd_poll #define op_cmd_poll 0x01 @@ -32,44 +32,43 @@ typedef _queue_t evoper_queue; typedef unsigned int evoper_ls; typedef struct evs_s evs_t; -#define op_ev_reading 0x01 -#define op_ev_readed 0x02 +#define op_ev_reading 0x01 +#define op_ev_readed 0x02 -#define op_ev_writeing 0x11 -#define op_ev_writed 0x12 +#define op_ev_writeing 0x11 +#define op_ev_writed 0x12 -#define op_ev_timering 0x21 -#define op_ev_timered 0x22 -#define op_ev_timerfailed 0x23 +#define op_ev_timering 0x21 +#define op_ev_timered 0x22 +#define op_ev_timerfailed 0x23 -#define op_ev_opening 0x31 -#define op_ev_opened 0x32 -#define op_ev_openfailed 0x33 +#define op_ev_opening 0x31 +#define op_ev_opened 0x32 +#define op_ev_openfailed 0x33 -#define op_ev_connecting 0x41 -#define op_ev_connected 0x42 -#define op_ev_connectfailed 0x43 +#define op_ev_connecting 0x41 +#define op_ev_connected 0x42 +#define op_ev_connectfailed 0x43 -#define op_ev_accepting 0x51 -#define op_ev_accepted 0x52 -#define op_ev_acceptfailed 0x53 +#define op_ev_accepting 0x51 +#define op_ev_accepted 0x52 +#define op_ev_acceptfailed 0x53 -#define op_ev_closeing 0x61 -#define op_ev_closed 0x62 +#define op_ev_closeing 0x61 +#define op_ev_closed 0x62 #ifndef ev_on -#define ev_on 0x00 +#define ev_on 0x00 #endif // !ev_on #ifndef ev_off -#define ev_off 0x01 +#define ev_off 0x01 #endif // !ev_off - struct evs_s { _atomic_t v; }; - + struct evbuf_s { buf_ptr ptr; buf_len len; @@ -77,11 +76,10 @@ struct evbuf_s { }; struct evoper_s { - - evtype t; + evtype t; void* ctx; void* private; - + evevent open; evevent conn; @@ -97,13 +95,12 @@ struct evoper_s { evevent close; evevent oneshot; - evevent eof; - evevent post; - evevent err; + evevent eof; + evevent post; + evevent err; - evevent vnode; // kqueue_vnode; - evevent pending_eof; // kqueue_vnode; - + evevent vnode; // kqueue_vnode; + evevent pending_eof; // kqueue_vnode; union { _fd_t fd; @@ -149,7 +146,7 @@ struct evloop_nodes_s { struct evloop_clock_s { _mutex_t lock; _clock_t clock; - crt_msec msec; + crt_msec msec; }; struct evloop_s { diff --git a/stdcrt/event/compat_event_win32.c b/stdcrt/event/compat_event_win32.c index bee6ede0..acea6557 100644 --- a/stdcrt/event/compat_event_win32.c +++ b/stdcrt/event/compat_event_win32.c @@ -38,7 +38,7 @@ int win32_sock_connectexed(evoper_t* oper) } else { if (sec == 0xFFFFFFFF) { rc = S_ERROR; - }else + } else rc = S_SUCCESS; } return rc; @@ -92,7 +92,6 @@ static int win32_sock_connectex(evoper_t* oper, const struct sockaddr* sa, sockl return S_ERROR; } - ret = base->fns.ConnectEx(oper->sock, sa, socklen, 0, 0, 0, &ov->overlapped); crterr err = crt_geterror(); @@ -101,7 +100,7 @@ static int win32_sock_connectex(evoper_t* oper, const struct sockaddr* sa, sockl rc = S_COMPLETED; } else if (ret == FALSE && ERROR_IO_PENDING == err) { rc = S_PENDING; - + } else { rc = S_ERROR; } @@ -122,7 +121,6 @@ int win32_sock_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) return win32_sock_connectex(oper, (struct sockaddr*)&saddr, sizeof(saddr)); } - int win32_sock_accept(evoper_t* accept_oper, wsasock* sk) { int rc = S_ERROR; @@ -144,13 +142,7 @@ int win32_sock_accept(evoper_t* accept_oper, wsasock* sk) rc = oper_overlapped_memset(accept_oper); rc_error(rc != S_ERROR, S_ERROR); - ret = base->fns.AcceptEx(accept_oper->sock, - oper->sock, - obj->addr, - 0, - ACCEPT_ADDRESS_LENGTH, - ACCEPT_ADDRESS_LENGTH, - &len, &obj->overlapped); + ret = base->fns.AcceptEx(accept_oper->sock, oper->sock, obj->addr, 0, ACCEPT_ADDRESS_LENGTH, ACCEPT_ADDRESS_LENGTH, &len, &obj->overlapped); crterr err = crt_geterror(); @@ -179,7 +171,7 @@ static int wsa_sock_recv(evoper_t* oper, int* ret, sock_size* bytes) buf_ptr ptr = NULL; buf_len len = 0; - + rc = evbuf_get_buf(&oper->rbuf, &ptr); rc_error(rc != S_ERROR, S_ERROR); @@ -190,10 +182,10 @@ static int wsa_sock_recv(evoper_t* oper, int* ret, sock_size* bytes) wsabuf.len = len & 0xFFFFFFFF; /* - * if a socket was bound with I/O completion port - * then GetQueuedCompletionStatus() would anyway return its status - * despite that WSARecv() was already complete - */ + * if a socket was bound with I/O completion port + * then GetQueuedCompletionStatus() would anyway return its status + * despite that WSARecv() was already complete + */ ov->r = ev_on; *ret = WSARecv(oper->sock, &wsabuf, 1, &bytes_transferred, &flags, &ov->overlapped, NULL); *bytes = bytes_transferred; @@ -209,13 +201,13 @@ static int wsa_sock_send(evoper_t* oper, int* ret, sock_size* bytes) rc_error(oper != NULL, S_ERROR); lpevoper_ov ov = (lpevoper_ov)evoper_private(oper); rc_error(ov != NULL, S_ERROR); - + rc = oper_overlapped_memset(oper); rc_error(rc != S_ERROR, S_ERROR); buf_ptr ptr = NULL; buf_len len = 0; - + rc = evbuf_get_buf(&oper->wbuf, &ptr); rc_error(rc != S_ERROR, S_ERROR); @@ -226,10 +218,10 @@ static int wsa_sock_send(evoper_t* oper, int* ret, sock_size* bytes) wsabuf.len = len & 0xFFFFFFFF; /* - * if a socket was bound with I/O completion port then - * GetQueuedCompletionStatus() would anyway return its status - * despite that WSASend() was already complete - */ + * if a socket was bound with I/O completion port then + * GetQueuedCompletionStatus() would anyway return its status + * despite that WSASend() was already complete + */ ov->w = ev_on; *ret = WSASend(oper->sock, &wsabuf, 1, &bytes_transferred, flags, &ov->overlapped, NULL); *bytes = bytes_transferred; @@ -246,8 +238,7 @@ int win32_sock_read_op(evoper_t* oper) rc = wsa_sock_recv(oper, &ret, &byte); err = crt_geterror(); - if (ret == SOCKET_ERROR) { - + if (ret == SOCKET_ERROR) { if (err == ERROR_NETNAME_DELETED) { rc = S_ERROR; goto end; @@ -255,10 +246,8 @@ int win32_sock_read_op(evoper_t* oper) rc = S_ERROR; goto end; } - } - if (ret == 0) { evbuf_op_off(&oper->rbuf, byte); if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { @@ -271,7 +260,7 @@ int win32_sock_read_op(evoper_t* oper) rc = S_PENDING; goto end; } - + if (byte == 0) { evoper_eof_op(oper, ev_on); rc = S_ERROR; @@ -290,15 +279,13 @@ int win32_sock_write_op(evoper_t* oper) sock_size byte = 0; crterr err = 0; rc_error(oper != NULL, S_ERROR); - + rc = wsa_sock_send(oper, &ret, &byte); - - if (ret == SOCKET_ERROR) { + if (ret == SOCKET_ERROR) { err = crt_geterror(); if (err == WSAEWOULDBLOCK) { - } else if (err == WSAECONNABORTED || err == WSAECONNRESET) { // Connection aborted or reset, close and reconnect rc = S_ERROR; @@ -317,7 +304,6 @@ int win32_sock_write_op(evoper_t* oper) } if (ret == 0) { - if (err == WSA_IO_PENDING) { rc = S_PENDING; goto end; @@ -334,7 +320,7 @@ int win32_sock_write_op(evoper_t* oper) rc = S_PENDING; goto end; } - + return S_ERROR; end: return rc; diff --git a/stdcrt/io/compat_file.c b/stdcrt/io/compat_file.c index 6c62ac12..c618137e 100644 --- a/stdcrt/io/compat_file.c +++ b/stdcrt/io/compat_file.c @@ -341,7 +341,6 @@ int _file_unlink(const char* filepath) return unlink(filepath) == 0 ? S_SUCCESS : S_ERROR; } - #elif (TARGET_OS == OS_UNIX) _fd_t _file_snamepipe(const char* name, long rsize, long wsize, int timeout, int flags, int mode) diff --git a/stdcrt/io/compat_path.c b/stdcrt/io/compat_path.c index b4b28a80..15b85a0e 100644 --- a/stdcrt/io/compat_path.c +++ b/stdcrt/io/compat_path.c @@ -389,8 +389,6 @@ int get_file_info(basic_tchar* name, get_file_cb entry, void* ctx) return S_SUCCESS; } - - #elif (TARGET_OS == OS_UNIX) #include @@ -442,7 +440,6 @@ int get_file_info(basic_tchar* name, get_file_cb entry, void* ctx) return S_SUCCESS; } - #endif int get_files(basic_tchar* path, get_file_cb entry, void* ctx) diff --git a/stdcrt/net/compat_sock.c b/stdcrt/net/compat_sock.c index 04cbd51b..d677de9c 100644 --- a/stdcrt/net/compat_sock.c +++ b/stdcrt/net/compat_sock.c @@ -34,7 +34,7 @@ int _bind_stcpsockv4(_sock_t s, const char* name, size_t len, int scount, unsign else _inet_pton(AF_INET, name, (char*)&saddr.sin_addr); - //saddr.sin_addr.s_addr = inet_addr(name); + // saddr.sin_addr.s_addr = inet_addr(name); saddr.sin_port = htons(port); diff --git a/stdcrt/net/compat_sockinet.c b/stdcrt/net/compat_sockinet.c index e773f217..2a5b16dc 100644 --- a/stdcrt/net/compat_sockinet.c +++ b/stdcrt/net/compat_sockinet.c @@ -380,7 +380,6 @@ int _inet_pton(int af, const char* src, void* dst) return -1; } - char* inet_ntop4(const unsigned char* src, char* dst, size_t size) { int alen = s_strlen("255.255.255.255"); diff --git a/stdcrt/stdlib/compat_atomic.c b/stdcrt/stdlib/compat_atomic.c index 6728a199..d2d4a74d 100644 --- a/stdcrt/stdlib/compat_atomic.c +++ b/stdcrt/stdlib/compat_atomic.c @@ -165,24 +165,24 @@ atomic_type _atomic_set(atomic_type set, _atomic_t* self) _InterlockedCompareExchange(&self->value, set, value); #elif (TARGET_OS == OS_POSIX) - #if defined(__GNUC__) && (__GNUC__ >= 4) - __sync_bool_compare_and_swap(&self->value, value, set); - #else - _mutex_lock(&self->lock); - self->value = set; - _mutex_unlock(&self->lock); - #endif +#if defined(__GNUC__) && (__GNUC__ >= 4) + __sync_bool_compare_and_swap(&self->value, value, set); +#else + _mutex_lock(&self->lock); + self->value = set; + _mutex_unlock(&self->lock); +#endif #elif (TARGET_OS == OS_MACH) OSAtomicCompareAndSwap32Barrier(value, set, &self->value); #elif (TARGET_OS == OS_UNIX) - #if defined(__GNUC__) && (__GNUC__ >= 4) - __sync_bool_compare_and_swap(&self->value, value, set); - #else - _mutex_lock(&self->lock); - self->value = set; - _mutex_unlock(&self->lock); - #endif +#if defined(__GNUC__) && (__GNUC__ >= 4) + __sync_bool_compare_and_swap(&self->value, value, set); +#else + _mutex_lock(&self->lock); + self->value = set; + _mutex_unlock(&self->lock); +#endif #endif @@ -203,16 +203,16 @@ int _atomic_cmp(atomic_type comp, _atomic_t* self) return (original == comp); #elif (TARGET_OS == OS_POSIX) atomic_type original = 0; - #if defined(__GNUC__) && (__GNUC__ >= 4) - value = self->value; - return __sync_bool_compare_and_swap(&self->value, comp, value); - #else - _mutex_lock(&self->lock); - original = self->value; - _mutex_unlock(&self->lock); - - return comp == original; - #endif +#if defined(__GNUC__) && (__GNUC__ >= 4) + value = self->value; + return __sync_bool_compare_and_swap(&self->value, comp, value); +#else + _mutex_lock(&self->lock); + original = self->value; + _mutex_unlock(&self->lock); + + return comp == original; +#endif #elif (TARGET_OS == OS_MACH) _mutex_lock(&self->lock); @@ -221,21 +221,18 @@ int _atomic_cmp(atomic_type comp, _atomic_t* self) return OSAtomicCompareAndSwap32Barrier(comp, value, &self->value); - - #elif (TARGET_OS == OS_UNIX) atomic_type original = 0; - #if defined(__GNUC__) && (__GNUC__ >= 4) - value = self->value; - return __sync_bool_compare_and_swap(&self->value, comp, value); - #else - _mutex_lock(&self->lock); - original = self->value; - _mutex_unlock(&self->lock); - - return comp == original; - #endif -#endif - +#if defined(__GNUC__) && (__GNUC__ >= 4) + value = self->value; + return __sync_bool_compare_and_swap(&self->value, comp, value); +#else + _mutex_lock(&self->lock); + original = self->value; + _mutex_unlock(&self->lock); + + return comp == original; +#endif +#endif } diff --git a/stdcrt/stdlib/compat_clock.c b/stdcrt/stdlib/compat_clock.c index da36501d..fcfbd179 100644 --- a/stdcrt/stdlib/compat_clock.c +++ b/stdcrt/stdlib/compat_clock.c @@ -144,7 +144,7 @@ int clock_outputlog(_clock_t* clock) { rc_error(clock != NULL, S_ERROR); - //logi("evclock_outputlog==>sec:%ld,usec:%ld", clock->monotonic_clock.tv_sec, clock->monotonic_clock.tv_usec); + // logi("evclock_outputlog==>sec:%ld,usec:%ld", clock->monotonic_clock.tv_sec, clock->monotonic_clock.tv_usec); return S_SUCCESS; } diff --git a/stdcrt/stdlib/compat_htable.c b/stdcrt/stdlib/compat_htable.c index 9cbfc0fd..76a0dadb 100644 --- a/stdcrt/stdlib/compat_htable.c +++ b/stdcrt/stdlib/compat_htable.c @@ -1,497 +1,491 @@ #include -static void *htable_iter_head(ITER *iter, _htable_t *table) +static void* htable_iter_head(ITER* iter, _htable_t* table) { - _htable_info_t* ptr = NULL; - iter->dlen = -1; - iter->klen = -1; - iter->i = 0; - iter->size = table->size; - iter->ptr = NULL; - - for (; iter->i < iter->size; iter->i++) { - if (table->data[iter->i] != NULL) { - iter->ptr = ptr = table->data[iter->i]; - break; - } - } - - if (ptr) { - iter->data = ptr->value; - iter->key = ptr->key; - } else { - iter->data = NULL; - iter->key = NULL; - } - return (iter->ptr); + _htable_info_t* ptr = NULL; + iter->dlen = -1; + iter->klen = -1; + iter->i = 0; + iter->size = table->size; + iter->ptr = NULL; + + for (; iter->i < iter->size; iter->i++) { + if (table->data[iter->i] != NULL) { + iter->ptr = ptr = table->data[iter->i]; + break; + } + } + + if (ptr) { + iter->data = ptr->value; + iter->key = ptr->key; + } else { + iter->data = NULL; + iter->key = NULL; + } + return (iter->ptr); } /* htable_iter_next */ -static void *htable_iter_next(ITER *iter, _htable_t *table) +static void* htable_iter_next(ITER* iter, _htable_t* table) { - _htable_info_t *ptr; - - ptr = (_htable_info_t*)iter->ptr; - if (ptr) { - iter->ptr = ptr = ptr->next; - if (ptr != NULL) { - iter->data = ptr->value; - iter->key = ptr->key; - return (iter->ptr); - } - } - - for (iter->i++; iter->i < iter->size; iter->i++) { - if (table->data[iter->i] != NULL) { - iter->ptr = ptr = table->data[iter->i]; - break; - } - } - - if (ptr) { - iter->data = ptr->value; - iter->key = ptr->key; - } else { - iter->data = NULL; - iter->key = NULL; - } - return (iter->ptr); + _htable_info_t* ptr; + + ptr = (_htable_info_t*)iter->ptr; + if (ptr) { + iter->ptr = ptr = ptr->next; + if (ptr != NULL) { + iter->data = ptr->value; + iter->key = ptr->key; + return (iter->ptr); + } + } + + for (iter->i++; iter->i < iter->size; iter->i++) { + if (table->data[iter->i] != NULL) { + iter->ptr = ptr = table->data[iter->i]; + break; + } + } + + if (ptr) { + iter->data = ptr->value; + iter->key = ptr->key; + } else { + iter->data = NULL; + iter->key = NULL; + } + return (iter->ptr); } /* htable_iter_tail */ -static void *htable_iter_tail(ITER *iter, _htable_t *table) +static void* htable_iter_tail(ITER* iter, _htable_t* table) { - _htable_info_t* ptr = NULL; - - iter->dlen = -1; - iter->klen = -1; - iter->i = table->size - 1; - iter->size = table->size; - iter->ptr = NULL; - - for (; iter->i >= 0; iter->i--) { - if (table->data[iter->i] != NULL) { - iter->ptr = ptr = table->data[iter->i]; - break; - } - } - - if (ptr) { - iter->data = ptr->value; - iter->key = ptr->key; - } else { - iter->data = NULL; - iter->key = NULL; - } - return (iter->ptr); + _htable_info_t* ptr = NULL; + + iter->dlen = -1; + iter->klen = -1; + iter->i = table->size - 1; + iter->size = table->size; + iter->ptr = NULL; + + for (; iter->i >= 0; iter->i--) { + if (table->data[iter->i] != NULL) { + iter->ptr = ptr = table->data[iter->i]; + break; + } + } + + if (ptr) { + iter->data = ptr->value; + iter->key = ptr->key; + } else { + iter->data = NULL; + iter->key = NULL; + } + return (iter->ptr); } /* htable_iter_prev */ -static void *htable_iter_prev(ITER *iter, _htable_t *table) +static void* htable_iter_prev(ITER* iter, _htable_t* table) { - _htable_info_t* ptr; - - ptr = (_htable_info_t*)iter->ptr; - if (ptr) { - iter->ptr = ptr = ptr->next; - if (ptr != NULL) { - iter->data = ptr->value; - iter->key = ptr->key; - return (iter->ptr); - } - } - - for (iter->i--; iter->i >= 0; iter->i--) { - if (table->data[iter->i] != NULL) { - iter->ptr = ptr = table->data[iter->i]; - break; - } - } - - if (ptr) { - iter->data = ptr->value; - iter->key = ptr->key; - } else { - iter->data = NULL; - iter->key = NULL; - } - return (iter->ptr); + _htable_info_t* ptr; + + ptr = (_htable_info_t*)iter->ptr; + if (ptr) { + iter->ptr = ptr = ptr->next; + if (ptr != NULL) { + iter->data = ptr->value; + iter->key = ptr->key; + return (iter->ptr); + } + } + + for (iter->i--; iter->i >= 0; iter->i--) { + if (table->data[iter->i] != NULL) { + iter->ptr = ptr = table->data[iter->i]; + break; + } + } + + if (ptr) { + iter->data = ptr->value; + iter->key = ptr->key; + } else { + iter->data = NULL; + iter->key = NULL; + } + return (iter->ptr); } - -static _htable_info_t* htable_iter_info(ITER *iter, _htable_t *table) +static _htable_info_t* htable_iter_info(ITER* iter, _htable_t* table) { - (void) table; - return (iter->ptr ? (_htable_info_t*) iter->ptr : NULL); + (void)table; + return (iter->ptr ? (_htable_info_t*)iter->ptr : NULL); } -static unsigned __def_hash_fn(const void *buffer, size_t len) +static unsigned __def_hash_fn(const void* buffer, size_t len) { - unsigned long h = 0; - unsigned long g; - const unsigned char* s = (const unsigned char *) buffer; - - while (len-- > 0) { - h = (h << 4) + *s++; - if ((g = (h & 0xf0000000)) != 0) { - h ^= (g >> 24); - h ^= g; - } - } - - return (unsigned) h; + unsigned long h = 0; + unsigned long g; + const unsigned char* s = (const unsigned char*)buffer; + + while (len-- > 0) { + h = (h << 4) + *s++; + if ((g = (h & 0xf0000000)) != 0) { + h ^= (g >> 24); + h ^= g; + } + } + + return (unsigned)h; } /* htable_link - insert element into table */ -#define htable_link(_table, _element, _n) { \ - _htable_info_t** _h = _table->data + _n; \ - _element->prev = 0; \ - if ((_element->next = *_h) != 0) \ - (*_h)->prev = _element; \ - *_h = _element; \ - _table->used++; \ -} +#define htable_link(_table, _element, _n) \ + { \ + _htable_info_t** _h = _table->data + _n; \ + _element->prev = 0; \ + if ((_element->next = *_h) != 0) \ + (*_h)->prev = _element; \ + *_h = _element; \ + _table->used++; \ + } static int __htable_size(_htable_t* table, unsigned size) { - _htable_info_t **h; + _htable_info_t** h; - size |= 1; + size |= 1; - table->data = h = (_htable_info_t **) heap_malloc(size * sizeof(_htable_info_t *)); - if(table->data == NULL) { - return -1; - } + table->data = h = (_htable_info_t**)heap_malloc(size * sizeof(_htable_info_t*)); + if (table->data == NULL) { + return -1; + } - table->size = size; - table->used = 0; + table->size = size; + table->used = 0; - while (size-- > 0) { - *h++ = 0; - } + while (size-- > 0) { + *h++ = 0; + } - return 0; + return 0; } -static int htable_grow(_htable_t *table) +static int htable_grow(_htable_t* table) { - int ret; - _htable_info_t* ht; - _htable_info_t* next; - unsigned old_size = table->size; - _htable_info_t** h0 = table->data; - _htable_info_t** old_entries = h0; - unsigned n; - - ret = __htable_size(table, 2 * old_size); - if (ret < 0) { - return -1; - } - - while (old_size-- > 0) { - for (ht = *h0++; ht; ht = next) { - next = ht->next; - n = __def_hash_fn(ht->key, strlen(ht->key)) % table->size; - htable_link(table, ht, n); - } - } - - heap_free(old_entries); - return 0; + int ret; + _htable_info_t* ht; + _htable_info_t* next; + unsigned old_size = table->size; + _htable_info_t** h0 = table->data; + _htable_info_t** old_entries = h0; + unsigned n; + + ret = __htable_size(table, 2 * old_size); + if (ret < 0) { + return -1; + } + + while (old_size-- > 0) { + for (ht = *h0++; ht; ht = next) { + next = ht->next; + n = __def_hash_fn(ht->key, strlen(ht->key)) % table->size; + htable_link(table, ht, n); + } + } + + heap_free(old_entries); + return 0; } _htable_t* htable_create(int size) { - _htable_t* table; - int ret; - - table = (_htable_t *) heap_calloc(1, sizeof(_htable_t)); - if (table == NULL) { - return NULL; - } - - table->init_size = size; - ret = __htable_size(table, size < 13 ? 13 : size); - if(ret < 0) { - heap_free(table); - return NULL; - } - - table->iter_head = htable_iter_head; - table->iter_next = htable_iter_next; - table->iter_tail = htable_iter_tail; - table->iter_prev = htable_iter_prev; - table->iter_info = htable_iter_info; - - return table; + _htable_t* table; + int ret; + + table = (_htable_t*)heap_calloc(1, sizeof(_htable_t)); + if (table == NULL) { + return NULL; + } + + table->init_size = size; + ret = __htable_size(table, size < 13 ? 13 : size); + if (ret < 0) { + heap_free(table); + return NULL; + } + + table->iter_head = htable_iter_head; + table->iter_next = htable_iter_next; + table->iter_tail = htable_iter_tail; + table->iter_prev = htable_iter_prev; + table->iter_info = htable_iter_info; + + return table; } -int htable_errno(_htable_t *table) +int htable_errno(_htable_t* table) { - if (table == NULL) { - return HTABLE_STAT_INVAL; - } - return table->status; + if (table == NULL) { + return HTABLE_STAT_INVAL; + } + return table->status; } -void htable_set_errno(_htable_t *table, int error) +void htable_set_errno(_htable_t* table, int error) { - if (table) { - table->status = error; - } + if (table) { + table->status = error; + } } -#define STREQ(x,y) (x == y || (x[0] == y[0] && strcmp(x,y) == 0)) +#define STREQ(x, y) (x == y || (x[0] == y[0] && strcmp(x, y) == 0)) _htable_info_t* htable_enter(_htable_t* table, const char* key, void* value) { - _htable_info_t* ht; - int ret; - unsigned hash, n; - - table->status = HTABLE_STAT_OK; - hash = __def_hash_fn(key, strlen(key)); - - if (table->used >= table->size) { - ret = htable_grow(table); - if(ret < 0) { - return NULL; - } - } - - n = hash % table->size; - - for (ht = table->data[n]; ht; ht = ht->next) { - if (STREQ(key, ht->key)) { - table->status = HTABLE_STAT_DUPLEX_KEY; - return ht; - } - } - - ht = (_htable_info_t*)heap_malloc(sizeof(_htable_info_t)); - if (ht == NULL) { - return NULL; - } + _htable_info_t* ht; + int ret; + unsigned hash, n; + + table->status = HTABLE_STAT_OK; + hash = __def_hash_fn(key, strlen(key)); + + if (table->used >= table->size) { + ret = htable_grow(table); + if (ret < 0) { + return NULL; + } + } + + n = hash % table->size; + + for (ht = table->data[n]; ht; ht = ht->next) { + if (STREQ(key, ht->key)) { + table->status = HTABLE_STAT_DUPLEX_KEY; + return ht; + } + } + + ht = (_htable_info_t*)heap_malloc(sizeof(_htable_info_t)); + if (ht == NULL) { + return NULL; + } #if defined(_WIN32) || defined(_WIN64) - ht->key = _strdup(key); + ht->key = _strdup(key); #else - ht->key = strdup(key); + ht->key = strdup(key); #endif - - - if (ht->key == NULL) { - heap_free(ht); - return NULL; - } - ht->hash = hash; - ht->value = value; - htable_link(table, ht, n); - - return ht; -} + if (ht->key == NULL) { + heap_free(ht); + return NULL; + } + ht->hash = hash; + ht->value = value; + htable_link(table, ht, n); + + return ht; +} -void* htable_find(_htable_t* table, const char *key) +void* htable_find(_htable_t* table, const char* key) { - _htable_info_t* ht = htable_locate(table, key); + _htable_info_t* ht = htable_locate(table, key); - return ht != NULL ? ht->value : NULL; + return ht != NULL ? ht->value : NULL; } -_htable_info_t* htable_locate(_htable_t *table, const char *key) +_htable_info_t* htable_locate(_htable_t* table, const char* key) { - _htable_info_t* ht; - unsigned n; + _htable_info_t* ht; + unsigned n; - n = __def_hash_fn(key, strlen(key)); - n = n % table->size; + n = __def_hash_fn(key, strlen(key)); + n = n % table->size; - for (ht = table->data[n]; ht; ht = ht->next) { - if (STREQ(key, ht->key)) { - return ht; - } - } + for (ht = table->data[n]; ht; ht = ht->next) { + if (STREQ(key, ht->key)) { + return ht; + } + } - return NULL; + return NULL; } -void htable_delete_entry(_htable_t *table, _htable_info_t *ht, - void (*free_fn) (void *)) +void htable_delete_entry(_htable_t* table, _htable_info_t* ht, void (*free_fn)(void*)) { - unsigned n = ht->hash % table->size; - _htable_info_t** h = table->data + n; - - if (ht->next) - ht->next->prev = ht->prev; - if (ht->prev) - ht->prev->next = ht->next; - else - *h = ht->next; - - heap_free(ht->key); - if (free_fn && ht->value) - (*free_fn) (ht->value); - heap_free(ht); - table->used--; + unsigned n = ht->hash % table->size; + _htable_info_t** h = table->data + n; + + if (ht->next) + ht->next->prev = ht->prev; + if (ht->prev) + ht->prev->next = ht->next; + else + *h = ht->next; + + heap_free(ht->key); + if (free_fn && ht->value) + (*free_fn)(ht->value); + heap_free(ht); + table->used--; } -int htable_delete(_htable_t* table, const char* key, void (*free_fn) (void *)) +int htable_delete(_htable_t* table, const char* key, void (*free_fn)(void*)) { - _htable_info_t* ht; - unsigned n; - _htable_info_t** h; - - n = __def_hash_fn(key, strlen(key)); - n = n % table->size; - - h = table->data + n; - for (ht = *h; ht; ht = ht->next) { - if (STREQ(key, ht->key)) { - htable_delete_entry(table, ht, free_fn); - return 0; - } - } - return -1; + _htable_info_t* ht; + unsigned n; + _htable_info_t** h; + + n = __def_hash_fn(key, strlen(key)); + n = n % table->size; + + h = table->data + n; + for (ht = *h; ht; ht = ht->next) { + if (STREQ(key, ht->key)) { + htable_delete_entry(table, ht, free_fn); + return 0; + } + } + return -1; } -void htable_free(_htable_t* table, void (*free_fn) (void *)) +void htable_free(_htable_t* table, void (*free_fn)(void*)) { - unsigned i = table->size; - _htable_info_t* ht; - _htable_info_t* next; - _htable_info_t** h = table->data; - - while (i-- > 0) { - for (ht = *h++; ht; ht = next) { - next = ht->next; - heap_free(ht->key); - if (free_fn && ht->value) - (*free_fn) (ht->value); - heap_free(ht); - } - } - - heap_free(table->data); - table->data = 0; - heap_free(table); + unsigned i = table->size; + _htable_info_t* ht; + _htable_info_t* next; + _htable_info_t** h = table->data; + + while (i-- > 0) { + for (ht = *h++; ht; ht = next) { + next = ht->next; + heap_free(ht->key); + if (free_fn && ht->value) + (*free_fn)(ht->value); + heap_free(ht); + } + } + + heap_free(table->data); + table->data = 0; + heap_free(table); } -int htable_reset(_htable_t* table, void (*free_fn) (void *)) +int htable_reset(_htable_t* table, void (*free_fn)(void*)) { - unsigned i = table->size; - _htable_info_t* ht; - _htable_info_t* next; - _htable_info_t** h; - int ret; - - h = table->data; - - while (i-- > 0) { - for (ht = *h++; ht; ht = next) { - next = ht->next; - heap_free(ht->key); - if (free_fn && ht->value) { - (*free_fn) (ht->value); - } - heap_free(ht); - } - } - heap_free(table->data); - ret = __htable_size(table, table->init_size < 13 ? 13 : table->init_size); - return ret; + unsigned i = table->size; + _htable_info_t* ht; + _htable_info_t* next; + _htable_info_t** h; + int ret; + + h = table->data; + + while (i-- > 0) { + for (ht = *h++; ht; ht = next) { + next = ht->next; + heap_free(ht->key); + if (free_fn && ht->value) { + (*free_fn)(ht->value); + } + heap_free(ht); + } + } + heap_free(table->data); + ret = __htable_size(table, table->init_size < 13 ? 13 : table->init_size); + return ret; } /* htable_walk - iterate over hash table */ -void htable_walk(_htable_t* table, void (*action)(_htable_info_t *, void *), void *arg) +void htable_walk(_htable_t* table, void (*action)(_htable_info_t*, void*), void* arg) { - unsigned i = table->size; - _htable_info_t** h = table->data; - _htable_info_t* ht; - - while (i-- > 0) { - for (ht = *h++; ht; ht = ht->next) { - (*action) (ht, arg); - } - } + unsigned i = table->size; + _htable_info_t** h = table->data; + _htable_info_t* ht; + + while (i-- > 0) { + for (ht = *h++; ht; ht = ht->next) { + (*action)(ht, arg); + } + } } -int htable_size(const _htable_t *table) +int htable_size(const _htable_t* table) { - if (table) { - return table->size; - } else { - return 0; - } + if (table) { + return table->size; + } else { + return 0; + } } -int htable_used(const _htable_t *table) +int htable_used(const _htable_t* table) { - if (table) { - return table->used; - } else { - return (0); - } + if (table) { + return table->used; + } else { + return (0); + } } /* HTABLE_INFO **htable_data(HTABLE *table) { - return (HTABLE_INFO**) table->data; + return (HTABLE_INFO**) table->data; } */ /* htable_list - list all table members */ -_htable_info_t** htable_list(const _htable_t *table) +_htable_info_t** htable_list(const _htable_t* table) { - _htable_info_t** list; - _htable_info_t* member; - int count = 0; - int i; - - if (table != 0) { - list = (_htable_info_t**)heap_malloc(sizeof(*list) * (table->used + 1)); - for (i = 0; i < table->size; i++) { - for (member = table->data[i]; member != 0; - member = member->next) { - list[count++] = member; - } - } - } else { - list = (_htable_info_t**)heap_malloc(sizeof(*list)); - } - list[count] = 0; - return list; + _htable_info_t** list; + _htable_info_t* member; + int count = 0; + int i; + + if (table != 0) { + list = (_htable_info_t**)heap_malloc(sizeof(*list) * (table->used + 1)); + for (i = 0; i < table->size; i++) { + for (member = table->data[i]; member != 0; member = member->next) { + list[count++] = member; + } + } + } else { + list = (_htable_info_t**)heap_malloc(sizeof(*list)); + } + list[count] = 0; + return list; } -void htable_stat(const _htable_t *table) +void htable_stat(const _htable_t* table) { - _htable_info_t* member; - int i, count; - - for(i = 0; i < table->size; i++) { - count = 0; - member = table->data[i]; - for(; member != 0; member = member->next) { - count++; - } - if(count > 0) { - - } - } - - for(i = 0; i < table->size; i++) { - member = table->data[i]; - if(member) { - logi("chains[%d]: ", i); - for(; member != 0; member = member->next) - logi("[%s]", member->key); - } - } - logi("hash table size=%d, used=%d\n", table->size, table->used); + _htable_info_t* member; + int i, count; + + for (i = 0; i < table->size; i++) { + count = 0; + member = table->data[i]; + for (; member != 0; member = member->next) { + count++; + } + if (count > 0) { } + } + + for (i = 0; i < table->size; i++) { + member = table->data[i]; + if (member) { + logi("chains[%d]: ", i); + for (; member != 0; member = member->next) + logi("[%s]", member->key); + } + } + logi("hash table size=%d, used=%d\n", table->size, table->used); } diff --git a/stdcrt/stdlib/compat_stdtime.c b/stdcrt/stdlib/compat_stdtime.c index c1c1673f..b85f5959 100644 --- a/stdcrt/stdlib/compat_stdtime.c +++ b/stdcrt/stdlib/compat_stdtime.c @@ -127,7 +127,6 @@ uint64_t _getclock_ms(void) #elif (TARGET_OS == OS_POSIX) - struct timespec tv; #ifdef CLOCK_MONOTONIC_FAST diff --git a/stdcrt/stdlib/compat_str.c b/stdcrt/stdlib/compat_str.c index 554f1d60..414cc55a 100644 --- a/stdcrt/stdlib/compat_str.c +++ b/stdcrt/stdlib/compat_str.c @@ -300,13 +300,11 @@ size_t s_strlen(const char* str) if (*char_ptr == '\0') return char_ptr - str; - longword_ptr = (unsigned long int*)char_ptr; - himagic = 0x80808080L; lomagic = 0x01010101L; - + if (sizeof(longword) > 4) { himagic = ((himagic << 16) << 16) | himagic; lomagic = ((lomagic << 16) << 16) | lomagic; @@ -317,7 +315,6 @@ size_t s_strlen(const char* str) longword = *longword_ptr++; if (((longword - lomagic) & ~longword & himagic) != 0) { - const char* cp = (const char*)(longword_ptr - 1); if (cp[0] == 0) diff --git a/stdcrt/thread/compat_cond.c b/stdcrt/thread/compat_cond.c index e3f296f9..ef847600 100644 --- a/stdcrt/thread/compat_cond.c +++ b/stdcrt/thread/compat_cond.c @@ -158,9 +158,7 @@ int _cond_destroy(_cond_t* cond) pthread_condattr_destroy(&(cond->attr)); } - if (pthread_mutex_destroy(&cond->mutex)) { - - } + if (pthread_mutex_destroy(&cond->mutex)) { } if (pthread_cond_destroy(&cond->c)) { return S_ERROR; @@ -258,9 +256,7 @@ int _cond_destroy(_cond_t* cond) { rc_error(cond != NULL, S_ERROR); - if (pthread_mutex_destroy(&cond->mutex)) { - - } + if (pthread_mutex_destroy(&cond->mutex)) { } if (pthread_cond_destroy(&cond->c)) { return S_ERROR; @@ -283,7 +279,6 @@ int _cond_broadcast(_cond_t* cond) { rc_error(cond != NULL, S_ERROR); if (pthread_cond_broadcast(&cond->c)) { - return S_ERROR; } @@ -450,5 +445,4 @@ int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) return S_SUCCESS; } - #endif diff --git a/stdcrt/thread/compat_msgq.c b/stdcrt/thread/compat_msgq.c index 66a457f7..4a7c37b0 100644 --- a/stdcrt/thread/compat_msgq.c +++ b/stdcrt/thread/compat_msgq.c @@ -15,14 +15,13 @@ int _msgq_destroy(_msgq_t* msgq) int _msgq_produce(_msgq_t* msgq, _msg_q* queue) { rc_error(msgq != NULL, S_ERROR); - _queue_insert_tail(&msgq->queue, queue); + _queue_insert_tail(&msgq->queue, queue); return S_SUCCESS; } int _msgq_consume(_msgq_t* msgq, _msg_q* queue) { rc_error(msgq != NULL, S_ERROR); - _msg_q* q = _queue_head(&msgq->queue); + _msg_q* q = _queue_head(&msgq->queue); _queue_split(&msgq->queue, q, queue); return S_SUCCESS; } - diff --git a/stdcrt/thread/compat_mutex.c b/stdcrt/thread/compat_mutex.c index d8348ad9..654b02ae 100644 --- a/stdcrt/thread/compat_mutex.c +++ b/stdcrt/thread/compat_mutex.c @@ -67,7 +67,7 @@ int _mutex_init_recursive(_mutex_t* lock) return S_ERROR; } - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) { + if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) { return S_ERROR; } @@ -177,7 +177,7 @@ int _mutex_lock(_mutex_t* lock) int _mutex_trylock(_mutex_t* lock) { rc_error(lock != NULL, S_ERROR); - if (pthread_mutex_trylock(&lock->mutex)) { + if (pthread_mutex_trylock(&lock->mutex)) { return S_ERROR; } diff --git a/stdcrt/thread/compat_rwlock.c b/stdcrt/thread/compat_rwlock.c index e8ae0d53..3cb43195 100644 --- a/stdcrt/thread/compat_rwlock.c +++ b/stdcrt/thread/compat_rwlock.c @@ -378,5 +378,4 @@ int _rwlock_wrunlock(_rwlock_t* lock) return S_SUCCESS; } - #endif diff --git a/stdcrt/thread/compat_sem.c b/stdcrt/thread/compat_sem.c index eee50c91..7c9a0464 100644 --- a/stdcrt/thread/compat_sem.c +++ b/stdcrt/thread/compat_sem.c @@ -166,23 +166,22 @@ int _sem_wait_time(_sem_t* sem, unsigned int sec) #ifdef HAVE_SYS_SEM_WAITTIME - struct timespec expire = {0, 0}; - rc_error(sem != NULL, S_ERROR); - #if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) - - expire.tv_sec = sec; - r = sem_timedwait(sem, &expire); + struct timespec expire = {0, 0}; + rc_error(sem != NULL, S_ERROR); +#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) - if (r == 0) { - } else if (r == -1 && errno == EINTR) { - return S_ERROR; - } - return S_SUCCESS; - #else + expire.tv_sec = sec; + r = sem_timedwait(sem, &expire); - #endif + if (r == 0) { + } else if (r == -1 && errno == EINTR) { + return S_ERROR; + } + return S_SUCCESS; #else +#endif +#else #endif // HAVE_SYS_SEM_WAITTIME @@ -197,7 +196,7 @@ int _sem_init(_sem_t* sem, unsigned int value) rc_error(sem != NULL, S_ERROR); err = semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, value); - rc_error(err == KERN_SUCCESS, S_ERROR); + rc_error(err == KERN_SUCCESS, S_ERROR); return S_SUCCESS; } @@ -206,8 +205,8 @@ int _sem_destroy(_sem_t* sem) kern_return_t err; rc_error(sem != NULL, S_ERROR); err = semaphore_destroy(mach_task_self(), *sem); - rc_error(err == KERN_SUCCESS, S_ERROR); - return S_SUCCESS; + rc_error(err == KERN_SUCCESS, S_ERROR); + return S_SUCCESS; } int _sem_post(_sem_t* sem) @@ -215,8 +214,8 @@ int _sem_post(_sem_t* sem) kern_return_t err; rc_error(sem != NULL, S_ERROR); err = semaphore_signal(*sem); - rc_error(err == KERN_SUCCESS, S_ERROR); - return S_SUCCESS; + rc_error(err == KERN_SUCCESS, S_ERROR); + return S_SUCCESS; } int _sem_wait(_sem_t* sem) @@ -224,8 +223,8 @@ int _sem_wait(_sem_t* sem) kern_return_t err; rc_error(sem != NULL, S_ERROR); err = semaphore_wait(*sem); - rc_error(err == KERN_SUCCESS, S_ERROR); - return S_SUCCESS; + rc_error(err == KERN_SUCCESS, S_ERROR); + return S_SUCCESS; } int _sem_trywait(_sem_t* sem) @@ -236,8 +235,8 @@ int _sem_trywait(_sem_t* sem) interval.tv_sec = 0; interval.tv_nsec = 0; err = semaphore_timedwait(*sem, interval); - rc_error(err == KERN_SUCCESS, S_ERROR); - return S_SUCCESS; + rc_error(err == KERN_SUCCESS, S_ERROR); + return S_SUCCESS; } int _sem_wait_time(_sem_t* sem, unsigned int sec) diff --git a/stdcrt/thread/compat_thread.c b/stdcrt/thread/compat_thread.c index 9866db82..785ef9d8 100644 --- a/stdcrt/thread/compat_thread.c +++ b/stdcrt/thread/compat_thread.c @@ -265,5 +265,4 @@ _thread_id _get_threadid(_thread_t* tid) return (uint64_t)(uintptr_t)pthread_self(); } - #endif diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index 6f81ae7e..eb692fea 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -10,11 +10,10 @@ int main(int argc, char* argv[]) init_sockenv(2, 2); int rc = 0; + logi("test_main"); - logi("test_main"); + test_init_evaddr(); - test_init_evaddr(); - _thread_t thread1; rc = _thread_create(&thread1, thread_proc1, NULL); rc_error(rc == S_SUCCESS, S_ERROR); @@ -31,8 +30,7 @@ int main(int argc, char* argv[]) rc = _thread_create(&thread4, thread_proc4, NULL); rc_error(rc == S_SUCCESS, S_ERROR); - - test_oper_run(); + test_oper_run(); uninit_sockenv(2, 2); return 0; diff --git a/stdcrt_test/test.c b/stdcrt_test/test.c index 81a9fdff..137cf4c1 100644 --- a/stdcrt_test/test.c +++ b/stdcrt_test/test.c @@ -21,20 +21,20 @@ int loop_mem_free(evloop_t* loop, void* ptr) void* loop_alloc(void* ctx, size_t size) { void* p = heap_calloc(1, size); - return p; + return p; } int loop_free(void* ctx, void* ptr) { - heap_free(ptr); - return 0; + heap_free(ptr); + return 0; } void* oper_alloc(void* ctx, size_t size) { void* p = heap_calloc(1, size); - return p; + return p; } int oper_free(void* ctx, void* ptr) { - heap_free(ptr); - return 0; + heap_free(ptr); + return 0; } diff --git a/stdcrt_test/test.h b/stdcrt_test/test.h index 5b5da431..f5fc4dc1 100644 --- a/stdcrt_test/test.h +++ b/stdcrt_test/test.h @@ -39,7 +39,6 @@ void test_timer(evloop_t* loop); void test_conn_oper(evloop_t* loop); void test_accept_oper(evloop_t* loop); - void test_write_oper(evloop_t* loop); void test_read_oper(evloop_t* loop); diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index 751f5e5e..dc0a0573 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -23,20 +23,19 @@ _mutex_t r_mutex; void thread_proc1(void* ctx) { - sleep_time(3); - test_conn_oper(loop); + sleep_time(3); + test_conn_oper(loop); while (1) { sleep_time(1000); } } void thread_proc2(void* ctx) { - _cond_wait(&r_cond, &r_mutex); - test_read_oper(loop); - while (1) { - sleep_time(10); - } - + _cond_wait(&r_cond, &r_mutex); + test_read_oper(loop); + while (1) { + sleep_time(10); + } } void thread_proc3(void* ctx) @@ -63,28 +62,27 @@ void thread_proc4(void* ctx) } } - void test_init_evaddr() { - _cond_init(&r_cond); - _mutex_init(&r_mutex); - - _cond_init(&w_cond); - _mutex_init(&w_mutex); - - evloop_alloc(&loop, NULL, loop_alloc); - evloop_init(loop, 1024, 0); - evloop_bind_memory(loop, loop_mem_alloc, loop_mem_free, NULL); - + _cond_init(&r_cond); + _mutex_init(&r_mutex); + + _cond_init(&w_cond); + _mutex_init(&w_mutex); + + evloop_alloc(&loop, NULL, loop_alloc); + evloop_init(loop, 1024, 0); + evloop_bind_memory(loop, loop_mem_alloc, loop_mem_free, NULL); + const char* ip = "127.0.0.1"; addr.ptr = ip; addr.len = s_strlen("127.0.0.1"); _pid_t aa = get_processid(); - aa += 1000; + aa += 1000; addr.port = aa % SHRT_MAX; - logi("port:%u\n", addr.port); - + logi("port:%u\n", addr.port); + send_data = heap_malloc(4096); recv_data = heap_malloc(4096); @@ -93,29 +91,28 @@ void test_init_evaddr() evoper_alloc(&w_oper, NULL, oper_alloc); evoper_alloc(&accept_oper, NULL, oper_alloc); - - test_accept_oper(loop); + + test_accept_oper(loop); } void test_oper_run() { - int rc = S_SUCCESS; - rc = evloop_run(loop, 5000000); + int rc = S_SUCCESS; + rc = evloop_run(loop, 5000000); } int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) { if (event == op_ev_connect && res == op_ev_success) { logi("open_connect"); - _cond_broadcast(&w_cond); + _cond_broadcast(&w_cond); } else if (event == op_ev_accept && res == op_ev_success) { logi("accept_connect"); r_oper = oper_s; - _cond_broadcast(&r_cond); + _cond_broadcast(&r_cond); } else if (event == op_ev_close && res == op_ev_success) { logi("close_connect"); - } else if (event == op_ev_write && res == op_ev_success) { - + } else if (event == op_ev_write && res == op_ev_success) { iwrite++; buf_ptr s = send_data + iwrite; evoper_write_buf(oper, s, buf_len); @@ -123,7 +120,6 @@ int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) evloop_disable_write(loop, oper); } else if (event == op_ev_read && res == op_ev_success) { - iread++; logi("read string:%s=%d\n", recv_data, iread); evoper_read_buf(oper, (buf_ptr)recv_data + iread, buf_len); @@ -161,15 +157,15 @@ void test_conn_oper(evloop_t* loop) void test_write_oper(evloop_t* loop) { - int rc = 0; + int rc = 0; s_strncpy(send_data, "hello,hello", 11); - + rc = evoper_write_buf(w_oper, (buf_ptr)send_data, buf_len); if (rc != S_SUCCESS) { logi("evoper_write"); - } + } - rc = evloop_enable_write(loop, w_oper, op_ev_oneshot, NULL); + rc = evloop_enable_write(loop, w_oper, op_ev_oneshot, NULL); if (rc != S_SUCCESS) { if (rc == S_COMPLETED) { @@ -186,7 +182,7 @@ void test_read_oper(evloop_t* loop) logi("evoper_read"); } - rc = evoper_bind_handler(r_oper, evop_proc); + rc = evoper_bind_handler(r_oper, evop_proc); if (rc != S_SUCCESS) { logi("evoper_bind_handler"); } @@ -199,5 +195,4 @@ void test_read_oper(evloop_t* loop) logi("evloop_add_read"); } } - } diff --git a/stdcrt_test/test_pipe.c b/stdcrt_test/test_pipe.c index 92eb6468..33296cc7 100644 --- a/stdcrt_test/test_pipe.c +++ b/stdcrt_test/test_pipe.c @@ -1,2 +1 @@ #include "test.h" - diff --git a/stdcrt_test/test_ssl.c b/stdcrt_test/test_ssl.c index 8008c573..d9478f00 100644 --- a/stdcrt_test/test_ssl.c +++ b/stdcrt_test/test_ssl.c @@ -5,4 +5,3 @@ > Created Time: Sat Sep 18 16:48:41 2021 ************************************************************************/ #include - diff --git a/stdcrt_test/test_stdlib.c b/stdcrt_test/test_stdlib.c index 71fcd251..1727d2f5 100644 --- a/stdcrt_test/test_stdlib.c +++ b/stdcrt_test/test_stdlib.c @@ -13,12 +13,10 @@ typedef struct myNode_s { int val; } myNode_t; - void travel_queue(_msg_q* queue) { _msg_q* q = NULL; - for (q = _queue_head(queue); q != _queue_sentinel(queue); q = _queue_next(q)) - { + for (q = _queue_head(queue); q != _queue_sentinel(queue); q = _queue_next(q)) { myNode_t* reqnode; reqnode = _queue_data(q, myNode_t, queue); printf("val:%d\n", reqnode->val); @@ -33,7 +31,6 @@ void test_msgq(void) _msgq_t msg1; _msgq_init(&msg1); - myNode_t* regnode = malloc(sizeof(myNode_t)); regnode->val = 1; @@ -42,50 +39,48 @@ void test_msgq(void) _msgq_produce(&msg, ®node->queue); _msgq_produce(&msg, ®node1->queue); - - //copy to msg1.queue + // copy to msg1.queue _msgq_consume(&msg, &msg1.queue); - //output + // output travel_queue(&msg1.queue); travel_queue(&msg.queue); } - void test_cjson(void) { - //const char* code = "{\"component\":1111111111111111111111}"; - const char* code = "{\"component\":1111111111111111111111}"; - //cJSON* jsRoot = cJSON_Parse(code); - - sjon* jsRoot = sjson_parse(code, 0, 1); - sjon* json = sjson_get_obj(jsRoot, "component"); - sjon* jsDup = sjson_duplicate(jsRoot); - - char* buf1 = sjson_print(jsDup, 1024, 1); - printf("%s\n", buf1); - - if (sjson_is_double(json) == S_SUCCESS) { - printf("%d\n",1); - } - - sjon* jsCode1 = sjson_create_double(10.0001); - sjon* jsCode2 = sjson_create_double(10.002); - sjon* jsString = sjson_create_string("hello"); - - sjson_add_obj(jsRoot, "jsCode1", jsCode1); - sjson_add_obj(jsRoot, "jsCode2", jsCode2); - sjson_add_obj(jsRoot, "jsString", jsString); - - if (sjson_is_double(jsCode1) == sjson_true) { - //printf("%d\n", 2); - } - - //char* buf = cJSON_Print(jsRoot, 1024, 0); - char* buf = sjson_print(jsRoot, 1024, 0); - printf("%s\n", buf); - sjson_delete(jsRoot); + // const char* code = "{\"component\":1111111111111111111111}"; + const char* code = "{\"component\":1111111111111111111111}"; + // cJSON* jsRoot = cJSON_Parse(code); + + sjon* jsRoot = sjson_parse(code, 0, 1); + sjon* json = sjson_get_obj(jsRoot, "component"); + sjon* jsDup = sjson_duplicate(jsRoot); + + char* buf1 = sjson_print(jsDup, 1024, 1); + printf("%s\n", buf1); + + if (sjson_is_double(json) == S_SUCCESS) { + printf("%d\n", 1); + } + + sjon* jsCode1 = sjson_create_double(10.0001); + sjon* jsCode2 = sjson_create_double(10.002); + sjon* jsString = sjson_create_string("hello"); + + sjson_add_obj(jsRoot, "jsCode1", jsCode1); + sjson_add_obj(jsRoot, "jsCode2", jsCode2); + sjson_add_obj(jsRoot, "jsString", jsString); + + if (sjson_is_double(jsCode1) == sjson_true) { + // printf("%d\n", 2); + } + + // char* buf = cJSON_Print(jsRoot, 1024, 0); + char* buf = sjson_print(jsRoot, 1024, 0); + printf("%s\n", buf); + sjson_delete(jsRoot); } struct test_node { @@ -310,7 +305,7 @@ int stdtest_func(void) unsigned char* str2hex(char* str) { unsigned char* ret = NULL; - size_t str_len = s_strlen(str); + size_t str_len = s_strlen(str); int i = 0; assert((str_len % 2) == 0); ret = (unsigned char*)malloc(str_len / 2); @@ -403,12 +398,10 @@ void test_ace(void) free(decrypt_buf); } - void test_stdlib() { - // test_rbtree(); - // stdtest_func(); - // mini_heap(); - // test_rbtree(); + // test_rbtree(); + // stdtest_func(); + // mini_heap(); + // test_rbtree(); } - diff --git a/stdcrt_test/test_timer.c b/stdcrt_test/test_timer.c index fc44842a..846427e8 100644 --- a/stdcrt_test/test_timer.c +++ b/stdcrt_test/test_timer.c @@ -16,7 +16,7 @@ int time_handler(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) logi("timer %ld==%ld", clockmsec, opermsec); int* id = NULL; evoper_get_ctx(oper, (void**)&id); - //sleep_time(4); + // sleep_time(4); } else { logi("timer out %ld==%ld", clockmsec, opermsec); int* id = NULL; @@ -57,5 +57,4 @@ void test_timer(evloop_t* loop) evoper_bind_ctx(timer3, &id3); evoper_bind_handler(timer3, time_handler); evloop_add_timer(loop, timer3, &tv); - } \ No newline at end of file diff --git a/stdcrt_test/test_unixsock.c b/stdcrt_test/test_unixsock.c index 92eb6468..33296cc7 100644 --- a/stdcrt_test/test_unixsock.c +++ b/stdcrt_test/test_unixsock.c @@ -1,2 +1 @@ #include "test.h" - diff --git a/testmain/appviewimpl.cpp b/testmain/appviewimpl.cpp index 18c59b32..1a3dbc45 100644 --- a/testmain/appviewimpl.cpp +++ b/testmain/appviewimpl.cpp @@ -26,17 +26,17 @@ HRESULT CAppViewImpl::Start(_pid_t pid, unsigned int type) InitBus(); - _lComPtr pINet; + _lComPtr pINet; m_pRot->GetObject(CLSID_INet, IID_INet, (IBase**)&pINet.m_p); rc_error(pINet.m_p != INULL, E_FAIL); hr = pINet->CreateProtocol(protocol_modbus, (IBase**)&m_pIModBus); rc_error(hr == S_OK, E_FAIL); - //m_pIHttp->Release(); + // m_pIHttp->Release(); //_lComPtr pBase; - // hr = this->QueryInterface(IID_IBase, (void**)&pBase); - // rc_error(hr == S_OK, E_FAIL) + // hr = this->QueryInterface(IID_IBase, (void**)&pBase); + // rc_error(hr == S_OK, E_FAIL) // hr = m_pIHttp->BindEvent(pBase); // rc_error(hr == S_OK, E_FAIL) diff --git a/testmain/appviewimpl.h b/testmain/appviewimpl.h index 8aa7ff7d..7d7ef505 100644 --- a/testmain/appviewimpl.h +++ b/testmain/appviewimpl.h @@ -6,10 +6,7 @@ //{a7957a54-37cb-42a4-9ee8-599168c2a3d1} _DEF_CLSID_IMPL(CLSID_AppView, 0xA7957A54, 0x37CB, 0x42A4, 0x9E, 0xE8, 0x59, 0x91, 0x68, 0xC2, 0xA3, 0xD1) -class CAppViewImpl : public IPlugin, - public IPluginRun, - public IHttpProc, - public CUnknownImp +class CAppViewImpl : public IPlugin, public IPluginRun, public IHttpProc, public CUnknownImp { public: CAppViewImpl(void); diff --git a/uibase/dllmain.cpp b/uibase/dllmain.cpp index fe7349ac..593c1405 100644 --- a/uibase/dllmain.cpp +++ b/uibase/dllmain.cpp @@ -33,9 +33,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = { - {CLSID_IUIbase, &ClassFactory::GetClass, "uibase.V1"} -}; +static_const stdcom_entry_t clsobject[] = {{CLSID_IUIbase, &ClassFactory::GetClass, "uibase.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/uibase/uibaseimpl.h b/uibase/uibaseimpl.h index c92b5705..36e64f3c 100644 --- a/uibase/uibaseimpl.h +++ b/uibase/uibaseimpl.h @@ -3,10 +3,7 @@ #include "stdafx.h" -class CUiBaseImpl : public IUIBase, - public IPlugin, - public IPluginRun, - public CUnknownImp +class CUiBaseImpl : public IUIBase, public IPlugin, public IPluginRun, public CUnknownImp { public: CUiBaseImpl(void); diff --git a/uibase/uicontrolimpl.cpp b/uibase/uicontrolimpl.cpp index d608472b..04b0bb87 100644 --- a/uibase/uicontrolimpl.cpp +++ b/uibase/uicontrolimpl.cpp @@ -130,7 +130,7 @@ int CUiControlImpl::GetY() } SIZE CUiControlImpl::GetFixed() { - SIZE rc = {0,0}; + SIZE rc = {0, 0}; return rc; } HRESULT CUiControlImpl::SetFixed(SIZE rc) @@ -139,7 +139,7 @@ HRESULT CUiControlImpl::SetFixed(SIZE rc) } RECT CUiControlImpl::GetPos() { - RECT rc = {0,0,0,0}; + RECT rc = {0, 0, 0, 0}; return rc; } HRESULT CUiControlImpl::SetPos(RECT rc) @@ -226,7 +226,7 @@ HRESULT CUiControlImpl::SetFocusBorderColor(DWORD dwBorderColor) } SIZE CUiControlImpl::GetBorderRound() { - SIZE rc = {0,0}; + SIZE rc = {0, 0}; return rc; } HRESULT CUiControlImpl::SetBorderRound(SIZE cxyRound) diff --git a/uibase/uimessageloopimpl.h b/uibase/uimessageloopimpl.h index d74c0370..42dd7676 100644 --- a/uibase/uimessageloopimpl.h +++ b/uibase/uimessageloopimpl.h @@ -3,8 +3,7 @@ #include "stdafx.h" -class CUiMessageloopImpl : public IUIMessageLoop, - public CUnknownImp +class CUiMessageloopImpl : public IUIMessageLoop, public CUnknownImp { public: CUiMessageloopImpl(void); diff --git a/uibase/uiwindowimpl.cpp b/uibase/uiwindowimpl.cpp index ec91c7a0..0e7782a3 100644 --- a/uibase/uiwindowimpl.cpp +++ b/uibase/uiwindowimpl.cpp @@ -57,4 +57,3 @@ HRESULT CUiWindowsImpl::UnBindEvent() { return S_OK; } - diff --git a/uibase/uiwindowimpl.h b/uibase/uiwindowimpl.h index 200bb748..cc2caa10 100644 --- a/uibase/uiwindowimpl.h +++ b/uibase/uiwindowimpl.h @@ -4,8 +4,7 @@ #include "stdafx.h" #include "uicontrolimpl.h" -class CUiWindowsImpl : public IUIWindow, - public CUnknownImp +class CUiWindowsImpl : public IUIWindow, public CUnknownImp { public: CUiWindowsImpl(void); -- Gitee From 5d9d9ad3bb0c4f7278d94f5b8e3ac7f38021be49 Mon Sep 17 00:00:00 2001 From: com Date: Tue, 13 Aug 2024 15:42:05 +0800 Subject: [PATCH 22/34] up --- crt/crt_array.h | 50 ---- crt/crt_htable.h | 69 ----- crt/crt_iterator.h | 36 --- crt/crt_util.h | 4 - stdcrt/stdcrt.vcxproj | 1 - stdcrt/stdcrt.vcxproj.filters | 3 - stdcrt/stdlib/compat_array.c | 383 -------------------------- stdcrt/stdlib/compat_htable.c | 491 ---------------------------------- stdcrt_test/main.c | 2 + stdcrt_test/test.h | 2 + stdcrt_test/test_stdlib.c | 6 + 11 files changed, 10 insertions(+), 1037 deletions(-) delete mode 100644 crt/crt_array.h delete mode 100644 crt/crt_htable.h delete mode 100644 crt/crt_iterator.h delete mode 100644 stdcrt/stdlib/compat_array.c delete mode 100644 stdcrt/stdlib/compat_htable.c diff --git a/crt/crt_array.h b/crt/crt_array.h deleted file mode 100644 index 0e05fb1e..00000000 --- a/crt/crt_array.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _CRT_ARRAY_H_ -#define _CRT_ARRAY_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct array_s array_t; - -struct array_s { - int capacity; - int count; - void** items; - - int (*push_back)(struct array_s*, void*); - int (*push_front)(struct array_s*, void*); - - int (*array_pred_insert)(array_t* a, int position, void* obj); - int (*array_succ_insert)(array_t* a, int position, void* obj); - - void* (*pop_back)(struct array_s*); - void* (*pop_front)(struct array_s*); - - int (*array_delete_idx)(array_t* a, int position, void (*free_fn)(void*)); - int (*array_delete)(array_t* a, int position, void (*free_fn)(void*)); - int (*array_delete_range)(array_t* a, int ibegin, int iend, void (*free_fn)(void*)); - int (*array_delete_obj)(array_t* a, void* obj, void (*free_fn)(void*)); - int (*array_mv_idx)(array_t* a, int ito, int ifrom, void (*free_fn)(void*)); - - void* (*iter_head)(ITER*, struct array_s*); - void* (*iter_next)(ITER*, struct array_s*); - void* (*iter_tail)(ITER*, struct array_s*); - void* (*iter_prev)(ITER*, struct array_s*); - - void (*array_pre_append)(array_t* a, int app_count); - void* (*array_index)(const array_t* a, int idx); - int (*array_size)(const array_t* a); -}; - -int array_init(array_t* a, int init_size); -void array_clean(array_t* a, void (*free_fn)(void*)); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/crt/crt_htable.h b/crt/crt_htable.h deleted file mode 100644 index e3156177..00000000 --- a/crt/crt_htable.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _CRT_HTABLE_H_ -#define _CRT_HTABLE_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _htable_s _htable_t; -typedef struct _htable_info_s _htable_info_t; - -struct _htable_s { - int size; - int init_size; - int used; - _htable_info_t** data; - int status; - void* (*iter_head)(ITER*, struct _htable_s*); - void* (*iter_next)(ITER*, struct _htable_s*); - void* (*iter_tail)(ITER*, struct _htable_s*); - void* (*iter_prev)(ITER*, struct _htable_s*); - _htable_info_t* (*iter_info)(ITER*, struct _htable_s*); -}; - -struct _htable_info_s { - char* key; - void* value; - unsigned hash; - struct _htable_info_s* next; - struct _htable_info_s* prev; -}; - -_htable_t* htable_create(int size); -int htable_errno(_htable_t* table); - -#define HTABLE_STAT_OK 0 -#define HTABLE_STAT_INVAL 1 -#define HTABLE_STAT_DUPLEX_KEY 2 - -void htable_set_errno(_htable_t* table, int error); -_htable_info_t* htable_enter(_htable_t* table, const char* key, void* value); -_htable_info_t* htable_locate(_htable_t* table, const char* key); -void* htable_find(_htable_t* table, const char* key); -int htable_delete(_htable_t* table, const char* key, void (*free_fn)(void*)); -void htable_delete_entry(_htable_t* table, _htable_info_t* ht, void (*free_fn)(void*)); -void htable_free(_htable_t* table, void (*free_fn)(void*)); -int htable_reset(_htable_t* table, void (*free_fn)(void*)); -void htable_walk(_htable_t* table, void (*walk_fn)(_htable_info_t*, void*), void* arg); -int htable_size(const _htable_t* table); -int htable_used(const _htable_t* table); -_htable_info_t** htable_list(const _htable_t* table); -void htable_stat(const _htable_t* table); - -#define htable_stat_r htable_stat - -#define HTABLE_ITER_KEY(iter) ((iter).ptr->key.c_key) - -#define htable_iter_key HTABLE_ITER_KEY - -#define HTABLE_ITER_VALUE(iter) ((iter).ptr->value) - -#define htable_iter_value HTABLE_ITER_VALUE - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/crt/crt_iterator.h b/crt/crt_iterator.h deleted file mode 100644 index 045e1152..00000000 --- a/crt/crt_iterator.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _CRT_ITERATOR_H_ -#define _CRT_ITERATOR_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ITER ITER; - -struct ITER { - void* ptr; - void* data; - int dlen; - const char* key; - int klen; - int i; - int size; -}; - -#define foreach_t(iter, container) for ((container)->iter_head(&(iter), (container)); (iter).ptr; (container)->iter_next(&(iter), (container))) - -#define foreach_reverse_t(iter, container) \ - for ((container)->iter_tail(&(iter), (container)); (iter).ptr; (container)->iter_prev(&(iter), (container))) - -#define ITER_INFO(iter, container) (container)->iter_info(&(iter), (container)) - -#define foreach_reverse foreach_reverse_t -#define foreach foreach_t - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/crt/crt_util.h b/crt/crt_util.h index 7945cf89..779442df 100644 --- a/crt/crt_util.h +++ b/crt/crt_util.h @@ -70,8 +70,6 @@ of a structure or union are aligned according to the widest member. #include #include -#include - #include #include @@ -102,7 +100,6 @@ of a structure or union are aligned according to the widest member. #include #include #include -#include #include #include #include @@ -120,7 +117,6 @@ of a structure or union are aligned according to the widest member. #include #include #include -#include #include diff --git a/stdcrt/stdcrt.vcxproj b/stdcrt/stdcrt.vcxproj index f11d5b5e..408449c5 100644 --- a/stdcrt/stdcrt.vcxproj +++ b/stdcrt/stdcrt.vcxproj @@ -104,7 +104,6 @@ - diff --git a/stdcrt/stdcrt.vcxproj.filters b/stdcrt/stdcrt.vcxproj.filters index 92dbafe4..8852541c 100644 --- a/stdcrt/stdcrt.vcxproj.filters +++ b/stdcrt/stdcrt.vcxproj.filters @@ -31,9 +31,6 @@ net - - stdlib - stdlib diff --git a/stdcrt/stdlib/compat_array.c b/stdcrt/stdlib/compat_array.c deleted file mode 100644 index 1bd9243f..00000000 --- a/stdcrt/stdlib/compat_array.c +++ /dev/null @@ -1,383 +0,0 @@ -#include - -static void array_grow(array_t* a, int min_capacity) -{ - int min_delta = 16; - int delta; - - /* don't need to grow the capacity of the array */ - if (a->capacity >= min_capacity) { - return; - } - - delta = min_capacity; - /* make delta a multiple of min_delta */ - delta += min_delta - 1; - delta /= min_delta; - delta *= min_delta; - /* actual grow */ - if (delta <= 0) { - return; - } - - a->capacity += delta; - - if (a->items == NULL) { - a->items = (void**)heap_malloc(a->capacity * sizeof(void*)); - } else { - a->items = (void**)heap_realloc(a->items, a->capacity * sizeof(void*)); - } - - /* reset, just in case */ - s_memset(a->items + a->count, 0, (a->capacity - a->count) * sizeof(void*)); -} - -static int array_pred_insert(array_t* a, int position, void* obj) -{ - int idx; - if (position < 0 || position >= a->count) { - return -1; - } - - if (a->count >= a->capacity) { - array_grow(a, a->count + 1); - } - - for (idx = a->count; idx > position && idx > 0; idx--) { - a->items[idx] = a->items[idx - 1]; - } - a->items[position] = obj; - a->count++; - return position; -} - -static int array_succ_insert(array_t* a, int position, void* obj) -{ - int idx, position_succ; - - if (position < 0 || position >= a->count) { - return -1; - } - - if (a->count >= a->capacity) { - array_grow(a, a->count + 1); - } - - position_succ = position + 1; - - for (idx = a->count; idx > position_succ; idx--) { - a->items[idx] = a->items[idx - 1]; - } - a->items[position_succ] = obj; - a->count++; - return position_succ; -} - -static int array_append(array_t* a, void* obj) -{ - if (a->count >= a->capacity) { - array_grow(a, a->count + 16); - } - a->items[a->count++] = obj; - return a->count - 1; -} - -static int array_prepend(array_t* a, void* obj) -{ - return array_pred_insert(a, 0, obj); -} - -static int array_push_back(struct array_s* a, void* obj) -{ - return array_append(a, obj); -} - -static int array_push_front(struct array_s* a, void* obj) -{ - return array_prepend(a, obj); -} - -static void* array_pop_back(struct array_s* a) -{ - void* obj; - if (a->count <= 0) { - return NULL; - } - a->count--; - obj = a->items[a->count]; - return obj; -} - -static void* array_pop_front(struct array_s* a) -{ - void* obj; - int i; - - if (a->count <= 0) { - return NULL; - } - obj = a->items[0]; - a->count--; - for (i = 0; i < a->count; i++) { - a->items[i] = a->items[i + 1]; - } - - return obj; -} - -static void* array_iter_head(ITER* iter, struct array_s* a) -{ - iter->dlen = -1; - iter->key = NULL; - iter->klen = 0; - iter->i = 0; - iter->size = a->count; - if (a->items == NULL || a->count <= 0) { - iter->ptr = iter->data = 0; - } else { - iter->ptr = iter->data = a->items[0]; - } - - return iter->ptr; -} - -static void* array_iter_next(ITER* iter, struct array_s* a) -{ - iter->i++; - if (iter->i >= a->count) { - iter->data = iter->ptr = 0; - } else { - iter->data = iter->ptr = a->items[iter->i]; - } - return iter->ptr; -} - -static void* array_iter_tail(ITER* iter, struct array_s* a) -{ - iter->dlen = -1; - iter->key = NULL; - iter->klen = 0; - iter->i = a->count - 1; - iter->size = a->count; - if (a->items == NULL || iter->i < 0) { - iter->ptr = iter->data = 0; - } else { - iter->data = iter->ptr = a->items[iter->i]; - } - return iter->ptr; -} - -static void* array_iter_prev(ITER* iter, struct array_s* a) -{ - iter->i--; - if (iter->i < 0) { - iter->data = iter->ptr = 0; - } else { - iter->data = iter->ptr = a->items[iter->i]; - } - return iter->ptr; -} - -static int array_delete_idx(array_t* a, int position, void (*free_fn)(void*)) -{ - int idx; - - if (position < 0 || position >= a->count) { - return -1; - } - if (free_fn != NULL && a->items[position] != NULL) { - free_fn(a->items[position]); - } - a->items[position] = NULL; /* sanity set to be null */ - - for (idx = position; idx < a->count - 1; idx++) { - a->items[idx] = a->items[idx + 1]; - } - a->count--; - return 0; -} - -static int array_delete(array_t* a, int idx, void (*free_fn)(void*)) -{ - if (idx < 0 || idx >= a->count) { - return -1; - } - if (free_fn != NULL && a->items[idx] != NULL) { - free_fn(a->items[idx]); - } - a->count--; - if (a->count > 0) { - a->items[idx] = a->items[a->count]; - } - return 0; -} - -static int array_delete_obj(array_t* a, void* obj, void (*free_fn)(void*)) -{ - int idx, position, ret; - - position = -1; - for (idx = 0; idx < a->count; idx++) { - if (a->items[idx] == obj) { - position = idx; - break; - } - } - - if (free_fn != NULL && obj != NULL) { - free_fn(obj); - } - if (position == -1) { /* not found */ - return -1; - } - - /* don't need to free the obj in array_delete_idx */ - a->items[idx] = NULL; - ret = array_delete_idx(a, position, NULL); - if (ret < 0) { - return -1; - } - return ret; -} - -static int array_delete_range(array_t* a, int ibegin, int iend, void (*free_fn)(void*)) -{ - int i, imax; - - if (ibegin < 0 || iend < 0 || a->count <= 0) { - return -1; - } - if (ibegin > iend) { - return -1; - } - - imax = a->count - 1; - if (iend > imax) { - iend = imax; - } - - if (free_fn != NULL) { - for (i = ibegin; i <= iend; i++) { - if (a->items[i] != NULL) { - free_fn(a->items[i]); - } - a->items[i] = NULL; - } - } - - a->count -= iend - ibegin + 1; - - for (iend++; iend <= imax;) { - a->items[ibegin++] = a->items[iend++]; - } - - return 0; -} - -static int array_mv_idx(array_t* a, int ito, int ifrom, void (*free_fn)(void*)) -{ - int i, i_obj, i_src, i_max; - - if (ito < 0 || ifrom < 0 || a->count < 0) { - return -1; - } - - if (a->count == 0 || ito >= ifrom || ifrom >= a->count) { - return 0; - } - - i_obj = ito; - i_src = ifrom; - i_max = a->count - 1; - - if (free_fn != NULL) { - for (i = i_obj; i < i_src; i++) { - if (a->items[i] != NULL) { - free_fn(a->items[i]); - } - a->items[i] = NULL; - } - } - for (; i_src <= i_max; i_src++) { - a->items[i_obj] = a->items[i_src]; - i_obj++; - } - - a->count -= ifrom - ito; - if (a->count < 0) { /* imposible, sanity check */ - return -1; - } - return 0; -} - -static void array_pre_append(array_t* a, int app_count) -{ - if (app_count <= 0) { } - - if (a->count + app_count > a->capacity) { - array_grow(a, a->count + app_count); - } -} - -static void* array_index(const array_t* a, int idx) -{ - if (idx < 0 || idx > a->count - 1) { - return NULL; - } - - return a->items[idx]; -} - -static int array_size(const array_t* a) -{ - return a->count; -} - -int array_init(array_t* a, int init_size) -{ - a->count = 0; - a->capacity = 0; - a->push_back = array_push_back; - a->push_front = array_push_front; - - a->array_pred_insert = array_pred_insert; - a->array_succ_insert = array_succ_insert; - - a->pop_back = array_pop_back; - a->pop_front = array_pop_front; - - a->array_delete_idx = array_delete_idx; - a->array_delete = array_delete; - a->array_delete_range = array_delete_range; - a->array_delete_obj = array_delete_obj; - a->array_mv_idx = array_mv_idx; - - a->iter_head = array_iter_head; - a->iter_next = array_iter_next; - a->iter_tail = array_iter_tail; - a->iter_prev = array_iter_prev; - - a->array_pre_append = array_pre_append; - a->array_index = array_index; - a->array_size = array_size; - - if (init_size <= 0) { - init_size = 100; - } - - array_pre_append(a, init_size); - return 1; -} - -void array_clean(array_t* a, void (*free_fn)(void*)) -{ - int idx; - - for (idx = 0; idx < a->count; idx++) { - if (free_fn != NULL && a->items[idx] != NULL) { - free_fn(a->items[idx]); - } - a->items[idx] = NULL; /* sanity set to be null */ - } - a->count = 0; -} diff --git a/stdcrt/stdlib/compat_htable.c b/stdcrt/stdlib/compat_htable.c deleted file mode 100644 index 76a0dadb..00000000 --- a/stdcrt/stdlib/compat_htable.c +++ /dev/null @@ -1,491 +0,0 @@ -#include - -static void* htable_iter_head(ITER* iter, _htable_t* table) -{ - _htable_info_t* ptr = NULL; - iter->dlen = -1; - iter->klen = -1; - iter->i = 0; - iter->size = table->size; - iter->ptr = NULL; - - for (; iter->i < iter->size; iter->i++) { - if (table->data[iter->i] != NULL) { - iter->ptr = ptr = table->data[iter->i]; - break; - } - } - - if (ptr) { - iter->data = ptr->value; - iter->key = ptr->key; - } else { - iter->data = NULL; - iter->key = NULL; - } - return (iter->ptr); -} - -/* htable_iter_next */ - -static void* htable_iter_next(ITER* iter, _htable_t* table) -{ - _htable_info_t* ptr; - - ptr = (_htable_info_t*)iter->ptr; - if (ptr) { - iter->ptr = ptr = ptr->next; - if (ptr != NULL) { - iter->data = ptr->value; - iter->key = ptr->key; - return (iter->ptr); - } - } - - for (iter->i++; iter->i < iter->size; iter->i++) { - if (table->data[iter->i] != NULL) { - iter->ptr = ptr = table->data[iter->i]; - break; - } - } - - if (ptr) { - iter->data = ptr->value; - iter->key = ptr->key; - } else { - iter->data = NULL; - iter->key = NULL; - } - return (iter->ptr); -} - -/* htable_iter_tail */ - -static void* htable_iter_tail(ITER* iter, _htable_t* table) -{ - _htable_info_t* ptr = NULL; - - iter->dlen = -1; - iter->klen = -1; - iter->i = table->size - 1; - iter->size = table->size; - iter->ptr = NULL; - - for (; iter->i >= 0; iter->i--) { - if (table->data[iter->i] != NULL) { - iter->ptr = ptr = table->data[iter->i]; - break; - } - } - - if (ptr) { - iter->data = ptr->value; - iter->key = ptr->key; - } else { - iter->data = NULL; - iter->key = NULL; - } - return (iter->ptr); -} - -/* htable_iter_prev */ - -static void* htable_iter_prev(ITER* iter, _htable_t* table) -{ - _htable_info_t* ptr; - - ptr = (_htable_info_t*)iter->ptr; - if (ptr) { - iter->ptr = ptr = ptr->next; - if (ptr != NULL) { - iter->data = ptr->value; - iter->key = ptr->key; - return (iter->ptr); - } - } - - for (iter->i--; iter->i >= 0; iter->i--) { - if (table->data[iter->i] != NULL) { - iter->ptr = ptr = table->data[iter->i]; - break; - } - } - - if (ptr) { - iter->data = ptr->value; - iter->key = ptr->key; - } else { - iter->data = NULL; - iter->key = NULL; - } - return (iter->ptr); -} - -static _htable_info_t* htable_iter_info(ITER* iter, _htable_t* table) -{ - (void)table; - return (iter->ptr ? (_htable_info_t*)iter->ptr : NULL); -} - -static unsigned __def_hash_fn(const void* buffer, size_t len) -{ - unsigned long h = 0; - unsigned long g; - const unsigned char* s = (const unsigned char*)buffer; - - while (len-- > 0) { - h = (h << 4) + *s++; - if ((g = (h & 0xf0000000)) != 0) { - h ^= (g >> 24); - h ^= g; - } - } - - return (unsigned)h; -} -/* htable_link - insert element into table */ - -#define htable_link(_table, _element, _n) \ - { \ - _htable_info_t** _h = _table->data + _n; \ - _element->prev = 0; \ - if ((_element->next = *_h) != 0) \ - (*_h)->prev = _element; \ - *_h = _element; \ - _table->used++; \ - } - -static int __htable_size(_htable_t* table, unsigned size) -{ - _htable_info_t** h; - - size |= 1; - - table->data = h = (_htable_info_t**)heap_malloc(size * sizeof(_htable_info_t*)); - if (table->data == NULL) { - return -1; - } - - table->size = size; - table->used = 0; - - while (size-- > 0) { - *h++ = 0; - } - - return 0; -} - -static int htable_grow(_htable_t* table) -{ - int ret; - _htable_info_t* ht; - _htable_info_t* next; - unsigned old_size = table->size; - _htable_info_t** h0 = table->data; - _htable_info_t** old_entries = h0; - unsigned n; - - ret = __htable_size(table, 2 * old_size); - if (ret < 0) { - return -1; - } - - while (old_size-- > 0) { - for (ht = *h0++; ht; ht = next) { - next = ht->next; - n = __def_hash_fn(ht->key, strlen(ht->key)) % table->size; - htable_link(table, ht, n); - } - } - - heap_free(old_entries); - return 0; -} - -_htable_t* htable_create(int size) -{ - _htable_t* table; - int ret; - - table = (_htable_t*)heap_calloc(1, sizeof(_htable_t)); - if (table == NULL) { - return NULL; - } - - table->init_size = size; - ret = __htable_size(table, size < 13 ? 13 : size); - if (ret < 0) { - heap_free(table); - return NULL; - } - - table->iter_head = htable_iter_head; - table->iter_next = htable_iter_next; - table->iter_tail = htable_iter_tail; - table->iter_prev = htable_iter_prev; - table->iter_info = htable_iter_info; - - return table; -} - -int htable_errno(_htable_t* table) -{ - if (table == NULL) { - return HTABLE_STAT_INVAL; - } - return table->status; -} - -void htable_set_errno(_htable_t* table, int error) -{ - if (table) { - table->status = error; - } -} - -#define STREQ(x, y) (x == y || (x[0] == y[0] && strcmp(x, y) == 0)) - -_htable_info_t* htable_enter(_htable_t* table, const char* key, void* value) -{ - _htable_info_t* ht; - int ret; - unsigned hash, n; - - table->status = HTABLE_STAT_OK; - hash = __def_hash_fn(key, strlen(key)); - - if (table->used >= table->size) { - ret = htable_grow(table); - if (ret < 0) { - return NULL; - } - } - - n = hash % table->size; - - for (ht = table->data[n]; ht; ht = ht->next) { - if (STREQ(key, ht->key)) { - table->status = HTABLE_STAT_DUPLEX_KEY; - return ht; - } - } - - ht = (_htable_info_t*)heap_malloc(sizeof(_htable_info_t)); - if (ht == NULL) { - return NULL; - } - -#if defined(_WIN32) || defined(_WIN64) - ht->key = _strdup(key); -#else - ht->key = strdup(key); -#endif - - if (ht->key == NULL) { - heap_free(ht); - return NULL; - } - ht->hash = hash; - ht->value = value; - htable_link(table, ht, n); - - return ht; -} - -void* htable_find(_htable_t* table, const char* key) -{ - _htable_info_t* ht = htable_locate(table, key); - - return ht != NULL ? ht->value : NULL; -} - -_htable_info_t* htable_locate(_htable_t* table, const char* key) -{ - _htable_info_t* ht; - unsigned n; - - n = __def_hash_fn(key, strlen(key)); - n = n % table->size; - - for (ht = table->data[n]; ht; ht = ht->next) { - if (STREQ(key, ht->key)) { - return ht; - } - } - - return NULL; -} - -void htable_delete_entry(_htable_t* table, _htable_info_t* ht, void (*free_fn)(void*)) -{ - unsigned n = ht->hash % table->size; - _htable_info_t** h = table->data + n; - - if (ht->next) - ht->next->prev = ht->prev; - if (ht->prev) - ht->prev->next = ht->next; - else - *h = ht->next; - - heap_free(ht->key); - if (free_fn && ht->value) - (*free_fn)(ht->value); - heap_free(ht); - table->used--; -} - -int htable_delete(_htable_t* table, const char* key, void (*free_fn)(void*)) -{ - _htable_info_t* ht; - unsigned n; - _htable_info_t** h; - - n = __def_hash_fn(key, strlen(key)); - n = n % table->size; - - h = table->data + n; - for (ht = *h; ht; ht = ht->next) { - if (STREQ(key, ht->key)) { - htable_delete_entry(table, ht, free_fn); - return 0; - } - } - return -1; -} - -void htable_free(_htable_t* table, void (*free_fn)(void*)) -{ - unsigned i = table->size; - _htable_info_t* ht; - _htable_info_t* next; - _htable_info_t** h = table->data; - - while (i-- > 0) { - for (ht = *h++; ht; ht = next) { - next = ht->next; - heap_free(ht->key); - if (free_fn && ht->value) - (*free_fn)(ht->value); - heap_free(ht); - } - } - - heap_free(table->data); - table->data = 0; - heap_free(table); -} - -int htable_reset(_htable_t* table, void (*free_fn)(void*)) -{ - unsigned i = table->size; - _htable_info_t* ht; - _htable_info_t* next; - _htable_info_t** h; - int ret; - - h = table->data; - - while (i-- > 0) { - for (ht = *h++; ht; ht = next) { - next = ht->next; - heap_free(ht->key); - if (free_fn && ht->value) { - (*free_fn)(ht->value); - } - heap_free(ht); - } - } - heap_free(table->data); - ret = __htable_size(table, table->init_size < 13 ? 13 : table->init_size); - return ret; -} - -/* htable_walk - iterate over hash table */ - -void htable_walk(_htable_t* table, void (*action)(_htable_info_t*, void*), void* arg) -{ - unsigned i = table->size; - _htable_info_t** h = table->data; - _htable_info_t* ht; - - while (i-- > 0) { - for (ht = *h++; ht; ht = ht->next) { - (*action)(ht, arg); - } - } -} - -int htable_size(const _htable_t* table) -{ - if (table) { - return table->size; - } else { - return 0; - } -} - -int htable_used(const _htable_t* table) -{ - if (table) { - return table->used; - } else { - return (0); - } -} - -/* -HTABLE_INFO **htable_data(HTABLE *table) -{ - return (HTABLE_INFO**) table->data; -} -*/ - -/* htable_list - list all table members */ - -_htable_info_t** htable_list(const _htable_t* table) -{ - _htable_info_t** list; - _htable_info_t* member; - int count = 0; - int i; - - if (table != 0) { - list = (_htable_info_t**)heap_malloc(sizeof(*list) * (table->used + 1)); - for (i = 0; i < table->size; i++) { - for (member = table->data[i]; member != 0; member = member->next) { - list[count++] = member; - } - } - } else { - list = (_htable_info_t**)heap_malloc(sizeof(*list)); - } - list[count] = 0; - return list; -} - -void htable_stat(const _htable_t* table) -{ - _htable_info_t* member; - int i, count; - - for (i = 0; i < table->size; i++) { - count = 0; - member = table->data[i]; - for (; member != 0; member = member->next) { - count++; - } - if (count > 0) { } - } - - for (i = 0; i < table->size; i++) { - member = table->data[i]; - if (member) { - logi("chains[%d]: ", i); - for (; member != 0; member = member->next) - logi("[%s]", member->key); - } - } - logi("hash table size=%d, used=%d\n", table->size, table->used); -} diff --git a/stdcrt_test/main.c b/stdcrt_test/main.c index eb692fea..077bf740 100644 --- a/stdcrt_test/main.c +++ b/stdcrt_test/main.c @@ -12,6 +12,8 @@ int main(int argc, char* argv[]) logi("test_main"); + test_array(); + test_init_evaddr(); _thread_t thread1; diff --git a/stdcrt_test/test.h b/stdcrt_test/test.h index f5fc4dc1..826fcf9e 100644 --- a/stdcrt_test/test.h +++ b/stdcrt_test/test.h @@ -42,4 +42,6 @@ void test_accept_oper(evloop_t* loop); void test_write_oper(evloop_t* loop); void test_read_oper(evloop_t* loop); +void test_array(); + #endif diff --git a/stdcrt_test/test_stdlib.c b/stdcrt_test/test_stdlib.c index 1727d2f5..36761422 100644 --- a/stdcrt_test/test_stdlib.c +++ b/stdcrt_test/test_stdlib.c @@ -405,3 +405,9 @@ void test_stdlib() // mini_heap(); // test_rbtree(); } + + +void test_array() +{ + +} \ No newline at end of file -- Gitee From 87a2e7e9f7a1c710236f5359d84d52a48fcec239 Mon Sep 17 00:00:00 2001 From: com Date: Thu, 15 Aug 2024 14:43:40 +0800 Subject: [PATCH 23/34] up --- crt/crt_cond.h | 4 +- crt/crt_event.h | 19 ++- include/utilex/cond.hpp | 22 +-- stdcrt/event/compat_event.c | 53 +++---- stdcrt/event/compat_event_epoll.c | 66 ++++---- stdcrt/event/compat_event_epoll.h | 12 +- stdcrt/event/compat_event_iocp.c | 42 +++--- stdcrt/event/compat_event_iocp.h | 7 + stdcrt/event/compat_event_kqueue.c | 48 +++--- stdcrt/event/compat_event_kqueue.h | 8 +- stdcrt/event/compat_event_mach.c | 143 ++++++------------ stdcrt/event/compat_event_mach.h | 2 - stdcrt/event/compat_event_posix.c | 232 +++++++++++------------------ stdcrt/event/compat_event_posix.h | 2 - stdcrt/event/compat_event_util.c | 26 ++++ stdcrt/event/compat_event_util.h | 10 +- stdcrt/thread/compat_cond.c | 44 +++--- stdcrt_test/test_oper.c | 40 ++--- 18 files changed, 355 insertions(+), 425 deletions(-) diff --git a/crt/crt_cond.h b/crt/crt_cond.h index 020c8a56..127c0d8b 100644 --- a/crt/crt_cond.h +++ b/crt/crt_cond.h @@ -86,8 +86,8 @@ int _cond_init(_cond_t* cond); int _cond_destroy(_cond_t* cond); int _cond_signal(_cond_t* cond); int _cond_broadcast(_cond_t* cond); -int _cond_wait(_cond_t* cond, _mutex_t* lock); -int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms); +int _cond_wait(_cond_t* cond); +int _cond_timedwait(_cond_t* cond, unsigned long ms); #ifdef __cplusplus } diff --git a/crt/crt_event.h b/crt/crt_event.h index 1e3e98b2..1a9f84f7 100644 --- a/crt/crt_event.h +++ b/crt/crt_event.h @@ -81,13 +81,13 @@ struct evaddr_s { #define op_ev_close 0x70 #endif // !op_ev_close -#ifndef op_ev_active -#define op_ev_active 0x10 -#endif // !op_ev_active +#ifndef op_ev_edge +#define op_ev_edge 0x10 +#endif // !op_ev_edge -#ifndef op_ev_oneshot -#define op_ev_oneshot 0x20 -#endif // !op_ev_oneshot +#ifndef op_ev_level +#define op_ev_level 0x20 +#endif // !op_ev_level /////////////////////////////////// #ifndef op_ev_success @@ -99,6 +99,9 @@ struct evaddr_s { #endif // !op_ev_faild /////////////////////////////////// +buf_len evoper_rbyte(evoper_t* oper); +buf_len evoper_wbyte(evoper_t* oper); + int evoper_read_buf(evoper_t* oper, buf_ptr buf, buf_len len); int evoper_write_buf(evoper_t* oper, buf_ptr buf, buf_len len); @@ -131,8 +134,8 @@ int evloop_bind_mmctx(evloop_t* loop, void* mmctx); int evloop_get_mmctx(evloop_t* loop, void** mmctx); int evloop_add_timer(evloop_t* loop, evoper_t* oper, ev_time_t tv); -int evloop_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); -int evloop_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv); +int evloop_enable_read(evloop_t* loop, evoper_t* oper, short event, socklen_t size, ev_time_t tv); +int evloop_enable_write(evloop_t* loop, evoper_t* oper, short event, socklen_t size, ev_time_t tv); int evloop_disable_read(evloop_t* loop, evoper_t* oper); int evloop_disable_write(evloop_t* loop, evoper_t* oper); int evloop_canncel(evloop_t* loop, evoper_t* oper); diff --git a/include/utilex/cond.hpp b/include/utilex/cond.hpp index 17994a07..b40e586b 100644 --- a/include/utilex/cond.hpp +++ b/include/utilex/cond.hpp @@ -12,57 +12,39 @@ public: { this->m_h.relative = WAIT_TIME_RELATIVE; _cond_init(&this->m_h); - _mutex_init(&this->m_mutex); } ~CCondHandle() { Close(); } HRESULT Close() { - _mutex_destroy(&this->m_mutex); _cond_destroy(&this->m_h); - return S_OK; } - HRESULT Wait() { - _mutex_lock(&this->m_mutex); - _cond_wait(&this->m_h, &this->m_mutex); - _mutex_unlock(&this->m_mutex); - + _cond_wait(&this->m_h); return S_OK; } - HRESULT WaitTime(int sec) { - _mutex_lock(&this->m_mutex); - _cond_timedwait(&this->m_h, &this->m_mutex, sec); - _mutex_unlock(&this->m_mutex); - + _cond_timedwait(&this->m_h, sec); return S_OK; } HRESULT Signal() { - _mutex_lock(&this->m_mutex); _cond_signal(&this->m_h); - _mutex_unlock(&this->m_mutex); - return S_OK; } HRESULT Broadcast() { - _mutex_lock(&this->m_mutex); _cond_broadcast(&this->m_h); - _mutex_unlock(&this->m_mutex); - return S_OK; } public: _cond_t m_h; - _mutex_t m_mutex; }; #endif diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index f857d728..b06fa66b 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -11,7 +11,7 @@ #include "compat_event_kqueue.h" #endif -static int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) +int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, evevent op) { if (op == op_ev_connect) { oper->handler(op_ev_success, oper, oper, op_ev_connect); @@ -21,26 +21,12 @@ static int complete_op(int err, crterr code, evoper_t* oper, evoper_t* oper_s, e oper->handler(op_ev_success, oper, oper, op_ev_close); } else if (op == op_ev_accept) { oper->handler(op_ev_success, oper, oper_s, op_ev_accept); - } - - if (op == op_ev_read) { - if (oper->bt == ev_io_complete) { - oper->handler(op_ev_success, oper, oper, op_ev_read); - } else if (oper->bt == ev_func_complete) { - oper->handler(op_ev_success, oper, oper, op_ev_read); - } - } - - if (op == op_ev_write) { - if (oper->bt == ev_io_complete) { - oper->handler(op_ev_success, oper, oper, op_ev_write); - } else if (oper->bt == ev_func_complete) { - oper->handler(op_ev_success, oper, oper, op_ev_write); - } - } - - if (oper->t == ev_time && (op == op_ev_timer)) { - oper->handler(err, oper, oper, op_ev_timer); + } else if (op == op_ev_timer) { + oper->handler(op_ev_success, oper, oper, op_ev_timer); + } else if (op == op_ev_read) { + oper->handler(op_ev_success, oper, oper, op_ev_read); + } else if (op == op_ev_write) { + oper->handler(op_ev_success, oper, oper, op_ev_write); } return S_SUCCESS; @@ -85,6 +71,14 @@ static int evsysop_bind_handler(evloop_t* loop, evsysop_t* op) { return op->op_handler(loop, complete_op); } +buf_len evoper_rbyte(evoper_t* oper) +{ + return oper->rbuf.byte; +} +buf_len evoper_wbyte(evoper_t* oper) +{ + return oper->wbuf.byte; +} int evoper_read_buf(evoper_t* oper, buf_ptr buf, buf_len len) { rc_error(oper != NULL, S_ERROR); @@ -188,6 +182,9 @@ int evoper_pollsock(evoper_t* oper, const evaddr_t* addr, int listen) sock = _createsock(AF_INET, SOCK_STREAM, IPPROTO_TCP); rc_error(sock != INVALID_SOCKET, S_ERROR); + rc = set_nosigpipe(sock, 1); + rc_error(rc == S_SUCCESS, S_ERROR); + rc = _bind_stcpsockv4(sock, addr->ptr, addr->len, listen, addr->port & UINT_MAX); rc_error(rc == S_SUCCESS, S_ERROR); @@ -276,7 +273,7 @@ int evloop_add_timer(evloop_t* loop, evoper_t* oper, ev_time_t tv) evloop_addtime(loop->nodes, oper); return S_SUCCESS; } -int evloop_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int evloop_enable_read(evloop_t* loop, evoper_t* oper, short event, socklen_t size, ev_time_t tv) { rc_error(oper != NULL, S_MEMERROR); rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); @@ -292,9 +289,11 @@ int evloop_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv rc_error(evsel != NULL, S_ERROR); rc_error(evsel->op_enable_read != NULL, S_ERROR); + set_recvlowat(oper->sock, event == op_ev_level ? size : 1); + return evsel->op_enable_read(loop, oper, event, tv); } -int evloop_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) +int evloop_enable_write(evloop_t* loop, evoper_t* oper, short event, socklen_t size, ev_time_t tv) { rc_error(oper != NULL, S_MEMERROR); rc_error(evoper_connected(oper) == S_SUCCESS, S_CONNERROR); @@ -394,10 +393,9 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) rs_error(oper->conn == op_ev_connected, S_COMPLETED) evoper_connect_op(oper, op_ev_connecting); rc = evsel->op_add_connect(loop, oper, addr, tv); - rs_error(rc == S_PENDING, S_SUCCESS) + rs_error(rc == S_PENDING, S_SUCCESS); - if (rc == S_COMPLETED) - { + if (rc == S_COMPLETED) { complete_op(S_SUCCESS, 0, oper, oper, op_ev_connect); evoper_connect_op(oper, op_ev_connected); } @@ -426,6 +424,9 @@ int evloop_alloc_evoper(evloop_t* loop, evoper_t* oper) evoper_bind_evloop(oper, loop); + evbuf_init(&oper->rbuf); + evbuf_init(&oper->wbuf); + return evsel->op_alloc_evoper(loop, oper); } int evloop_dealloc_evoper(evloop_t* loop, evoper_t* oper) diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index 49e3af5c..22af3200 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -128,32 +128,32 @@ static int sys_hook_api(epoll_op_t* base) return S_SUCCESS; } -static uint32_t epoll_event_add(epoll_event_t* ptr, uint32_t op) +static uint32_t epoll_event_add(eevent_t* ptr, uint32_t op) { uint32_t event = 0; event = ptr->op; event |= op; return event; } -static uint32_t epoll_event_del(epoll_event_t* ptr, uint32_t op) +static uint32_t epoll_event_del(eevent_t* ptr, uint32_t op) { uint32_t event = 0; event = ptr->op; event &= ~op; return event; } -static uint32_t get_epoll_op(epoll_event_t* ptr) +static uint32_t get_epoll_op(eevent_t* ptr) { rc_error(ptr != NULL, S_ERROR); return ptr->op; } -static int set_epoll_op(epoll_event_t* ptr, uint32_t op) +static int set_epoll_op(eevent_t* ptr, uint32_t op) { rc_error(ptr != NULL, S_ERROR); ptr->op = op; return S_SUCCESS; } -static int epoll_op(epoll_op_t* base, evoper_t* oper, epoll_event_t* ptr, int op) +static int epoll_op(epoll_op_t* base, evoper_t* oper, eevent_t* ptr, int op) { struct epoll_event ee; ee.events = get_epoll_op(ptr); @@ -223,6 +223,8 @@ int epoll_alloc(evloop_t* loop, int size) base->poll = loop->mm_malloc(loop, base->size, sizeof(struct epoll_event)); if (base->poll == NULL) goto err; + + evloop_queue_init(&base->queue); return evloop_bind_evbase(loop, base); err: @@ -252,7 +254,7 @@ int epoll_alloc_evoper(evloop_t* loop, evoper_t* oper) epoll_op_t* base = (epoll_op_t*)evloop_evbase(loop); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)heap_calloc(1, sizeof(epoll_event_t)); + eevent_t* ptr = (eevent_t*)heap_calloc(1, sizeof(eevent_t)); rc_error(ptr != NULL, S_ERROR); evoper_bind_private(oper, ptr); @@ -271,7 +273,7 @@ int epoll_dealloc_evoper(evloop_t* loop, evoper_t* oper) rc_error(loop != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evloop_evbase(loop); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + eevent_t* ptr = (eevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); set_epoll_op(ptr, ev_clear_event); @@ -287,15 +289,14 @@ int epoll_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + eevent_t* ptr = (eevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); + // add epoll uint32_t op = epoll_event_add(ptr, ev_read_event); set_epoll_op(ptr, op); epoll_op(base, oper, ptr, EPOLL_CTL_MOD); - // recv - rc = posix_tcpsock_recv(oper, 0); - + return rc; } int epoll_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv) @@ -304,16 +305,18 @@ int epoll_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv rc_error(oper != NULL, S_ERROR); epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + eevent_t* ptr = (eevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - // add epoll - uint32_t op = epoll_event_add(ptr, ev_write_event); - set_epoll_op(ptr, op); - rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); - + // send - rc = posix_tcpsock_send(oper, 0); + rc = epoll_tcpsock_send(oper, S_SUCCESS, 0, base->ev); + if (rc == S_PENDING) { + // add epoll + uint32_t op = epoll_event_add(ptr, ev_write_event); + set_epoll_op(ptr, op); + rc = epoll_op(base, oper, ptr, EPOLL_CTL_MOD); + } return rc; } @@ -323,7 +326,7 @@ int epoll_disable_read(evloop_t* loop, evoper_t* oper, short event) epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + eevent_t* ptr = (eevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); uint32_t op = epoll_event_del(ptr, ev_read_event); @@ -337,7 +340,7 @@ int epoll_disable_write(evloop_t* loop, evoper_t* oper, short event) epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + eevent_t* ptr = (eevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); evoper_write_op(oper, op_ev_write); @@ -352,7 +355,7 @@ int epoll_cancel(evloop_t* loop, evoper_t* oper) epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + eevent_t* ptr = (eevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); set_epoll_op(ptr, ev_clear_event); @@ -369,7 +372,7 @@ int epoll_poll(evloop_t* loop, evoper_t* oper) epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + eevent_t* ptr = (eevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); set_epoll_op(ptr, ev_poll_event | ev_base_event); @@ -383,7 +386,7 @@ int epoll_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_t epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + eevent_t* ptr = (eevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); rc = evoper_sock_connect(oper, addr); @@ -402,7 +405,7 @@ int epoll_del_connect(evloop_t* loop, evoper_t* oper) epoll_op_t* base = (epoll_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - epoll_event_t* ptr = (epoll_event_t*)evoper_private(oper); + eevent_t* ptr = (eevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); uint32_t op = epoll_event_del(ptr, ev_conn_event); @@ -435,10 +438,9 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) oper = base->poll[n].data.ptr; rc_error_continue(oper != NULL); events = base->poll[n].events; - rc_error_continue(oper->fd != INVALID_SOCKET) + rc_error_continue(oper->fd != INVALID_SOCKET); - if (base->poll[n].data.fd == base->notify_fd) - { + if (base->poll[n].data.fd == base->notify_fd) { if (base->notify_handler(base) == S_EXIT) { break; } @@ -470,8 +472,8 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) continue; } - oper->bt = ev_io_complete; complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); + } if (events & EPOLLOUT) { if (oper->conn == op_ev_connecting) { @@ -479,7 +481,6 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) continue; } - oper->bt = ev_io_complete; complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); if (evoper_writeing(oper) == S_SUCCESS) @@ -538,5 +539,10 @@ int epoll_evop_t(evsysop_t* op) return S_SUCCESS; } - +int epollevop_set_oper(eevent_t* ptr, evoper_t* oper) +{ + ptr->oper = oper; + return S_SUCCESS; +} #endif + diff --git a/stdcrt/event/compat_event_epoll.h b/stdcrt/event/compat_event_epoll.h index 0ff42162..51f6e735 100644 --- a/stdcrt/event/compat_event_epoll.h +++ b/stdcrt/event/compat_event_epoll.h @@ -10,12 +10,16 @@ extern "C" { #if (TARGET_OS == OS_POSIX) -typedef struct epoll_event_s epoll_event_t; typedef struct epoll_op_s epoll_op_t; +typedef struct epoll_event_s eevent_t; struct epoll_event_s { int ctl; uint32_t op; + + evoper_t* oper; + evoper_queue queue; + evevent event; }; typedef int (*epoll_create_fn)(int); @@ -50,7 +54,7 @@ struct epoll_op_s { // notify->epoll 2.6.22 int notify_fd; - epoll_event_t notify_event; + eevent_t notify_event; base_notify_handler notify_handler; // op @@ -58,9 +62,13 @@ struct epoll_op_s { // mode uint32_t mode; + + _mutex_t lock; + evloop_queue_t queue; }; int epoll_evop_t(evsysop_t* op); +int epollevop_set_oper(eevent_t* ptr, evoper_t* oper); #endif diff --git a/stdcrt/event/compat_event_iocp.c b/stdcrt/event/compat_event_iocp.c index 4ecd5e6d..c95b1e44 100644 --- a/stdcrt/event/compat_event_iocp.c +++ b/stdcrt/event/compat_event_iocp.c @@ -3,9 +3,6 @@ #if (TARGET_OS == OS_WIN) -int sock_iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err, DWORD bytes); -int sock_iocp_err_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err); - void _waitsem_threadProc(void* obj) { iocp_op_t* base = NULL; @@ -44,10 +41,11 @@ static int iocp_hook_api(iocp_op_t* base) { // process==>kernel32.dll HMODULE hModule = load_windows_system_library_(TEXT("kernel32.dll")); - - rc_error(hModule != NULL, S_ERROR) base->iocp.CancelIo = (CancelIoPtr)GetProcAddress(hModule, "CancelIo"); + rc_error(hModule != NULL, S_ERROR); + base->iocp.CancelIo = (CancelIoPtr)GetProcAddress(hModule, "CancelIo"); base->iocp.CancelIoEx = (CancelIoExPtr)GetProcAddress(hModule, "CancelIoEx"); FreeLibrary(hModule); + return S_SUCCESS; } @@ -143,6 +141,8 @@ int iocp_alloc(evloop_t* loop, int size) if (rc != S_SUCCESS) goto err; + evloop_queue_init(&base->queue); + return evloop_bind_evbase(loop, base); err: @@ -260,7 +260,7 @@ int icop_del_connect(evloop_t* loop, evoper_t* oper) { return S_SUCCESS; } -static int poll_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) +static int sockpoll_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) { lpwsasock sock = NULL; int rc = 0; @@ -275,7 +275,7 @@ static int poll_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWO return complete_sock_accept(loop, S_SUCCESS, err, sock->accept_oper, sock->oper, base->ev); } -static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) +static int sock_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWORD err, DWORD bytes) { evoper_t* oper = NULL; int rc = 0; @@ -304,21 +304,22 @@ static int oper_handle(evloop_t* loop, iocp_op_t* base, lpevoper_ov oper_ov, DWO } if (oper_ov->r == ev_on && bytes) { - oper->bt = ev_io_complete; + + evoper_set_rbyte(oper, bytes); base->ev(0, err, oper, NULL, op_ev_read); oper_ov->r = ev_off; - if (evoper_reading(oper) == S_SUCCESS) - iocp_enable_read(loop, oper, op_ev_active, NULL); + iocp_enable_read(loop, oper, op_ev_level, NULL); } if (oper_ov->w == ev_on && bytes) { - oper->bt = ev_io_complete; + + evoper_set_wbyte(oper, bytes); base->ev(0, err, oper, NULL, op_ev_write); oper_ov->w = ev_off; - int rc = evoper_writeing(oper); - if (rc == S_SUCCESS) - iocp_enable_write(loop, oper, op_ev_active, NULL); + if (evoper_writeing(oper) == S_SUCCESS) + iocp_enable_write(loop, oper, op_ev_level, NULL); + } return S_SUCCESS; @@ -367,15 +368,12 @@ static int sock_iocp_err_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper } static int sock_iocp_handle(evloop_t* loop, iocp_op_t* base, evoper_ov* oper_ov, ULONG_PTR key, DWORD err, DWORD bytes) { - rc_error(oper_ov != NULL, S_ERROR) + rc_error(oper_ov != NULL, S_ERROR); - if (key == ev_sockpoll) - { - poll_handle(loop, base, oper_ov, err, bytes); - } - else if (key == ev_sock) - { - oper_handle(loop, base, oper_ov, err, bytes); + if (key == ev_sockpoll) { + sockpoll_handle(loop, base, oper_ov, err, bytes); + } else if (key == ev_sock) { + sock_handle(loop, base, oper_ov, err, bytes); } return S_SUCCESS; } diff --git a/stdcrt/event/compat_event_iocp.h b/stdcrt/event/compat_event_iocp.h index fc028dee..1f4adba1 100644 --- a/stdcrt/event/compat_event_iocp.h +++ b/stdcrt/event/compat_event_iocp.h @@ -96,6 +96,10 @@ typedef struct { crterr error; evevent r; evevent w; + + evoper_t* oper; + evoper_queue queue; + } evoper_ov, *lpevoper_ov; typedef struct { @@ -113,6 +117,9 @@ struct iocp_op_s { _cond_t waitcond; _mutex_t waitlock; ev_op ev; + + _mutex_t lock; + evloop_queue_t queue; }; int iocp_evop_t(evsysop_t* op); diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 5400f002..d322252a 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -14,23 +14,24 @@ #define ev_close_event EV_EOF #define ev_clear_event EV_CLEAR + #define kevent_add_op EV_ADD | EV_CLEAR #define kevent_del_op EV_DELETE | EV_CLEAR #define kevent_op_enable EV_ENABLE | EV_CLEAR #define kevent_op_disable EV_DISABLE | EV_CLEAR -static int set_kevent_ctl(kqueue_event_t* ptr, uint32_t ctl) +static int set_kevent_ctl(kevent_t* ptr, uint32_t ctl) { rc_error(ptr != NULL, S_ERROR); ptr->ctl = ctl; return S_SUCCESS; } -static uint32_t get_kevent_ctl(kqueue_event_t* ptr) +static uint32_t get_kevent_ctl(kevent_t* ptr) { return ptr->ctl; } -static int kqueue_op_ctl(kqueue_op_t* base, evoper_t* oper, kqueue_event_t* ptr, const struct timespec* tm, int op) +static int kqueue_op_ctl(kqueue_op_t* base, evoper_t* oper, kevent_t* ptr, const struct timespec* tm, int op) { int rc = 0; @@ -124,6 +125,9 @@ int kqueue_alloc(evloop_t* loop, int size) base->change = loop->mm_malloc(loop, base->size, sizeof(struct kevent)); if (base->poll == NULL) goto err; + + + evloop_queue_init(&base->queue); return evloop_bind_evbase(loop, base); @@ -150,7 +154,7 @@ int kqueue_alloc_evoper(evloop_t* loop, evoper_t* oper) rc_error(loop != NULL, S_ERROR); kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); rc_error(oper != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)loop->mm_malloc(loop, 1, sizeof(kqueue_event_t)); + kevent_t* ptr = (kevent_t*)loop->mm_malloc(loop, 1, sizeof(kevent_t)); rc_error(ptr != NULL, S_ERROR); evoper_bind_private(oper, ptr); @@ -170,7 +174,7 @@ int kqueue_dealloc_evoper(evloop_t* loop, evoper_t* oper) kqueue_op_t* base = (kqueue_op_t*)evloop_evbase(loop); rc_error(oper != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + kevent_t* ptr = (kevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); set_kevent_ctl(ptr, kevent_del_op | kevent_op_disable); @@ -186,7 +190,7 @@ int kqueue_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + kevent_t* ptr = (kevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); // add kqueue @@ -194,7 +198,7 @@ int kqueue_enable_read(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv kqueue_op_ctl(base, oper, ptr, NULL, ev_read_event); // recv - rc = mach_tcpsock_recv(oper, 0); + //rc = mach_tcpsock_recv(oper, 0); return S_SUCCESS; } @@ -204,16 +208,17 @@ int kqueue_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t t kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + kevent_t* ptr = (kevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); - // add kqueue - set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); - kqueue_op_ctl(base, oper, ptr, NULL, ev_write_event); - - // send - rc = mach_tcpsock_send(oper, 0); - + // send + rc = kqueue_tcpsock_send(oper, S_SUCCESS, 0, base->ev); + if (rc == S_PENDING) { + // add kqueue + set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); + kqueue_op_ctl(base, oper, ptr, NULL, ev_write_event); + } + return S_SUCCESS; } int kqueue_disable_read(evloop_t* loop, evoper_t* oper, short event) @@ -221,7 +226,7 @@ int kqueue_disable_read(evloop_t* loop, evoper_t* oper, short event) kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + kevent_t* ptr = (kevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); evoper_read_op(oper, op_ev_readed); @@ -236,7 +241,7 @@ int kqueue_disable_write(evloop_t* loop, evoper_t* oper, short event) kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + kevent_t* ptr = (kevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); evoper_write_op(oper, op_ev_writed); @@ -263,7 +268,7 @@ int kqueue_poll(evloop_t* loop, evoper_t* oper) kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + kevent_t* ptr = (kevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); @@ -277,7 +282,7 @@ int kqueue_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_ kqueue_op_t* base = (kqueue_op_t*)evoper_evbase(oper); rc_error(base != NULL, S_ERROR); - kqueue_event_t* ptr = (kqueue_event_t*)evoper_private(oper); + kevent_t* ptr = (kevent_t*)evoper_private(oper); rc_error(ptr != NULL, S_ERROR); rc = evoper_sock_connect(oper, addr); @@ -396,4 +401,9 @@ int kqueue_evop_t(evsysop_t* op) return S_SUCCESS; } +int keventt_set_oper(kevent_t* ptr, evoper_t* oper) +{ + ptr->oper = oper; + return S_SUCCESS; +} #endif diff --git a/stdcrt/event/compat_event_kqueue.h b/stdcrt/event/compat_event_kqueue.h index ca7ad8bf..8b821e86 100644 --- a/stdcrt/event/compat_event_kqueue.h +++ b/stdcrt/event/compat_event_kqueue.h @@ -11,10 +11,13 @@ extern "C" { #if (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) typedef struct kqueue_op_s kqueue_op_t; -typedef struct kevent_s kqueue_event_t; +typedef struct kevent_s kevent_t; struct kevent_s { uint32_t ctl; + evoper_t* oper; + evoper_queue queue; + evevent event; }; typedef int (*kqueue_fn)(void); @@ -29,10 +32,13 @@ struct kqueue_op_s { struct kevent* change; struct kevent notify_kev; ev_op ev; + _mutex_t lock; + evloop_queue_t queue; }; int kqueue_evop_t(evsysop_t* op); +int kevent_set_oper(kevent_t* ptr, evoper_t* oper); #endif diff --git a/stdcrt/event/compat_event_mach.c b/stdcrt/event/compat_event_mach.c index a1491748..3e7e0acf 100644 --- a/stdcrt/event/compat_event_mach.c +++ b/stdcrt/event/compat_event_mach.c @@ -10,29 +10,47 @@ int kqueue_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func) { int rc = S_SUCCESS; rc_error(oper != NULL, rc); - ssize_t n = 0; - int error = 0; - buf_ptr ptr = NULL; - buf_len len = 0; + for (;;) { + ssize_t n = 0; + int error = 0; + buf_ptr ptr = NULL; + buf_len len = 0; - while (n != -1) { rc = evbuf_get_buf(&oper->wbuf, &ptr); rc_error(rc != S_ERROR, S_ERROR); rc = evbuf_get_len(&oper->wbuf, &len); rc_error(rc != S_ERROR, S_ERROR); - n = send(oper->fd, ptr, len, 0); + /* + if use set_sendbuflen(oper->sock, 1); + order error + */ + + n = write(oper->fd, ptr, len); + error = (n == -1) ? errno : 0; + if (n > 0) { - func(error, code, oper, NULL, op_ev_write); + evoper_set_wbyte(oper, n); + evbuf_op_off(&oper->wbuf, n); + func(err, code, oper, oper, op_ev_write); } if (evoper_writeing(oper) == S_ERROR) break; - } + if (error != 0) { + if (error == EAGAIN) { + return S_PENDING; + } else if (error == EINTR) { + continue; + } else { + return S_ERROR; + } + } + } return rc; } @@ -40,10 +58,10 @@ int kqueue_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) { int rc = S_SUCCESS; rc_error(oper != NULL, rc); - ssize_t n = 0; - while (n != -1) { - int err = 0; + for (;;) { + ssize_t n = 0; + int error = 0; buf_ptr ptr = NULL; buf_len len = 0; @@ -53,107 +71,30 @@ int kqueue_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) rc = evbuf_get_len(&oper->rbuf, &len); rc_error(rc != S_ERROR, S_ERROR); - n = recv(oper->fd, ptr, len, 0); - err = (n == -1) ? errno : 0; + n = read(oper->fd, ptr, len); + + error = (n == -1) ? errno : 0; + if (n > 0) { + evoper_set_rbyte(oper, n); + evbuf_op_off(&oper->rbuf, n); func(err, code, oper, NULL, op_ev_read); } if (evoper_reading(oper) == S_ERROR) break; - } - return rc; -} - -int mach_tcpsock_send(evoper_t* oper, int flags) -{ - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->wbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->wbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - for (;;) { - int err = 0; - n = send(oper->fd, ptr, len, flags); - err = (n == -1) ? errno : 0; - - if (n > 0) { - evbuf_op_off(&oper->wbuf, n); - if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { - return S_COMPLETED; - } - return S_PENDING; - } - - if (err == EAGAIN) { - rc = S_PENDING; - goto end; - } else if (err == EINTR) { - // sync - } else { - rc = S_ERROR; - goto end; - } - } - return rc; -end: - return rc; -} - -int mach_tcpsock_recv(evoper_t* oper, int flags) -{ - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->rbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - rc = evbuf_get_len(&oper->rbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - for (;;) { - int err = 0; - n = recv(oper->fd, ptr, len, flags); - err = (n == -1) ? errno : 0; - if (n > 0) { - evbuf_op_off(&oper->rbuf, n); - if (is_evbuf_compelete(&oper->rbuf) == S_SUCCESS) { - rc = S_COMPLETED; - goto end; + if (error != 0) { + if (error == EAGAIN) { + return S_PENDING; + } else if (error == EINTR) { + continue; + } else { + return S_ERROR; } - rc = S_PENDING; - goto end; - } - - if (n == 0) { - evoper_close_op(oper, ev_on); - rc = S_ERROR; - goto end; - } - - if (err == EAGAIN) { - rc = S_PENDING; - goto end; - } else if (err == EINTR) { - // sync - } else { - rc = S_ERROR; - goto end; } } return rc; -end: - return rc; } #endif diff --git a/stdcrt/event/compat_event_mach.h b/stdcrt/event/compat_event_mach.h index 289cab08..83f9e373 100644 --- a/stdcrt/event/compat_event_mach.h +++ b/stdcrt/event/compat_event_mach.h @@ -11,8 +11,6 @@ extern "C" { int kqueue_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func); int kqueue_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func); -int mach_tcpsock_send(evoper_t* oper, int flags); -int mach_tcpsock_recv(evoper_t* oper, int flags); #endif diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index 89dec934..844b7930 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -8,153 +8,99 @@ int epoll_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func) { - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n = 0; - - int error = 0; - buf_ptr ptr = NULL; - buf_len len = 0; - - while (n != -1) { - rc = evbuf_get_buf(&oper->wbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->wbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - n = send(oper->fd, ptr, len, 0); - error = (n == -1) ? errno : 0; - if (n > 0) { - func(error, code, oper, NULL, op_ev_write); - } - - if (evoper_writeing(oper) == S_ERROR) - break; - } - - return rc; + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + + for (;;) { + + ssize_t n = 0; + int error = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->wbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->wbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + + /* + if use set_sendbuflen(oper->sock, 1); + order error + */ + + n = write(oper->fd, ptr, len); + + error = (n == -1) ? errno : 0; + + if (n > 0) { + evoper_set_wbyte(oper, n); + evbuf_op_off(&oper->wbuf, n); + func(err, code, oper, oper, op_ev_write); + } + + if (evoper_writeing(oper) == S_ERROR) + break; + + + if (error != 0) { + if(error == EAGAIN) { + return S_PENDING; + } else if (error == EINTR) { + continue; + } else { + return S_ERROR; + } + } + } + return rc; } int epoll_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) { - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n = 0; - - while (n != -1) { - int err = 0; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->rbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->rbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - n = recv(oper->fd, ptr, len, 0); - err = (n == -1) ? errno : 0; - if (n > 0) { - func(err, code, oper, NULL, op_ev_read); - } - - if (evoper_reading(oper) == S_ERROR) - break; - } - return rc; -} - -int posix_tcpsock_send(evoper_t* oper, int flags) -{ - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->wbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->wbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - for (;;) { - int err = 0; - n = send(oper->fd, ptr, len, flags); - err = (n == -1) ? errno : 0; - - if (n > 0) { - evbuf_op_off(&oper->wbuf, n); - if (is_evbuf_compelete(&oper->wbuf) == S_SUCCESS) { - return S_COMPLETED; - } - return S_PENDING; - } - - if (err == EAGAIN) { - rc = S_PENDING; - goto end; - } else if (err == EINTR) { - // sync - printf("error"); - - } else { - rc = S_ERROR; - goto end; - } - } - return rc; -end: - return rc; -} -int posix_tcpsock_recv(evoper_t* oper, int flags) -{ - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - ssize_t n; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->rbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->rbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - for (;;) { - int err = 0; - n = recv(oper->fd, ptr, len, flags); - err = (n == -1) ? errno : 0; - if (n > 0) { - evbuf_op_off(&oper->rbuf, n); - if (is_evbuf_compelete(&oper->rbuf) == S_SUCCESS) { - rc = S_COMPLETED; - goto end; - } - rc = S_PENDING; - goto end; - } - - if (n == 0) { - evoper_close_op(oper, ev_on); - rc = S_ERROR; - goto end; - } - - if (err == EAGAIN) { - rc = S_PENDING; - goto end; - } else if (err == EINTR) { - // sync - } else { - rc = S_ERROR; - goto end; - } - } - return rc; -end: - return rc; + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + + + for (;;) { + + ssize_t n = 0; + int error = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->rbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->rbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + n = read(oper->fd, ptr, len); + + error = (n == -1) ? errno : 0; + + if (n > 0) { + evoper_set_rbyte(oper, n); + evbuf_op_off(&oper->rbuf, n); + func(err, code, oper, NULL, op_ev_read); + } + + if (evoper_reading(oper) == S_ERROR) + break; + + if (error != 0) { + if(error == EAGAIN) { + return S_PENDING; + } else if (error == EINTR) { + continue; + } else { + return S_ERROR; + } + } + + } + return rc; } #endif diff --git a/stdcrt/event/compat_event_posix.h b/stdcrt/event/compat_event_posix.h index 57e83185..871c0332 100644 --- a/stdcrt/event/compat_event_posix.h +++ b/stdcrt/event/compat_event_posix.h @@ -11,8 +11,6 @@ extern "C" { int epoll_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func); int epoll_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func); -int posix_tcpsock_send(evoper_t* oper, int flags); -int posix_tcpsock_recv(evoper_t* oper, int flags); #endif diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index 22348319..b9e462a6 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -391,6 +391,18 @@ int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev } return S_SUCCESS; } +int evbuf_init(evbuf_t* buf) +{ + rc_error(buf != NULL, S_ERROR); + _mutex_init(&buf->lock); + return S_SUCCESS; +} +int evbuf_uninit(evbuf_t* buf) +{ + rc_error(buf != NULL, S_ERROR); + _mutex_unlock(&buf->lock); + return S_SUCCESS; +} int evbuf_is_eof(evbuf_t* buf) { rc_error(buf != NULL, S_ERROR); @@ -435,7 +447,11 @@ int evbuf_set_off(evbuf_t* buf, buf_len off) int evbuf_op_off(evbuf_t* buf, buf_len off) { rc_error(buf != NULL, S_ERROR); + + _mutex_lock(&buf->lock); buf->off += off; + _mutex_unlock(&buf->lock); + return S_SUCCESS; } int is_evbuf_compelete(evbuf_t* buf) @@ -443,6 +459,16 @@ int is_evbuf_compelete(evbuf_t* buf) rc_error(buf != NULL, S_ERROR); return buf->off == buf->len ? S_SUCCESS : S_ERROR; } +int evoper_set_rbyte(evoper_t* oper, buf_len byte) +{ + rc_error(oper != NULL, S_ERROR); + return oper->rbuf.byte = byte; +} +int evoper_set_wbyte(evoper_t* oper, buf_len byte) +{ + rc_error(oper != NULL, S_ERROR); + return oper->wbuf.byte = byte; +} int evs_init(evs_t* on) { rc_error(on != NULL, S_ERROR); diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index fed94e52..79905b17 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -73,6 +73,8 @@ struct evbuf_s { buf_ptr ptr; buf_len len; buf_len off; + buf_len byte; + _mutex_t lock; }; struct evoper_s { @@ -114,8 +116,6 @@ struct evoper_s { crterr code; evoper_queue queue; - - int bt; }; typedef int (*ev_op)(int err, crterr code, evoper_t* oper, evoper_t* accepet_oper, evevent op); @@ -219,6 +219,10 @@ int complete_sock_close(evloop_t* loop, int err, crterr code, evoper_t* oper, ev int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func); int complete_sock_write(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_op func); + +int evbuf_init(evbuf_t* buf); +int evbuf_uninit(evbuf_t* buf); + int evbuf_is_eof(evbuf_t* buf); int evbuf_bind(evbuf_t* buf, buf_ptr ptr, buf_len len, buf_len off); int evbuf_get_buf(evbuf_t* buf, buf_ptr* ptr); @@ -228,6 +232,8 @@ int evbuf_get_off(evbuf_t* buf, buf_len* off); int evbuf_set_off(evbuf_t* buf, buf_len off); int evbuf_op_off(evbuf_t* buf, buf_len off); int is_evbuf_compelete(evbuf_t* buf); +int evoper_set_rbyte(evoper_t* oper, buf_len byte); +int evoper_set_wbyte(evoper_t* oper, buf_len byte); int evs_init(evs_t* on); int evs_uninit(evs_t* on); diff --git a/stdcrt/thread/compat_cond.c b/stdcrt/thread/compat_cond.c index ef847600..86375433 100644 --- a/stdcrt/thread/compat_cond.c +++ b/stdcrt/thread/compat_cond.c @@ -73,23 +73,21 @@ int _cond_broadcast(_cond_t* cond) return S_SUCCESS; } -int _cond_wait(_cond_t* cond, _mutex_t* lock) +int _cond_wait(_cond_t* cond) { rc_error(cond != NULL, S_ERROR); - rc_error(lock != NULL, S_ERROR); - return _cond_timedwait(cond, lock, INFINITE); + return _cond_timedwait(cond, INFINITE); } -int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) +int _cond_timedwait(_cond_t* cond, unsigned long ms) { rc_error(cond != NULL, S_ERROR); - rc_error(lock != NULL, S_ERROR); unsigned long result = 0; int last_waiter; HANDLE handles[2] = {cond->wait_sem, cond->wait_done}; - _mutex_unlock(lock); + _mutex_unlock(&cond->lock); { _mutex_lock(&cond->lock); @@ -113,7 +111,7 @@ int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) } } - _mutex_lock(lock); + _mutex_lock(&cond->lock); if (result == WAIT_OBJECT_0 || result == WAIT_OBJECT_0 + 1) return S_SUCCESS; @@ -184,20 +182,18 @@ int _cond_broadcast(_cond_t* cond) return S_SUCCESS; } -int _cond_wait(_cond_t* cond, _mutex_t* lock) +int _cond_wait(_cond_t* cond) { rc_error(cond != NULL, S_ERROR); - rc_error(lock != NULL, S_ERROR); - if (pthread_cond_wait(&cond->c, &lock->mutex)) { + if (pthread_cond_wait(&cond->c, &cond->mutex)) { return S_ERROR; } return S_SUCCESS; } -int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) +int _cond_timedwait(_cond_t* cond, unsigned long ms) { rc_error(cond != NULL, S_ERROR); - rc_error(lock != NULL, S_ERROR); int rc; int retval; @@ -220,9 +216,9 @@ int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) } #if defined(__ANDROID_API__) && __ANDROID_API__ < 21 - rc = pthread_cond_timedwait_monotonic_np(&cond->c, &lock->mutex, &abstime); + rc = pthread_cond_timedwait_monotonic_np(&cond->c, &cond->mutex, &abstime); #else - rc = pthread_cond_timedwait(&cond->c, &lock->mutex, &abstime); + rc = pthread_cond_timedwait(&cond->c, &cond->mutex, &abstime); #endif if (rc == ETIMEDOUT) @@ -285,21 +281,19 @@ int _cond_broadcast(_cond_t* cond) return S_SUCCESS; } -int _cond_wait(_cond_t* cond, _mutex_t* lock) +int _cond_wait(_cond_t* cond) { rc_error(cond != NULL, S_ERROR); - rc_error(lock != NULL, S_ERROR); - if (pthread_cond_wait(&cond->c, &lock->mutex)) { + if (pthread_cond_wait(&cond->c, &cond->mutex)) { return S_ERROR; } return S_SUCCESS; } -int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) +int _cond_timedwait(_cond_t* cond, unsigned long ms) { rc_error(cond != NULL, S_ERROR); - rc_error(lock != NULL, S_ERROR); int rc; struct timespec abstime; @@ -326,7 +320,7 @@ int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) abstime.tv_nsec -= 1000000000; } - rc = pthread_cond_timedwait_relative_np(&cond->c, &lock->mutex, &abstime); + rc = pthread_cond_timedwait_relative_np(&cond->c, &cond->mutex, &abstime); if (rc == ETIMEDOUT) return S_TIMEOUT; @@ -398,20 +392,18 @@ int _cond_broadcast(_cond_t* cond) return S_SUCCESS; } -int _cond_wait(_cond_t* cond, _mutex_t* lock) +int _cond_wait(_cond_t* cond) { rc_error(cond != NULL, S_ERROR); - rc_error(lock != NULL, S_ERROR); - if (pthread_cond_wait(&cond->c, &lock->mutex)) { + if (pthread_cond_wait(&cond->c, &cond->mutex)) { return S_ERROR; } return S_SUCCESS; } -int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) +int _cond_timedwait(_cond_t* cond, unsigned long ms) { rc_error(cond != NULL, S_ERROR); - rc_error(lock != NULL, S_ERROR); int rc; int retval; @@ -433,7 +425,7 @@ int _cond_timedwait(_cond_t* cond, _mutex_t* lock, unsigned long ms) abstime.tv_nsec -= 1000000000; } - rc = pthread_cond_timedwait(&cond->c, &lock->mutex, &abstime); + rc = pthread_cond_timedwait(&cond->c, &cond->mutex, &abstime); if (rc == ETIMEDOUT) return S_TIMEOUT; diff --git a/stdcrt_test/test_oper.c b/stdcrt_test/test_oper.c index dc0a0573..6e4281b2 100644 --- a/stdcrt_test/test_oper.c +++ b/stdcrt_test/test_oper.c @@ -7,7 +7,7 @@ evoper_t* w_oper; evoper_t* r_oper; evoper_t* accept_oper; -#define buf_len 1 +#define d_buf_len 2 unsigned char* send_data; unsigned char* recv_data; @@ -31,7 +31,7 @@ void thread_proc1(void* ctx) } void thread_proc2(void* ctx) { - _cond_wait(&r_cond, &r_mutex); + _cond_wait(&r_cond); test_read_oper(loop); while (1) { sleep_time(10); @@ -40,7 +40,7 @@ void thread_proc2(void* ctx) void thread_proc3(void* ctx) { - _cond_wait(&w_cond, &w_mutex); + _cond_wait(&w_cond); sleep_time(10); test_write_oper(loop); while (1) { @@ -54,8 +54,8 @@ void thread_proc4(void* ctx) iwrite = 0; iread = 0; s_memset(recv_data, 0x00, 4096); - evoper_read_buf(r_oper, (buf_ptr)recv_data, buf_len); - evloop_enable_read(loop, r_oper, op_ev_active, NULL); + evoper_read_buf(r_oper, (buf_ptr)recv_data, d_buf_len); + evloop_enable_read(loop, r_oper, op_ev_level, 0, NULL); test_write_oper(loop); while (1) { sleep_time(15); @@ -65,10 +65,7 @@ void thread_proc4(void* ctx) void test_init_evaddr() { _cond_init(&r_cond); - _mutex_init(&r_mutex); - _cond_init(&w_cond); - _mutex_init(&w_mutex); evloop_alloc(&loop, NULL, loop_alloc); evloop_init(loop, 1024, 0); @@ -113,16 +110,21 @@ int evop_proc(evevent res, evoper_t* oper, evoper_t* oper_s, evevent event) } else if (event == op_ev_close && res == op_ev_success) { logi("close_connect"); } else if (event == op_ev_write && res == op_ev_success) { - iwrite++; - buf_ptr s = send_data + iwrite; - evoper_write_buf(oper, s, buf_len); + + buf_len len = evoper_wbyte(oper); + + iwrite = iwrite + d_buf_len; + + evoper_write_buf(oper, send_data + iwrite, d_buf_len); if (iwrite == 10) evloop_disable_write(loop, oper); } else if (event == op_ev_read && res == op_ev_success) { - iread++; - logi("read string:%s=%d\n", recv_data, iread); - evoper_read_buf(oper, (buf_ptr)recv_data + iread, buf_len); + + buf_len len = evoper_rbyte(oper); + iread = iread + d_buf_len; + logi("read string:%s = %d\n", recv_data, iread); + evoper_read_buf(oper, (buf_ptr)recv_data + iread, d_buf_len); if (iread == 10) evloop_disable_read(loop, oper); } @@ -158,14 +160,14 @@ void test_conn_oper(evloop_t* loop) void test_write_oper(evloop_t* loop) { int rc = 0; - s_strncpy(send_data, "hello,hello", 11); + s_strncpy(send_data, "hello,world", 11); - rc = evoper_write_buf(w_oper, (buf_ptr)send_data, buf_len); + rc = evoper_write_buf(w_oper, (buf_ptr)send_data, d_buf_len); if (rc != S_SUCCESS) { logi("evoper_write"); } - rc = evloop_enable_write(loop, w_oper, op_ev_oneshot, NULL); + rc = evloop_enable_write(loop, w_oper, op_ev_level, 0, NULL); if (rc != S_SUCCESS) { if (rc == S_COMPLETED) { @@ -177,7 +179,7 @@ void test_write_oper(evloop_t* loop) void test_read_oper(evloop_t* loop) { int rc = 0; - rc = evoper_read_buf(r_oper, (buf_ptr)recv_data, buf_len); + rc = evoper_read_buf(r_oper, (buf_ptr)recv_data, d_buf_len); if (rc != S_SUCCESS) { logi("evoper_read"); } @@ -187,7 +189,7 @@ void test_read_oper(evloop_t* loop) logi("evoper_bind_handler"); } - rc = evloop_enable_read(loop, r_oper, op_ev_active, NULL); + rc = evloop_enable_read(loop, r_oper, op_ev_level, d_buf_len, NULL); if (rc != S_SUCCESS) { if (rc == S_COMPLETED) { -- Gitee From 771fbfed4c794e5990ec10c3dffbebcb31796bda Mon Sep 17 00:00:00 2001 From: com Date: Thu, 15 Aug 2024 17:58:40 +0800 Subject: [PATCH 24/34] up --- stdcrt/code/compat_sjson.c | 2 +- stdcrt/event/compat_event.c | 2 +- stdcrt/event/compat_event_kqueue.c | 4 +--- stdcrt/net/compat_sock.c | 2 +- stdcrt/thread/compat_cond.c | 21 +++++++++++++++++++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/stdcrt/code/compat_sjson.c b/stdcrt/code/compat_sjson.c index 9d91d92f..0fd23b50 100644 --- a/stdcrt/code/compat_sjson.c +++ b/stdcrt/code/compat_sjson.c @@ -204,7 +204,7 @@ static int print_int64(sjsoncvptr item, sjsonprintvptr output_buffer) #if (TARGET_OS == OS_WIN) length = sprintf((char*)number_buffer, fmt_i64d, d); #else - length = sprintf((char*)number_buffer, "%" PRId64, d); + length = s_snprintf((char*)number_buffer, "%" PRId64, d); #endif if (length < 0) { diff --git a/stdcrt/event/compat_event.c b/stdcrt/event/compat_event.c index b06fa66b..b65ef154 100644 --- a/stdcrt/event/compat_event.c +++ b/stdcrt/event/compat_event.c @@ -396,8 +396,8 @@ int evloop_add_connect(evoper_t* oper, const evaddr_t* addr, ev_time_t tv) rs_error(rc == S_PENDING, S_SUCCESS); if (rc == S_COMPLETED) { - complete_op(S_SUCCESS, 0, oper, oper, op_ev_connect); evoper_connect_op(oper, op_ev_connected); + complete_op(S_SUCCESS, 0, oper, oper, op_ev_connect); } return rc; diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index d322252a..85b95c1b 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -292,7 +292,7 @@ int kqueue_add_connect(evloop_t* loop, evoper_t* oper, const evaddr_t* addr, ev_ kqueue_op_ctl(base, oper, ptr, NULL, ev_conn_event); } - return S_SUCCESS; + return rc; } int kqueue_del_connect(evloop_t* loop, evoper_t* oper) { @@ -332,7 +332,6 @@ static int kqueue_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) continue; } - oper->bt = ev_io_complete; complete_sock_read(loop, S_SUCCESS, err, oper, base->ev); continue; } @@ -342,7 +341,6 @@ static int kqueue_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) complete_sock_connect(loop, S_SUCCESS, err, oper, base->ev); continue; } - oper->bt = ev_io_complete; complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); if (evoper_writeing(oper) == S_SUCCESS) diff --git a/stdcrt/net/compat_sock.c b/stdcrt/net/compat_sock.c index d677de9c..0118319a 100644 --- a/stdcrt/net/compat_sock.c +++ b/stdcrt/net/compat_sock.c @@ -169,7 +169,7 @@ int _asynconnect_sock(_sock_t s, SOCKADDR_PTR sa, socklen_t socklen) } else { // The connect succeeded - return S_SUCCESS; + return S_COMPLETED; } return S_ERROR; diff --git a/stdcrt/thread/compat_cond.c b/stdcrt/thread/compat_cond.c index 86375433..c44a7b31 100644 --- a/stdcrt/thread/compat_cond.c +++ b/stdcrt/thread/compat_cond.c @@ -185,6 +185,9 @@ int _cond_broadcast(_cond_t* cond) int _cond_wait(_cond_t* cond) { rc_error(cond != NULL, S_ERROR); + + pthread_mutex_lock(&cond->mutex); + if (pthread_cond_wait(&cond->c, &cond->mutex)) { return S_ERROR; } @@ -215,6 +218,8 @@ int _cond_timedwait(_cond_t* cond, unsigned long ms) abstime.tv_nsec -= 1000000000; } + rc = pthread_mutex_lock(&cond->mutex); + #if defined(__ANDROID_API__) && __ANDROID_API__ < 21 rc = pthread_cond_timedwait_monotonic_np(&cond->c, &cond->mutex, &abstime); #else @@ -284,6 +289,9 @@ int _cond_broadcast(_cond_t* cond) int _cond_wait(_cond_t* cond) { rc_error(cond != NULL, S_ERROR); + + pthread_mutex_lock(&cond->mutex); + if (pthread_cond_wait(&cond->c, &cond->mutex)) { return S_ERROR; } @@ -320,6 +328,8 @@ int _cond_timedwait(_cond_t* cond, unsigned long ms) abstime.tv_nsec -= 1000000000; } + rc = pthread_mutex_lock(&cond->mutex); + rc = pthread_cond_timedwait_relative_np(&cond->c, &cond->mutex, &abstime); if (rc == ETIMEDOUT) @@ -345,6 +355,7 @@ int _cond_init(_cond_t* cond) if (cond->relative) { int ret = 0; ret = pthread_condattr_init(&cond->attr); + ret = pthread_condattr_setclock(&cond->attr, CLOCK_MONOTONIC); if (pthread_cond_init(&cond->c, &cond->attr)) { @@ -392,9 +403,16 @@ int _cond_broadcast(_cond_t* cond) return S_SUCCESS; } +/* +https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/lib/librthread/Attic/rthread_cond.c?rev=1.3&content-type=text/plain +*/ + int _cond_wait(_cond_t* cond) { rc_error(cond != NULL, S_ERROR); + + pthread_mutex_lock(&cond->mutex); + if (pthread_cond_wait(&cond->c, &cond->mutex)) { return S_ERROR; } @@ -425,6 +443,9 @@ int _cond_timedwait(_cond_t* cond, unsigned long ms) abstime.tv_nsec -= 1000000000; } + + rc = pthread_mutex_lock(&cond->mutex); + rc = pthread_cond_timedwait(&cond->c, &cond->mutex, &abstime); if (rc == ETIMEDOUT) -- Gitee From 5658db2899d0d583001379e20aa0aeaede3614ad Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Thu, 15 Aug 2024 18:16:50 +0800 Subject: [PATCH 25/34] up --- container/objectrun.cpp | 5 +++++ crt/crt_common.hpp | 10 ++++++++++ include/utilex/plus.hpp | 3 +++ include/utilex/safeptr.hpp | 16 ++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/container/objectrun.cpp b/container/objectrun.cpp index b0c98d5c..9bfb0e01 100644 --- a/container/objectrun.cpp +++ b/container/objectrun.cpp @@ -720,6 +720,11 @@ path_string CObjectRunImpl::ContainerPath(LPCSTR ComponentName) basic_tchar szPluginName[DYNAMIC_NAME_LEN + 1] = {0x00}; get_dynamicname(ComponentName, szPluginName, DYNAMIC_NAME_LEN); +#elif (TARGET_OS == OS_UNIX) + + basic_tchar szPluginName[DYNAMIC_NAME_LEN + 1] = {0x00}; + get_dynamicname(ComponentName, szPluginName, DYNAMIC_NAME_LEN); + #endif stringpath += szPluginName; diff --git a/crt/crt_common.hpp b/crt/crt_common.hpp index 626a9236..fdda4c5c 100644 --- a/crt/crt_common.hpp +++ b/crt/crt_common.hpp @@ -47,6 +47,10 @@ typedef long _off_t; #define _unused __attribute__((__unused__)) #define _VISIBILITY_DEFAULT __attribute__((visibility("default"))) #define _VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) +#elif (TARGET_OS == OS_UNIX) +#define _unused __attribute__((__unused__)) +#define _VISIBILITY_DEFAULT __attribute__((visibility("default"))) +#define _VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) #endif #if (TARGET_OS == OS_WIN) @@ -55,6 +59,8 @@ typedef long _off_t; #define path_slash _T("/") #elif (TARGET_OS == OS_MACH) #define path_slash _T("/") +#elif (TARGET_OS == OS_UNIX) +#define path_slash _T("/") #endif #ifdef __cplusplus @@ -109,6 +115,10 @@ typedef long _off_t; #define OS_STDCALL #define OS_CALLBACK_(_type, _name) _type(OS_STDCALL* _name) #define _stdmethod_export(type, method) EXTERN_C type _VISIBILITY_DEFAULT method +#elif (TARGET_OS == OS_UNIX) +#define OS_STDCALL +#define OS_CALLBACK_(_type, _name) _type(OS_STDCALL* _name) +#define _stdmethod_export(type, method) EXTERN_C type _VISIBILITY_DEFAULT method #endif typedef unsigned char u_char; diff --git a/include/utilex/plus.hpp b/include/utilex/plus.hpp index 8a2a9c15..0a49ae54 100644 --- a/include/utilex/plus.hpp +++ b/include/utilex/plus.hpp @@ -20,6 +20,9 @@ typedef std::string path_string; #elif (TARGET_OS == OS_MACH) typedef std::string basestring; typedef std::string path_string; +#elif (TARGET_OS == OS_UNIX) +typedef std::string basestring; +typedef std::string path_string; #endif #endif diff --git a/include/utilex/safeptr.hpp b/include/utilex/safeptr.hpp index a8076a14..7e0d03f0 100644 --- a/include/utilex/safeptr.hpp +++ b/include/utilex/safeptr.hpp @@ -199,6 +199,22 @@ struct hmodule_safeptr { #define DynamiclibPtr SafePtr + +#elif (TARGET_OS == OS_UNIX) + +struct hmodule_safeptr { + static HMODULE default_value() { return 0; } + static bool equal_to(HMODULE l, HMODULE r) { return l == r; } + static void destroy(HMODULE h) + { + if (h) + dlclose(h); + } +}; + +#define DynamiclibPtr SafePtr + + #endif #endif -- Gitee From 47db0294a203b5ebda6929d1f05e0746d2305b7e Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Thu, 15 Aug 2024 18:27:45 +0800 Subject: [PATCH 26/34] up --- container/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/container/CMakeLists.txt b/container/CMakeLists.txt index 289801b7..01ecc46a 100644 --- a/container/CMakeLists.txt +++ b/container/CMakeLists.txt @@ -38,7 +38,15 @@ else() set_target_properties(container PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(container PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(container dl) + + if(${LINUX_OS}) + target_link_libraries(container dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(container) + endif() + endif() -- Gitee From ceb200e092d58283fd7cc05c51c616cd17a5d8bf Mon Sep 17 00:00:00 2001 From: com Date: Thu, 15 Aug 2024 18:36:06 +0800 Subject: [PATCH 27/34] up --- access/CMakeLists.txt | 10 +++++++++- asynio/CMakeLists.txt | 9 ++++++++- configure/CMakeLists.txt | 9 ++++++++- container/CMakeLists.txt | 2 -- dispatch/CMakeLists.txt | 10 +++++++++- license/CMakeLists.txt | 10 +++++++++- logs/CMakeLists.txt | 10 +++++++++- main/CMakeLists.txt | 8 +++++++- mainview/CMakeLists.txt | 9 ++++++++- msgbus/CMakeLists.txt | 9 ++++++++- net/CMakeLists.txt | 9 ++++++++- plugin/CMakeLists.txt | 8 +++++++- runtime/CMakeLists.txt | 9 ++++++++- testmain/CMakeLists.txt | 9 ++++++++- uibase/CMakeLists.txt | 10 +++++++++- 15 files changed, 115 insertions(+), 16 deletions(-) diff --git a/access/CMakeLists.txt b/access/CMakeLists.txt index b123d424..b3ff5cc8 100644 --- a/access/CMakeLists.txt +++ b/access/CMakeLists.txt @@ -36,7 +36,15 @@ else() set_target_properties(access PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(access PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(access dl) + if(${LINUX_OS}) + target_link_libraries(access dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(access) + endif() + + endif() diff --git a/asynio/CMakeLists.txt b/asynio/CMakeLists.txt index 2acecffb..89aa8c52 100644 --- a/asynio/CMakeLists.txt +++ b/asynio/CMakeLists.txt @@ -41,7 +41,14 @@ else() set_target_properties(asynio PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(asynio PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(asynio dl) + if(${LINUX_OS}) + target_link_libraries(asynio dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(asynio) + endif() + endif() diff --git a/configure/CMakeLists.txt b/configure/CMakeLists.txt index e25acce2..06223221 100644 --- a/configure/CMakeLists.txt +++ b/configure/CMakeLists.txt @@ -31,7 +31,14 @@ else() set_target_properties(configure PROPERTIES COMPILE_FLAGS ${dynamic}) set_target_properties(configure PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(configure PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(configure dl) + + if(${LINUX_OS}) + target_link_libraries(configure dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(configure) + endif() endif() diff --git a/container/CMakeLists.txt b/container/CMakeLists.txt index 01ecc46a..c28a170f 100644 --- a/container/CMakeLists.txt +++ b/container/CMakeLists.txt @@ -38,7 +38,6 @@ else() set_target_properties(container PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(container PROPERTIES LINK_FLAGS ${r_path}) - if(${LINUX_OS}) target_link_libraries(container dl) endif() @@ -47,7 +46,6 @@ else() target_link_libraries(container) endif() - endif() diff --git a/dispatch/CMakeLists.txt b/dispatch/CMakeLists.txt index cdbe1b66..5eb54a1a 100644 --- a/dispatch/CMakeLists.txt +++ b/dispatch/CMakeLists.txt @@ -42,6 +42,14 @@ set_target_properties(dispatch PROPERTIES COMPILE_FLAGS ${dynamic}) set_target_properties(dispatch PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(dispatch PROPERTIES LINK_FLAGS ${r_path}) -target_link_libraries(dispatch dl stdcrt) +if(${LINUX_OS}) + target_link_libraries(dispatch dl stdcrt) +endif() + +if(${UNIX_OS}) + target_link_libraries(dispatch stdcrt) +endif() + + diff --git a/license/CMakeLists.txt b/license/CMakeLists.txt index 3369fca6..23a09b3b 100644 --- a/license/CMakeLists.txt +++ b/license/CMakeLists.txt @@ -31,7 +31,15 @@ else() set_target_properties(license PROPERTIES COMPILE_FLAGS ${dynamic}) set_target_properties(license PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(license PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(license dl) + + if(${LINUX_OS}) + target_link_libraries(license dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(license) + endif() + endif() diff --git a/logs/CMakeLists.txt b/logs/CMakeLists.txt index bd1baf4a..213689be 100644 --- a/logs/CMakeLists.txt +++ b/logs/CMakeLists.txt @@ -34,7 +34,15 @@ else() set_target_properties(logs PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(logs PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(logs dl) + + if(${LINUX_OS}) + target_link_libraries(logs dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(logs) + endif() + endif() diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 2384f26c..4fc02bcc 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -29,7 +29,13 @@ else() set_target_properties(main PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(main PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(main dl) + if(${LINUX_OS}) + target_link_libraries(main dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(main) + endif() endif() diff --git a/mainview/CMakeLists.txt b/mainview/CMakeLists.txt index 0e67d043..7c16e38b 100644 --- a/mainview/CMakeLists.txt +++ b/mainview/CMakeLists.txt @@ -32,7 +32,14 @@ else() set_target_properties(mainview PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(mainview PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(mainview dl) + if(${LINUX_OS}) + target_link_libraries(mainview dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(mainview) + endif() + endif() diff --git a/msgbus/CMakeLists.txt b/msgbus/CMakeLists.txt index 759a31b9..0367cca5 100644 --- a/msgbus/CMakeLists.txt +++ b/msgbus/CMakeLists.txt @@ -33,7 +33,14 @@ else() set_target_properties(msgbus PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(msgbus PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(msgbus dl) + if(${LINUX_OS}) + target_link_libraries(msgbus dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(msgbus) + endif() + endif() diff --git a/net/CMakeLists.txt b/net/CMakeLists.txt index 37f7b118..f4f92a61 100644 --- a/net/CMakeLists.txt +++ b/net/CMakeLists.txt @@ -50,7 +50,14 @@ else() set_target_properties(net PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(net PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(net dl) + if(${LINUX_OS}) + target_link_libraries(net dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(net) + endif() + endif() diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index 9d9ab487..0a82c4e7 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -34,7 +34,13 @@ else() set_target_properties(plugin PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(plugin PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(plugin dl) + if(${LINUX_OS}) + target_link_libraries(plugin dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(plugin) + endif() endif() diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 18b3dba7..fb99fd52 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -34,7 +34,14 @@ else() set_target_properties(runtime PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(runtime PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(runtime dl) + if(${LINUX_OS}) + target_link_libraries(runtime dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(runtime) + endif() + endif() diff --git a/testmain/CMakeLists.txt b/testmain/CMakeLists.txt index 876a2b00..3e6d4f9e 100644 --- a/testmain/CMakeLists.txt +++ b/testmain/CMakeLists.txt @@ -37,7 +37,14 @@ else() set_target_properties(testmain PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(testmain PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(testmain dl) + if(${LINUX_OS}) + target_link_libraries(testmain dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(testmain) + endif() + endif() diff --git a/uibase/CMakeLists.txt b/uibase/CMakeLists.txt index d84dc68e..499526f0 100644 --- a/uibase/CMakeLists.txt +++ b/uibase/CMakeLists.txt @@ -59,7 +59,15 @@ else() set_target_properties(uibase PROPERTIES COMPILE_FLAGS ${compile}) set_target_properties(uibase PROPERTIES LINK_FLAGS ${r_path}) - target_link_libraries(uibase dl) + if(${LINUX_OS}) + target_link_libraries(uibase dl) + endif() + + if(${UNIX_OS}) + target_link_libraries(uibase) + endif() + + endif() -- Gitee From d3b941ef0624ed7badc1c7f0645b815957f4a0b2 Mon Sep 17 00:00:00 2001 From: com Date: Thu, 15 Aug 2024 18:43:54 +0800 Subject: [PATCH 28/34] up --- extensions/include/net/inet.h | 4 ++-- main/main.cpp | 6 ++++++ net/netimpl.cpp | 2 +- net/netimpl.h | 2 +- stdcom_tool/main.cpp | 7 +++++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/extensions/include/net/inet.h b/extensions/include/net/inet.h index 1827d966..983a83d0 100644 --- a/extensions/include/net/inet.h +++ b/extensions/include/net/inet.h @@ -16,11 +16,11 @@ typedef enum TagNetProtocol { protocol_https_s = 111, protocol_websocket = 150 -} Net_Protocol; +} INetProtocol; interface INet : public IBase { - std_method(CreateProtocol)(Net_Protocol netp, IBase** pBase) PURE; + std_method(CreateProtocol)(INetProtocol netp, IBase * *pBase) PURE; }; // {7EB8185F-0F4E-4420-9991-B70671967377} diff --git a/main/main.cpp b/main/main.cpp index 3147a4f7..1bed0306 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -132,6 +132,12 @@ int main(int argc, char* argv[]) _pid_t pid = get_processid(); return main_t(pid, argc, argv); } +#elif (TARGET_OS == OS_UNIX) +int main(int argc, char* argv[]) +{ + _pid_t pid = get_processid(); + return main_t(pid, argc, argv); +} #elif (TARGET_OS == OS_WIN) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) diff --git a/net/netimpl.cpp b/net/netimpl.cpp index f54b10e1..8f4d73e5 100644 --- a/net/netimpl.cpp +++ b/net/netimpl.cpp @@ -44,7 +44,7 @@ HRESULT CNetImpl::Stop(unsigned int exit) return hr; } -HRESULT CNetImpl::CreateProtocol(Net_Protocol netp, IBase** pBase) +HRESULT CNetImpl::CreateProtocol(INetProtocol netp, IBase** pBase) { rc_error(m_pIAsynFrame.m_p != INULL, E_FAIL); diff --git a/net/netimpl.h b/net/netimpl.h index c5dbf0da..84381359 100644 --- a/net/netimpl.h +++ b/net/netimpl.h @@ -25,7 +25,7 @@ public: std_method(Stop)(unsigned int exit); // INet - std_method(CreateProtocol)(Net_Protocol netp, IBase** pBase); + std_method(CreateProtocol)(INetProtocol netp, IBase** pBase); private: _lComPtr m_pRot; diff --git a/stdcom_tool/main.cpp b/stdcom_tool/main.cpp index a575d159..eaf30c13 100644 --- a/stdcom_tool/main.cpp +++ b/stdcom_tool/main.cpp @@ -71,6 +71,13 @@ int main(int argc, char* argv[]) #elif (TARGET_OS == OS_MACH) +int main(int argc, char* argv[]) +{ + _pid_t pid = get_processid(); + return main_t(pid, argc, argv); +} +#elif (TARGET_OS == OS_UNIX) + int main(int argc, char* argv[]) { _pid_t pid = get_processid(); -- Gitee From acbddbf1ba0a42a9042efb7b97258d9ae157bec5 Mon Sep 17 00:00:00 2001 From: com Date: Thu, 15 Aug 2024 19:13:12 +0800 Subject: [PATCH 29/34] up --- extensions/include/net/inet.h | 6 +++--- net/httpimpl.cpp | 2 +- net/netimpl.cpp | 2 +- net/netimpl.h | 2 +- testmain/appviewimpl.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/include/net/inet.h b/extensions/include/net/inet.h index 983a83d0..3959665d 100644 --- a/extensions/include/net/inet.h +++ b/extensions/include/net/inet.h @@ -4,7 +4,7 @@ #include #include -typedef enum TagNetProtocol { +enum NetProtocol { protocol_base = 0, protocol_dns = 2, @@ -16,11 +16,11 @@ typedef enum TagNetProtocol { protocol_https_s = 111, protocol_websocket = 150 -} INetProtocol; +}; interface INet : public IBase { - std_method(CreateProtocol)(INetProtocol netp, IBase * *pBase) PURE; + std_method(Create)(NetProtocol netp, IBase * *pBase) PURE; }; // {7EB8185F-0F4E-4420-9991-B70671967377} diff --git a/net/httpimpl.cpp b/net/httpimpl.cpp index 17a0b871..be066730 100644 --- a/net/httpimpl.cpp +++ b/net/httpimpl.cpp @@ -19,7 +19,7 @@ HRESULT CHttpIImpl::init_class(const _lComPtr& AsynFrame, const _lCo hr = AsynFrame->CreateIo(io_tcp_ssl_socket, (IBase**)&pISocket.m_p); rc_error(hr == S_OK, E_FAIL); - hr = Net->CreateProtocol(protocol_dns, (IBase**)&m_pIDns); + hr = Net->Create(protocol_dns, (IBase**)&m_pIDns); rc_error(hr == S_OK, E_FAIL); /* diff --git a/net/netimpl.cpp b/net/netimpl.cpp index 8f4d73e5..2ef26859 100644 --- a/net/netimpl.cpp +++ b/net/netimpl.cpp @@ -44,7 +44,7 @@ HRESULT CNetImpl::Stop(unsigned int exit) return hr; } -HRESULT CNetImpl::CreateProtocol(INetProtocol netp, IBase** pBase) +HRESULT CNetImpl::Create(NetProtocol netp, IBase** pBase) { rc_error(m_pIAsynFrame.m_p != INULL, E_FAIL); diff --git a/net/netimpl.h b/net/netimpl.h index 84381359..c1adb211 100644 --- a/net/netimpl.h +++ b/net/netimpl.h @@ -25,7 +25,7 @@ public: std_method(Stop)(unsigned int exit); // INet - std_method(CreateProtocol)(INetProtocol netp, IBase** pBase); + std_method(Create)(NetProtocol netp, IBase** pBase); private: _lComPtr m_pRot; diff --git a/testmain/appviewimpl.cpp b/testmain/appviewimpl.cpp index 1a3dbc45..a666c611 100644 --- a/testmain/appviewimpl.cpp +++ b/testmain/appviewimpl.cpp @@ -30,7 +30,7 @@ HRESULT CAppViewImpl::Start(_pid_t pid, unsigned int type) m_pRot->GetObject(CLSID_INet, IID_INet, (IBase**)&pINet.m_p); rc_error(pINet.m_p != INULL, E_FAIL); - hr = pINet->CreateProtocol(protocol_modbus, (IBase**)&m_pIModBus); + hr = pINet->Create(protocol_modbus, (IBase**)&m_pIModBus); rc_error(hr == S_OK, E_FAIL); // m_pIHttp->Release(); -- Gitee From 7aad270d73624103a6a005ba1b95e47bac8084a5 Mon Sep 17 00:00:00 2001 From: com Date: Fri, 16 Aug 2024 10:31:00 +0800 Subject: [PATCH 30/34] up --- crt/crt_common.hpp | 10 --- extensions/include/net/idns.h | 27 ------- extensions/include/net/imodbus.h | 33 -------- extensions/include/net/inet.h | 76 ++++++++++++++++-- extensions/include/net/issh.h | 14 ---- extensions/include/net/iwebsocket.h | 7 -- net/dllmain.cpp | 4 +- net/httpimpl.cpp | 2 +- net/httpimpl.h | 2 +- net/interface.cpp | 4 +- net/net.vcxproj | 4 +- net/net.vcxproj.filters | 4 +- net/{netimpl.cpp => netframeimpl.cpp} | 24 ++---- net/{netimpl.h => netframeimpl.h} | 11 ++- net/stdafx.h | 5 +- stdcrt/event/compat_event_epoll.c | 4 +- stdcrt/event/compat_event_kqueue.c | 4 +- stdcrt/event/compat_event_mach.c | 91 ---------------------- stdcrt/event/compat_event_mach.h | 2 - stdcrt/event/compat_event_posix.c | 96 ----------------------- stdcrt/event/compat_event_posix.h | 2 - stdcrt/event/compat_event_util.c | 107 +++++++++++++++++++++++++- stdcrt/event/compat_event_util.h | 7 ++ testmain/appviewimpl.cpp | 4 +- testmain/interface.cpp | 4 +- testmain/stdafx.h | 1 - 26 files changed, 215 insertions(+), 334 deletions(-) delete mode 100644 extensions/include/net/idns.h delete mode 100644 extensions/include/net/imodbus.h delete mode 100644 extensions/include/net/iwebsocket.h rename net/{netimpl.cpp => netframeimpl.cpp} (71%) rename net/{netimpl.h => netframeimpl.h} (69%) diff --git a/crt/crt_common.hpp b/crt/crt_common.hpp index fdda4c5c..626a9236 100644 --- a/crt/crt_common.hpp +++ b/crt/crt_common.hpp @@ -47,10 +47,6 @@ typedef long _off_t; #define _unused __attribute__((__unused__)) #define _VISIBILITY_DEFAULT __attribute__((visibility("default"))) #define _VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) -#elif (TARGET_OS == OS_UNIX) -#define _unused __attribute__((__unused__)) -#define _VISIBILITY_DEFAULT __attribute__((visibility("default"))) -#define _VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) #endif #if (TARGET_OS == OS_WIN) @@ -59,8 +55,6 @@ typedef long _off_t; #define path_slash _T("/") #elif (TARGET_OS == OS_MACH) #define path_slash _T("/") -#elif (TARGET_OS == OS_UNIX) -#define path_slash _T("/") #endif #ifdef __cplusplus @@ -115,10 +109,6 @@ typedef long _off_t; #define OS_STDCALL #define OS_CALLBACK_(_type, _name) _type(OS_STDCALL* _name) #define _stdmethod_export(type, method) EXTERN_C type _VISIBILITY_DEFAULT method -#elif (TARGET_OS == OS_UNIX) -#define OS_STDCALL -#define OS_CALLBACK_(_type, _name) _type(OS_STDCALL* _name) -#define _stdmethod_export(type, method) EXTERN_C type _VISIBILITY_DEFAULT method #endif typedef unsigned char u_char; diff --git a/extensions/include/net/idns.h b/extensions/include/net/idns.h deleted file mode 100644 index 01c137ed..00000000 --- a/extensions/include/net/idns.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _IDNS_H_ -#define _IDNS_H_ - -#define DNS_PROC_RES_NOERROR S_SUCCESS -#define DNS_PROC_RES_ERROR S_ERROR - -interface IDnsProc : public IBase -{ - std_method(OnGetHost)(crterr err, LPCSTR hostname, LPCSTR host) PURE; -}; - -// {92EBBD6E-BF4D-41EC-9DFB-07C9AFF0CCC0} -_DEF_IID(IID_IDnsProc, 0x92ebbd6e, 0xbf4d, 0x41ec, 0x9d, 0xfb, 0x7, 0xc9, 0xaf, 0xf0, 0xcc, 0xc0); - -interface IDns : public IBase -{ - std_method(Post)(LPCSTR hostname, IBase* pProc) PURE; - std_method(Close)() PURE; -}; - -// {510FD0EA-BAE2-4BC8-B650-76E8FD5ED853} -_DEF_IID(IID_IDns, 0x510fd0ea, 0xbae2, 0x4bc8, 0xb6, 0x50, 0x76, 0xe8, 0xfd, 0x5e, 0xd8, 0x53); - -// {99148517-E9AB-4F72-A2E3-012625A35E95} -_DEF_CLSID(CLSID_IDns, 0x99148517, 0xe9ab, 0x4f72, 0xa2, 0xe3, 0x1, 0x26, 0x25, 0xa3, 0x5e, 0x95); - -#endif diff --git a/extensions/include/net/imodbus.h b/extensions/include/net/imodbus.h deleted file mode 100644 index f876feca..00000000 --- a/extensions/include/net/imodbus.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _IMODBUS_H_ -#define _IMODBUS_H_ - -interface IModBusProc : public IBase -{ -}; - -// {9A102441-E383-4B3C-8CC8-7C8E0B0162FF} -_DEF_IID(IID_IModBusProc, 0x9a102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); - -interface IModBus : public IBase -{ -}; - -// {9b102441-E383-4B3C-8CC8-7C8E0B0162FF} -_DEF_IID(IID_IModBus, 0x9b102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); - -interface IModBusSrvProc : public IBase -{ - std_method(OnAccept)(int error, LPCSTR hostname, LPCSTR host) PURE; -}; - -// {9b102441-E383-4B3C-8CC8-7C8E0B0162FF} -_DEF_IID(IID_IModBusSrvProc, 0x9c102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); - -interface IID_IModBusSrv : public IBase -{ -}; - -// {9d102441-E383-4B3C-8CC8-7C8E0B0162FF} -_DEF_IID(IID_IModBusSrv, 0x9d102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); - -#endif diff --git a/extensions/include/net/inet.h b/extensions/include/net/inet.h index 3959665d..4521ce21 100644 --- a/extensions/include/net/inet.h +++ b/extensions/include/net/inet.h @@ -1,8 +1,74 @@ #ifndef _INET_H_ #define _INET_H_ -#include -#include + +#define DNS_PROC_RES_NOERROR S_SUCCESS +#define DNS_PROC_RES_ERROR S_ERROR + +interface IDnsProc : public IBase +{ + std_method(OnGetHost)(crterr err, LPCSTR hostname, LPCSTR host) PURE; +}; + +// {92EBBD6E-BF4D-41EC-9DFB-07C9AFF0CCC0} +_DEF_IID(IID_IDnsProc, 0x92ebbd6e, 0xbf4d, 0x41ec, 0x9d, 0xfb, 0x7, 0xc9, 0xaf, 0xf0, 0xcc, 0xc0); + +interface IDns : public IBase +{ + std_method(Post)(LPCSTR hostname, IBase * pProc) PURE; + std_method(Close)() PURE; +}; + +// {510FD0EA-BAE2-4BC8-B650-76E8FD5ED853} +_DEF_IID(IID_IDns, 0x510fd0ea, 0xbae2, 0x4bc8, 0xb6, 0x50, 0x76, 0xe8, 0xfd, 0x5e, 0xd8, 0x53); + +// {99148517-E9AB-4F72-A2E3-012625A35E95} +_DEF_CLSID(CLSID_IDns, 0x99148517, 0xe9ab, 0x4f72, 0xa2, 0xe3, 0x1, 0x26, 0x25, 0xa3, 0x5e, 0x95); + +// {13429C36-9903-42D1-AD82-F243D48E1A76} +_DEF_CLSID(CLSID_IWebSocket, 0x13429c36, 0x9903, 0x42d1, 0xad, 0x82, 0xf2, 0x43, 0xd4, 0x8e, 0x1a, 0x76); + + +typedef long ChannelId; + +interface IChannel : public IBase +{ + std_method_(ChannelId, CreateChannel)() PURE; + std_method(CloseChannel)(ChannelId id) PURE; + std_method_(ssize_t, SendChannel)(ChannelId id, char* buf, size_t len) PURE; + std_method_(ssize_t, RecvChannel)(ChannelId id, char* buf, size_t len) PURE; +}; + +// {7EB8185F-0F4E-4420-9991-B70671967377} +_DEF_IID(IID_IChannel, 0x7eb8185f, 0xf4e, 0x4420, 0x99, 0x91, 0xb7, 0x6, 0x71, 0x96, 0x73, 0x77); + +// {4A27FA11-BEA7-46E8-9F32-EC0C9F6E1A9E} +_DEF_CLSID(CLSID_Channel, 0x4a27fa11, 0xbea7, 0x46e8, 0x9f, 0x32, 0xec, 0xc, 0x9f, 0x6e, 0x1a, 0x9e); + + +interface IModBusProc : public IBase{}; + +// {9A102441-E383-4B3C-8CC8-7C8E0B0162FF} +_DEF_IID(IID_IModBusProc, 0x9a102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); + +interface IModBus : public IBase{}; + +// {9b102441-E383-4B3C-8CC8-7C8E0B0162FF} +_DEF_IID(IID_IModBus, 0x9b102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); + +interface IModBusSrvProc : public IBase +{ + std_method(OnAccept)(int error, LPCSTR hostname, LPCSTR host) PURE; +}; + +// {9b102441-E383-4B3C-8CC8-7C8E0B0162FF} +_DEF_IID(IID_IModBusSrvProc, 0x9c102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); + +interface IID_IModBusSrv : public IBase{}; + +// {9d102441-E383-4B3C-8CC8-7C8E0B0162FF} +_DEF_IID(IID_IModBusSrv, 0x9d102441, 0xe383, 0x4b3c, 0x8c, 0xc8, 0x7c, 0x8e, 0xb, 0x1, 0x62, 0xff); + enum NetProtocol { @@ -18,15 +84,15 @@ enum NetProtocol { }; -interface INet : public IBase +interface INetFrame : public IBase { std_method(Create)(NetProtocol netp, IBase * *pBase) PURE; }; // {7EB8185F-0F4E-4420-9991-B70671967377} -_DEF_IID(IID_INet, 0x7eb8185f, 0xf4e, 0x4420, 0x99, 0x91, 0xb7, 0x6, 0x71, 0x96, 0x73, 0x77); +_DEF_IID(IID_INetFrame, 0x7eb8185f, 0xf4e, 0x4420, 0x99, 0x91, 0xb7, 0x6, 0x71, 0x96, 0x73, 0x77); // {C54C9CC0-F448-4A49-A622-0467D02E8EB8} -_DEF_CLSID(CLSID_INet, 0xc54c9cc0, 0xf448, 0x4a49, 0xa6, 0x22, 0x4, 0x67, 0xd0, 0x2e, 0x8e, 0xb8); +_DEF_CLSID(CLSID_INetFrame, 0xc54c9cc0, 0xf448, 0x4a49, 0xa6, 0x22, 0x4, 0x67, 0xd0, 0x2e, 0x8e, 0xb8); #endif diff --git a/extensions/include/net/issh.h b/extensions/include/net/issh.h index f06ac5a4..464ef952 100644 --- a/extensions/include/net/issh.h +++ b/extensions/include/net/issh.h @@ -1,20 +1,6 @@ #ifndef _ISSH_H_ #define _ISSH_H_ -typedef long ChannelId; -interface IChannel : public IBase -{ - std_method_(ChannelId, CreateChannel)() PURE; - std_method(CloseChannel)(ChannelId id) PURE; - std_method_(ssize_t, SendChannel)(ChannelId id, char* buf, size_t len) PURE; - std_method_(ssize_t, RecvChannel)(ChannelId id, char* buf, size_t len) PURE; -}; - -// {7EB8185F-0F4E-4420-9991-B70671967377} -_DEF_IID(IID_IChannel, 0x7eb8185f, 0xf4e, 0x4420, 0x99, 0x91, 0xb7, 0x6, 0x71, 0x96, 0x73, 0x77); - -// {4A27FA11-BEA7-46E8-9F32-EC0C9F6E1A9E} -_DEF_CLSID(CLSID_Channel, 0x4a27fa11, 0xbea7, 0x46e8, 0x9f, 0x32, 0xec, 0xc, 0x9f, 0x6e, 0x1a, 0x9e); #endif diff --git a/extensions/include/net/iwebsocket.h b/extensions/include/net/iwebsocket.h deleted file mode 100644 index dd7f1a6b..00000000 --- a/extensions/include/net/iwebsocket.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _IWEBSOCKET_H_ -#define _IWEBSOCKET_H_ - -// {13429C36-9903-42D1-AD82-F243D48E1A76} -_DEF_CLSID(CLSID_IWebSocket, 0x13429c36, 0x9903, 0x42d1, 0xad, 0x82, 0xf2, 0x43, 0xd4, 0x8e, 0x1a, 0x76); - -#endif diff --git a/net/dllmain.cpp b/net/dllmain.cpp index 4a033c2d..8f677307 100644 --- a/net/dllmain.cpp +++ b/net/dllmain.cpp @@ -1,5 +1,5 @@ // dllmain.cpp : Defines the entry point for the DLL application. -#include "netimpl.h" +#include "netframeimpl.h" #include "stdafx.h" #if (TARGET_OS == OS_POSIX) @@ -33,7 +33,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv #endif -static_const stdcom_entry_t clsobject[] = {{CLSID_INet, &ClassFactory::GetClass, "net.V1"}}; +static_const stdcom_entry_t clsobject[] = {{CLSID_INetFrame, &ClassFactory::GetClass, "net.V1"}}; static_const stdcom_entry_t* GetClassObjectMap() { diff --git a/net/httpimpl.cpp b/net/httpimpl.cpp index be066730..b40b1b94 100644 --- a/net/httpimpl.cpp +++ b/net/httpimpl.cpp @@ -11,7 +11,7 @@ CHttpIImpl::~CHttpIImpl(void) logi("CHttptImpl::~CHttptImpl"); } -HRESULT CHttpIImpl::init_class(const _lComPtr& AsynFrame, const _lComPtr& Net) +HRESULT CHttpIImpl::init_class(const _lComPtr& AsynFrame, const _lComPtr& Net) { HRESULT hr = S_OK; diff --git a/net/httpimpl.h b/net/httpimpl.h index 8b4b08fc..b99b32de 100644 --- a/net/httpimpl.h +++ b/net/httpimpl.h @@ -19,7 +19,7 @@ public: END_STDCOM_MAP public: - HRESULT init_class(const _lComPtr& AsynFrame, const _lComPtr& Net); + HRESULT init_class(const _lComPtr& AsynFrame, const _lComPtr& Net); public: // IHttp diff --git a/net/interface.cpp b/net/interface.cpp index 7b286742..870d46b6 100644 --- a/net/interface.cpp +++ b/net/interface.cpp @@ -90,9 +90,9 @@ _DEF_CLSID_IMPL(CLSID_IWebSocket, 0x13429c36, 0x9903, 0x42d1, 0xad, 0x82, 0xf2, // inet.h // {7EB8185F-0F4E-4420-9991-B70671967377} -_DEF_IID_IMPL(IID_INet, 0x7eb8185f, 0xf4e, 0x4420, 0x99, 0x91, 0xb7, 0x6, 0x71, 0x96, 0x73, 0x77); +_DEF_IID_IMPL(IID_INetFrame, 0x7eb8185f, 0xf4e, 0x4420, 0x99, 0x91, 0xb7, 0x6, 0x71, 0x96, 0x73, 0x77); // {C54C9CC0-F448-4A49-A622-0467D02E8EB8} -_DEF_CLSID_IMPL(CLSID_INet, 0xc54c9cc0, 0xf448, 0x4a49, 0xa6, 0x22, 0x4, 0x67, 0xd0, 0x2e, 0x8e, 0xb8); +_DEF_CLSID_IMPL(CLSID_INetFrame, 0xc54c9cc0, 0xf448, 0x4a49, 0xa6, 0x22, 0x4, 0x67, 0xd0, 0x2e, 0x8e, 0xb8); // ihttp.h // {8C102441-E383-4B3C-8CC8-7C8E0B0162FE} diff --git a/net/net.vcxproj b/net/net.vcxproj index 9f6365db..ede79671 100644 --- a/net/net.vcxproj +++ b/net/net.vcxproj @@ -117,7 +117,7 @@ - + @@ -141,7 +141,7 @@ - + diff --git a/net/net.vcxproj.filters b/net/net.vcxproj.filters index 7b4f7e85..2534fdb0 100644 --- a/net/net.vcxproj.filters +++ b/net/net.vcxproj.filters @@ -6,7 +6,6 @@ - protocol @@ -48,13 +47,13 @@ + - protocol @@ -114,6 +113,7 @@ + diff --git a/net/netimpl.cpp b/net/netframeimpl.cpp similarity index 71% rename from net/netimpl.cpp rename to net/netframeimpl.cpp index 2ef26859..cf3f8c2c 100644 --- a/net/netimpl.cpp +++ b/net/netframeimpl.cpp @@ -1,28 +1,28 @@ -#include "netimpl.h" +#include "netframeimpl.h" #include "dnsimpl.h" #include "websocketimpl.h" #include "httpimpl.h" #include "modbusimpl.h" -CNetImpl::CNetImpl(void) +CNetFrameImpl::CNetFrameImpl(void) { } -CNetImpl::~CNetImpl(void) +CNetFrameImpl::~CNetFrameImpl(void) { logi("CNetImpl::~CNetImpl"); } -HRESULT CNetImpl::Init(IBase* pRot, IBase* pBase) +HRESULT CNetFrameImpl::Init(IBase* pRot, IBase* pBase) { rc_error(pRot != NULL, E_FAIL); return pRot->QueryInterface(IID_IRot, (void**)&m_pRot); } -HRESULT CNetImpl::Uninit() +HRESULT CNetFrameImpl::Uninit() { HRESULT hr = S_OK; return hr; } -HRESULT CNetImpl::Start(_pid_t pid, unsigned int type) +HRESULT CNetFrameImpl::Start(_pid_t pid, unsigned int type) { HRESULT hr = S_OK; @@ -30,21 +30,16 @@ HRESULT CNetImpl::Start(_pid_t pid, unsigned int type) rc_error(hr == S_OK, E_FAIL); rc_error(m_pIAsynFrame.m_p != INULL, E_FAIL); - hr = this->QueryInterface(IID_INet, (void**)&m_pINet); - rc_error(hr == S_OK, E_FAIL); - rc_error(m_pIAsynFrame.m_p != INULL, E_FAIL); - return hr; } -HRESULT CNetImpl::Stop(unsigned int exit) +HRESULT CNetFrameImpl::Stop(unsigned int exit) { HRESULT hr = S_OK; - m_pINet.dispose(); return hr; } -HRESULT CNetImpl::Create(NetProtocol netp, IBase** pBase) +HRESULT CNetFrameImpl::Create(NetProtocol netp, IBase** pBase) { rc_error(m_pIAsynFrame.m_p != INULL, E_FAIL); @@ -71,9 +66,6 @@ HRESULT CNetImpl::Create(NetProtocol netp, IBase** pBase) rc_error(pObj != NULL, E_FAIL); pObj->AddRef(); - hr = pObj->init_class(m_pIAsynFrame, m_pINet); - rc_error(hr == S_OK, E_FAIL); - return pObj->QueryInterface(IID_IHttp, (void**)pBase); } else { } diff --git a/net/netimpl.h b/net/netframeimpl.h similarity index 69% rename from net/netimpl.h rename to net/netframeimpl.h index c1adb211..37d75f2e 100644 --- a/net/netimpl.h +++ b/net/netframeimpl.h @@ -3,17 +3,17 @@ #include "stdafx.h" -class CNetImpl : public INet, public IPlugin, public IPluginRun, public CUnknownImp +class CNetFrameImpl : public INetFrame, public IPlugin, public IPluginRun, public CUnknownImp { public: - CNetImpl(void); - virtual ~CNetImpl(void); + CNetFrameImpl(void); + virtual ~CNetFrameImpl(void); BEGIN_STDCOM_MAP - STDCOM_INTERFACE_ENTRY_UNKNOWN_(INet) + STDCOM_INTERFACE_ENTRY_UNKNOWN_(INetFrame) STDCOM_INTERFACE_ENTRY(IPlugin) STDCOM_INTERFACE_ENTRY(IPluginRun) - STDCOM_INTERFACE_ENTRY(INet) + STDCOM_INTERFACE_ENTRY(INetFrame) END_STDCOM_MAP // IPlugin @@ -30,7 +30,6 @@ public: private: _lComPtr m_pRot; _lComPtr m_pIAsynFrame; - _lComPtr m_pINet; }; #endif diff --git a/net/stdafx.h b/net/stdafx.h index 597640c1..170c4db9 100644 --- a/net/stdafx.h +++ b/net/stdafx.h @@ -15,10 +15,7 @@ #include #include -#include #include -#include -#include -#include + #endif diff --git a/stdcrt/event/compat_event_epoll.c b/stdcrt/event/compat_event_epoll.c index 22af3200..d3070a62 100644 --- a/stdcrt/event/compat_event_epoll.c +++ b/stdcrt/event/compat_event_epoll.c @@ -310,7 +310,7 @@ int epoll_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t tv // send - rc = epoll_tcpsock_send(oper, S_SUCCESS, 0, base->ev); + rc = evoper_tcpsock_send(oper, S_SUCCESS, 0, base->ev); if (rc == S_PENDING) { // add epoll uint32_t op = epoll_event_add(ptr, ev_write_event); @@ -484,7 +484,7 @@ static int epoll_cmd_poll(epoll_op_t* base, evloop_t* loop, crt_msec msec) complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); if (evoper_writeing(oper) == S_SUCCESS) - epoll_tcpsock_send(oper, S_SUCCESS, err, base->ev); + evoper_tcpsock_send(oper, S_SUCCESS, err, base->ev); } } diff --git a/stdcrt/event/compat_event_kqueue.c b/stdcrt/event/compat_event_kqueue.c index 85b95c1b..5dbbfc67 100644 --- a/stdcrt/event/compat_event_kqueue.c +++ b/stdcrt/event/compat_event_kqueue.c @@ -212,7 +212,7 @@ int kqueue_enable_write(evloop_t* loop, evoper_t* oper, short event, ev_time_t t rc_error(ptr != NULL, S_ERROR); // send - rc = kqueue_tcpsock_send(oper, S_SUCCESS, 0, base->ev); + rc = evoper_tcpsock_send(oper, S_SUCCESS, 0, base->ev); if (rc == S_PENDING) { // add kqueue set_kevent_ctl(ptr, kevent_add_op | kevent_op_enable); @@ -344,7 +344,7 @@ static int kqueue_cmd_poll(kqueue_op_t* base, evloop_t* loop, crt_msec timer) complete_sock_write(loop, S_SUCCESS, err, oper, base->ev); if (evoper_writeing(oper) == S_SUCCESS) - kqueue_tcpsock_send(oper, S_SUCCESS, err, base->ev); + evoper_tcpsock_send(oper, S_SUCCESS, err, base->ev); continue; } diff --git a/stdcrt/event/compat_event_mach.c b/stdcrt/event/compat_event_mach.c index 3e7e0acf..c7a6b117 100644 --- a/stdcrt/event/compat_event_mach.c +++ b/stdcrt/event/compat_event_mach.c @@ -6,95 +6,4 @@ #include "compat_event_kqueue.h" #include "compat_event_mach.h" -int kqueue_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func) -{ - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - - for (;;) { - ssize_t n = 0; - int error = 0; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->wbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->wbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - /* - if use set_sendbuflen(oper->sock, 1); - order error - */ - - n = write(oper->fd, ptr, len); - - error = (n == -1) ? errno : 0; - - if (n > 0) { - evoper_set_wbyte(oper, n); - evbuf_op_off(&oper->wbuf, n); - func(err, code, oper, oper, op_ev_write); - } - - if (evoper_writeing(oper) == S_ERROR) - break; - - if (error != 0) { - if (error == EAGAIN) { - return S_PENDING; - } else if (error == EINTR) { - continue; - } else { - return S_ERROR; - } - } - } - return rc; -} - -int kqueue_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) -{ - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - - for (;;) { - ssize_t n = 0; - int error = 0; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->rbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->rbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - n = read(oper->fd, ptr, len); - - error = (n == -1) ? errno : 0; - - if (n > 0) { - evoper_set_rbyte(oper, n); - evbuf_op_off(&oper->rbuf, n); - func(err, code, oper, NULL, op_ev_read); - } - - if (evoper_reading(oper) == S_ERROR) - break; - - if (error != 0) { - if (error == EAGAIN) { - return S_PENDING; - } else if (error == EINTR) { - continue; - } else { - return S_ERROR; - } - } - } - return rc; -} - #endif diff --git a/stdcrt/event/compat_event_mach.h b/stdcrt/event/compat_event_mach.h index 83f9e373..6f5d7fb7 100644 --- a/stdcrt/event/compat_event_mach.h +++ b/stdcrt/event/compat_event_mach.h @@ -9,8 +9,6 @@ extern "C" { #if (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) -int kqueue_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func); -int kqueue_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func); #endif diff --git a/stdcrt/event/compat_event_posix.c b/stdcrt/event/compat_event_posix.c index 844b7930..574db551 100644 --- a/stdcrt/event/compat_event_posix.c +++ b/stdcrt/event/compat_event_posix.c @@ -6,101 +6,5 @@ #include "compat_event_epoll.h" #include "compat_event_posix.h" -int epoll_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func) -{ - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - - for (;;) { - - ssize_t n = 0; - int error = 0; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->wbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->wbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - - /* - if use set_sendbuflen(oper->sock, 1); - order error - */ - - n = write(oper->fd, ptr, len); - - error = (n == -1) ? errno : 0; - - if (n > 0) { - evoper_set_wbyte(oper, n); - evbuf_op_off(&oper->wbuf, n); - func(err, code, oper, oper, op_ev_write); - } - - if (evoper_writeing(oper) == S_ERROR) - break; - - - if (error != 0) { - if(error == EAGAIN) { - return S_PENDING; - } else if (error == EINTR) { - continue; - } else { - return S_ERROR; - } - } - } - return rc; -} - -int epoll_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) -{ - int rc = S_SUCCESS; - rc_error(oper != NULL, rc); - - - for (;;) { - - ssize_t n = 0; - int error = 0; - buf_ptr ptr = NULL; - buf_len len = 0; - - rc = evbuf_get_buf(&oper->rbuf, &ptr); - rc_error(rc != S_ERROR, S_ERROR); - - rc = evbuf_get_len(&oper->rbuf, &len); - rc_error(rc != S_ERROR, S_ERROR); - - n = read(oper->fd, ptr, len); - - error = (n == -1) ? errno : 0; - - if (n > 0) { - evoper_set_rbyte(oper, n); - evbuf_op_off(&oper->rbuf, n); - func(err, code, oper, NULL, op_ev_read); - } - - if (evoper_reading(oper) == S_ERROR) - break; - - if (error != 0) { - if(error == EAGAIN) { - return S_PENDING; - } else if (error == EINTR) { - continue; - } else { - return S_ERROR; - } - } - - } - return rc; -} #endif diff --git a/stdcrt/event/compat_event_posix.h b/stdcrt/event/compat_event_posix.h index 871c0332..947610a6 100644 --- a/stdcrt/event/compat_event_posix.h +++ b/stdcrt/event/compat_event_posix.h @@ -9,8 +9,6 @@ extern "C" { #if (TARGET_OS == OS_POSIX) -int epoll_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func); -int epoll_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func); #endif diff --git a/stdcrt/event/compat_event_util.c b/stdcrt/event/compat_event_util.c index b9e462a6..a784e71a 100644 --- a/stdcrt/event/compat_event_util.c +++ b/stdcrt/event/compat_event_util.c @@ -371,9 +371,9 @@ int complete_sock_read(evloop_t* loop, int err, crterr code, evoper_t* oper, ev_ #if (TARGET_OS == OS_WIN) func(err, code, oper, NULL, op_ev_read); #elif (TARGET_OS == OS_POSIX) - epoll_tcpsock_recv(oper, err, code, func); + evoper_tcpsock_recv(oper, err, code, func); #elif (TARGET_OS == OS_MACH || TARGET_OS == OS_UNIX) - kqueue_tcpsock_recv(oper, err, code, func); + evoper_tcpsock_recv(oper, err, code, func); #else #endif @@ -501,3 +501,106 @@ int is_evs_on(evs_t* on) } return S_ERROR; } + +#if (TARGET_OS != OS_WIN) + +int evoper_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func) +{ + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + + for (;;) { + + ssize_t n = 0; + int error = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->wbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->wbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + + /* + if use set_sendbuflen(oper->sock, 1); + order error + */ + + n = write(oper->fd, ptr, len); + + error = (n == -1) ? errno : 0; + + if (n > 0) { + evoper_set_wbyte(oper, n); + evbuf_op_off(&oper->wbuf, n); + func(err, code, oper, oper, op_ev_write); + } + + if (evoper_writeing(oper) == S_ERROR) + break; + + + if (error != 0) { + if(error == EAGAIN) { + return S_PENDING; + } else if (error == EINTR) { + continue; + } else { + return S_ERROR; + } + } + } + return rc; +} + +int evoper_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func) +{ + int rc = S_SUCCESS; + rc_error(oper != NULL, rc); + + + for (;;) { + + ssize_t n = 0; + int error = 0; + buf_ptr ptr = NULL; + buf_len len = 0; + + rc = evbuf_get_buf(&oper->rbuf, &ptr); + rc_error(rc != S_ERROR, S_ERROR); + + rc = evbuf_get_len(&oper->rbuf, &len); + rc_error(rc != S_ERROR, S_ERROR); + + n = read(oper->fd, ptr, len); + + error = (n == -1) ? errno : 0; + + if (n > 0) { + evoper_set_rbyte(oper, n); + evbuf_op_off(&oper->rbuf, n); + func(err, code, oper, NULL, op_ev_read); + } + + if (evoper_reading(oper) == S_ERROR) + break; + + if (error != 0) { + if(error == EAGAIN) { + return S_PENDING; + } else if (error == EINTR) { + continue; + } else { + return S_ERROR; + } + } + + } + return rc; +} +#endif + + + diff --git a/stdcrt/event/compat_event_util.h b/stdcrt/event/compat_event_util.h index 79905b17..321d60ba 100644 --- a/stdcrt/event/compat_event_util.h +++ b/stdcrt/event/compat_event_util.h @@ -241,4 +241,11 @@ int evs_on(evs_t* on); int evs_off(evs_t* on); int is_evs_on(evs_t* on); +#if (TARGET_OS != OS_WIN) + +int evoper_tcpsock_send(evoper_t* oper, int err, crterr code, ev_op func); +int evoper_tcpsock_recv(evoper_t* oper, int err, crterr code, ev_op func); + +#endif + #endif diff --git a/testmain/appviewimpl.cpp b/testmain/appviewimpl.cpp index a666c611..a657c84e 100644 --- a/testmain/appviewimpl.cpp +++ b/testmain/appviewimpl.cpp @@ -26,8 +26,8 @@ HRESULT CAppViewImpl::Start(_pid_t pid, unsigned int type) InitBus(); - _lComPtr pINet; - m_pRot->GetObject(CLSID_INet, IID_INet, (IBase**)&pINet.m_p); + _lComPtr pINet; + m_pRot->GetObject(CLSID_INetFrame, IID_INetFrame, (IBase**)&pINet.m_p); rc_error(pINet.m_p != INULL, E_FAIL); hr = pINet->Create(protocol_modbus, (IBase**)&m_pIModBus); diff --git a/testmain/interface.cpp b/testmain/interface.cpp index d3fee002..2afce223 100644 --- a/testmain/interface.cpp +++ b/testmain/interface.cpp @@ -66,9 +66,9 @@ _DEF_CLSID_IMPL(CLSID_IWebSocket, 0x13429c36, 0x9903, 0x42d1, 0xad, 0x82, 0xf2, // inet.h // {7EB8185F-0F4E-4420-9991-B70671967377} -_DEF_IID_IMPL(IID_INet, 0x7eb8185f, 0xf4e, 0x4420, 0x99, 0x91, 0xb7, 0x6, 0x71, 0x96, 0x73, 0x77); +_DEF_IID_IMPL(IID_INetFrame, 0x7eb8185f, 0xf4e, 0x4420, 0x99, 0x91, 0xb7, 0x6, 0x71, 0x96, 0x73, 0x77); // {C54C9CC0-F448-4A49-A622-0467D02E8EB8} -_DEF_CLSID_IMPL(CLSID_INet, 0xc54c9cc0, 0xf448, 0x4a49, 0xa6, 0x22, 0x4, 0x67, 0xd0, 0x2e, 0x8e, 0xb8); +_DEF_CLSID_IMPL(CLSID_INetFrame, 0xc54c9cc0, 0xf448, 0x4a49, 0xa6, 0x22, 0x4, 0x67, 0xd0, 0x2e, 0x8e, 0xb8); // imsgbus.h // {A1DA4FBA-D0DB-434D-ABC5-ACF313391D4D} diff --git a/testmain/stdafx.h b/testmain/stdafx.h index 9d70985a..874627a7 100644 --- a/testmain/stdafx.h +++ b/testmain/stdafx.h @@ -15,6 +15,5 @@ #include #include #include -#include #endif -- Gitee From eaf29e4f6885859d6054e3f9fa0b8689e5d92e29 Mon Sep 17 00:00:00 2001 From: com Date: Fri, 16 Aug 2024 10:38:04 +0800 Subject: [PATCH 31/34] up --- crt/crt_common.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crt/crt_common.hpp b/crt/crt_common.hpp index 626a9236..fdda4c5c 100644 --- a/crt/crt_common.hpp +++ b/crt/crt_common.hpp @@ -47,6 +47,10 @@ typedef long _off_t; #define _unused __attribute__((__unused__)) #define _VISIBILITY_DEFAULT __attribute__((visibility("default"))) #define _VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) +#elif (TARGET_OS == OS_UNIX) +#define _unused __attribute__((__unused__)) +#define _VISIBILITY_DEFAULT __attribute__((visibility("default"))) +#define _VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) #endif #if (TARGET_OS == OS_WIN) @@ -55,6 +59,8 @@ typedef long _off_t; #define path_slash _T("/") #elif (TARGET_OS == OS_MACH) #define path_slash _T("/") +#elif (TARGET_OS == OS_UNIX) +#define path_slash _T("/") #endif #ifdef __cplusplus @@ -109,6 +115,10 @@ typedef long _off_t; #define OS_STDCALL #define OS_CALLBACK_(_type, _name) _type(OS_STDCALL* _name) #define _stdmethod_export(type, method) EXTERN_C type _VISIBILITY_DEFAULT method +#elif (TARGET_OS == OS_UNIX) +#define OS_STDCALL +#define OS_CALLBACK_(_type, _name) _type(OS_STDCALL* _name) +#define _stdmethod_export(type, method) EXTERN_C type _VISIBILITY_DEFAULT method #endif typedef unsigned char u_char; -- Gitee From aa402032ac7432c3b013d472d3745fcd9c057b41 Mon Sep 17 00:00:00 2001 From: com Date: Fri, 16 Aug 2024 10:53:54 +0800 Subject: [PATCH 32/34] up --- extensions/include/net/inet.h | 2 +- net/netframeimpl.cpp | 10 +++++----- net/netframeimpl.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/include/net/inet.h b/extensions/include/net/inet.h index 4521ce21..aadd977b 100644 --- a/extensions/include/net/inet.h +++ b/extensions/include/net/inet.h @@ -86,7 +86,7 @@ enum NetProtocol { interface INetFrame : public IBase { - std_method(Create)(NetProtocol netp, IBase * *pBase) PURE; + std_method(Create)(int type, IBase * *pBase) PURE; }; // {7EB8185F-0F4E-4420-9991-B70671967377} diff --git a/net/netframeimpl.cpp b/net/netframeimpl.cpp index cf3f8c2c..b6dab4f4 100644 --- a/net/netframeimpl.cpp +++ b/net/netframeimpl.cpp @@ -39,13 +39,13 @@ HRESULT CNetFrameImpl::Stop(unsigned int exit) return hr; } -HRESULT CNetFrameImpl::Create(NetProtocol netp, IBase** pBase) +HRESULT CNetFrameImpl::Create(int type, IBase** pBase) { rc_error(m_pIAsynFrame.m_p != INULL, E_FAIL); HRESULT hr = S_OK; - if (netp == protocol_dns) { + if (type == protocol_dns) { CDnsImpl* pDns = ALLOC_NEW CDnsImpl(); rc_error(pDns != NULL, E_FAIL); @@ -54,14 +54,14 @@ HRESULT CNetFrameImpl::Create(NetProtocol netp, IBase** pBase) return pDns->QueryInterface(IID_IDns, (void**)pBase); - } else if (netp == protocol_websocket) { + } else if (type == protocol_websocket) { CWebSocketImpl* pWebSocket = ALLOC_NEW CWebSocketImpl(); rc_error(pWebSocket != NULL, E_FAIL); - } else if (protocol_modbus == netp) { + } else if (protocol_modbus == type) { return E_FAIL; - } else if (protocol_http == netp || protocol_https == netp) { + } else if (protocol_http == type || protocol_https == type) { CHttpIImpl* pObj = ALLOC_NEW CHttpIImpl(); rc_error(pObj != NULL, E_FAIL); pObj->AddRef(); diff --git a/net/netframeimpl.h b/net/netframeimpl.h index 37d75f2e..32212597 100644 --- a/net/netframeimpl.h +++ b/net/netframeimpl.h @@ -25,7 +25,7 @@ public: std_method(Stop)(unsigned int exit); // INet - std_method(Create)(NetProtocol netp, IBase** pBase); + std_method(Create)(int type, IBase** pBase); private: _lComPtr m_pRot; -- Gitee From 0bea59bb39ef7b0a5b082466da9496e62b492173 Mon Sep 17 00:00:00 2001 From: com Date: Fri, 16 Aug 2024 11:39:00 +0800 Subject: [PATCH 33/34] up --- extensions/include/net/{inet.h => inetframe.h} | 4 ++-- extensions/include/net/issh.h | 6 ------ net/netframeimpl.h | 4 ++-- net/stdafx.h | 2 +- stdcrt/code/compat_sjson.c | 8 ++++++-- testmain/main.cpp | 7 ++++++- testmain/stdafx.h | 2 +- 7 files changed, 18 insertions(+), 15 deletions(-) rename extensions/include/net/{inet.h => inetframe.h} (98%) delete mode 100644 extensions/include/net/issh.h diff --git a/extensions/include/net/inet.h b/extensions/include/net/inetframe.h similarity index 98% rename from extensions/include/net/inet.h rename to extensions/include/net/inetframe.h index aadd977b..d3eaf8e7 100644 --- a/extensions/include/net/inet.h +++ b/extensions/include/net/inetframe.h @@ -1,5 +1,5 @@ -#ifndef _INET_H_ -#define _INET_H_ +#ifndef _INETFRAME_H_ +#define _INETFRAME_H_ #define DNS_PROC_RES_NOERROR S_SUCCESS diff --git a/extensions/include/net/issh.h b/extensions/include/net/issh.h deleted file mode 100644 index 464ef952..00000000 --- a/extensions/include/net/issh.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ISSH_H_ -#define _ISSH_H_ - - - -#endif diff --git a/net/netframeimpl.h b/net/netframeimpl.h index 32212597..729f530b 100644 --- a/net/netframeimpl.h +++ b/net/netframeimpl.h @@ -1,5 +1,5 @@ -#ifndef _NETIMPL_H_ -#define _NETIMPL_H_ +#ifndef _NETFRAMEIMPL_H_ +#define _NETFRAMEIMPL_H_ #include "stdafx.h" diff --git a/net/stdafx.h b/net/stdafx.h index 170c4db9..ed407445 100644 --- a/net/stdafx.h +++ b/net/stdafx.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include diff --git a/stdcrt/code/compat_sjson.c b/stdcrt/code/compat_sjson.c index 0fd23b50..f58d2d5e 100644 --- a/stdcrt/code/compat_sjson.c +++ b/stdcrt/code/compat_sjson.c @@ -203,8 +203,12 @@ static int print_int64(sjsoncvptr item, sjsonprintvptr output_buffer) #if (TARGET_OS == OS_WIN) length = sprintf((char*)number_buffer, fmt_i64d, d); -#else - length = s_snprintf((char*)number_buffer, "%" PRId64, d); +#elif (TARGET_OS == OS_POSIX) + length = sprintf((char*)number_buffer, "%" PRId64, d); +#elif (TARGET_OS == OS_MACH) + length = sprintf((char*)number_buffer, "%" PRId64, d); +#elif (TARGET_OS == OS_UNIX) + length = sprintf((char*)number_buffer, "%" PRId64, d); #endif if (length < 0) { diff --git a/testmain/main.cpp b/testmain/main.cpp index be650c4d..6b88b119 100644 --- a/testmain/main.cpp +++ b/testmain/main.cpp @@ -106,7 +106,12 @@ int main(int argc, char* argv[]) _pid_t pid = get_processid(); return main_t(pid, argc, argv); } - +#elif (TARGET_OS == OS_UNIX) +int main(int argc, char* argv[]) +{ + _pid_t pid = get_processid(); + return main_t(pid, argc, argv); +} #elif (TARGET_OS == OS_WIN) // #pragma comment(lib,"Kernel32.lib") diff --git a/testmain/stdafx.h b/testmain/stdafx.h index 874627a7..39fc14f4 100644 --- a/testmain/stdafx.h +++ b/testmain/stdafx.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #endif -- Gitee From f2eb66b70d3177085dc2d222f0b845e874a5cf9c Mon Sep 17 00:00:00 2001 From: com Date: Fri, 16 Aug 2024 11:46:57 +0800 Subject: [PATCH 34/34] up --- stdcrt/code/compat_sjson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdcrt/code/compat_sjson.c b/stdcrt/code/compat_sjson.c index f58d2d5e..8b02fc9f 100644 --- a/stdcrt/code/compat_sjson.c +++ b/stdcrt/code/compat_sjson.c @@ -202,7 +202,7 @@ static int print_int64(sjsoncvptr item, sjsonprintvptr output_buffer) } #if (TARGET_OS == OS_WIN) - length = sprintf((char*)number_buffer, fmt_i64d, d); + length = snprintf((char*)number_buffer, 41, fmt_i64d, d); #elif (TARGET_OS == OS_POSIX) length = sprintf((char*)number_buffer, "%" PRId64, d); #elif (TARGET_OS == OS_MACH) -- Gitee

0K9oZlAODnftay;tBWk zj_4rq&g&1WwDRWq&Z0(k@p;RLvDE@I-Byc51yy8=bczakM#M-cWbdc8hbuoyZD()r z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