...
FossilOrigin-Name: 2a80ff74e83e1f6e99aba589ec8cec08d640199362326c61959aff81e93c5e0c
This commit is contained in:
parent
a7a0616854
commit
e638fd4aa2
@ -13,6 +13,7 @@ static int pmessage(void *w, struct cwrmsg * cwrmsg)
|
|||||||
{
|
{
|
||||||
uint8_t * buffer;
|
uint8_t * buffer;
|
||||||
buffer = malloc( sizeof (struct cwrmsg) + cwrmsg->msgelems_len);
|
buffer = malloc( sizeof (struct cwrmsg) + cwrmsg->msgelems_len);
|
||||||
|
|
||||||
memcpy(buffer,cwrmsg,sizeof(struct cwrmsg));
|
memcpy(buffer,cwrmsg,sizeof(struct cwrmsg));
|
||||||
memcpy(buffer+sizeof(struct cwrmsg),cwrmsg->msgelems,cwrmsg->msgelems_len);
|
memcpy(buffer+sizeof(struct cwrmsg),cwrmsg->msgelems,cwrmsg->msgelems_len);
|
||||||
((struct cwrmsg*)(buffer))->msgelems=buffer+sizeof(struct cwrmsg);
|
((struct cwrmsg*)(buffer))->msgelems=buffer+sizeof(struct cwrmsg);
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
struct cwrmsg * conn_get_response(struct conn * conn)
|
struct cwrmsg * conn_get_response(struct conn * conn)
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("Starting timer 120\n");
|
|
||||||
time_t timer = cw_timer_start(160);
|
|
||||||
|
|
||||||
struct cwmsg * cwmsg = &conn->req_msg;
|
struct cwmsg * cwmsg = &conn->req_msg;
|
||||||
|
|
||||||
@ -23,36 +21,31 @@ struct cwrmsg * conn_get_response(struct conn * conn)
|
|||||||
|
|
||||||
struct cwrmsg * cwrmsg;
|
struct cwrmsg * cwrmsg;
|
||||||
|
|
||||||
time_t rpt_timer = cw_timer_start(5);
|
int i;
|
||||||
do {
|
for (i=0; i<conn->max_retransmit; i++) {
|
||||||
cwrmsg = conn_get_message(conn);
|
|
||||||
|
|
||||||
|
time_t r_timer = cw_timer_start(conn->retransmit_interval);
|
||||||
|
|
||||||
if (cwrmsg){
|
while(!cw_timer_timeout(r_timer)){
|
||||||
cw_dbg(DBG_CW_MSG,"Received message from %s, type=%d - %s"
|
cwrmsg = conn_get_message(conn);
|
||||||
,sock_addr2str(&conn->addr),cwrmsg->type,cw_msgtostr(cwrmsg->type));
|
if (cwrmsg){
|
||||||
if (cwrmsg->type == type){
|
cw_dbg(DBG_CW_MSG,"Received message from %s, type=%d - %s"
|
||||||
printf("Jea!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11\n");
|
,sock_addr2str(&conn->addr),cwrmsg->type,cw_msgtostr(cwrmsg->type));
|
||||||
return cwrmsg;
|
if (cwrmsg->type == type){
|
||||||
}
|
printf("Jea!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11\n");
|
||||||
|
return cwrmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (cw_timer_timeout(rpt_timer)){
|
if (conn->dtls_error)
|
||||||
rpt_timer = cw_timer_start(5);
|
return 0;
|
||||||
printf("Retransmitting request\n");
|
|
||||||
conn_send_cwmsg(conn,&conn->req_msg);
|
|
||||||
}
|
}
|
||||||
|
cw_dbg(DBG_CW_MSG_ERR,"Retransmitting message, type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
||||||
|
conn_send_cwmsg(conn,&conn->req_msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
cw_dbg(DBG_CW_MSG_ERR,"Max retransmit's reached, message type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
||||||
if (conn->dtls_error)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}while(!cw_timer_timeout(timer));
|
|
||||||
|
|
||||||
printf("Timeout!!!!!\n");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ int conn_q_recv_packet(struct conn * conn, uint8_t * buffer,int len)
|
|||||||
{
|
{
|
||||||
if ( !conn->cur_packet)
|
if ( !conn->cur_packet)
|
||||||
{
|
{
|
||||||
|
/* while ((conn->cur_packet = conn_q_get_packet(conn)) == 0){*/
|
||||||
if ((conn->cur_packet = conn_q_get_packet(conn)) == 0){
|
if ((conn->cur_packet = conn_q_get_packet(conn)) == 0){
|
||||||
errno = EAGAIN;
|
errno = EAGAIN;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -7,15 +7,17 @@
|
|||||||
#include "conn.h"
|
#include "conn.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int conn_recv_packet(struct conn* conn,uint8_t *buf,int len)
|
int conn_recv_packet(struct conn* conn,uint8_t *buf,int len)
|
||||||
{
|
{
|
||||||
// printf("Conn recv packet called\n");
|
printf("THHHHHHHHHHHHHHHHHHHHHHHHHe Conn recv packet called\n");
|
||||||
int n;
|
int n;
|
||||||
int flags=0;
|
int flags=0;
|
||||||
while( (n = recv(conn->sock,(char*)buf,len,flags)) < 0 ){
|
while( (n = recv(conn->sock,(char*)buf,len,flags)) < 0 ){
|
||||||
if (errno!=EINTR)
|
if (errno!=EINTR)
|
||||||
{
|
{
|
||||||
/* if (errno == EWOULDBLOCK)
|
if (errno == EWOULDBLOCK)
|
||||||
{
|
{
|
||||||
printf("would block\n");
|
printf("would block\n");
|
||||||
}
|
}
|
||||||
@ -24,8 +26,8 @@ int conn_recv_packet(struct conn* conn,uint8_t *buf,int len)
|
|||||||
printf("again\n");
|
printf("again\n");
|
||||||
}
|
}
|
||||||
perror("recv");
|
perror("recv");
|
||||||
*/
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
|
@ -32,25 +32,42 @@ void cwmsg_addelem_ac_descriptor(struct cwmsg *msg,struct ac_info * acinfo)
|
|||||||
int sublen;
|
int sublen;
|
||||||
|
|
||||||
|
|
||||||
|
sublen = 4;
|
||||||
|
|
||||||
|
*((uint32_t*)(acd+len))=htonl(CW_VENDOR_ID_CISCO);
|
||||||
|
len+=4;
|
||||||
|
*((uint32_t*)(acd+len))=htonl((1<<16)|sublen);
|
||||||
|
len+=4;
|
||||||
|
*(acd+len)=7; len++;
|
||||||
|
*(acd+len)=3; len++;
|
||||||
|
*(acd+len)=1; len++;
|
||||||
|
*(acd+len)=72; len++;
|
||||||
|
/* *(acd+len)=5; len++;
|
||||||
|
*(acd+len)=6; len++;
|
||||||
|
*(acd+len)=7; len++;
|
||||||
|
*(acd+len)=8; len++;
|
||||||
|
*/
|
||||||
|
|
||||||
/* software version subelement */
|
/* software version subelement */
|
||||||
*((uint32_t*)(acd+len))=0;
|
|
||||||
|
/* *((uint32_t*)(acd+len))=htonl(CW_VENDOR_ID_CISCO);
|
||||||
len+=4;
|
len+=4;
|
||||||
sublen=strlen((const char*)acinfo->software_version);
|
sublen=strlen((const char*)acinfo->software_version);
|
||||||
*((uint32_t*)(acd+len))=htonl((5<<16)|sublen);
|
*((uint32_t*)(acd+len))=htonl((1<<16)|sublen);
|
||||||
len+=4;
|
len+=4;
|
||||||
memcpy(acd+len,acinfo->software_version,sublen);
|
memcpy(acd+len,acinfo->software_version,sublen);
|
||||||
len+=sublen;
|
len+=sublen;
|
||||||
|
|
||||||
|
*/
|
||||||
/* hardware version subelement */
|
/* hardware version subelement */
|
||||||
*((uint32_t*)(acd+len))=0;
|
/* *((uint32_t*)(acd+len))=htonl(CW_VENDOR_ID_CISCO);
|
||||||
len+=4;
|
len+=4;
|
||||||
sublen=strlen((const char*)acinfo->hardware_version);
|
sublen=strlen((const char*)acinfo->hardware_version);
|
||||||
*((uint32_t*)(acd+len))=htonl((4<<16)|sublen);
|
*((uint32_t*)(acd+len))=htonl((4<<16)|sublen);
|
||||||
len+=4;
|
len+=4;
|
||||||
memcpy(acd+len,acinfo->hardware_version,sublen);
|
memcpy(acd+len,acinfo->hardware_version,sublen);
|
||||||
len+=sublen;
|
len+=sublen;
|
||||||
|
*/
|
||||||
|
|
||||||
cwmsg_addelem(msg,CWMSGELEM_AC_DESCRIPTOR,acd,len);
|
cwmsg_addelem(msg,CWMSGELEM_AC_DESCRIPTOR,acd,len);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,21 @@ int cwsend_image_data_request(struct conn * conn, struct image_data * data, stru
|
|||||||
if (data){
|
if (data){
|
||||||
// cwmsg_addelem(&cwmsg,CWMSGELEM_IMAGE_DATA,(uint8_t*)&data->type,sizeof(data->type));
|
// cwmsg_addelem(&cwmsg,CWMSGELEM_IMAGE_DATA,(uint8_t*)&data->type,sizeof(data->type));
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t type=3;
|
||||||
|
uint16_t checksum=0;
|
||||||
cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_DATA, 2,
|
cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_DATA, 2,
|
||||||
|
&type, 1,
|
||||||
|
&checksum,2,
|
||||||
|
data->data, data->len
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/* cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_DATA, 2,
|
||||||
&data->type, sizeof(data->type),
|
&data->type, sizeof(data->type),
|
||||||
data->data, data->len
|
data->data, data->len
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
return conn_send_cwmsg(conn,cwmsg);
|
return conn_send_cwmsg(conn,cwmsg);
|
||||||
|
@ -89,6 +89,9 @@ int join(struct sockaddr *sa)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef WITH_DTLS
|
#ifdef WITH_DTLS
|
||||||
|
cw_dbg (DBG_DTLS,"Establishing DTLS session with %s",sock_addr2str(sa));
|
||||||
|
|
||||||
|
/*
|
||||||
#ifdef WITH_CW_LOG_DEBUG
|
#ifdef WITH_CW_LOG_DEBUG
|
||||||
{
|
{
|
||||||
char str[100];
|
char str[100];
|
||||||
@ -96,7 +99,7 @@ int join(struct sockaddr *sa)
|
|||||||
cw_log_debug0("Establishing DTLS connection to %s",str);
|
cw_log_debug0("Establishing DTLS connection to %s",str);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
if (conf_dtls_psk){
|
if (conf_dtls_psk){
|
||||||
conn->dtls_psk=conf_dtls_psk;
|
conn->dtls_psk=conf_dtls_psk;
|
||||||
conn->dtls_psk_len=strlen(conn->dtls_psk);
|
conn->dtls_psk_len=strlen(conn->dtls_psk);
|
||||||
@ -125,6 +128,9 @@ int join(struct sockaddr *sa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
cw_dbg (DBG_DTLS,"DTLS session established with %s, cipher=%s",sock_addr2str(sa),dtls_get_cipher(conn));
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
|
||||||
#ifdef WITH_CW_LOG_DEBUG
|
#ifdef WITH_CW_LOG_DEBUG
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct wtpinfo wtpinfo;
|
struct wtpinfo wtpinfo;
|
||||||
|
|
||||||
//int conf_rids[2];
|
//int conf_rids[2];
|
||||||
@ -100,17 +101,16 @@ int wtp_main(const char *ad)
|
|||||||
|
|
||||||
wtpconf_init();
|
wtpconf_init();
|
||||||
|
|
||||||
cw_log_debug_level=6; //conf_debug_level;
|
// cw_log_debug_level=6; //conf_debug_level;
|
||||||
|
|
||||||
conf_dtls_psk="Tube";
|
conf_dtls_psk="Tube";
|
||||||
conf_dtls_psk=0;
|
// conf_dtls_psk=0;
|
||||||
|
// conf_sslkeyfilename="../../ssl/wtp.key";
|
||||||
|
// conf_sslcertfilename="../../ssl/wtp.crt";
|
||||||
|
// conf_sslkeypass="7u83";
|
||||||
|
|
||||||
|
|
||||||
conf_sslkeyfilename="../../ssl/wtp.key";
|
cw_dbg_opt_type = DBG_DTLS;
|
||||||
conf_sslcertfilename="../../ssl/wtp.crt";
|
|
||||||
conf_sslkeypass="7u83";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef WITH_DTLS
|
#ifdef WITH_DTLS
|
||||||
dtls_init();
|
dtls_init();
|
||||||
|
Loading…
Reference in New Issue
Block a user