author | viric@llimona |
Thu, 27 Sep 2007 00:25:54 +0200 | |
changeset 58 | 2cf8c513d18f |
parent 53 | 07500c5c53cb |
child 60 | 18c24be2b1a6 |
permissions | -rw-r--r-- |
53 | 1 |
/* |
2 |
Terminal Mixer - multi-point multi-user access to terminal applications |
|
3 |
Copyright (C) 2007 LluĂs Batlle i Rossell |
|
4 |
||
5 |
Please find the license in the provided COPYING file. |
|
6 |
*/ |
|
43
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
7 |
#include <unistd.h> |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
8 |
#include <sys/types.h> |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
9 |
#include <sys/select.h> |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
10 |
#include "main.h" |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
11 |
#include "handlers.h" |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
12 |
|
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
13 |
static int myfd = -1; |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
14 |
|
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
15 |
void s_eth_init() |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
16 |
{ |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
17 |
eth_proto_init(); |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
18 |
myfd = eth_proto_open(); |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
19 |
if (myfd < 0) |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
20 |
error("Cannot eth_proto_open"); |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
21 |
} |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
22 |
|
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
23 |
void s_eth_shutdown() |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
24 |
{ |
45 | 25 |
eth_proto_send(0, 0); |
43
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
26 |
if (myfd >= 0) |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
27 |
close(myfd); |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
28 |
} |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
29 |
|
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
30 |
void s_eth_prepare_read_fdset(fd_set *read_set, int *maxfd) |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
31 |
{ |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
32 |
FD_SET(myfd, read_set); |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
33 |
*maxfd = max(*maxfd, myfd); |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
34 |
} |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
35 |
|
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
36 |
void s_eth_process_read_fdset(fd_set *read_set) |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
37 |
{ |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
38 |
if (FD_ISSET(myfd, read_set)) |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
39 |
{ |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
40 |
int res; |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
41 |
|
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
42 |
res = eth_proto_recv(stream_buffer, stream_buffer_size); |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
43 |
|
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
44 |
app_control_remote_send_to_stdin(stream_buffer, res); |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
45 |
} |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
46 |
} |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
47 |
|
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
48 |
void s_eth_send_to_connected(const char *buffer, size_t size) |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
49 |
{ |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
50 |
eth_proto_send(buffer, size); |
625794738afc
Added first attempt for an ethernet protocol. Even not tried.
viric@llimona
parents:
diff
changeset
|
51 |
} |