Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
c0398417
Commit
c0398417
authored
Mar 07, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arch-gnu-linux: support raw sockets
parent
6d48414d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
main-loop.c
arch-gnu-linux/main-loop.c
+2
-1
posix-socket.c
arch-gnu-linux/posix-socket.c
+15
-3
No files found.
arch-gnu-linux/main-loop.c
View file @
c0398417
...
...
@@ -35,6 +35,7 @@ void posix_main_loop(struct pp_instance *ppi)
while
(
1
)
{
int
i
;
unsigned
char
packet
[
1500
];
void
*
payload
=
packet
+
16
;
/* aligned */
again:
...
...
@@ -52,7 +53,7 @@ void posix_main_loop(struct pp_instance *ppi)
* We got a packet. If it's not ours, continue consuming
* the pending timeout
*/
i
=
posix_recv_packet
(
ppi
,
pa
cket
,
sizeof
(
packet
)
,
i
=
posix_recv_packet
(
ppi
,
pa
yload
,
sizeof
(
packet
)
-
16
,
&
ppi
->
last_rcv_time
);
ppi
->
last_rcv_time
.
seconds
+=
DSPRO
(
ppi
)
->
currentUtcOffset
;
...
...
arch-gnu-linux/posix-socket.c
View file @
c0398417
...
...
@@ -13,6 +13,7 @@
#include <sys/ioctl.h>
#include <netpacket/packet.h>
#include <net/if.h>
#include <net/ethernet.h>
#include <arpa/inet.h>
...
...
@@ -106,9 +107,17 @@ int posix_recv_packet(struct pp_instance *ppi, void *pkt, int len,
TimeInternal
*
t
)
{
struct
pp_channel
*
ch1
=
NULL
,
*
ch2
=
NULL
;
void
*
hdr
;
int
ret
;
if
(
OPTS
(
ppi
)
->
ethernet_mode
)
return
posix_recv_msg
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
,
pkt
,
len
,
t
);
if
(
OPTS
(
ppi
)
->
ethernet_mode
)
{
hdr
=
PROTO_HDR
(
pkt
);
ret
=
posix_recv_msg
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
,
hdr
,
len
+
NP
(
ppi
)
->
proto_ofst
,
t
);
return
ret
<=
0
?
ret
:
ret
-
NP
(
ppi
)
->
proto_ofst
;
/* FIXME: check header */
}
/* else: UDP */
if
(
POSIX_ARCH
(
ppi
)
->
rcv_switch
)
{
...
...
@@ -135,12 +144,15 @@ int posix_send_packet(struct pp_instance *ppi, void *pkt, int len, int chtype,
int
use_pdelay_addr
)
{
struct
sockaddr_in
addr
;
void
*
hdr
;
struct
ethhdr
*
hdr
;
if
(
OPTS
(
ppi
)
->
ethernet_mode
)
{
hdr
=
PROTO_HDR
(
pkt
);
/* TODO: fill header */
hdr
->
h_proto
=
htons
(
ETH_P_1588
);
memcpy
(
hdr
->
h_dest
,
"
\x01\x1B\x19\x00\x00\x00
"
,
6
);
/* raw sockets implementation always use gen socket */
memcpy
(
hdr
->
h_source
,
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
,
6
);
return
send
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
,
hdr
,
len
+
NP
(
ppi
)
->
proto_ofst
,
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment