Added data packet handler.
FossilOrigin-Name: c2ee89129a1ecba805a69ecad3b1ba3476b44e013d1e5ff1f668acbcefd10441
This commit is contained in:
parent
59d21b531f
commit
d91999f338
@ -218,6 +218,7 @@ m->init();
|
|||||||
|
|
||||||
void process_ctrl_packet(int index, struct sockaddr *addr, uint8_t * buffer, int len);
|
void process_ctrl_packet(int index, struct sockaddr *addr, uint8_t * buffer, int len);
|
||||||
|
|
||||||
|
void process_cw_data_packet(int index, struct sockaddr *addr, uint8_t * buffer, int len);
|
||||||
|
|
||||||
|
|
||||||
int ac_run()
|
int ac_run()
|
||||||
@ -308,6 +309,11 @@ int ac_run()
|
|||||||
FD_SET(socklist[i].sockfd, &fset);
|
FD_SET(socklist[i].sockfd, &fset);
|
||||||
if (socklist[i].sockfd > max)
|
if (socklist[i].sockfd > max)
|
||||||
max = socklist[i].sockfd;
|
max = socklist[i].sockfd;
|
||||||
|
if (socklist[i].data_sockfd) {
|
||||||
|
FD_SET(socklist[i].data_sockfd,&fset);
|
||||||
|
if (socklist[i].sockfd > max)
|
||||||
|
max = socklist[i].sockfd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wait for an event */
|
/* wait for an event */
|
||||||
@ -320,32 +326,52 @@ int ac_run()
|
|||||||
|
|
||||||
/* process the received packet */
|
/* process the received packet */
|
||||||
for (i = 0; i < socklist_len; i++) {
|
for (i = 0; i < socklist_len; i++) {
|
||||||
|
|
||||||
if (!FD_ISSET(socklist[i].sockfd, &fset))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
struct sockaddr_storage srcaddr;
|
|
||||||
socklen_t sockaddrlen;
|
|
||||||
|
|
||||||
memset(&srcaddr, 0, sizeof(struct sockaddr_storage));
|
|
||||||
sockaddrlen = sizeof(struct sockaddr_storage);
|
|
||||||
|
|
||||||
uint8_t buffer[4096];
|
uint8_t buffer[4096];
|
||||||
|
struct sockaddr_storage srcaddr;
|
||||||
|
socklen_t srcaddrlen;
|
||||||
|
|
||||||
|
|
||||||
|
if (FD_ISSET(socklist[i].data_sockfd, &fset)){
|
||||||
|
|
||||||
|
int len = sock_receive(socklist[i].data_sockfd,
|
||||||
|
buffer, sizeof(buffer),
|
||||||
|
0,
|
||||||
|
(struct sockaddr *) &srcaddr,
|
||||||
|
&srcaddrlen);
|
||||||
|
|
||||||
|
process_cw_data_packet(i, (struct sockaddr *) &srcaddr, buffer, len);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (FD_ISSET(socklist[i].sockfd, &fset)){
|
||||||
|
|
||||||
|
// memset(&srcaddr, 0, sizeof(struct sockaddr_storage));
|
||||||
|
// sockaddrlen = sizeof(struct sockaddr_storage);
|
||||||
|
|
||||||
int len = sock_receive(socklist[i].sockfd,
|
int len = sock_receive(socklist[i].sockfd,
|
||||||
buffer, sizeof(buffer),
|
buffer, sizeof(buffer),
|
||||||
0,
|
0,
|
||||||
(struct sockaddr *) &srcaddr,
|
(struct sockaddr *) &srcaddr,
|
||||||
&sockaddrlen);
|
&srcaddrlen);
|
||||||
|
|
||||||
process_ctrl_packet(i, (struct sockaddr *) &srcaddr, buffer, len);
|
process_ctrl_packet(i, (struct sockaddr *) &srcaddr, buffer, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void process_cw_data_packet(int index, struct sockaddr *addr, uint8_t * buffer, int len)
|
||||||
|
{
|
||||||
|
printf("Data packet received len = %d\n",len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void process_cw_ctrl_packet(int index, struct sockaddr *addr, uint8_t * buffer, int len)
|
void process_cw_ctrl_packet(int index, struct sockaddr *addr, uint8_t * buffer, int len)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user