Skip to content

Instantly share code, notes, and snippets.

View RoadRunnr's full-sized avatar

Andreas Schultz RoadRunnr

  • Travelping GmbH
  • Magdeburg
View GitHub Profile
-module(testm).
-behaviour(gen_statem).
-export([start_link/0, run/1, run/2]).
-export([callback_mode/0, init/1, terminate/3]).
-export([handle_event/4]).
-define(SERVER, ?MODULE).
#!/usr/bin/env escript
%% -*- erlang -*-
%%! +sbtu +A1
-mode(compile).
-export([init_server/1]).
-define(UNIT, nanosecond).
%%-define(UNIT, millisecond).
#!/usr/bin/env escript
-include_lib("kernel/include/inet.hrl").
-include_lib("kernel/include/inet_sctp.hrl").
main([Protocol, IP, Port, Len, Cnt]) ->
bench(list_to_atom(Protocol), inet:parse_address(IP),
list_to_integer(Port), list_to_integer(Len), list_to_integer(Cnt));
main(_) ->
io:format("invalid arguments~n~n"),
@RoadRunnr
RoadRunnr / aes_cmac.erl
Created August 21, 2016 12:38
Erlang AES CMAC
-module(aes_cmac).
%% R20 will have CMAC in crypto....
-export([aes_cmac/2, generate_subkeys/1]).
-define(Zero, <<0:128>>).
-define(Rb, <<16#87:128>>).
-define(BlockSize, 16).
%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%%----------------------------------------------------------------------
%% Purpose : UDP API Wrapper
%%----------------------------------------------------------------------
-module(capwap_udp).
-behavior(gen_server).
-include("capwap_debug.hrl").
@RoadRunnr
RoadRunnr / echo_ssl_udp.erl
Created March 4, 2016 09:51
simple echo server for DTLSex
-module(echo_ssl_udp).
-compile([export_all]).
%%-include_lib("ssl/include/ssl_srp.hrl").
main() ->
application:ensure_all_started(ssl),
application:set_env(ssl, dtls_msg_seq, [[1],[2,1,3]]),
{ok, ListenSocket} = ssl:listen(4433, mk_opts("server")),
@RoadRunnr
RoadRunnr / dtls_client.erl
Created February 8, 2016 07:50
Erlang DTLS sample client
-module(dtls_client).
-export([connect/1]).
psk_verify(Username, UserState) ->
io:format("Server Hint: ~p~n", [Username]),
{ok, UserState}.
connect(Port) ->
[application:start(X) || X <- [crypto, asn1, public_key, ssl]],