Module ppspp_options

Provides opaque wrapper around PPSPP options, including wire encoding and decoding.

Description

This module implements opaque types and accessor functions necessary to handle parsing PPSPP options wire-protocol of PPSPP over UDP, including functions for encoding and decoding.

Data Types

content_integrity_protection_method()


content_integrity_protection_method() = no_integrity_protection |merkle_hash_tree |sign_all |unified_merkle_hash_tree

merkle_tree_hash_function()


merkle_tree_hash_function() = sha | sha224 | sha256 | sha384 | sha512

option()


option() = supported_version |minimum_version |swarm_id |content_integrity_check_method |merkle_hash_tree_function |live_signature_algorithm |live_discard_window |supported_messages |end_option |default_chunk_size |chunk_addressing_method

options()


options() = #{option() => any()}

TODO could be restricted further.

swarm_id()


swarm_id() = binary()

TODO could be restricted further.

Function Index

get_chunk_addressing_method/1Returns chunking method for the swarm.
get_chunk_size/1Returns the swarm chunk size.
get_content_integrity_check_method/1Returns CIPM for the provided swarm.
get_maximum_supported_version/1Returns the highest accepted PPSP version for the swarm.
get_merkle_hash_tree_function/1Returns the hash function for the provided swarm.
get_minimum_version/1Returns the lowest accepted PPSP version for the swarm.
get_swarm_id/1Returns the embedded swarm_id.
pack/1Pack a map of erlang terms into a binary PPSPP message segment.
unpack/1Unpack PPPSPP options as encoded in wire format into erlang terms.
use_default_options/0Provides standard options from the PPSPP RFC as erlang terms.
use_default_options/1Provides standard options from the PPSPP RFC as erlang terms.
use_minimum_options/0Provides standard options from the PPSPP RFC as erlang terms.

Function Details

get_chunk_addressing_method/1


get_chunk_addressing_method(Options :: options()) -> any()

Returns chunking method for the swarm

get_chunk_size/1


get_chunk_size(Options :: options()) -> pos_integer()

Returns the swarm chunk size

get_content_integrity_check_method/1


get_content_integrity_check_method(Options :: options()) -> any()

Returns CIPM for the provided swarm

get_maximum_supported_version/1


get_maximum_supported_version(Options :: options()) -> any()

Returns the highest accepted PPSP version for the swarm.

get_merkle_hash_tree_function/1


get_merkle_hash_tree_function(Options :: options()) -> any()

Returns the hash function for the provided swarm

get_minimum_version/1


get_minimum_version(Options :: options()) -> any()

Returns the lowest accepted PPSP version for the swarm.

get_swarm_id/1


get_swarm_id(Options :: options()) -> swarm_id()

Returns the embedded swarm_id.

pack/1


pack(X1 :: options()) -> binary()

Pack a map of erlang terms into a binary PPSPP message segment

unpack/1


unpack(Maybe_Options :: binary()) ->{binary(), options()} | {error, any()}

Unpack PPPSPP options as encoded in wire format into erlang terms.

use_default_options/0


use_default_options() -> options()

Provides standard options from the PPSPP RFC as erlang terms.

Most users and programmers will take the standard options from the RFC. Takes 1 optional parameter, a binary representing the root hash, or a string in hex. Blank swarm options are used for starting peer_workers that may handle many peer swarms concurrently on different channels. It returns:


  options => #{
         chunk_addressing_method => chunking_32bit_chunks,
         chunk_size => 1024,
         content_integrity_check_method => merkle_hash_tree,
         merkle_hash_tree_function => sha256,
         minimum_version => 1,
         supported_version => 1,
         swarm_id => your_swarm_id_here }.

use_default_options/1


use_default_options(Hex_String :: string() | swarm_id()) ->options()

Provides standard options from the PPSPP RFC as erlang terms.

use_minimum_options/0


use_minimum_options() -> options()

Provides standard options from the PPSPP RFC as erlang terms. This function provides the minimum set of ppspp options to use during parsing of handshake messages. In all other message types, one can expect a full set of valid options to be retrieved from the mutually agreed swarm options that are assigned to this particular swarm / channel.