Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add tcp6/ssl6 transport modules + define behaviour

  • Loading branch information...
commit ad09b084cd1b4319ece7f2ccddfd3211a5b604ea 1 parent 71138a9
Nicolas Niclausse nniclausse authored
37 src/tsung/gen_ts_transport.erl
... ... @@ -0,0 +1,37 @@
  1 +%%% Copyright (C) 2012 Nicolas Niclausse
  2 +%%%
  3 +%%% This program is free software; you can redistribute it and/or modify
  4 +%%% it under the terms of the GNU General Public License as published by
  5 +%%% the Free Software Foundation; either version 2 of the License, or
  6 +%%% (at your option) any later version.
  7 +%%%
  8 +%%% This program is distributed in the hope that it will be useful,
  9 +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
  10 +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11 +%%% GNU General Public License for more details.
  12 +%%%
  13 +%%% You should have received a copy of the GNU General Public License
  14 +%%% along with this program; if not, write to the Free Software
  15 +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  16 +%%%
  17 +%%% Created : 7 Sep 2012 by Nicolas Niclausse <nicolas@niclux.org>
  18 +
  19 +%%% In addition, as a special exception, you have the permission to
  20 +%%% link the code of this program with any library released under
  21 +%%% the EPL license and distribute linked combinations including
  22 +%%% the two.
  23 +
  24 +-module(gen_ts_transport).
  25 +
  26 +-export([behaviour_info/1]).
  27 +
  28 +behaviour_info(callbacks) ->
  29 + [{connect, 3},
  30 + {send, 3},
  31 + {close, 1},
  32 + {set_opts, 2},
  33 + {protocol_options, 1},
  34 + {normalize_incomming_data, 2}];
  35 +
  36 +behaviour_info(_Other) ->
  37 + undefined.
61 src/tsung/ts_ssl6.erl
... ... @@ -0,0 +1,61 @@
  1 +%%%
  2 +%%% Copyright 2012 © Nicolas Niclausse
  3 +%%%
  4 +%%% Author : Nicolas Niclausse <nicolas.nniclausse@niclux.org>
  5 +%%% Created: 7 sep 2012 by Nicolas Niclausse <nicolas.nniclausse@niclux.org>
  6 +%%%
  7 +%%% This program is free software; you can redistribute it and/or modify
  8 +%%% it under the terms of the GNU General Public License as published by
  9 +%%% the Free Software Foundation; either version 2 of the License, or
  10 +%%% (at your option) any later version.
  11 +%%%
  12 +%%% This program is distributed in the hope that it will be useful,
  13 +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15 +%%% GNU General Public License for more details.
  16 +%%%
  17 +%%% You should have received a copy of the GNU General Public License
  18 +%%% along with this program; if not, write to the Free Software
  19 +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  20 +%%%
  21 +%%% In addition, as a special exception, you have the permission to
  22 +%%% link the code of this program with any library released under
  23 +%%% the EPL license and distribute linked combinations including
  24 +%%% the two.
  25 +
  26 +-module(ts_ssl6).
  27 +
  28 +-export([ connect/3,connect/2, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]).
  29 +
  30 +-behaviour(gen_ts_transport).
  31 +
  32 +-include("ts_profile.hrl").
  33 +-include("ts_config.hrl").
  34 +
  35 +
  36 +protocol_options(Opts) ->
  37 + [inet6]++ts_ssl:protocol_options(Opts).
  38 +
  39 +%% -> {ok, Socket}
  40 +connect(Host, Port, Opts) ->
  41 + ssl:connect(Host, Port, Opts).
  42 +
  43 +connect(Socket, Opts)->
  44 + ssl:connect(Socket, Opts).
  45 +
  46 +%% send/3 -> ok | {error, Reason}
  47 +send(Socket, Data, _Opts) ->
  48 + ssl:send(Socket, Data).
  49 +
  50 +close(Socket) ->
  51 + ssl:close(Socket).
  52 +
  53 +% set_opts/2 -> socket()
  54 +set_opts(Socket, Opts) ->
  55 + ssl:setopts(Socket, Opts),
  56 + Socket.
  57 +
  58 +normalize_incomming_data(Socket, Data) ->
  59 + ts_ssl:normalize_incomming_data(Socket,Data).
  60 +
  61 +
56 src/tsung/ts_tcp6.erl
... ... @@ -0,0 +1,56 @@
  1 +%%%
  2 +%%% Copyright 2012 © Nicolas Niclausse
  3 +%%%
  4 +%%% Author : Nicolas Niclausse <nicolas.nniclausse@niclux.org>
  5 +%%% Created: 7 sep 2012 by Nicolas Niclausse <nicolas.nniclausse@niclux.org>
  6 +%%%
  7 +%%% This program is free software; you can redistribute it and/or modify
  8 +%%% it under the terms of the GNU General Public License as published by
  9 +%%% the Free Software Foundation; either version 2 of the License, or
  10 +%%% (at your option) any later version.
  11 +%%%
  12 +%%% This program is distributed in the hope that it will be useful,
  13 +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15 +%%% GNU General Public License for more details.
  16 +%%%
  17 +%%% You should have received a copy of the GNU General Public License
  18 +%%% along with this program; if not, write to the Free Software
  19 +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  20 +%%%
  21 +%%% In addition, as a special exception, you have the permission to
  22 +%%% link the code of this program with any library released under
  23 +%%% the EPL license and distribute linked combinations including
  24 +%%% the two.
  25 +
  26 +-module(ts_tcp6).
  27 +
  28 +-export([ connect/3, send/3, close/1, set_opts/2, protocol_options/1, normalize_incomming_data/2 ]).
  29 +
  30 +-behaviour(gen_ts_transport).
  31 +
  32 +-include("ts_profile.hrl").
  33 +-include("ts_config.hrl").
  34 +
  35 +protocol_options(Opts) ->
  36 + [inet6]++ts_tcp:protocol_options(Opts).
  37 +
  38 +connect(Host, Port, Opts) ->
  39 + gen_tcp:connect(Host, Port, Opts).
  40 +
  41 +%% send/3 -> ok | {error, Reason}
  42 +send(Socket, Data, _Opts) ->
  43 + gen_tcp:send(Socket, Data).
  44 +
  45 +close(Socket) ->
  46 + gen_tcp:close(Socket).
  47 +
  48 +% set_opts/2 -> socket()
  49 +set_opts(Socket, Opts) ->
  50 + inet:setopts(Socket, Opts),
  51 + Socket.
  52 +
  53 +normalize_incomming_data(Socket,Data) ->
  54 + ts_tcp:normalize_incomming_data(Socket,Data).
  55 +
  56 +

0 comments on commit ad09b08

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