-#include "fwp_ctabe.h"
+#include "fwp_ctable.h"
#define UN_CRTL_SOCKET "/var/run/fwp_local"
#define FWP_CONN_MAX 10
#define FWP_MTU 2346
+#define FWP_DATAMSG_SIZE_MAX FWP_MTU
+#define FWP_MNGTMSG_SIZE_MAX 128
+
#define MNGT_CLIENT_UDP_PORT 33333
#define MNGT_SERVER_UDP_PORT 33334
-#define NEGOTIATE_REQUEST 0x02
-#define NEGOTIATE_RESPONSE 0x03
-
-unsigned char buffer[FWP_MTU];
-
-struct fwp_msg_header{
- unsigned int code;
- unsigned int hid; /* /< handshake ID */
-};
+/*
+ * Global variables
+ * */
-struct fwp_negotiate_msg_t
-{
- struct fwp_msg_header header;
- unsigned int id; /*/< global contract_id */
- unsigned int ac_id; /*/< AC id ~ priority of vres */
- int bandwidth_bps; /*/< bits per second */
- long period_usec; /*/< all time units are in microseconds */
-};
+struct fwp_msgq msgq_negotiate;
+struct fwp_ctable ctable_negotiate;
+struct fwp_ctable ctable_accepted;
+unsigned char buffer[FWP_MTU];
-struct fwp_msgq negotiate_msgq;
-struct fwp_msgq mngt_msgq;
+/***/
void* recv_thread(void*udp_port)
{
#include "fwp_conf.h"
-typedef enum {
- LOCAL = 0,
- REMOTE = 1,
-} fwp_addr_t;
-
-struct fwp_msgq_entry {
+struct fwp_msgb {
struct sockaddr addr;
socklen_t addrlen;
- const void* data;// unsigned char data[FWP_MTU];
- size_t size;
+ unsigned char* data;// unsigned char data[FWP_MTU];
+ unsigned char* tail;
+ size_t len;
};
struct fwp_msgq {
/*struct sockaddr_in dest_addr;*/
/* For simplicity now */
- struct fwp_msgq_entry queue[FWP_MSGQ_SIZE];
+ struct fwp_msgb queue[FWP_MSGQ_SIZE];
unsigned int first, last;
/* will be replaced by :*/
return msgq->nr_pending;
}
+
+/*unsigned char* fwp_msgb_put(struct fwp_msgb* msgb, unsigned int len)
+{
+ unsigned char *tmp= msgb->tail;
+
+ skb->tail+=len;
+ skb->len+=len;
+ return tmp;
+}
+
+unsigned char* fwp_msgb_push(struct fwp_msgb* msgb, unsigned int len)
+{
+ msgb->data-=len;
+ msgb->len+=len;
+ return msgb->data;
+}
+
+unsigned char* fwp_msgb_pull(struct msgb* msgb, unsigned int len)
+{
+ if (len > msgb->len)
+ return NULL;
+
+ msgb->len -= len;
+ return msgb->data += len;
+}
+
+void fwp_msgb_reserve(struct msgb* msgb, unsigned int len)
+{
+ msgb->data+=len;
+ msgb->tail+=len;
+}
+*/