mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 10:46:23 +00:00
Display where packets came from in debug messages
This commit is contained in:
parent
6c16b95a38
commit
a9545ea004
@ -830,7 +830,7 @@ static struct overlay_buffer * encrypt_payload(
|
||||
|
||||
// encrypt or sign the plaintext, then queue the frame for transmission.
|
||||
// Note, the position of the payload MUST be at the start of the data, the limit MUST be used to specify the end
|
||||
int overlay_send_frame(struct internal_mdp_header *header, struct overlay_buffer *payload)
|
||||
int _overlay_send_frame(struct __sourceloc whence, struct internal_mdp_header *header, struct overlay_buffer *payload)
|
||||
{
|
||||
if ((!header->destination) || header->destination->reachable == REACHABLE_SELF){
|
||||
ob_checkpoint(payload);
|
||||
@ -958,7 +958,7 @@ int overlay_send_frame(struct internal_mdp_header *header, struct overlay_buffer
|
||||
if (!frame->destination && frame->ttl>1)
|
||||
overlay_broadcast_generate_address(&frame->broadcast_id);
|
||||
|
||||
if (overlay_payload_enqueue(frame)){
|
||||
if (_overlay_payload_enqueue(whence, frame)){
|
||||
op_free(frame);
|
||||
return -1;
|
||||
}
|
||||
|
@ -41,8 +41,10 @@ struct overlay_frame {
|
||||
// packet queue pointers
|
||||
struct overlay_frame *prev;
|
||||
struct overlay_frame *next;
|
||||
|
||||
// when did we insert into the queue?
|
||||
time_ms_t enqueued_at;
|
||||
struct __sourceloc whence;
|
||||
|
||||
// deprecated, all future "types" should just be assigned port numbers
|
||||
unsigned int type;
|
||||
|
@ -143,7 +143,7 @@ int overlay_queue_remaining(int queue){
|
||||
return overlay_tx[queue].maxLength - overlay_tx[queue].length;
|
||||
}
|
||||
|
||||
int overlay_payload_enqueue(struct overlay_frame *p)
|
||||
int _overlay_payload_enqueue(struct __sourceloc whence, struct overlay_frame *p)
|
||||
{
|
||||
/* Add payload p to queue q.
|
||||
|
||||
@ -156,6 +156,7 @@ int overlay_payload_enqueue(struct overlay_frame *p)
|
||||
assert(p != NULL);
|
||||
assert(p->queue < OQ_MAX);
|
||||
assert(p->payload != NULL);
|
||||
p->whence = whence;
|
||||
overlay_txqueue *queue = &overlay_tx[p->queue];
|
||||
|
||||
if (config.debug.packettx)
|
||||
@ -331,7 +332,7 @@ overlay_calc_queue_time(struct overlay_frame *frame)
|
||||
}
|
||||
|
||||
static void
|
||||
overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, time_ms_t now){
|
||||
overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, time_ms_t now, strbuf debug){
|
||||
struct overlay_frame *frame = queue->first;
|
||||
|
||||
// TODO stop when the packet is nearly full?
|
||||
@ -419,6 +420,12 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
||||
if (frame->source_full)
|
||||
my_subscriber->send_full=1;
|
||||
if (overlay_init_packet(packet, frame->packet_version, dest) != -1) {
|
||||
if (debug){
|
||||
strbuf_sprintf(debug, "building packet %s %s %d [",
|
||||
packet->destination->interface->name,
|
||||
alloca_socket_address(&packet->destination->address),
|
||||
packet->seq);
|
||||
}
|
||||
destination_index=i;
|
||||
frame->destinations[i].sent_sequence = dest->sequence_number;
|
||||
break;
|
||||
@ -472,7 +479,8 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
||||
}
|
||||
|
||||
frame->transmit_count++;
|
||||
|
||||
if (debug)
|
||||
strbuf_sprintf(debug, "%d(%s), ", frame->mdp_sequence, frame->whence.function);
|
||||
if (config.debug.overlayframes){
|
||||
DEBUGF("Appended payload %p, %d type %x len %zd for %s via %s",
|
||||
frame, frame->mdp_sequence,
|
||||
@ -503,10 +511,11 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
||||
|
||||
// fill a packet from our outgoing queues and send it
|
||||
static int
|
||||
overlay_fill_send_packet(struct outgoing_packet *packet, time_ms_t now) {
|
||||
overlay_fill_send_packet(struct outgoing_packet *packet, time_ms_t now, strbuf debug) {
|
||||
IN();
|
||||
int i;
|
||||
int ret=0;
|
||||
|
||||
// while we're looking at queues, work out when to schedule another packet
|
||||
unschedule(&next_packet);
|
||||
next_packet.alarm=0;
|
||||
@ -515,10 +524,14 @@ overlay_fill_send_packet(struct outgoing_packet *packet, time_ms_t now) {
|
||||
for (i=0;i<OQ_MAX;i++){
|
||||
overlay_txqueue *queue=&overlay_tx[i];
|
||||
|
||||
overlay_stuff_packet(packet, queue, now);
|
||||
overlay_stuff_packet(packet, queue, now, debug);
|
||||
}
|
||||
|
||||
if(packet->buffer){
|
||||
if (debug){
|
||||
strbuf_sprintf(debug, "]");
|
||||
DEBUGF("%s", strbuf_str(debug));
|
||||
}
|
||||
|
||||
overlay_broadcast_ensemble(packet->destination, packet->buffer);
|
||||
ret=1;
|
||||
@ -535,15 +548,25 @@ static void overlay_send_packet(struct sched_ent *UNUSED(alarm))
|
||||
struct outgoing_packet packet;
|
||||
bzero(&packet, sizeof(struct outgoing_packet));
|
||||
packet.seq=-1;
|
||||
overlay_fill_send_packet(&packet, gettime_ms());
|
||||
strbuf debug = config.debug.overlayframes?strbuf_alloca(256):NULL;
|
||||
overlay_fill_send_packet(&packet, gettime_ms(), debug);
|
||||
}
|
||||
|
||||
int overlay_send_tick_packet(struct network_destination *destination)
|
||||
{
|
||||
struct outgoing_packet packet;
|
||||
bzero(&packet, sizeof(struct outgoing_packet));
|
||||
if (overlay_init_packet(&packet, 0, destination) != -1)
|
||||
overlay_fill_send_packet(&packet, gettime_ms());
|
||||
if (overlay_init_packet(&packet, 0, destination) != -1){
|
||||
strbuf debug = NULL;
|
||||
if (config.debug.overlayframes){
|
||||
debug = strbuf_alloca(256);
|
||||
strbuf_sprintf(debug, "building packet %s %s %d [",
|
||||
packet.destination->interface->name,
|
||||
alloca_socket_address(&packet.destination->address),
|
||||
packet.seq);
|
||||
}
|
||||
overlay_fill_send_packet(&packet, gettime_ms(), debug);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
7
serval.h
7
serval.h
@ -206,7 +206,8 @@ void rhizome_sync_status_html(struct strbuf *b, struct subscriber *subscriber);
|
||||
int rhizome_cache_count();
|
||||
|
||||
int overlayServerMode(void);
|
||||
int overlay_payload_enqueue(struct overlay_frame *p);
|
||||
int _overlay_payload_enqueue(struct __sourceloc whence, struct overlay_frame *p);
|
||||
#define overlay_payload_enqueue(P) _overlay_payload_enqueue(__WHENCE__,P)
|
||||
int overlay_queue_remaining(int queue);
|
||||
int overlay_queue_schedule_next(time_ms_t next_allowed_packet);
|
||||
int overlay_send_tick_packet(struct network_destination *destination);
|
||||
@ -230,8 +231,8 @@ void mdp_init_response(const struct internal_mdp_header *in, struct internal_mdp
|
||||
void overlay_mdp_encode_ports(struct overlay_buffer *plaintext, mdp_port_t dst_port, mdp_port_t src_port);
|
||||
int overlay_mdp_dnalookup_reply(struct subscriber *dest, mdp_port_t dest_port,
|
||||
struct subscriber *resolved_sid, const char *uri, const char *did, const char *name);
|
||||
int overlay_send_frame(struct internal_mdp_header *header, struct overlay_buffer *payload);
|
||||
|
||||
int _overlay_send_frame(struct __sourceloc whence, struct internal_mdp_header *header, struct overlay_buffer *payload);
|
||||
#define overlay_send_frame(H, P) _overlay_send_frame(__WHENCE__, H, P)
|
||||
int mdp_bind_internal(struct subscriber *subscriber, mdp_port_t port,
|
||||
int (*internal)(struct internal_mdp_header *header, struct overlay_buffer *payload));
|
||||
int mdp_unbind_internal(struct subscriber *subscriber, mdp_port_t port,
|
||||
|
Loading…
Reference in New Issue
Block a user