+/* rfb.c
+ * Remote framebuffer server
+ * NetWatch system management mode administration console
+ *
+ * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms found in the file LICENSE in the root of this source tree.
+ *
+ */
+
#include <stdint.h>
#include <minilib.h>
#include <output.h>
#include <fb.h>
#include <keyboard.h>
+#include <tables.h>
#include "lwip/tcp.h"
#include "lwip/stats.h"
-#include "rfb.h"
+#define RFB_PORT 5900
#define SET_PIXEL_FORMAT 0
#define SET_ENCODINGS 2
#define POINTER_EVENT 5
#define CLIENT_CUT_TEXT 6
-#define RFB_BUF_SIZE 512
+#define RFB_BUF_SIZE 1536
#define SCREEN_CHUNKS_X 8
#define SCREEN_CHUNKS_Y 8
state->chunk_ynum = 0;
state->send_state = SST_IDLE;
if (!(state->chunk_actually_sent))
- state->try_in_a_bit = 2;
+ state->try_in_a_bit = 1;
return 1;
}
/* Checksum gets set in data block, AFTER the data has been sent. */
}
- outputf("actually sent");
state->chunk_actually_sent = 1;
/* Send a header */
static err_t rfb_poll(void *arg, struct tcp_pcb *pcb) {
struct rfb_state *state = arg;
- send_fsm(pcb, state);
if (state->try_in_a_bit) {
state->try_in_a_bit--;
if (!(state->try_in_a_bit)) {
state->update_requested = 1;
}
}
+ send_fsm(pcb, state);
/*
stats_display();
*/
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, NULL);
- mem_free(state);
mem_free(state->blockbuf);
+ mem_free(state);
tcp_close(pcb);
outputf("close_conn: done");
}
static enum fsm_result recv_fsm(struct tcp_pcb *pcb, struct rfb_state *state) {
int i;
int pktsize;
-
+/*
outputf("RFB FSM: st %d rp %d wp %d", state->state, state->readpos,
state->writepos);
-
+*/
switch(state->state) {
case ST_BEGIN:
if (state->writepos < 12) return NEEDMORE;
case ST_MAIN:
if (state->writepos < 1) return NEEDMORE;
- outputf("RFB: cmd %d", state->data[0]);
switch (state->data[0]) {
case SET_PIXEL_FORMAT:
}
copylen = pbuf_copy_partial(p, state->data + state->writepos, p->tot_len, 0);
+
outputf("RFB: Processing %d, wp %d, cp %d", p->tot_len, state->writepos, copylen);
+
state->writepos += p->tot_len;
tcp_recved(pcb, p->tot_len);
goto doneprocessing;
case OK:
- outputf("RFB FSM: ok");
-
if (state->readpos == state->writepos) {
state->readpos = 0;
state->writepos = 0;
return ERR_OK;
}
-void rfb_init() {
+static void rfb_init() {
struct tcp_pcb *pcb;
init_server_info();
pcb = tcp_listen(pcb);
tcp_accept(pcb, rfb_accept);
}
+
+PROTOCOL(rfb_init);