Skip to content
Browse files

add tcp6/ssl6 transport modules + define behaviour

  • Loading branch information...
1 parent 71138a9 commit ad09b084cd1b4319ece7f2ccddfd3211a5b604ea @nniclausse nniclausse committed Sep 7, 2012
Showing with 154 additions and 0 deletions.
  1. +37 −0 src/tsung/gen_ts_transport.erl
  2. +61 −0 src/tsung/ts_ssl6.erl
  3. +56 −0 src/tsung/ts_tcp6.erl
View
37 src/tsung/gen_ts_transport.erl
@@ -0,0 +1,37 @@
+%%% Copyright (C) 2012 Nicolas Niclausse
+%%%
+%%% This program is free software; you can redistribute it and/or modify
+%%% it under the terms of the GNU General Public License as published by
+%%% the Free Software Foundation; either version 2 of the License, or
+%%% (at your option) any later version.
+%%%
+%%% This program is distributed in the hope that it will be useful,
+%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+%%% GNU General Public License for more details.
+%%%
+%%% You should have received a copy of the GNU General Public License
+%%% along with this program; if not, write to the Free Software
+%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+%%%
+%%% Created : 7 Sep 2012 by Nicolas Niclausse <nicolas@niclux.org>
+
+%%% In addition, as a special exception, you have the permission to
+%%% link the code of this program with any library released under
+%%% the EPL license and distribute linked combinations including
+%%% the two.
+
+-module(gen_ts_transport).
+
+-export([behaviour_info/1]).
+
+behaviour_info(callbacks) ->
+ [{connect, 3},
+ {send, 3},
+ {close, 1},
+ {set_opts, 2},
+ {protocol_options, 1},
+ {normalize_incomming_data, 2}];
+
+behaviour_info(_Other) ->
+ undefined.
View
61 src/tsung/ts_ssl6.erl
@@ -0,0 +1,61 @@
+%%%
+%%% Copyright 2012 © Nicolas Niclausse
+%%%
+%%% Author : Nicolas Niclausse <nicolas.nniclausse@niclux.org>
+%%% Created: 7 sep 2012 by Nicolas Niclausse <nicolas.nniclausse@niclux.org>
+%%%
+%%% This program is free software; you can redistribute it and/or modify
+%%% it under the terms of the GNU General Public License as published by
+%%% the Free Software Foundation; either version 2 of the License, or
+%%% (at your option) any later version.
+%%%
+%%% This program is distributed in the hope that it will be useful,
+%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+%%% GNU General Public License for more details.
+%%%
+%%% You should have received a copy of the GNU General Public License
+%%% along with this program; if not, write to the Free Software
+%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+%%%
+%%% In addition, as a special exception, you have the permission to
+%%% link the code of this program with any library released under
+%%% the EPL license and distribute linked combinations including
+%%% the two.
+
+-module(ts_ssl6).
+
+-export([ connect/3,connect/2, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]).
+
+-behaviour(gen_ts_transport).
+
+-include("ts_profile.hrl").
+-include("ts_config.hrl").
+
+
+protocol_options(Opts) ->
+ [inet6]++ts_ssl:protocol_options(Opts).
+
+%% -> {ok, Socket}
+connect(Host, Port, Opts) ->
+ ssl:connect(Host, Port, Opts).
+
+connect(Socket, Opts)->
+ ssl:connect(Socket, Opts).
+
+%% send/3 -> ok | {error, Reason}
+send(Socket, Data, _Opts) ->
+ ssl:send(Socket, Data).
+
+close(Socket) ->
+ ssl:close(Socket).
+
+% set_opts/2 -> socket()
+set_opts(Socket, Opts) ->
+ ssl:setopts(Socket, Opts),
+ Socket.
+
+normalize_incomming_data(Socket, Data) ->
+ ts_ssl:normalize_incomming_data(Socket,Data).
+
+
View
56 src/tsung/ts_tcp6.erl
@@ -0,0 +1,56 @@
+%%%
+%%% Copyright 2012 © Nicolas Niclausse
+%%%
+%%% Author : Nicolas Niclausse <nicolas.nniclausse@niclux.org>
+%%% Created: 7 sep 2012 by Nicolas Niclausse <nicolas.nniclausse@niclux.org>
+%%%
+%%% This program is free software; you can redistribute it and/or modify
+%%% it under the terms of the GNU General Public License as published by
+%%% the Free Software Foundation; either version 2 of the License, or
+%%% (at your option) any later version.
+%%%
+%%% This program is distributed in the hope that it will be useful,
+%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+%%% GNU General Public License for more details.
+%%%
+%%% You should have received a copy of the GNU General Public License
+%%% along with this program; if not, write to the Free Software
+%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+%%%
+%%% In addition, as a special exception, you have the permission to
+%%% link the code of this program with any library released under
+%%% the EPL license and distribute linked combinations including
+%%% the two.
+
+-module(ts_tcp6).
+
+-export([ connect/3, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]).
+
+-behaviour(gen_ts_transport).
+
+-include("ts_profile.hrl").
+-include("ts_config.hrl").
+
+protocol_options(Opts) ->
+ [inet6]++ts_tcp:protocol_options(Opts).
+
+connect(Host, Port, Opts) ->
+ gen_tcp:connect(Host, Port, Opts).
+
+%% send/3 -> ok | {error, Reason}
+send(Socket, Data, _Opts) ->
+ gen_tcp:send(Socket, Data).
+
+close(Socket) ->
+ gen_tcp:close(Socket).
+
+% set_opts/2 -> socket()
+set_opts(Socket, Opts) ->
+ inet:setopts(Socket, Opts),
+ Socket.
+
+normalize_incomming_data(Socket,Data) ->
+ ts_tcp:normalize_incomming_data(Socket,Data).
+
+

0 comments on commit ad09b08

Please sign in to comment.
Something went wrong with that request. Please try again.