Permalink
Browse files

All inter-VM's traffic

Allow the VM's to communicate by broadcasting the traffic.
  • Loading branch information...
msantos committed Dec 29, 2010
1 parent 6d6a8bb commit 46bf2b80ec1d95bbae46d05a418c90f4aa6187f4
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/evum_switch.erl
View
@@ -146,13 +146,21 @@ handle_call({net, Data}, _From, #state{s = Socket, addr = Addr} = State) ->
),
{reply, ok, State#state{addr = Addr1}};
-handle_call({unix, Sun, Data}, _From, #state{ip = IP, arp = ARP, ifindex = Ifindex, addr = Addr} = State) ->
+handle_call({unix, Sun, Data}, _From, #state{
+ s = Unix,
+ ip = IP,
+ arp = ARP,
+ ifindex = Ifindex,
+ addr = Addr
+ } = State) ->
{#ether{type = Type}, _Packet} = pkt:ether(Data),
Socket = case Type of
?ETH_P_ARP -> ARP;
?ETH_P_IP -> IP
end,
ok = packet:send(Socket, Ifindex, Data),
+ % Broadcast the packets to all VM's, including the sender
+ [ procket:sendto(Unix, Data, 0, Un) || Un <- ordsets:to_list(Addr) ],
{reply, ok, State#state{addr = ordsets:add_element(Sun, Addr)}};
handle_call(stop, {Pid,_}, #state{pid = Pid} = State) ->

0 comments on commit 46bf2b8

Please sign in to comment.