minor fixes
This commit is contained in:
+5
-10
@@ -70,7 +70,7 @@ static void ws_state_free(struct ws_state *wss) {
|
||||
} else {
|
||||
struct ws_state * last;
|
||||
for (last = ws_connections; last->next != NULL; last = last->next) {
|
||||
if (last->next = wss) {
|
||||
if (last->next == wss) {
|
||||
last->next = wss->next;
|
||||
break;
|
||||
}
|
||||
@@ -187,6 +187,8 @@ static err_t ws_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t err
|
||||
|
||||
// called when data has been sent over the websocket
|
||||
static err_t ws_sent(void *arg, struct altcp_pcb *pcb, uint16_t len) {
|
||||
(void) pcb;
|
||||
|
||||
struct ws_state *wss = (struct ws_state *)arg;
|
||||
|
||||
LWIP_DEBUGF(WS_DEBUG | LWIP_DBG_TRACE, ("ws_sent %p\n", (void*) pcb));
|
||||
@@ -309,13 +311,11 @@ static err_t ws_handshake(struct altcp_pcb *pcb, struct ws_state *wss, struct pb
|
||||
|
||||
// create response packet with encoded response key
|
||||
unsigned char response[sizeof(WS_RESPONSE) + sizeof(key_base64)+3];
|
||||
//strncpy(response, WS_RESPONSE, sizeof(WS_RESPONSE));
|
||||
//strlcpy(&response[sizeof(WS_RESPONSE)-1], key_base64, strlen(key_base64));
|
||||
size_t count = sprintf(response, "%s%s\r\n\r\n", WS_RESPONSE, key_base64);
|
||||
|
||||
// send completed data packet
|
||||
LWIP_DEBUGF(WS_DEBUG, ("ws_handshake: sending response\n"));
|
||||
if(altcp_write(pcb, response, strlen(response), TCP_WRITE_FLAG_COPY) == ERR_OK) {
|
||||
if(altcp_write(pcb, response, count, TCP_WRITE_FLAG_COPY) == ERR_OK) {
|
||||
wss->active = true;
|
||||
}
|
||||
|
||||
@@ -341,6 +341,7 @@ static err_t ws_handshake(struct altcp_pcb *pcb, struct ws_state *wss, struct pb
|
||||
|
||||
// handle reading of websocket data and pass to ws_receive_cb
|
||||
static err_t ws_read(struct altcp_pcb *pcb, struct ws_state *wss, struct pbuf *p) {
|
||||
(void) pcb;
|
||||
uint8_t *data = (uint8_t *) p->payload;
|
||||
uint16_t len = p->len;
|
||||
|
||||
@@ -365,12 +366,6 @@ static err_t ws_read(struct altcp_pcb *pcb, struct ws_state *wss, struct pbuf *p
|
||||
// lwIP's pbuf only handles 16-bit lengths, so error
|
||||
LWIP_DEBUGF(WS_DEBUG, ("ws_read: received 64-bit length %u\n", msg_len));
|
||||
return ERR_MEM;
|
||||
|
||||
//memcpy(&msg_len, &data[2], 4);
|
||||
//if (len >= 10) {
|
||||
// msg = &data[10];
|
||||
//}
|
||||
//break;
|
||||
default:
|
||||
if (len >= 6) {
|
||||
msg = &data[6];
|
||||
|
||||
Reference in New Issue
Block a user