2012-08-27 00:34:59 +00:00
|
|
|
/*
|
2013-12-04 06:26:55 +00:00
|
|
|
Serval DNA MDP overlay frame
|
2012-08-27 00:34:59 +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__OVERLAY_PACKET_H
|
|
|
|
#define __SERVAL_DNA__OVERLAY_PACKET_H
|
2012-08-27 00:34:59 +00:00
|
|
|
|
|
|
|
#include "overlay_address.h"
|
|
|
|
#include "serval.h"
|
|
|
|
|
2013-05-20 03:53:35 +00:00
|
|
|
#define FRAME_NOT_SENT -1
|
|
|
|
#define FRAME_DONT_SEND -2
|
|
|
|
|
2013-08-08 05:50:31 +00:00
|
|
|
#define MAX_PACKET_DESTINATIONS OVERLAY_MAX_INTERFACES
|
|
|
|
|
|
|
|
struct packet_destination{
|
|
|
|
// if we've sent this packet once, what was the envelope sequence number?
|
|
|
|
int sent_sequence;
|
2013-08-29 05:35:32 +00:00
|
|
|
// track when we last sent this packet. if we don't get an ack, send it again.
|
|
|
|
time_ms_t transmit_time;
|
2013-08-15 00:45:08 +00:00
|
|
|
// the actual out going stream for this packet
|
2013-08-08 05:50:31 +00:00
|
|
|
struct network_destination *destination;
|
|
|
|
};
|
|
|
|
|
2012-08-27 00:34:59 +00:00
|
|
|
struct overlay_frame {
|
2013-08-15 00:45:08 +00:00
|
|
|
// packet queue pointers
|
2012-08-27 00:34:59 +00:00
|
|
|
struct overlay_frame *prev;
|
|
|
|
struct overlay_frame *next;
|
2013-08-15 00:45:08 +00:00
|
|
|
// when did we insert into the queue?
|
|
|
|
time_ms_t enqueued_at;
|
2012-08-27 00:34:59 +00:00
|
|
|
|
2013-08-15 00:45:08 +00:00
|
|
|
// deprecated, all future "types" should just be assigned port numbers
|
2012-08-27 00:34:59 +00:00
|
|
|
unsigned int type;
|
2013-08-15 00:45:08 +00:00
|
|
|
// encrypted? signed?
|
2012-08-27 00:34:59 +00:00
|
|
|
unsigned int modifiers;
|
|
|
|
|
|
|
|
unsigned char ttl;
|
2013-08-15 00:45:08 +00:00
|
|
|
// Which QOS queue?
|
2012-10-09 05:14:37 +00:00
|
|
|
unsigned char queue;
|
2013-08-15 00:45:08 +00:00
|
|
|
// Should we keep trying until acked?
|
2013-05-15 02:03:43 +00:00
|
|
|
char resend;
|
2013-08-15 00:45:08 +00:00
|
|
|
|
|
|
|
// callback and context just before packet sending
|
2013-05-15 04:57:38 +00:00
|
|
|
void *send_context;
|
|
|
|
int (*send_hook)(struct overlay_frame *, int seq, void *context);
|
2012-08-27 00:34:59 +00:00
|
|
|
|
2013-08-15 00:45:08 +00:00
|
|
|
// when should we send it?
|
2013-08-08 05:50:31 +00:00
|
|
|
time_ms_t delay_until;
|
2013-08-15 00:45:08 +00:00
|
|
|
// where should we send it?
|
2013-08-08 05:50:31 +00:00
|
|
|
struct packet_destination destinations[MAX_PACKET_DESTINATIONS];
|
|
|
|
int destination_count;
|
2013-08-15 00:45:08 +00:00
|
|
|
// how often have we sent it?
|
2013-08-09 06:49:45 +00:00
|
|
|
int transmit_count;
|
|
|
|
|
2013-08-08 05:50:31 +00:00
|
|
|
// each payload gets a sequence number that is reused on retransmission
|
2013-05-24 04:22:31 +00:00
|
|
|
int32_t mdp_sequence;
|
2012-08-27 00:34:59 +00:00
|
|
|
|
2013-08-15 00:45:08 +00:00
|
|
|
// packet addressing;
|
|
|
|
// where did this packet originate?
|
|
|
|
struct subscriber *source;
|
|
|
|
// where is this packet destined for
|
|
|
|
// for broadcast packets, the destination will be null and the broadcast_id will be set if ttl>1
|
2012-08-27 00:34:59 +00:00
|
|
|
struct subscriber *destination;
|
2013-08-08 05:50:31 +00:00
|
|
|
struct broadcast broadcast_id;
|
2013-08-15 00:45:08 +00:00
|
|
|
// where is this packet going next?
|
2012-12-03 03:14:31 +00:00
|
|
|
struct subscriber *next_hop;
|
2013-08-15 00:45:08 +00:00
|
|
|
|
|
|
|
// should we force the next packet header to include our full public key?
|
2012-12-11 03:02:02 +00:00
|
|
|
int source_full;
|
2012-08-27 00:34:59 +00:00
|
|
|
|
2013-08-15 00:45:08 +00:00
|
|
|
// how did we receive this packet?
|
2012-11-30 03:15:08 +00:00
|
|
|
overlay_interface *interface;
|
2013-08-15 00:45:08 +00:00
|
|
|
struct sockaddr_in recvaddr;
|
|
|
|
// packet envelope header;
|
|
|
|
// Was it a unicast frame
|
2012-12-14 06:30:54 +00:00
|
|
|
char unicast;
|
2013-08-15 00:45:08 +00:00
|
|
|
// what encoding version was used / should be used?
|
2013-05-24 04:22:31 +00:00
|
|
|
int packet_version;
|
2013-08-15 00:45:08 +00:00
|
|
|
// which interface did the previous hop sent it from?
|
2013-08-08 05:50:31 +00:00
|
|
|
int sender_interface;
|
2012-08-27 00:34:59 +00:00
|
|
|
|
2013-08-15 00:45:08 +00:00
|
|
|
// Raw wire format of the payload, probably encrypted or signed.
|
2012-08-27 00:34:59 +00:00
|
|
|
struct overlay_buffer *payload;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int op_free(struct overlay_frame *p);
|
|
|
|
struct overlay_frame *op_dup(struct overlay_frame *f);
|
|
|
|
|
2013-12-04 06:44:14 +00:00
|
|
|
#endif //__SERVAL_DNA__OVERLAY_PACKET_H
|