Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EtherBone Core
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
EtherBone Core
Commits
1b86b03c
Commit
1b86b03c
authored
13 years ago
by
Wesley W. Terpstra
Browse files
Options
Downloads
Patches
Plain Diff
Prototype code for accepting TCP
parent
948eff13
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/glue/device.c
+37
-0
37 additions, 0 deletions
api/glue/device.c
api/glue/device.h
+2
-0
2 additions, 0 deletions
api/glue/device.h
api/glue/socket.c
+13
-2
13 additions, 2 deletions
api/glue/socket.c
with
52 additions
and
2 deletions
api/glue/device.c
+
37
−
0
View file @
1b86b03c
...
...
@@ -154,6 +154,43 @@ eb_status_t eb_device_open(eb_socket_t socketp, const char* address, eb_width_t
return
EB_OK
;
}
eb_link_t
eb_device_new_slave
(
eb_socket_t
socketp
,
eb_transport_t
transportp
,
eb_link_t
linkp
)
{
eb_device_t
devicep
;
eb_link_t
new_linkp
;
struct
eb_device
*
device
;
struct
eb_transport
*
transport
;
struct
eb_socket
*
socket
;
struct
eb_link
*
link
;
devicep
=
eb_new_device
();
if
(
devicep
==
EB_NULL
)
goto
fail0
;
new_linkp
=
eb_new_link
();
if
(
new_linkp
==
EB_NULL
)
goto
fail1
;
socket
=
EB_SOCKET
(
socketp
);
device
=
EB_DEVICE
(
devicep
);
device
->
socket
=
socketp
;
device
->
passive
=
devicep
;
device
->
unready
=
0
;
device
->
widths
=
0
;
device
->
link
=
linkp
;
device
->
transport
=
transportp
;
device
->
next
=
socket
->
first_device
;
socket
->
first_device
=
devicep
;
return
new_linkp
;
fail1:
eb_free_device
(
devicep
);
fail0:
transport
=
EB_TRANSPORT
(
transportp
);
link
=
EB_LINK
(
linkp
);
eb_transports
[
transport
->
link_type
].
disconnect
(
transport
,
link
);
return
linkp
;
}
eb_status_t
eb_device_close
(
eb_device_t
devicep
)
{
struct
eb_socket
*
socket
;
struct
eb_device
*
device
;
...
...
This diff is collapsed.
Click to expand it.
api/glue/device.h
+
2
−
0
View file @
1b86b03c
...
...
@@ -49,5 +49,7 @@ struct eb_device {
eb_transport_t
transport
;
};
/* Create a new slave device */
eb_link_t
eb_device_new_slave
(
eb_socket_t
socketp
,
eb_transport_t
transportp
,
eb_link_t
linkp
);
#endif
This diff is collapsed.
Click to expand it.
api/glue/socket.c
+
13
−
2
View file @
1b86b03c
...
...
@@ -303,8 +303,10 @@ eb_status_t eb_socket_poll(eb_socket_t socketp) {
struct
eb_transport
*
transport
;
struct
eb_response
*
response
;
struct
eb_cycle
*
cycle
;
struct
eb_link
*
new_link
;
eb_device_t
devicep
,
next_devicep
;
eb_transport_t
transportp
,
next_transportp
;
eb_link_t
new_linkp
;
eb_response_t
responsep
;
eb_cycle_t
cyclep
;
eb_socket_aux_t
auxp
;
...
...
@@ -338,16 +340,25 @@ eb_status_t eb_socket_poll(eb_socket_t socketp) {
/* Step 2. Check all devices */
/* Poll all the transports */
/* Get some memory for accepting connections */
new_linkp
=
eb_new_link
();
new_link
=
0
;
/* Poll all the transports, potentially discovering new devices */
aux
=
EB_SOCKET_AUX
(
auxp
);
for
(
transportp
=
aux
->
first_transport
;
transportp
!=
EB_NULL
;
transportp
=
next_transportp
)
{
transport
=
EB_TRANSPORT
(
transportp
);
next_transportp
=
transport
->
next
;
eb_device_slave
(
socketp
,
transportp
,
EB_NULL
);
/* Try to accept inbound connections */
if
(
new_linkp
!=
EB_NULL
)
new_link
=
EB_LINK
(
new_linkp
);
if
((
*
eb_transports
[
transport
->
link_type
].
accept
)(
transport
,
new_link
)
>
0
)
new_linkp
=
eb_device_new_slave
(
socketp
,
transportp
,
new_linkp
);
}
/*
Add
all the
sockets to the listen set
*/
/*
Poll
all the
connections
*/
socket
=
EB_SOCKET
(
socketp
);
for
(
devicep
=
socket
->
first_device
;
devicep
!=
EB_NULL
;
devicep
=
next_devicep
)
{
device
=
EB_DEVICE
(
devicep
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment