1
%% ``The contents of this file are subject to the Erlang Public License,
4
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
2
7
%% Version 1.1, (the "License"); you may not use this file except in
3
8
%% compliance with the License. You should have received a copy of the
4
9
%% Erlang Public License along with this software. If not, it can be
5
%% retrieved via the world wide web at http://www.erlang.org/.
10
%% retrieved online at http://www.erlang.org/.
7
12
%% Software distributed under the License is distributed on an "AS IS"
8
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
%% the License for the specific language governing rights and limitations
10
15
%% under the License.
12
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
%% AB. All Rights Reserved.''
18
19
-module(inet6_udp).
37
38
open(Port) -> open(Port, []).
39
open(Port, Opts) when is_integer(Port), Port >= 0, Port =< 65535 ->
40
41
case inet:udp_options([{port,Port} | Opts], inet6) of
41
42
{error, Reason} -> exit(Reason);
44
BAddr = R#udp_opts.ifaddr,
45
BPort = R#udp_opts.port,
46
SockOpts = R#udp_opts.opts,
47
inet:open(Fd,BAddr,BPort,SockOpts,udp,inet6,?MODULE)
44
ifaddr=BAddr={A,B,C,D,E,F,G,H},
47
when ?ip6(A,B,C,D,E,F,G,H), ?port(BPort) ->
48
inet:open(Fd,BAddr,BPort,SockOpts,udp,inet6,?MODULE);
49
{ok, _} -> exit(badarg)
50
send(S, Addr = {A,B,C,D,E,F,G,H}, P, Data)
51
when ?ip6(A,B,C,D,E,F,G,H), is_integer(P), P > 0, P =< 65535 ->
52
send(S, Addr = {A,B,C,D,E,F,G,H}, P, Data)
53
when ?ip6(A,B,C,D,E,F,G,H), ?port(P) ->
52
54
prim_inet:sendto(S, Addr, P, Data).
55
57
prim_inet:sendto(S, {0,0,0,0,0,0,0,0}, 0, Data).
57
59
connect(S, Addr = {A,B,C,D,E,F,G,H}, P)
58
when ?ip6(A,B,C,D,E,F,G,H), is_integer(P), P > 0, P =< 65535 ->
60
when ?ip6(A,B,C,D,E,F,G,H), ?port(P) ->
59
61
prim_inet:connect(S, Addr, P).