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
7a5377a9
Commit
7a5377a9
authored
Mar 07, 2012
by
Alessandro Rubini
Committed by
Aurelio Colosimo
Mar 08, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
posix-socket: bind to multicast mac address
parent
879ad56f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
posix-socket.c
arch-gnu-linux/posix-socket.c
+12
-2
No files found.
arch-gnu-linux/posix-socket.c
View file @
7a5377a9
...
...
@@ -148,9 +148,9 @@ int posix_send_packet(struct pp_instance *ppi, void *pkt, int len, int chtype,
hdr
=
PROTO_HDR
(
pkt
);
hdr
->
h_proto
=
htons
(
ETH_P_1588
);
memcpy
(
hdr
->
h_dest
,
"
\x01\x1B\x19\x00\x00\x00
"
,
6
);
memcpy
(
hdr
->
h_dest
,
PP_MCAST_MACADDRESS
,
ETH_ALEN
);
/* raw socket implementation always uses gen socket */
memcpy
(
hdr
->
h_source
,
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
,
6
);
memcpy
(
hdr
->
h_source
,
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
addr
,
ETH_ALEN
);
return
send
(
NP
(
ppi
)
->
ch
[
PP_NP_GEN
].
fd
,
hdr
,
len
+
NP
(
ppi
)
->
proto_ofst
,
0
);
}
...
...
@@ -187,6 +187,7 @@ int posix_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
struct
sockaddr_in
addr
;
struct
sockaddr_ll
addr_ll
;
struct
ip_mreq
imr
;
struct
packet_mreq
pmr
;
char
addr_str
[
INET_ADDRSTRLEN
];
if
(
OPTS
(
ppi
)
->
ethernet_mode
)
{
...
...
@@ -229,6 +230,15 @@ int posix_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
return
-
1
;
}
/* accept the multicast address for raw-ethernet ptp */
memset
(
&
pmr
,
0
,
sizeof
(
pmr
));
pmr
.
mr_ifindex
=
iindex
;
pmr
.
mr_type
=
PACKET_MR_MULTICAST
;
pmr
.
mr_alen
=
ETH_ALEN
;
memcpy
(
pmr
.
mr_address
,
PP_MCAST_MACADDRESS
,
ETH_ALEN
);
setsockopt
(
sock
,
SOL_PACKET
,
PACKET_ADD_MEMBERSHIP
,
&
pmr
,
sizeof
(
pmr
));
/* lazily ignore errors */
NP
(
ppi
)
->
ch
[
chtype
].
fd
=
sock
;
return
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