Skip to content
Snippets Groups Projects
Commit 643d905d authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[*] Renames, updates relates to peer-to-peer connections

parent 458d4e55
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "dap_client_remote.h" #include "dap_client_remote.h"
#include "dap_http_client.h" #include "dap_http_client.h"
#include "stream.h" #include "dap_stream.h"
#include "dap_stream_ch.h" #include "dap_stream_ch.h"
#include "dap_stream_ch_proc.h" #include "dap_stream_ch_proc.h"
#include "dap_stream_ch_pkt.h" #include "dap_stream_ch_pkt.h"
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
#include "dap_enc_key.h" #include "dap_enc_key.h"
#include "dap_client_remote.h" #include "dap_client_remote.h"
#include "stream.h" #include "dap_stream.h"
#include "dap_stream_ch.h" #include "dap_stream_ch.h"
#include "dap_stream_ch_pkt.h" #include "dap_stream_ch_pkt.h"
#include "dap_stream_ch_proc.h" #include "dap_stream_ch_proc.h"
#include "stream_pkt.h" #include "dap_stream_pkt.h"
#define LOG_TAG "dap_stream_ch_pkt" #define LOG_TAG "dap_stream_ch_pkt"
...@@ -63,7 +63,7 @@ size_t stream_ch_pkt_write_seq_id(struct dap_stream_ch * ch, uint8_t type, uint6 ...@@ -63,7 +63,7 @@ size_t stream_ch_pkt_write_seq_id(struct dap_stream_ch * ch, uint8_t type, uint6
//log_it(L_DEBUG,"Output: Has %u bytes of %c type for %c channel id",data_size, (char)type, (char) ch->proc->id ); //log_it(L_DEBUG,"Output: Has %u bytes of %c type for %c channel id",data_size, (char)type, (char) ch->proc->id );
stream_ch_pkt_hdr_t hdr; dap_stream_ch_pkt_hdr_t hdr;
memset(&hdr,0,sizeof(hdr)); memset(&hdr,0,sizeof(hdr));
hdr.id = ch->proc->id; hdr.id = ch->proc->id;
...@@ -79,7 +79,7 @@ size_t stream_ch_pkt_write_seq_id(struct dap_stream_ch * ch, uint8_t type, uint6 ...@@ -79,7 +79,7 @@ size_t stream_ch_pkt_write_seq_id(struct dap_stream_ch * ch, uint8_t type, uint6
memcpy(ch->buf,&hdr,sizeof(hdr) ); memcpy(ch->buf,&hdr,sizeof(hdr) );
memcpy(ch->buf+sizeof(hdr),data,data_size ); memcpy(ch->buf+sizeof(hdr),data,data_size );
size_t ret=stream_pkt_write(ch->stream,ch->buf,data_size+sizeof(hdr)); size_t ret=dap_stream_pkt_write(ch->stream,ch->buf,data_size+sizeof(hdr));
ch->stat.bytes_write+=data_size; ch->stat.bytes_write+=data_size;
pthread_mutex_unlock( &ch->mutex); pthread_mutex_unlock( &ch->mutex);
return ret; return ret;
...@@ -123,7 +123,7 @@ size_t stream_ch_pkt_write_f(struct dap_stream_ch * ch, uint8_t type, const char ...@@ -123,7 +123,7 @@ size_t stream_ch_pkt_write_f(struct dap_stream_ch * ch, uint8_t type, const char
size_t stream_ch_send_keepalive(struct dap_stream_ch * ch){ size_t stream_ch_send_keepalive(struct dap_stream_ch * ch){
pthread_mutex_lock( &ch->mutex); pthread_mutex_lock( &ch->mutex);
stream_ch_pkt_hdr_t hdr; dap_stream_ch_pkt_hdr_t hdr;
memset(&hdr,0,sizeof(hdr)); memset(&hdr,0,sizeof(hdr));
hdr.id = ch->proc->id; hdr.id = ch->proc->id;
...@@ -134,7 +134,7 @@ size_t stream_ch_send_keepalive(struct dap_stream_ch * ch){ ...@@ -134,7 +134,7 @@ size_t stream_ch_send_keepalive(struct dap_stream_ch * ch){
memcpy(ch->buf,&hdr,sizeof(hdr) ); memcpy(ch->buf,&hdr,sizeof(hdr) );
size_t ret=stream_pkt_write(ch->stream,ch->buf,sizeof(hdr)); size_t ret=dap_stream_pkt_write(ch->stream,ch->buf,sizeof(hdr));
pthread_mutex_unlock( &ch->mutex); pthread_mutex_unlock( &ch->mutex);
return ret; return ret;
} }
...@@ -19,15 +19,14 @@ ...@@ -19,15 +19,14 @@
*/ */
#ifndef _STREAM_CH_PKT_H_ #pragma once
#define _STREAM_CH_PKT_H_
#define KEEPALIVE_PACKET 0x11 #define KEEPALIVE_PACKET 0x11
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
struct dap_stream_ch; struct dap_stream_ch;
typedef struct stream_ch_pkt_hdr{ typedef struct dap_stream_ch_pkt_hdr{
uint8_t id; // Channel id uint8_t id; // Channel id
uint8_t enc_type; // Zero if not encrypted uint8_t enc_type; // Zero if not encrypted
uint8_t type; // general, command, info, signal and etc uint8_t type; // general, command, info, signal and etc
...@@ -35,20 +34,18 @@ typedef struct stream_ch_pkt_hdr{ ...@@ -35,20 +34,18 @@ typedef struct stream_ch_pkt_hdr{
uint64_t seq_id; // Sequence id or position id uint64_t seq_id; // Sequence id or position id
// uint64_t seq // uint64_t seq
uint32_t size; uint32_t size;
} __attribute__((packed)) stream_ch_pkt_hdr_t; } __attribute__((packed)) dap_stream_ch_pkt_hdr_t;
typedef struct stream_ch_pkt{ typedef struct dap_stream_ch_pkt{
stream_ch_pkt_hdr_t hdr; dap_stream_ch_pkt_hdr_t hdr;
uint8_t data[]; uint8_t data[];
} __attribute__((packed)) stream_ch_pkt_t; } __attribute__((packed)) dap_stream_ch_pkt_t;
extern int stream_ch_pkt_init(); int stream_ch_pkt_init();
extern void stream_ch_pkt_deinit(); void stream_ch_pkt_deinit();
extern size_t stream_ch_pkt_write_f(struct dap_stream_ch * ch, uint8_t type, const char * str,...); size_t stream_ch_pkt_write_f(struct dap_stream_ch * ch, uint8_t type, const char * str,...);
extern size_t stream_ch_pkt_write(struct dap_stream_ch * ch, uint8_t type, const void * data, uint32_t data_size); size_t stream_ch_pkt_write(struct dap_stream_ch * ch, uint8_t type, const void * data, uint32_t data_size);
extern size_t stream_ch_pkt_write_seq_id(struct dap_stream_ch * ch, uint8_t type, uint64_t seq_id, const void * data, uint32_t data_size); size_t stream_ch_pkt_write_seq_id(struct dap_stream_ch * ch, uint8_t type, uint64_t seq_id, const void * data, uint32_t data_size);
extern size_t stream_ch_send_keepalive(struct dap_stream_ch * ch); size_t stream_ch_send_keepalive(struct dap_stream_ch * ch);
#endif
...@@ -49,7 +49,7 @@ void stream_ch_proc_deinit() ...@@ -49,7 +49,7 @@ void stream_ch_proc_deinit()
* @param packet_in_callback * @param packet_in_callback
* @param packet_out_callback * @param packet_out_callback
*/ */
void stream_ch_proc_add(uint8_t id,dap_stream_ch_callback_t new_callback,dap_stream_ch_callback_t delete_callback, void dap_stream_ch_proc_add(uint8_t id,dap_stream_ch_callback_t new_callback,dap_stream_ch_callback_t delete_callback,
dap_stream_ch_callback_t packet_in_callback, dap_stream_ch_callback_t packet_in_callback,
dap_stream_ch_callback_t packet_out_callback dap_stream_ch_callback_t packet_out_callback
) )
......
...@@ -40,7 +40,7 @@ typedef struct dap_stream_ch_proc{ ...@@ -40,7 +40,7 @@ typedef struct dap_stream_ch_proc{
extern int stream_ch_proc_init(); extern int stream_ch_proc_init();
extern void stream_ch_proc_deinit(); extern void stream_ch_proc_deinit();
extern void stream_ch_proc_add(uint8_t id, extern void dap_stream_ch_proc_add(uint8_t id,
dap_stream_ch_callback_t new_callback, dap_stream_ch_callback_t delete_callback, dap_stream_ch_callback_t new_callback, dap_stream_ch_callback_t delete_callback,
dap_stream_ch_callback_t packet_in_callback, dap_stream_ch_callback_t packet_in_callback,
dap_stream_ch_callback_t packet_out_callback dap_stream_ch_callback_t packet_out_callback
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment