2012-07-30 03:28:21 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2012 Serval Project Inc.
|
|
|
|
|
|
|
|
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2013-12-04 06:44:14 +00:00
|
|
|
#ifndef __SERVAL_DNA__CONSTANTS_H
|
|
|
|
#define __SERVAL_DNA__CONSTANTS_H
|
2012-07-29 03:05:53 +00:00
|
|
|
|
2013-12-09 07:52:18 +00:00
|
|
|
/* Useful macros not specific to Serval DNA
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Number of elements in an array (Warning: does not work if A is a pointer!).
|
|
|
|
#define NELS(A) (sizeof (A) / sizeof *(A))
|
|
|
|
|
|
|
|
// To suppress the "unused parameter" warning from -Wunused-parameter.
|
|
|
|
#ifdef __GNUC__
|
|
|
|
# define UNUSED(x) x __attribute__((__unused__))
|
|
|
|
#else
|
|
|
|
# define UNUSED(x) x
|
|
|
|
#endif
|
2012-12-04 03:42:28 +00:00
|
|
|
|
2014-05-23 08:19:00 +00:00
|
|
|
// UDP Port numbers for various Serval services.
|
|
|
|
#define PORT_DNA 4110
|
2012-07-29 03:05:53 +00:00
|
|
|
|
|
|
|
#define OVERLAY_MAX_INTERFACES 16
|
|
|
|
|
|
|
|
#define CRYPT_CIPHERED 1
|
|
|
|
#define CRYPT_SIGNED 2
|
|
|
|
#define CRYPT_PUBLIC 4
|
|
|
|
|
|
|
|
#define OVERLAY_INTERFACE_UNKNOWN 0
|
|
|
|
#define OVERLAY_INTERFACE_ETHERNET 1
|
|
|
|
#define OVERLAY_INTERFACE_WIFI 2
|
|
|
|
#define OVERLAY_INTERFACE_PACKETRADIO 3
|
|
|
|
|
|
|
|
#define OQ_ISOCHRONOUS_VOICE 0
|
|
|
|
#define OQ_MESH_MANAGEMENT 1
|
|
|
|
#define OQ_ISOCHRONOUS_VIDEO 2
|
|
|
|
#define OQ_ORDINARY 3
|
|
|
|
#define OQ_OPPORTUNISTIC 4
|
|
|
|
#define OQ_MAX 5
|
|
|
|
|
|
|
|
#define OVERLAY_MAX_LOCAL_IDENTITIES 256
|
|
|
|
|
2012-11-27 00:54:03 +00:00
|
|
|
/* All of these types should be considered deprecated. Processing code should migrate to well known MDP port numbers */
|
2012-07-29 03:05:53 +00:00
|
|
|
/* Overlay mesh packet codes */
|
2013-05-09 05:29:33 +00:00
|
|
|
#define OF_TYPE_SELFANNOUNCE_ACK 0x20
|
2012-07-29 03:05:53 +00:00
|
|
|
#define OF_TYPE_DATA 0x30 /* Ordinary data frame.
|
|
|
|
Upto MTU bytes of payload.
|
|
|
|
32 bit channel/port indicator for each end.
|
|
|
|
*/
|
|
|
|
#define OF_TYPE_RHIZOME_ADVERT 0x50 /* Advertisment of file availability via Rhizome */
|
|
|
|
#define OF_TYPE_PLEASEEXPLAIN 0x60 /* Request for resolution of an abbreviated address */
|
2012-11-22 22:42:23 +00:00
|
|
|
|
2012-11-26 04:22:49 +00:00
|
|
|
#define PAYLOAD_FLAG_SENDER_SAME (1<<0)
|
|
|
|
#define PAYLOAD_FLAG_TO_BROADCAST (1<<1)
|
|
|
|
#define PAYLOAD_FLAG_ONE_HOP (1<<2)
|
|
|
|
#define PAYLOAD_FLAG_CIPHERED (1<<4)
|
|
|
|
#define PAYLOAD_FLAG_SIGNED (1<<5)
|
2013-08-30 07:54:52 +00:00
|
|
|
#define PAYLOAD_FLAG_ACK_SOON (1<<6)
|
2012-07-29 03:05:53 +00:00
|
|
|
|
2013-04-23 06:32:39 +00:00
|
|
|
/* Time-to-live is a 'uint5_t'.
|
|
|
|
*/
|
|
|
|
#define PAYLOAD_TTL_MAX (31)
|
|
|
|
#define PAYLOAD_TTL_DEFAULT (31)
|
|
|
|
|
2013-02-07 04:46:07 +00:00
|
|
|
// return codes for parsing mdp packet headers
|
|
|
|
#define HEADER_PROCESS 1
|
|
|
|
#define HEADER_FORWARD 2
|
|
|
|
|
2012-11-27 00:54:03 +00:00
|
|
|
// this can be removed once all overlay messages have been turned into mdp payloads
|
|
|
|
#define PAYLOAD_FLAG_LEGACY_TYPE (1<<7)
|
|
|
|
|
2012-07-29 03:05:53 +00:00
|
|
|
/* Crypto/security options */
|
|
|
|
#define OF_CRYPTO_NONE 0x00
|
2012-11-26 04:22:49 +00:00
|
|
|
#define OF_CRYPTO_CIPHERED PAYLOAD_FLAG_CIPHERED /* Encrypted frame */
|
|
|
|
#define OF_CRYPTO_SIGNED PAYLOAD_FLAG_SIGNED /* signed frame */
|
2012-07-29 03:05:53 +00:00
|
|
|
|
|
|
|
/* Keep track of last 32 observations of a node.
|
|
|
|
Hopefully this is enough, if not, we will increase.
|
|
|
|
To keep the requirement down we will collate contigious neighbour observations on each interface.
|
|
|
|
For node observations we can just replace old observations with new ones.
|
|
|
|
*/
|
|
|
|
#define OVERLAY_MAX_OBSERVATIONS 32
|
|
|
|
|
|
|
|
/* bitmask values for monitor_tell_clients */
|
|
|
|
#define MONITOR_VOMP (1<<0)
|
|
|
|
#define MONITOR_RHIZOME (1<<1)
|
|
|
|
#define MONITOR_PEERS (1<<2)
|
2012-08-10 05:58:56 +00:00
|
|
|
#define MONITOR_DNAHELPER (1<<3)
|
2013-05-02 04:57:23 +00:00
|
|
|
#define MONITOR_LINKS (1<<4)
|
2012-07-29 03:05:53 +00:00
|
|
|
|
|
|
|
#define MAX_SIGNATURES 16
|
|
|
|
|
2012-11-27 00:59:42 +00:00
|
|
|
#define MDP_PORT_KEYMAPREQUEST 1
|
2013-04-26 07:23:04 +00:00
|
|
|
#define MDP_PORT_LINKSTATE 2
|
2012-12-07 05:34:40 +00:00
|
|
|
#define MDP_PORT_STUNREQ 4
|
|
|
|
#define MDP_PORT_STUN 5
|
2012-12-04 04:17:57 +00:00
|
|
|
#define MDP_PORT_PROBE 6
|
2012-11-27 00:59:42 +00:00
|
|
|
#define MDP_PORT_ECHO 7
|
2013-02-18 04:01:01 +00:00
|
|
|
#define MDP_PORT_TRACE 8
|
2012-12-03 03:40:32 +00:00
|
|
|
#define MDP_PORT_DNALOOKUP 10
|
2014-05-09 00:32:44 +00:00
|
|
|
#define MDP_PORT_SERVICE_DISCOVERY 11
|
2012-12-03 03:40:32 +00:00
|
|
|
#define MDP_PORT_VOMP 12
|
|
|
|
#define MDP_PORT_RHIZOME_REQUEST 13
|
|
|
|
#define MDP_PORT_RHIZOME_RESPONSE 14
|
|
|
|
#define MDP_PORT_DIRECTORY 15
|
2013-02-12 00:04:04 +00:00
|
|
|
#define MDP_PORT_RHIZOME_MANIFEST_REQUEST 16
|
2013-06-18 03:57:26 +00:00
|
|
|
#define MDP_PORT_RHIZOME_SYNC 17
|
2012-11-27 00:59:42 +00:00
|
|
|
#define MDP_PORT_NOREPLY 0x3f
|
2012-07-29 03:05:53 +00:00
|
|
|
|
|
|
|
#define MDP_TYPE_MASK 0xff
|
|
|
|
#define MDP_FLAG_MASK 0xff00
|
|
|
|
#define MDP_FORCE 0x0100
|
|
|
|
#define MDP_NOCRYPT 0x0200
|
|
|
|
#define MDP_NOSIGN 0x0400
|
2012-11-26 04:58:56 +00:00
|
|
|
#define MDP_MTU 1200
|
2012-07-29 03:05:53 +00:00
|
|
|
|
|
|
|
#define MDP_TX 1
|
|
|
|
#define MDP_BIND 3
|
|
|
|
#define MDP_ERROR 4
|
|
|
|
#define MDP_GETADDRS 5
|
|
|
|
#define MDP_ADDRLIST 6
|
2012-11-26 04:10:22 +00:00
|
|
|
#define MDP_ROUTING_TABLE 7
|
|
|
|
#define MDP_GOODBYE 9
|
2012-12-05 04:43:47 +00:00
|
|
|
#define MDP_SCAN 10
|
2012-07-29 03:05:53 +00:00
|
|
|
|
|
|
|
// These are back-compatible with the old values of 'mode' when it was 'selfP'
|
|
|
|
#define MDP_ADDRLIST_MODE_ROUTABLE_PEERS 0
|
|
|
|
#define MDP_ADDRLIST_MODE_SELF 1
|
|
|
|
#define MDP_ADDRLIST_MODE_ALL_PEERS 2
|
|
|
|
|
|
|
|
/* 59*32 < (MDP_MTU-100), so up to 59 SIDs in a single reply.
|
|
|
|
Multiple replies can be used to respond with more. */
|
|
|
|
#define MDP_MAX_SID_REQUEST 59
|
|
|
|
|
|
|
|
/* Maximum amount of audio to cram into a VoMP audio packet.
|
|
|
|
More lets us include preemptive retransmissions.
|
|
|
|
Less reduces the chance of packets getting lost, and reduces
|
|
|
|
the bandwidth used. */
|
|
|
|
#define VOMP_STUFF_BYTES 800
|
|
|
|
|
|
|
|
#define MAX_AUDIO_BYTES 1024
|
|
|
|
#define MDP_AWAITREPLY 9999
|
|
|
|
|
2012-11-14 05:20:22 +00:00
|
|
|
// codec's with well defined parameters
|
|
|
|
#define VOMP_CODEC_16SIGNED 0x01
|
|
|
|
#define VOMP_CODEC_ULAW 0x02
|
|
|
|
#define VOMP_CODEC_ALAW 0x03
|
|
|
|
#define VOMP_CODEC_GSM 0x04
|
2013-06-25 01:04:26 +00:00
|
|
|
#define VOMP_CODEC_CODEC2_1200 0x05
|
|
|
|
#define VOMP_CODEC_CODEC2_3200 0x06
|
|
|
|
#define VOMP_CODEC_OPUS 0x07
|
2012-11-14 05:20:22 +00:00
|
|
|
|
|
|
|
// other out of band signals, probably shouldn't be codecs
|
|
|
|
#define VOMP_CODEC_DTMF 0x20
|
|
|
|
#define VOMP_CODEC_TEXT 0x21
|
|
|
|
|
|
|
|
// Note, Don't add codec's we aren't using yet
|
2012-09-27 06:57:37 +00:00
|
|
|
|
|
|
|
#define CODEC_FLAGS_LENGTH 32
|
2012-07-29 03:05:53 +00:00
|
|
|
|
2012-08-09 02:22:44 +00:00
|
|
|
// force state packet interval
|
2012-07-29 03:05:53 +00:00
|
|
|
#define VOMP_CALL_STATUS_INTERVAL 1000
|
|
|
|
|
2013-02-14 03:48:56 +00:00
|
|
|
#define SOCK_FILE 0xFF
|
|
|
|
#define SOCK_UNSPECIFIED 0
|
|
|
|
|
|
|
|
#define ENCAP_OVERLAY 1
|
|
|
|
#define ENCAP_SINGLE 2
|
|
|
|
|
2013-10-14 03:58:48 +00:00
|
|
|
// numbers chosen to not conflict with KEYTYPE flags
|
|
|
|
#define UNLOCK_REQUEST (0xF0)
|
|
|
|
#define UNLOCK_CHALLENGE (0xF1)
|
|
|
|
#define UNLOCK_RESPONSE (0xF2)
|
|
|
|
|
2013-12-04 06:44:14 +00:00
|
|
|
#endif // __SERVAL_DNA__CONSTANTS_H
|