version 1.14, 2014/02/08 22:06:17
|
version 1.16, 2016/08/18 09:06:31
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004 - 2014 | Copyright 2004 - 2016 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 53 io_closeClient(sched_task_t *task)
|
Line 53 io_closeClient(sched_task_t *task)
|
sock_t *s = (sock_t*) cli->cli_parent; |
sock_t *s = (sock_t*) cli->cli_parent; |
int stat; |
int stat; |
|
|
|
schedCancelby(s->sock_root, taskMAX, CRITERIA_ARG, cli, NULL); |
|
|
pthread_mutex_lock(&s->sock_mtx); |
pthread_mutex_lock(&s->sock_mtx); |
TAILQ_REMOVE(&s->sock_cli, cli, cli_node); |
TAILQ_REMOVE(&s->sock_cli, cli, cli_node); |
pthread_mutex_unlock(&s->sock_mtx); |
pthread_mutex_unlock(&s->sock_mtx); |
|
|
schedCancelby(s->sock_root, taskMAX, CRITERIA_ARG, cli, NULL); |
|
|
|
if (*cli->cli_name) |
if (*cli->cli_name) |
ioFreePTY(cli->cli_pty, cli->cli_name); |
ioFreePTY(cli->cli_pty, cli->cli_name); |
if (s->sock_prog) { |
if (s->sock_prog) { |
Line 168 io_txNet(sched_task_t *task)
|
Line 168 io_txNet(sched_task_t *task)
|
if (s->sock_type == SOCK_STREAM) |
if (s->sock_type == SOCK_STREAM) |
wlen = send(TASK_FD(task), buf, len, 0); |
wlen = send(TASK_FD(task), buf, len, 0); |
else |
else |
wlen = sendto(TASK_FD(task), buf, len, 0, | #ifndef __linux__ |
&cli->cli_addr.sa, cli->cli_addr.sa.sa_len); | wlen = sendto(TASK_FD(task), buf, len, 0, &cli->cli_addr.sa, cli->cli_addr.sa.sa_len); |
| #else |
| wlen = sendto(TASK_FD(task), buf, len, 0, &cli->cli_addr.sa, |
| cli->cli_addr.sa.sa_family == AF_INET ? |
| sizeof cli->cli_addr.sin : sizeof cli->cli_addr.sin6); |
| #endif |
if (wlen < 1) { |
if (wlen < 1) { |
schedEvent(TASK_ROOT(task), io_closeClient, cli, 0, NULL, 0); |
schedEvent(TASK_ROOT(task), io_closeClient, cli, 0, NULL, 0); |
break; |
break; |
Line 211 io_rxNet(sched_task_t *task)
|
Line 216 io_rxNet(sched_task_t *task)
|
else { |
else { |
rlen = recvfrom(TASK_FD(task), AIT_GET_BUF(&cli->cli_buf[0]), |
rlen = recvfrom(TASK_FD(task), AIT_GET_BUF(&cli->cli_buf[0]), |
AIT_LEN(&cli->cli_buf[0]), 0, &sa.sa, &salen); |
AIT_LEN(&cli->cli_buf[0]), 0, &sa.sa, &salen); |
if (e_addrcmp(&cli->cli_addr, &sa, 42)) | if (e_addrcmp(&cli->cli_addr, &sa, 42)) { |
goto end; | schedReadSelf(task); |
| taskExit(task, NULL); |
| } |
} |
} |
if (rlen < 1) |
if (rlen < 1) |
schedEvent(TASK_ROOT(task), io_closeClient, cli, 0, NULL, 0); |
schedEvent(TASK_ROOT(task), io_closeClient, cli, 0, NULL, 0); |
else | else { |
schedEvent(TASK_ROOT(task), io_txPty, cli, cli->cli_pty, |
schedEvent(TASK_ROOT(task), io_txPty, cli, cli->cli_pty, |
AIT_GET_BUF(&cli->cli_buf[0]), rlen); |
AIT_GET_BUF(&cli->cli_buf[0]), rlen); |
end: | schedReadSelf(task); |
schedReadSelf(task); | } |
| |
taskExit(task, NULL); |
taskExit(task, NULL); |
} |
} |
|
|
Line 235 io_rxPty(sched_task_t *task)
|
Line 243 io_rxPty(sched_task_t *task)
|
rlen = read(TASK_FD(task), AIT_GET_BUF(&cli->cli_buf[1]), AIT_LEN(&cli->cli_buf[1])); |
rlen = read(TASK_FD(task), AIT_GET_BUF(&cli->cli_buf[1]), AIT_LEN(&cli->cli_buf[1])); |
if (rlen < 1) |
if (rlen < 1) |
schedEvent(TASK_ROOT(task), io_closeClient, cli, 0, NULL, 0); |
schedEvent(TASK_ROOT(task), io_closeClient, cli, 0, NULL, 0); |
else | else { |
schedEvent(TASK_ROOT(task), io_txNet, cli, cli->cli_fd, |
schedEvent(TASK_ROOT(task), io_txNet, cli, cli->cli_fd, |
AIT_GET_BUF(&cli->cli_buf[1]), rlen); |
AIT_GET_BUF(&cli->cli_buf[1]), rlen); |
|
schedReadSelf(task); |
|
} |
|
|
schedReadSelf(task); |
|
taskExit(task, NULL); |
taskExit(task, NULL); |
} |
} |
|
|
Line 297 io_bridgeClient(sched_task_t *task)
|
Line 306 io_bridgeClient(sched_task_t *task)
|
break; |
break; |
case 0: |
case 0: |
cli->cli_pty = pty; |
cli->cli_pty = pty; |
|
ioSetRAWMode(STDIN_FILENO, NULL); |
|
|
array_Args(cli->cli_cmdline, 0, " \t", &args); |
array_Args(cli->cli_cmdline, 0, " \t", &args); |
argv = array_To(args); |
argv = array_To(args); |
Line 447 ioInitSocket(int role, int type, int proto, const char
|
Line 457 ioInitSocket(int role, int type, int proto, const char
|
e_free(s); |
e_free(s); |
return NULL; |
return NULL; |
} |
} |
|
#ifndef __linux__ |
if (bind(s->sock_fd, &s->sock_addr.sa, s->sock_addr.sa.sa_len) == -1) { |
if (bind(s->sock_fd, &s->sock_addr.sa, s->sock_addr.sa.sa_len) == -1) { |
|
#else |
|
if (bind(s->sock_fd, &s->sock_addr.sa, s->sock_addr.sa.sa_family == AF_INET ? |
|
sizeof s->sock_addr.sin : sizeof s->sock_addr.sin6) == -1) { |
|
#endif |
LOGERR; |
LOGERR; |
AIT_FREE_VAL(&s->sock_buf); |
AIT_FREE_VAL(&s->sock_buf); |
e_free(s); |
e_free(s); |
Line 544 ioUpSocket(sock_t * __restrict s, void *arg, int timeo
|
Line 559 ioUpSocket(sock_t * __restrict s, void *arg, int timeo
|
case IO_SOCK_ROLE_CLIENT: |
case IO_SOCK_ROLE_CLIENT: |
memcpy(&s->sock_peer, peer, sizeof s->sock_peer); |
memcpy(&s->sock_peer, peer, sizeof s->sock_peer); |
|
|
if (connect(s->sock_fd, &s->sock_peer.sa, | #ifndef __linux__ |
s->sock_peer.sa.sa_len) == -1) { | if (connect(s->sock_fd, &s->sock_peer.sa, s->sock_peer.sa.sa_len) == -1) { |
| #else |
| if (connect(s->sock_fd, &s->sock_peer.sa, s->sock_addr.sa.sa_family == AF_INET ? |
| sizeof s->sock_peer.sin : sizeof s->sock_peer.sin6) == -1) { |
| #endif |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
} |
} |