From 0a20f8e8bb82960f60459a6b34a86b2827cbd528 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 10 Jan 2017 11:33:52 +1100 Subject: [PATCH 001/163] Add auto refresh to display pages OpenFlow status page & port status page now refresh every 30 seconds. Formatting for ports page improved. --- ZodiacFX/src/http.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 27d5d00..0a08f20 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -1866,6 +1866,7 @@ static uint8_t interfaceCreate_Display_Ports(uint8_t step) snprintf(shared_buffer, SHARED_BUFFER_LEN,\ ""\ + ""\ ""\ ""\ ""\ ""\ ""\ @@ -1905,7 +1909,7 @@ static uint8_t interfaceCreate_Display_Ports(uint8_t step) "Ports"\ ""\ ""\ - ""\ + ""\ ""\ ""\ ""\ @@ -2269,6 +2273,7 @@ static uint8_t interfaceCreate_Display_OpenFlow(void) if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ ""\ + ""\ ""\ ""\ ""\ + ""\ + ""\ + "

"\ + "

Firmware Update

"\ + "

"\ + ""\ + "

Firmware upload successful.

"\ + "Current version: %s
"\ + "Uploaded version: %s

"\ + "Zodiac FX will be updated on the next restart.

"\ + ""\ + ""\ + ""\ + ""\ + ""\ + , VERSION, uploaded_version) < SHARED_BUFFER_LEN) + { + TRACE("http.c: html written to buffer"); + return 1; + } + else + { + TRACE("http.c: WARNING: html truncated to prevent buffer overflow"); + return 0; + } + } + else + { + if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + ""\ + ""\ + ""\ + ""\ + ""\ + ""\ + "

"\ + "

Firmware Update

"\ + "

"\ + ""\ + "

Firmware upload failed. Please try again.

"\ + "Current version: %s

"\ + ""\ + ""\ + , VERSION) < SHARED_BUFFER_LEN) + { + TRACE("http.c: html written to buffer"); + return 1; + } + else + { + TRACE("http.c: WARNING: html truncated to prevent buffer overflow"); + return 0; + } + } +} + /* * Create and format HTML for display help page * @@ -2413,7 +2542,7 @@ static uint8_t interfaceCreate_Display_OpenFlow(void) "

"\ "

OpenFlow Information

"\ "

"\ - ""\ + ""\ "
"\ "OpenFlow"\ "Status:
"\ @@ -3193,7 +3322,7 @@ static uint8_t interfaceCreate_Config_OpenFlow(void) "

"\ "

OpenFlow Configuration

"\ "

"\ - ""\ + ""\ "
"\ "OpenFlow"\ ); From 2b4c65d5c549cfa33e9c96ddc3c8d6f7e5917b9e Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Wed, 18 Jan 2017 16:06:38 +1100 Subject: [PATCH 015/163] Add boundary match verification Check file transfer boundaries --- ZodiacFX/src/http.c | 77 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 8 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index ae69e16..ce061c6 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -1312,16 +1312,54 @@ static uint8_t upload_handler(char *ppart, int len) static uint16_t saved_bytes = 0; // Persistent counter of unwritten data uint16_t handled_bytes = 0; // Counter of handled data static int boundary_start = 1; // Check for start of data + static char boundary_ID[50] = {0}; // Storage for boundary ID char *px; // Start address pointer char *py; // End address pointer - char filetype[30] = {0}; int i = 0; int final = 0; int data_len = 0; // Length of actual upload data if(boundary_start) { + // Store the boundary ID + + memset(&shared_buffer, 0, SHARED_BUFFER_LEN); // Clear shared_buffer + + i = 0; + while(i < len) + { + shared_buffer[i] = ppart[i]; + i++; + } + + px = strstr(shared_buffer, "----"); + if(px == NULL) + { + TRACE("http.c: boundary ID not found - waiting for next packet"); + return 0; + } + else + { + // Traverse forward until the ID begins + while(*px == '\x2d') + { + px++; + } + // Store entirety of boundary ID + i = 0; + while(i < 50 && *px != '\x2d' && *px != '\x0d' && *px != '\x0a') + { + boundary_ID[i] = *px; + + px++; + i++; + } + TRACE("http.c: boundary ID : %s", boundary_ID); + } + + memset(&shared_buffer, 0, SHARED_BUFFER_LEN); // Clear shared_buffer + // Search for starting boundary (support MIME types) if(strstr(ppart, "application/mac-binary") != NULL) { @@ -1396,20 +1434,43 @@ static uint8_t upload_handler(char *ppart, int len) while(i>0) { py--; - // Latch onto '------' - if((*py) == '\x2d' && (*(py-1)) == '\x2d' && (*(py-2)) == '\x2d' && (*(py-3)) == '\x2d' && (*(py-4)) == '\x2d' && (*(py-5)) == '\x2d') + // Latch onto '----' ("----[boundary ID]") + if((*(py-1)) == '\x2d' && (*(py-2)) == '\x2d' && (*(py-3)) == '\x2d' && (*(py-4)) == '\x2d') { - // Traverse through the preceding newline characters - while(*(py-1) == '\x0d' || *(py-1) == '\x0a' || *(py-1) == '\x2d') + // Store the discovered boundary + char tmpID[50] = {0}; + int z = 0; + while(z < 50 && *(py+z) != '\x2d' && *(py+z) != '\x0d' && *(py+z) != '\x0a') { - py--; + tmpID[z] = *(py+z); + z++; } - i = 0; - // 'i' will be decremented to -1 if this line is run + TRACE("http.c: discovered boundary ID : %s", tmpID); + + // Match the boundary ID with stored ID + if(strcmp(tmpID, boundary_ID) == 0) + { + TRACE("http.c: boundary IDs match"); + TRACE("http.c: moving data end pointer"); + // Traverse through the preceding newline characters + while(*(py-1) == '\x0d' || *(py-1) == '\x0a' || *(py-1) == '\x2d') + { + py--; + } + + i = 0; + // 'i' will be decremented to -1 if this line is run + } + else + { + i = 1; + // 'i' will be decremented to 0 if this line is run + } } i--; } + if(i == 0) { From 4386cba21fdb15de60215f5eac8ab44891763291 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Wed, 18 Jan 2017 17:47:46 +1100 Subject: [PATCH 016/163] Add upload handler debug messages --- ZodiacFX/src/http.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index ce061c6..eaef386 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -1320,6 +1320,8 @@ static uint8_t upload_handler(char *ppart, int len) int final = 0; int data_len = 0; // Length of actual upload data + TRACE("http.c: upload handler received %d payload bytes", len) + if(boundary_start) { // Store the boundary ID @@ -1491,6 +1493,8 @@ static uint8_t upload_handler(char *ppart, int len) // Check if any existing data needs to be handled if(saved_bytes) { + TRACE("http.c: %d saved bytes need to be cleared", saved_bytes); + if(!final) { // Fill existing partially-complete page with new data @@ -1547,6 +1551,7 @@ static uint8_t upload_handler(char *ppart, int len) // Saved bytes have been handled - clear the counter saved_bytes = 0; + TRACE("http.c: saved bytes have been cleared"); TRACE("http.c: handled_bytes: %04d, data_len: %04d", handled_bytes, data_len); } @@ -1585,6 +1590,7 @@ static uint8_t upload_handler(char *ppart, int len) else if(!final) { /* Data needs to be saved */ + TRACE("http.c: data needs to be saved"); // Save leftover into page array for next run-through int j = 0; @@ -1603,6 +1609,8 @@ static uint8_t upload_handler(char *ppart, int len) handled_bytes++; saved_bytes++; } + + TRACE("http.c: %d bytes saved", saved_bytes); } else { @@ -1654,6 +1662,8 @@ static uint8_t upload_handler(char *ppart, int len) uploaded_version[k] = *(pNN_check+4+k); k++; } + + TRACE("http.c: NN verification : %s", uploaded_version); return 2; } From 0b36e819e320dee55392e76639db5364e4f57a74 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 19 Jan 2017 17:29:38 +1100 Subject: [PATCH 017/163] Handle interrupted file upload "Upload failed" page will display if a page request is sent while the Zodiac FX is expecting firmware data --- ZodiacFX/src/flash.c | 2 + ZodiacFX/src/http.c | 126 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 105 insertions(+), 23 deletions(-) diff --git a/ZodiacFX/src/flash.c b/ZodiacFX/src/flash.c index 0e345c8..1f07417 100644 --- a/ZodiacFX/src/flash.c +++ b/ZodiacFX/src/flash.c @@ -34,6 +34,7 @@ #include "flash.h" #include "config_zodiac.h" #include "openflow/openflow.h" +#include "trace.h" // Global variables extern uint8_t shared_buffer[SHARED_BUFFER_LEN]; @@ -113,6 +114,7 @@ int firmware_update_init(void) */ int flash_write_page(uint8_t *flash_page) { + TRACE("flash.c: writing to 0x%08x", flash_page_addr); if(flash_page_addr <= IFLASH_ADDR + IFLASH_SIZE - IFLASH_PAGE_SIZE) { ul_rc = flash_write(flash_page_addr, flash_page, diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index eaef386..facaa4e 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -98,6 +98,7 @@ static uint8_t interfaceCreate_About(void); static uint8_t upload_handler(char *ppart, int len); static char uploaded_version[5] = {0}; static int page_ctr = 1; +static int boundary_start = 1; // Check for start of data static uint8_t flowBase = 0; // Current set of flows to display @@ -159,22 +160,67 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err if(file_upload == true) { - int ret = 0; - // Handle multi-part file data - ret = upload_handler(http_payload, len); - if(ret == 2) + // Check HTTP method + i = 0; + while(i < 63 && (http_payload[i] != ' ')) { - file_upload = false; + http_msg[i] = http_payload[i]; + i++; + } + + if(strcmp(http_msg,"GET") == 0) + { + memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array - // upload check - if(interfaceCreate_Upload_Complete(1)) + // Specified resource directly follows GET + i = 0; + while(i < 63 && (http_payload[i+5] != ' ')) + { + http_msg[i] = http_payload[i+5]; // Offset http_payload to isolate resource + i++; + } + + if(strcmp(http_msg,"header.htm") == 0) { - http_send(&shared_buffer, pcb, 1); - TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); + return ERR_OK; } else { - TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); + file_upload = false; + boundary_start = 1; + + // upload failed + if(interfaceCreate_Upload_Complete(0)) + { + http_send(&shared_buffer, pcb, 1); + TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); + } + else + { + TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); + } + } + } + else + { + int ret = 0; + // Handle multi-part file data + ret = upload_handler(http_payload, len); + if(ret == 2) + { + file_upload = false; + boundary_start = 1; + flash_clear_gpnvm(1); + // upload check + if(interfaceCreate_Upload_Complete(1)) + { + http_send(&shared_buffer, pcb, 1); + TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); + } + else + { + TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); + } } } } @@ -1311,7 +1357,6 @@ static uint8_t upload_handler(char *ppart, int len) static char page[512] = {0}; // Storage for each page of data static uint16_t saved_bytes = 0; // Persistent counter of unwritten data uint16_t handled_bytes = 0; // Counter of handled data - static int boundary_start = 1; // Check for start of data static char boundary_ID[50] = {0}; // Storage for boundary ID char *px; // Start address pointer @@ -1495,7 +1540,31 @@ static uint8_t upload_handler(char *ppart, int len) { TRACE("http.c: %d saved bytes need to be cleared", saved_bytes); - if(!final) + if(saved_bytes + len < 512) + { + int max_len = saved_bytes + len; + // Fill existing partially-complete page with new data + while(saved_bytes < max_len && handled_bytes < len) + { + page[saved_bytes] = *px; + if(px < py) + { + px++; + } + else + { + TRACE("http.c: ERROR - multi-part start pointer has passed the end pointer"); + } + saved_bytes++; + handled_bytes++; + } + + // Handle edge-case + TRACE("http.c: unable to fill a complete page - skipping page write"); + TRACE("http.c: %d bytes saved", saved_bytes); + return 1; + } + else if(!final) { // Fill existing partially-complete page with new data while(saved_bytes < 512 && handled_bytes < len) @@ -1512,6 +1581,17 @@ static uint8_t upload_handler(char *ppart, int len) saved_bytes++; handled_bytes++; } + + // Write data to page + if(flash_write_page(&page)) + { + TRACE("http.c: firmware page written successfully"); + page_ctr++; + } + else + { + TRACE("http.c: firmware page write FAILED"); + } } else { @@ -1535,17 +1615,17 @@ static uint8_t upload_handler(char *ppart, int len) saved_bytes++; } - } - - // Write data to page - if(flash_write_page(&page)) - { - TRACE("http.c: firmware page written successfully"); - page_ctr++; - } - else - { - TRACE("http.c: firmware page write FAILED"); + + // Write data to page + if(flash_write_page(&page)) + { + TRACE("http.c: final firmware page written successfully"); + page_ctr++; + } + else + { + TRACE("http.c: final firmware page write FAILED"); + } } // Saved bytes have been handled - clear the counter From 6f58ae48e7ce0a6fbd6f97682222f51d7da2bd13 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 20 Jan 2017 16:07:40 +1100 Subject: [PATCH 018/163] Add debug messages to HTTP recv function --- ZodiacFX/src/http.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index facaa4e..3f0e051 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -158,6 +158,8 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err http_payload = (char*)p->payload; len = p->tot_len; + TRACE("http.c: -- HTTP recv received %d payload bytes", len) + if(file_upload == true) { // Check HTTP method @@ -210,7 +212,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err { file_upload = false; boundary_start = 1; - flash_clear_gpnvm(1); + //flash_clear_gpnvm(1); // upload check if(interfaceCreate_Upload_Complete(1)) { @@ -1307,6 +1309,10 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err } } } + else + { + TRACE("http.c: receive error"); + } pbuf_free(p); @@ -1365,7 +1371,7 @@ static uint8_t upload_handler(char *ppart, int len) int final = 0; int data_len = 0; // Length of actual upload data - TRACE("http.c: upload handler received %d payload bytes", len) + TRACE("http.c: -- upload handler received %d payload bytes", len) if(boundary_start) { From 4dde61ed1b0416e7a383885aa6f3de2daa5cc7cb Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 20 Jan 2017 16:21:34 +1100 Subject: [PATCH 019/163] Add improved flow stats handling Set flow stats to process 15 at a time --- ZodiacFX/src/config/config_zodiac.h | 2 + ZodiacFX/src/openflow/openflow.c | 1 + ZodiacFX/src/openflow/openflow_13.c | 57 ++++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/ZodiacFX/src/config/config_zodiac.h b/ZodiacFX/src/config/config_zodiac.h index 17d8650..2c405ee 100644 --- a/ZodiacFX/src/config/config_zodiac.h +++ b/ZodiacFX/src/config/config_zodiac.h @@ -46,4 +46,6 @@ #define HB_TIMEOUT 6 // Number of seconds to wait when there is no response from the controller +#define MAX_OF_STATS 15 // Maximum number of flows to send to controller + #endif /* CONFIG_ZODIAC_H_ */ diff --git a/ZodiacFX/src/openflow/openflow.c b/ZodiacFX/src/openflow/openflow.c index e2beac1..e615f93 100644 --- a/ZodiacFX/src/openflow/openflow.c +++ b/ZodiacFX/src/openflow/openflow.c @@ -69,6 +69,7 @@ int tcp_wait = 0; int totaltime = 0; int heartbeat = 0; int multi_pos; +bool reply_more_flag = false; bool rcv_freq; // Internal Functions diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index d8d33a7..8d801a9 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -61,6 +61,7 @@ extern struct ofp_switch_config Switch_config; extern uint8_t shared_buffer[SHARED_BUFFER_LEN]; extern int multi_pos; extern uint8_t NativePortMatrix; +extern bool reply_more_flag; // Internal functions void features_reply13(uint32_t xid); @@ -561,6 +562,18 @@ void of13_message(struct ofp_header *ofph, int size, int len) if (size == len && multi_pos !=0) { sendtcp(&shared_buffer, multi_pos); + if(reply_more_flag == true) + { + //tcp_output(tcp_pcb); + while(reply_more_flag == true) + { + multi_pos = 0; + multi_pos += multi_flow_reply13(&shared_buffer[multi_pos], multi_req); + sendtcp(&shared_buffer, multi_pos); + //tcp_output(tcp_pcb); + } + } + } return; } @@ -685,14 +698,54 @@ int multi_desc_reply13(uint8_t *buffer, struct ofp13_multipart_request *msg) int multi_flow_reply13(uint8_t *buffer, struct ofp13_multipart_request *msg) { char statsbuffer[2048]; + static int statsStart = 0; + static int statsEnd = 0; struct ofp13_multipart_reply *reply; + + if(reply_more_flag == false) + { + statsStart = 0; + statsEnd = 0; + } + reply = (struct ofp13_multipart_reply *) buffer; reply->header.version = OF_Version; reply->header.type = OFPT13_MULTIPART_REPLY; reply->header.xid = msg->header.xid; - reply->flags = 0; reply->type = htons(OFPMP13_FLOW); - int len = flow_stats_msg13(&statsbuffer, 0, iLastFlow); + if(iLastFlow > 15) + { + //TRACE("openflow_13.c: %d flows - multiple stats packets must be sent", iLastFlow); + if(statsEnd == 0) + { + statsEnd = 15; + } + + if(statsEnd < iLastFlow) + { + reply_more_flag = true; + reply->flags = OFPMPF13_REPLY_MORE; + } + else + { + statsEnd = iLastFlow; + reply_more_flag = false; + reply->flags = 0; + } + + } + else + { + statsStart = 0; + statsEnd = iLastFlow; + reply_more_flag = false; + reply->flags = 0; + } + //TRACE("openflow_13.c: generating stats message for flows %d to %d", statsStart, statsEnd); + int len = flow_stats_msg13(&statsbuffer, statsStart, statsEnd); + statsStart += 15; + statsEnd += 15; + memcpy(reply->body, &statsbuffer, len); len += sizeof(struct ofp13_multipart_reply); reply->header.length = htons(len); From d30ffa338c92eb62b05767382f832744c56421ba Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 20 Jan 2017 17:02:24 +1100 Subject: [PATCH 020/163] Add of_sent callback function (WIP) --- ZodiacFX/src/openflow/openflow.c | 29 +++++++++++++++++++++ ZodiacFX/src/openflow/openflow.h | 1 + ZodiacFX/src/openflow/openflow_13.c | 40 ++++++++++++++++++++--------- 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/ZodiacFX/src/openflow/openflow.c b/ZodiacFX/src/openflow/openflow.c index e615f93..05e4ac3 100644 --- a/ZodiacFX/src/openflow/openflow.c +++ b/ZodiacFX/src/openflow/openflow.c @@ -69,6 +69,7 @@ int tcp_wait = 0; int totaltime = 0; int heartbeat = 0; int multi_pos; +uint32_t reply_more_xid = 0; bool reply_more_flag = false; bool rcv_freq; @@ -79,6 +80,7 @@ void echo_reply(uint32_t xid); err_t TCPready(void *arg, struct tcp_pcb *tpcb, err_t err); void tcp_error(void * arg, err_t err); static err_t of_receive(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err); +static err_t of_sent(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err); /* * Converts a 64bit value from host to network format @@ -203,6 +205,32 @@ static err_t of_receive(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t e return ERR_OK; } +/* +* OpenFlow Sent callback function +* +* @param *arg - pointer the additional TCP args +* @param *tcp_pcb - pointer the TCP session structure. +* @param *p - pointer to the buffer containing the TCP packet. +* @param err - error code. +* +*/ +static err_t of_sent(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err) +{ + if (err == ERR_OK && p != NULL) + { + if(reply_more_flag == true) + { + + } + else + { + reply_more_xid = 0; + } + } + + return ERR_OK; +} + /* * OpenFlow HELLO message function * @@ -378,6 +406,7 @@ err_t TCPready(void *arg, struct tcp_pcb *tpcb, err_t err) tcp_recv(tpcb, of_receive); tcp_poll(tpcb, NULL, 4); tcp_err(tpcb, NULL); + tcp_sent(tpcb, of_sent); if(Zodiac_Config.failstate == 0) clear_flows(); // Clear the flow if in secure mode TRACE("openflow.c: Connected to controller"); OF_hello(); diff --git a/ZodiacFX/src/openflow/openflow.h b/ZodiacFX/src/openflow/openflow.h index 00a63d7..2db680b 100644 --- a/ZodiacFX/src/openflow/openflow.h +++ b/ZodiacFX/src/openflow/openflow.h @@ -72,6 +72,7 @@ void nnOF10_tablelookup(uint8_t *p_uc_data, uint32_t *ul_size, int port); void nnOF13_tablelookup(uint8_t *p_uc_data, uint32_t *ul_size, int port); void of10_message(struct ofp_header *ofph, int size, int len); void of13_message(struct ofp_header *ofph, int size, int len); +void multipart_stats_handler(void); void barrier10_reply(uint32_t xid); void barrier13_reply(uint32_t xid); void sendtcp(const void *buffer, u16_t len); diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index 8d801a9..db1b2d7 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -62,6 +62,7 @@ extern uint8_t shared_buffer[SHARED_BUFFER_LEN]; extern int multi_pos; extern uint8_t NativePortMatrix; extern bool reply_more_flag; +extern uint32_t reply_more_xid; // Internal functions void features_reply13(uint32_t xid); @@ -562,18 +563,25 @@ void of13_message(struct ofp_header *ofph, int size, int len) if (size == len && multi_pos !=0) { sendtcp(&shared_buffer, multi_pos); - if(reply_more_flag == true) - { - //tcp_output(tcp_pcb); - while(reply_more_flag == true) - { - multi_pos = 0; - multi_pos += multi_flow_reply13(&shared_buffer[multi_pos], multi_req); - sendtcp(&shared_buffer, multi_pos); - //tcp_output(tcp_pcb); - } - } + } + return; +} +/* +* OpenFlow reply more stats function +* +* @param xid - transaction ID +* +*/ +void multipart_stats_handler(void) +{ + struct ofp13_multipart_request *multi_req; + + multi_pos += multi_flow_reply13(&shared_buffer, multi_req); + + if (size == len && multi_pos !=0) + { + sendtcp(&shared_buffer, multi_pos); } return; } @@ -711,7 +719,14 @@ int multi_flow_reply13(uint8_t *buffer, struct ofp13_multipart_request *msg) reply = (struct ofp13_multipart_reply *) buffer; reply->header.version = OF_Version; reply->header.type = OFPT13_MULTIPART_REPLY; - reply->header.xid = msg->header.xid; + if(reply_more_flag == true) + { + reply->header.xid = reply_more_xid; + } + else + { + reply->header.xid = msg->header.xid; + } reply->type = htons(OFPMP13_FLOW); if(iLastFlow > 15) { @@ -719,6 +734,7 @@ int multi_flow_reply13(uint8_t *buffer, struct ofp13_multipart_request *msg) if(statsEnd == 0) { statsEnd = 15; + reply_more_xid = msg->header.xid; } if(statsEnd < iLastFlow) From d8782b533860f6947fd6ca7f26a1dd5f45d2fedf Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 20 Jan 2017 17:03:39 +1100 Subject: [PATCH 021/163] Comment out WIP function --- ZodiacFX/src/openflow/openflow_13.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index db1b2d7..1d7b354 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -579,10 +579,10 @@ void multipart_stats_handler(void) multi_pos += multi_flow_reply13(&shared_buffer, multi_req); - if (size == len && multi_pos !=0) - { - sendtcp(&shared_buffer, multi_pos); - } + //if (size == len && multi_pos !=0) + //{ + //sendtcp(&shared_buffer, multi_pos); + //} return; } From ae499bbfe39624be86a7354771be2d2f86ebb319 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 20 Jan 2017 17:35:36 +1100 Subject: [PATCH 022/163] Fix firmware update final page write --- ZodiacFX/src/http.c | 72 ++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 3f0e051..8164f16 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -1546,34 +1546,45 @@ static uint8_t upload_handler(char *ppart, int len) { TRACE("http.c: %d saved bytes need to be cleared", saved_bytes); - if(saved_bytes + len < 512) + if(final) { - int max_len = saved_bytes + len; - // Fill existing partially-complete page with new data - while(saved_bytes < max_len && handled_bytes < len) + /* Final page needs to be written */ + + // Fill 512-byte array + while(saved_bytes < 512) { - page[saved_bytes] = *px; if(px < py) { + // Write data + page[saved_bytes] = *px; px++; + handled_bytes++; } else { - TRACE("http.c: ERROR - multi-part start pointer has passed the end pointer"); + // Append 0xFF + page[saved_bytes] = 0xFF; } + saved_bytes++; - handled_bytes++; } - // Handle edge-case - TRACE("http.c: unable to fill a complete page - skipping page write"); - TRACE("http.c: %d bytes saved", saved_bytes); - return 1; + // Write data to page + if(flash_write_page(&page)) + { + TRACE("http.c: final firmware page written successfully"); + page_ctr++; + } + else + { + TRACE("http.c: final firmware page write FAILED"); + } } - else if(!final) + else if(saved_bytes + len < 512) { + int max_len = saved_bytes + len; // Fill existing partially-complete page with new data - while(saved_bytes < 512 && handled_bytes < len) + while(saved_bytes < max_len && handled_bytes < len) { page[saved_bytes] = *px; if(px < py) @@ -1588,52 +1599,41 @@ static uint8_t upload_handler(char *ppart, int len) handled_bytes++; } - // Write data to page - if(flash_write_page(&page)) - { - TRACE("http.c: firmware page written successfully"); - page_ctr++; - } - else - { - TRACE("http.c: firmware page write FAILED"); - } + // Handle edge-case + TRACE("http.c: unable to fill a complete page - skipping page write"); + TRACE("http.c: %d bytes saved", saved_bytes); + return 1; } else { - /* Final page needs to be written */ - - // Fill 512-byte array - while(saved_bytes < 512) + // Fill existing partially-complete page with new data + while(saved_bytes < 512 && handled_bytes < len) { + page[saved_bytes] = *px; if(px < py) { - // Write data - page[saved_bytes] = *px; px++; - handled_bytes++; } else { - // Append 0xFF - page[saved_bytes] = 0xFF; + TRACE("http.c: ERROR - multi-part start pointer has passed the end pointer"); } - saved_bytes++; + handled_bytes++; } // Write data to page if(flash_write_page(&page)) { - TRACE("http.c: final firmware page written successfully"); + TRACE("http.c: firmware page written successfully"); page_ctr++; } else { - TRACE("http.c: final firmware page write FAILED"); + TRACE("http.c: firmware page write FAILED"); } } - + // Saved bytes have been handled - clear the counter saved_bytes = 0; From 259d1d0fa6f0a2c2dc5f6de6aa71d2fb5a96aedf Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Wed, 25 Jan 2017 10:20:59 +1100 Subject: [PATCH 023/163] Change web interface help page --- ZodiacFX/ZodiacFX.cproj | 4 ++-- ZodiacFX/src/http.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ZodiacFX/ZodiacFX.cproj b/ZodiacFX/ZodiacFX.cproj index 7af9923..7168674 100644 --- a/ZodiacFX/ZodiacFX.cproj +++ b/ZodiacFX/ZodiacFX.cproj @@ -274,11 +274,11 @@ JTAG com.atmel.avrdbg.tool.atmelice - J41800009874 + J41800058832 Atmel-ICE JTAG - J41800009874 + J41800058832 0xA3CC0CE0 7500000 diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 8164f16..a791db3 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -2220,7 +2220,7 @@ static uint8_t interfaceCreate_Display_Home(void) "

"\ "

Flows

"\ "

"\ - "View the current flows in the flow table. This page is currently limited to displaying a maximum of 5 flows."\ + "View the current flows in the flow table. 4 flows are displayed per page."\ "

"\ ""\ ""\ From 112c928d131877ba2d4a6f60751e92a57239a0a2 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Wed, 25 Jan 2017 15:31:43 +1100 Subject: [PATCH 024/163] Remove flow stats output limit OFPMPF_REPLY_MORE flag used to send individual flow statistics 15 at a time. --- ZodiacFX/src/openflow/openflow.c | 18 ++--- ZodiacFX/src/openflow/openflow.h | 2 +- ZodiacFX/src/openflow/openflow_13.c | 118 ++++++++++++++-------------- 3 files changed, 63 insertions(+), 75 deletions(-) diff --git a/ZodiacFX/src/openflow/openflow.c b/ZodiacFX/src/openflow/openflow.c index 05e4ac3..5c577e5 100644 --- a/ZodiacFX/src/openflow/openflow.c +++ b/ZodiacFX/src/openflow/openflow.c @@ -80,7 +80,7 @@ void echo_reply(uint32_t xid); err_t TCPready(void *arg, struct tcp_pcb *tpcb, err_t err); void tcp_error(void * arg, err_t err); static err_t of_receive(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err); -static err_t of_sent(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err); +static err_t of_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len); /* * Converts a 64bit value from host to network format @@ -210,22 +210,14 @@ static err_t of_receive(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t e * * @param *arg - pointer the additional TCP args * @param *tcp_pcb - pointer the TCP session structure. -* @param *p - pointer to the buffer containing the TCP packet. -* @param err - error code. * */ -static err_t of_sent(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err) +static err_t of_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len) { - if (err == ERR_OK && p != NULL) + TRACE("openflow.c: [of_sent] %d bytes acknowledged ", len); + if(reply_more_flag == true) { - if(reply_more_flag == true) - { - - } - else - { - reply_more_xid = 0; - } + multi_flow_more_reply13(); } return ERR_OK; diff --git a/ZodiacFX/src/openflow/openflow.h b/ZodiacFX/src/openflow/openflow.h index 2db680b..1837967 100644 --- a/ZodiacFX/src/openflow/openflow.h +++ b/ZodiacFX/src/openflow/openflow.h @@ -72,7 +72,7 @@ void nnOF10_tablelookup(uint8_t *p_uc_data, uint32_t *ul_size, int port); void nnOF13_tablelookup(uint8_t *p_uc_data, uint32_t *ul_size, int port); void of10_message(struct ofp_header *ofph, int size, int len); void of13_message(struct ofp_header *ofph, int size, int len); -void multipart_stats_handler(void); +void multi_flow_more_reply13(void); void barrier10_reply(uint32_t xid); void barrier13_reply(uint32_t xid); void sendtcp(const void *buffer, u16_t len); diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index 1d7b354..448e1fb 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -567,25 +567,6 @@ void of13_message(struct ofp_header *ofph, int size, int len) return; } -/* -* OpenFlow reply more stats function -* -* @param xid - transaction ID -* -*/ -void multipart_stats_handler(void) -{ - struct ofp13_multipart_request *multi_req; - - multi_pos += multi_flow_reply13(&shared_buffer, multi_req); - - //if (size == len && multi_pos !=0) - //{ - //sendtcp(&shared_buffer, multi_pos); - //} - return; -} - /* * OpenFlow FEATURE Reply message function * @@ -705,67 +686,82 @@ int multi_desc_reply13(uint8_t *buffer, struct ofp13_multipart_request *msg) */ int multi_flow_reply13(uint8_t *buffer, struct ofp13_multipart_request *msg) { + int len = 0; char statsbuffer[2048]; - static int statsStart = 0; - static int statsEnd = 0; struct ofp13_multipart_reply *reply; - - if(reply_more_flag == false) - { - statsStart = 0; - statsEnd = 0; - } - reply = (struct ofp13_multipart_reply *) buffer; reply->header.version = OF_Version; reply->header.type = OFPT13_MULTIPART_REPLY; - if(reply_more_flag == true) + reply->header.xid = msg->header.xid; + reply->flags = 0; + reply->type = htons(OFPMP13_FLOW); + if(iLastFlow > 15) { - reply->header.xid = reply_more_xid; + // Only send first 15 flows + len = flow_stats_msg13(&statsbuffer, 0, 15); + reply->flags = htons(OFPMPF13_REPLY_MORE); // More replies will follow + reply_more_flag = true; // Notify of_sent that more messages need to be sent + reply_more_xid = msg->header.xid; // Store xid for later replies } else { - reply->header.xid = msg->header.xid; + // Send all flows + len = flow_stats_msg13(&statsbuffer, 0, iLastFlow); } + memcpy(reply->body, &statsbuffer, len); + len += sizeof(struct ofp13_multipart_reply); + reply->header.length = htons(len); + return len; +} + +/* +* OpenFlow reply more stats function +* +* @param xid - transaction ID +* +*/ +void multi_flow_more_reply13(void) +{ + // Clear shared_buffer + memset(&shared_buffer, 0, SHARED_BUFFER_LEN); + + static int startFlow = 15; + int len = 0; + char statsbuffer[2048]; + struct ofp13_multipart_reply *reply; + reply = (struct ofp13_multipart_reply *) shared_buffer; + reply->header.version = OF_Version; + reply->header.type = OFPT13_MULTIPART_REPLY; + reply->header.xid = reply_more_xid; reply->type = htons(OFPMP13_FLOW); - if(iLastFlow > 15) + if((startFlow+15) < iLastFlow) { - //TRACE("openflow_13.c: %d flows - multiple stats packets must be sent", iLastFlow); - if(statsEnd == 0) - { - statsEnd = 15; - reply_more_xid = msg->header.xid; - } - - if(statsEnd < iLastFlow) - { - reply_more_flag = true; - reply->flags = OFPMPF13_REPLY_MORE; - } - else - { - statsEnd = iLastFlow; - reply_more_flag = false; - reply->flags = 0; - } - + // Send first 15 flows + TRACE("openflow_13.c: writing next 15 flow stats"); + len = flow_stats_msg13(&statsbuffer, startFlow, (startFlow+15)); + reply->flags = OFPMPF13_REPLY_MORE; // More replies will follow + reply_more_flag = true; // Notify of_sent that more messages need to be sent + startFlow += 15; } else { - statsStart = 0; - statsEnd = iLastFlow; - reply_more_flag = false; - reply->flags = 0; + // Finish sending flows + TRACE("openflow_13.c: writing final set of flow stats"); + len = flow_stats_msg13(&statsbuffer, startFlow, iLastFlow); + reply->flags = 0; // No more replies will follow + reply_more_flag = false; // Notify of_sent that no more messages need to be sent + reply_more_xid = 0; // Clear stored xid } - //TRACE("openflow_13.c: generating stats message for flows %d to %d", statsStart, statsEnd); - int len = flow_stats_msg13(&statsbuffer, statsStart, statsEnd); - statsStart += 15; - statsEnd += 15; - memcpy(reply->body, &statsbuffer, len); len += sizeof(struct ofp13_multipart_reply); reply->header.length = htons(len); - return len; + + if (len < 2048) + { + TRACE("openflow_13.c: sending flow stats"); + sendtcp(&shared_buffer, len); + } + return; } /* From 9de1abfaf1fbc8f3e03e16e0580c399abb508aa5 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Wed, 25 Jan 2017 17:36:21 +1100 Subject: [PATCH 025/163] Fix flow stats output Call htons on REPLY_MORE flag for subsequent messages Additional trace messages added --- ZodiacFX/src/openflow/openflow_13.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index 448e1fb..7ae4c88 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -737,20 +737,21 @@ void multi_flow_more_reply13(void) if((startFlow+15) < iLastFlow) { // Send first 15 flows - TRACE("openflow_13.c: writing next 15 flow stats"); + TRACE("openflow_13.c: writing flow stats: %d to %d", startFlow, (startFlow+15)); len = flow_stats_msg13(&statsbuffer, startFlow, (startFlow+15)); - reply->flags = OFPMPF13_REPLY_MORE; // More replies will follow + reply->flags = htons(OFPMPF13_REPLY_MORE); // More replies will follow reply_more_flag = true; // Notify of_sent that more messages need to be sent startFlow += 15; } else { // Finish sending flows - TRACE("openflow_13.c: writing final set of flow stats"); + TRACE("openflow_13.c: writing final flow stats: %d to %d", startFlow, iLastFlow); len = flow_stats_msg13(&statsbuffer, startFlow, iLastFlow); reply->flags = 0; // No more replies will follow reply_more_flag = false; // Notify of_sent that no more messages need to be sent reply_more_xid = 0; // Clear stored xid + startFlow = 0; // Clear startFlow } memcpy(reply->body, &statsbuffer, len); len += sizeof(struct ofp13_multipart_reply); From d11514fe0d123083fa8e3c4e955c72253138a42c Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 30 Jan 2017 16:04:37 +1100 Subject: [PATCH 026/163] Add basic Safari support - All pages display correctly in Safari - Configurations are currently unhandled Other: - Minor variable scope fixes --- ZodiacFX/src/http.c | 170 ++++++++++++++++++++++++++++---------------- ZodiacFX/src/http.h | 3 +- 2 files changed, 110 insertions(+), 63 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index a791db3..770614d 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -72,8 +72,14 @@ extern int flash_write_page(uint8_t *flash_page); // Local Variables struct tcp_pcb *http_pcb; char http_msg[64]; // Buffer for HTTP message filtering -static bool file_upload = false; // Multi-part firmware file upload flag -bool reset_required; +static uint8_t upload_handler(char *ppart, int len); +static char uploaded_version[5] = {0}; +static int page_ctr = 1; +static int boundary_start = 1; // Check for start of data +static uint8_t flowBase = 0; // Current set of flows to display + +// Flag variables +static bool reset_required; // Track if any configuration changes are pending a restart static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err); @@ -95,13 +101,6 @@ static uint8_t interfaceCreate_Config_VLANs(void); static uint8_t interfaceCreate_Config_OpenFlow(void); static uint8_t interfaceCreate_About(void); -static uint8_t upload_handler(char *ppart, int len); -static char uploaded_version[5] = {0}; -static int page_ctr = 1; -static int boundary_start = 1; // Check for start of data - -static uint8_t flowBase = 0; // Current set of flows to display - /* * Converts a 64bit value from host to network format * @@ -146,6 +145,11 @@ static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err) */ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { + // Local static flag variables + //static bool + static bool file_upload = false; // Multi-part firmware file upload flag + + // Local variables int len; int i = 0; char *http_payload; @@ -1822,7 +1826,10 @@ static uint8_t interfaceCreate_Header(void) // Send header if(reset_required == false) { - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -1874,7 +1881,10 @@ static uint8_t interfaceCreate_Header(void) } else if(reset_required == true) { - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -1946,7 +1956,10 @@ static uint8_t interfaceCreate_Header(void) static uint8_t interfaceCreate_Menu(void) { // Send menu - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -2015,7 +2028,10 @@ static uint8_t interfaceCreate_Home(void) int t = (totaltime/2)%3600; int min = t/60; - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -2062,7 +2078,10 @@ static uint8_t interfaceCreate_Home(void) */ static uint8_t interfaceCreate_Upload(void) { - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -2192,7 +2211,10 @@ static uint8_t interfaceCreate_Upload_Complete(uint8_t sel) */ static uint8_t interfaceCreate_Display_Home(void) { - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -2272,8 +2294,11 @@ static uint8_t interfaceCreate_Display_Ports(uint8_t step) vlCtr++; } } - - snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -2498,8 +2523,8 @@ static uint8_t interfaceCreate_Display_Ports(uint8_t step) "
"\ "
Port 1Port 2Port 3
"\ "
"\ - ""\ - "
"\ + ""\ + "
"\ ""\ ""\ ""\ @@ -2577,8 +2602,8 @@ static uint8_t interfaceCreate_Display_Ports(uint8_t step) ""\ ""\ "
"\ - ""\ - "
"\ + ""\ + "
"\ ""\ ""\ ""\ @@ -2680,7 +2705,10 @@ static uint8_t interfaceCreate_Display_OpenFlow(void) snprintf(wi_ofVersion, 15, "Auto"); } - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -2737,7 +2765,10 @@ static uint8_t interfaceCreate_Display_OpenFlow(void) */ static uint8_t interfaceCreate_Display_Flows(void) { - snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -3232,7 +3263,10 @@ if (iLastFlow > 0) */ static uint8_t interfaceCreate_Config_Home(void) { - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -3281,42 +3315,45 @@ static uint8_t interfaceCreate_Config_Home(void) */ static uint8_t interfaceCreate_Config_Network(void) { - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - "

"\ - "

Network Configuration

"\ - "

"\ - "
"\ - "
"\ - "Connection"\ - "Name:
"\ - "

"\ - "MAC Address:
"\ - "

"\ - "IP Address:
"\ - "

"\ - "Netmask:
"\ - "

"\ - "Gateway:
"\ - "

"\ - ""\ - ""\ - "
"\ - "
"\ - ""\ + ""\ + ""\ + ""\ + ""\ + ""\ + "

"\ + "

Network Configuration

"\ + "

"\ + "
"\ + "
"\ + "Connection"\ + "Name:
"\ + "

"\ + "MAC Address:
"\ + "

"\ + "IP Address:
"\ + "

"\ + "Netmask:
"\ + "

"\ + "Gateway:
"\ + "

"\ + ""\ + ""\ + "
"\ + "
"\ + ""\ ""\ , Zodiac_Config.device_name\ , Zodiac_Config.MAC_address[0], Zodiac_Config.MAC_address[1], Zodiac_Config.MAC_address[2], Zodiac_Config.MAC_address[3], Zodiac_Config.MAC_address[4], Zodiac_Config.MAC_address[5]\ @@ -3346,7 +3383,10 @@ static uint8_t interfaceCreate_Config_VLANs(void) char wi_vlType[10] = ""; // Opening tags, and base table - snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -3461,7 +3501,10 @@ static uint8_t interfaceCreate_Config_VLANs(void) */ static uint8_t interfaceCreate_Config_OpenFlow(void) { - snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ @@ -3596,7 +3639,10 @@ static uint8_t interfaceCreate_Config_OpenFlow(void) */ static uint8_t interfaceCreate_About(void) { - if( snprintf(shared_buffer, SHARED_BUFFER_LEN,\ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ diff --git a/ZodiacFX/src/http.h b/ZodiacFX/src/http.h index 4427288..fe3cbc9 100644 --- a/ZodiacFX/src/http.h +++ b/ZodiacFX/src/http.h @@ -32,7 +32,8 @@ #define HTTP_H_ #define FLOW_LIMIT 4 // Displayable flows per page - +#define SUCCESS 0 +#define FAILURE 1 void http_init(void); #endif /* HTTP_H_ */ \ No newline at end of file From 8c901ea370319d047601f2400b2545fe97538c6f Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 2 Feb 2017 10:17:16 +1100 Subject: [PATCH 027/163] http.c cleanup - Revert Safari changes until full support is added - Variable scope cleanup - Separate network configuration into function --- ZodiacFX/src/http.c | 466 +++++++++++++++++++++++--------------------- 1 file changed, 243 insertions(+), 223 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 770614d..81f0818 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -71,7 +71,7 @@ extern int flash_write_page(uint8_t *flash_page); // Local Variables struct tcp_pcb *http_pcb; -char http_msg[64]; // Buffer for HTTP message filtering +static char http_msg[64]; // Buffer for HTTP message filtering static uint8_t upload_handler(char *ppart, int len); static char uploaded_version[5] = {0}; static int page_ctr = 1; @@ -101,6 +101,9 @@ static uint8_t interfaceCreate_Config_VLANs(void); static uint8_t interfaceCreate_Config_OpenFlow(void); static uint8_t interfaceCreate_About(void); +static uint8_t Config_Network(char *payload, int len); + + /* * Converts a 64bit value from host to network format * @@ -146,7 +149,6 @@ static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err) static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { // Local static flag variables - //static bool static bool file_upload = false; // Multi-part firmware file upload flag // Local variables @@ -480,236 +482,27 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err } else if(strcmp(http_msg,"save_config") == 0) { - memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array - - // Device Name - pdat = strstr(http_payload, "wi_deviceName"); // Search for element - if(pdat != NULL) // Check that element exists - { - pdat += (strlen("wi_deviceName")+1); // Data format: wi_deviceName=(name) - - i = 0; - while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) - { - http_msg[i] = pdat[i]; // Store value of element - i++; - } - if(pdat[i+1] == 'w') // Check that the next parameter directly follows the "&" at end of data - { - uint8_t namelen = strlen(http_msg); - if (namelen > 15 ) namelen = 15; // Make sure name is less than 16 characters - sprintf(Zodiac_Config.device_name, http_msg, namelen); - TRACE("http.c: device name set to '%s'",Zodiac_Config.device_name); - } - else - { - TRACE("http.c: \"&\" cannot be used in device name"); - } - } - else - { - TRACE("http.c: no device name found"); - } - - memset(&http_msg, 0, sizeof(http_msg)); - - // MAC Address - pdat = strstr(http_payload, "wi_macAddress"); - if(pdat != NULL) // Check that element exists + if(Config_Network(&http_payload, len) == SUCCESS) { - pdat += (strlen("wi_macAddress")+1); // Data format: wi_deviceName=(name) - - i = 0; - while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) - { - http_msg[i] = pdat[i]; // Store value of element - i++; - } - if(pdat[i+1] == 'w') - { - int mac1,mac2,mac3,mac4,mac5,mac6; - char decArr[18] = ""; - int j, k; - - if (strlen(http_msg) != 27 ) // Accounting for ":" as "%3A" - { - TRACE("http.c: incorrect MAC address format"); - return; - } - - // Decode http string - j = 0; k = 0; - while(j < strlen(http_msg) && k < 18) - { - if(http_msg[j] == '%' && http_msg[j+1] == '3' && http_msg[j+2] == 'A') - { - decArr[k] = ':'; - j+=3; k++; - } - else - { - decArr[k] = http_msg[j]; - j++; k++; - } - } - - sscanf(decArr, "%x:%x:%x:%x:%x:%x", &mac1, &mac2, &mac3, &mac4, &mac5, &mac6); - Zodiac_Config.MAC_address[0] = mac1; - Zodiac_Config.MAC_address[1] = mac2; - Zodiac_Config.MAC_address[2] = mac3; - Zodiac_Config.MAC_address[3] = mac4; - Zodiac_Config.MAC_address[4] = mac5; - Zodiac_Config.MAC_address[5] = mac6; - TRACE("http.c: MAC address set to %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",Zodiac_Config.MAC_address[0], Zodiac_Config.MAC_address[1], Zodiac_Config.MAC_address[2], Zodiac_Config.MAC_address[3], Zodiac_Config.MAC_address[4], Zodiac_Config.MAC_address[5]); - } - else - { - TRACE("http.c: \"&\" cannot be used in form"); - } - } - else - { - TRACE("http.c: no MAC address found"); - } - - memset(&http_msg, 0, sizeof(http_msg)); - - // IP Address - pdat = strstr(http_payload, "wi_ipAddress"); - if(pdat != NULL) // Check that element exists - { - pdat += (strlen("wi_ipAddress")+1); // Data format: wi_deviceName=(name) - - i = 0; - while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) - { - http_msg[i] = pdat[i]; // Store value of element - i++; - } - if(pdat[i+1] == 'w') - { - int ip1,ip2,ip3,ip4; - if (strlen(http_msg) > 15 ) - { - TRACE("http.c: incorrect IP format"); - return; - } - sscanf(http_msg, "%d.%d.%d.%d", &ip1, &ip2,&ip3,&ip4); - Zodiac_Config.IP_address[0] = ip1; - Zodiac_Config.IP_address[1] = ip2; - Zodiac_Config.IP_address[2] = ip3; - Zodiac_Config.IP_address[3] = ip4; - TRACE("http.c: IP address set to %d.%d.%d.%d" , Zodiac_Config.IP_address[0], Zodiac_Config.IP_address[1], Zodiac_Config.IP_address[2], Zodiac_Config.IP_address[3]); - } - else - { - TRACE("http.c: \"&\" cannot be used in form"); - } - } - else - { - TRACE("http.c: no IP address found"); - } - - memset(&http_msg, 0, sizeof(http_msg)); - - // Netmask - pdat = strstr(http_payload, "wi_netmask"); - if(pdat != NULL) // Check that element exists - { - pdat += (strlen("wi_netmask")+1); // Data format: wi_deviceName=(name) - - i = 0; - while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) - { - http_msg[i] = pdat[i]; // Store value of element - i++; - } - if(pdat[i+1] == 'w') - { - int nm1,nm2,nm3,nm4; - if (strlen(http_msg) > 15 ) - { - TRACE("http.c: incorrect netmask format"); - return; - } - sscanf(http_msg, "%d.%d.%d.%d", &nm1, &nm2,&nm3,&nm4); - Zodiac_Config.netmask[0] = nm1; - Zodiac_Config.netmask[1] = nm2; - Zodiac_Config.netmask[2] = nm3; - Zodiac_Config.netmask[3] = nm4; - TRACE("http.c: netmask set to %d.%d.%d.%d" , Zodiac_Config.netmask[0], Zodiac_Config.netmask[1], Zodiac_Config.netmask[2], Zodiac_Config.netmask[3]); - } - else - { - TRACE("http.c: \"&\" cannot be used in form"); - } - } - else - { - TRACE("http.c: no netmask found"); - } - - memset(&http_msg, 0, sizeof(http_msg)); + TRACE("http.c: network configuration successful"); - // Gateway - pdat = strstr(http_payload, "wi_gateway"); - if(pdat != NULL) // Check that element exists - { - pdat += (strlen("wi_gateway")+1); // Data format: wi_deviceName=(name) - - i = 0; - while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) + // Send updated config page + if(interfaceCreate_Config_Network()) { - http_msg[i] = pdat[i]; // Store value of element - i++; + http_send(&shared_buffer, pcb, 1); + TRACE("http.c: updated page sent successfully - %d bytes", strlen(shared_buffer)); + return SUCCESS; } - - // No next 'w' character check as this is the last element - - int gw1,gw2,gw3,gw4; - if (strlen(http_msg) > 15 ) + else { - TRACE("http.c: incorrect gateway format"); - return; + TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); + return FAILURE; } - sscanf(http_msg, "%d.%d.%d.%d", &gw1, &gw2,&gw3,&gw4); - Zodiac_Config.gateway_address[0] = gw1; - Zodiac_Config.gateway_address[1] = gw2; - Zodiac_Config.gateway_address[2] = gw3; - Zodiac_Config.gateway_address[3] = gw4; - TRACE("http.c: gateway set to %d.%d.%d.%d" , Zodiac_Config.gateway_address[0], Zodiac_Config.gateway_address[1], Zodiac_Config.gateway_address[2], Zodiac_Config.gateway_address[3]); - } - else - { - TRACE("http.c: no gateway address found"); - } - - // Save configuration to EEPROM - eeprom_write(); - TRACE("http.c: config written to EEPROM"); - - // Set update required flag - reset_required = true; - - // Send updated config page - if(interfaceCreate_Config_Network()) - { - http_send(&shared_buffer, pcb, 1); - TRACE("http.c: updated page sent successfully - %d bytes", strlen(shared_buffer)); } else { - TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); + TRACE("http.c: ERROR: network configuration failed"); } - - // Send updated header page (with restart button) - - // ***** Placeholder until frame refresh targeting is implemented - // - // - // - } else if(strcmp(http_msg,"btn_restart") == 0) { @@ -1348,7 +1141,7 @@ void http_send(char *buffer, struct tcp_pcb *pcb, bool out) { // Write data to tcp buffer err = tcp_write(pcb, buffer, len, TCP_WRITE_FLAG_COPY + TCP_WRITE_FLAG_MORE); - TRACE("http.c: sending %d bytes to TCP stack, %d REMAINING in buffer", len, (buf_size - len)); + TRACE("http.c: tcp buffer %d/%d", len, buf_size); // Check if more data needs to be written if(out == true) @@ -1763,6 +1556,233 @@ static uint8_t upload_handler(char *ppart, int len) } } +static uint8_t Config_Network(char *payload, int len) +{ + int i = 0; + char *pdat; + + memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array + + // Device Name + pdat = strstr(payload, "wi_deviceName"); // Search for element + if(pdat != NULL) // Check that element exists + { + pdat += (strlen("wi_deviceName")+1); // Data format: wi_deviceName=(name) + + i = 0; + while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) + { + http_msg[i] = pdat[i]; // Store value of element + i++; + } + if(pdat[i+1] == 'w') // Check that the next parameter directly follows the "&" at end of data + { + uint8_t namelen = strlen(http_msg); + if (namelen > 15 ) namelen = 15; // Make sure name is less than 16 characters + sprintf(Zodiac_Config.device_name, http_msg, namelen); + TRACE("http.c: device name set to '%s'",Zodiac_Config.device_name); + } + else + { + TRACE("http.c: \"&\" cannot be used in device name"); + } + } + else + { + TRACE("http.c: no device name found"); + } + + memset(&http_msg, 0, sizeof(http_msg)); + + // MAC Address + pdat = strstr(payload, "wi_macAddress"); + if(pdat != NULL) // Check that element exists + { + pdat += (strlen("wi_macAddress")+1); // Data format: wi_deviceName=(name) + + i = 0; + while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) + { + http_msg[i] = pdat[i]; // Store value of element + i++; + } + if(pdat[i+1] == 'w') + { + int mac1,mac2,mac3,mac4,mac5,mac6; + char decArr[18] = ""; + int j, k; + + if (strlen(http_msg) != 27 ) // Accounting for ":" as "%3A" + { + TRACE("http.c: incorrect MAC address format"); + return; + } + + // Decode http string + j = 0; k = 0; + while(j < strlen(http_msg) && k < 18) + { + if(http_msg[j] == '%' && http_msg[j+1] == '3' && http_msg[j+2] == 'A') + { + decArr[k] = ':'; + j+=3; k++; + } + else + { + decArr[k] = http_msg[j]; + j++; k++; + } + } + + sscanf(decArr, "%x:%x:%x:%x:%x:%x", &mac1, &mac2, &mac3, &mac4, &mac5, &mac6); + Zodiac_Config.MAC_address[0] = mac1; + Zodiac_Config.MAC_address[1] = mac2; + Zodiac_Config.MAC_address[2] = mac3; + Zodiac_Config.MAC_address[3] = mac4; + Zodiac_Config.MAC_address[4] = mac5; + Zodiac_Config.MAC_address[5] = mac6; + TRACE("http.c: MAC address set to %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",Zodiac_Config.MAC_address[0], Zodiac_Config.MAC_address[1], Zodiac_Config.MAC_address[2], Zodiac_Config.MAC_address[3], Zodiac_Config.MAC_address[4], Zodiac_Config.MAC_address[5]); + } + else + { + TRACE("http.c: \"&\" cannot be used in form"); + } + } + else + { + TRACE("http.c: no MAC address found"); + } + + memset(&http_msg, 0, sizeof(http_msg)); + + // IP Address + pdat = strstr(payload, "wi_ipAddress"); + if(pdat != NULL) // Check that element exists + { + pdat += (strlen("wi_ipAddress")+1); // Data format: wi_deviceName=(name) + + i = 0; + while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) + { + http_msg[i] = pdat[i]; // Store value of element + i++; + } + if(pdat[i+1] == 'w') + { + int ip1,ip2,ip3,ip4; + if (strlen(http_msg) > 15 ) + { + TRACE("http.c: incorrect IP format"); + return; + } + sscanf(http_msg, "%d.%d.%d.%d", &ip1, &ip2,&ip3,&ip4); + Zodiac_Config.IP_address[0] = ip1; + Zodiac_Config.IP_address[1] = ip2; + Zodiac_Config.IP_address[2] = ip3; + Zodiac_Config.IP_address[3] = ip4; + TRACE("http.c: IP address set to %d.%d.%d.%d" , Zodiac_Config.IP_address[0], Zodiac_Config.IP_address[1], Zodiac_Config.IP_address[2], Zodiac_Config.IP_address[3]); + } + else + { + TRACE("http.c: \"&\" cannot be used in form"); + } + } + else + { + TRACE("http.c: no IP address found"); + } + + memset(&http_msg, 0, sizeof(http_msg)); + + // Netmask + pdat = strstr(payload, "wi_netmask"); + if(pdat != NULL) // Check that element exists + { + pdat += (strlen("wi_netmask")+1); // Data format: wi_deviceName=(name) + + i = 0; + while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) + { + http_msg[i] = pdat[i]; // Store value of element + i++; + } + if(pdat[i+1] == 'w') + { + int nm1,nm2,nm3,nm4; + if (strlen(http_msg) > 15 ) + { + TRACE("http.c: incorrect netmask format"); + return; + } + sscanf(http_msg, "%d.%d.%d.%d", &nm1, &nm2,&nm3,&nm4); + Zodiac_Config.netmask[0] = nm1; + Zodiac_Config.netmask[1] = nm2; + Zodiac_Config.netmask[2] = nm3; + Zodiac_Config.netmask[3] = nm4; + TRACE("http.c: netmask set to %d.%d.%d.%d" , Zodiac_Config.netmask[0], Zodiac_Config.netmask[1], Zodiac_Config.netmask[2], Zodiac_Config.netmask[3]); + } + else + { + TRACE("http.c: \"&\" cannot be used in form"); + } + } + else + { + TRACE("http.c: no netmask found"); + } + + memset(&http_msg, 0, sizeof(http_msg)); + + // Gateway + pdat = strstr(payload, "wi_gateway"); + if(pdat != NULL) // Check that element exists + { + pdat += (strlen("wi_gateway")+1); // Data format: wi_deviceName=(name) + + i = 0; + while(i < 63 && (pdat[i] != '&') && (pdat[i] >= 31) && (pdat[i] <= 122)) + { + http_msg[i] = pdat[i]; // Store value of element + i++; + } + + // No next 'w' character check as this is the last element + + int gw1,gw2,gw3,gw4; + if (strlen(http_msg) > 15 ) + { + TRACE("http.c: incorrect gateway format"); + return; + } + sscanf(http_msg, "%d.%d.%d.%d", &gw1, &gw2,&gw3,&gw4); + Zodiac_Config.gateway_address[0] = gw1; + Zodiac_Config.gateway_address[1] = gw2; + Zodiac_Config.gateway_address[2] = gw3; + Zodiac_Config.gateway_address[3] = gw4; + TRACE("http.c: gateway set to %d.%d.%d.%d" , Zodiac_Config.gateway_address[0], Zodiac_Config.gateway_address[1], Zodiac_Config.gateway_address[2], Zodiac_Config.gateway_address[3]); + } + else + { + TRACE("http.c: no gateway address found"); + } + + // Save configuration to EEPROM + eeprom_write(); + TRACE("http.c: config written to EEPROM"); + + // Set update required flag + reset_required = true; + + return SUCCESS; + + // Send updated header page (with restart button) + + // ***** Placeholder until frame refresh targeting is implemented + // + // + // +} + /* * Create and format HTTP/HTML for frames * From ce29b2b7a364a42ac6d4de5a6ed4eb6dca314782 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 2 Feb 2017 12:02:08 +1100 Subject: [PATCH 028/163] Adjust HTTP persistent connection --- ZodiacFX/src/http.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 81f0818..ed77450 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -1791,7 +1791,7 @@ static uint8_t interfaceCreate_Frames(void) { // Format HTTP response sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); // Send frames strcat(shared_buffer, \ @@ -1847,7 +1847,7 @@ static uint8_t interfaceCreate_Header(void) if(reset_required == false) { sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -1902,7 +1902,7 @@ static uint8_t interfaceCreate_Header(void) else if(reset_required == true) { sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -1977,7 +1977,7 @@ static uint8_t interfaceCreate_Menu(void) { // Send menu sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -2049,7 +2049,7 @@ static uint8_t interfaceCreate_Home(void) int min = t/60; sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -2099,7 +2099,7 @@ static uint8_t interfaceCreate_Home(void) static uint8_t interfaceCreate_Upload(void) { sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -2232,7 +2232,7 @@ static uint8_t interfaceCreate_Upload_Complete(uint8_t sel) static uint8_t interfaceCreate_Display_Home(void) { sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -2316,7 +2316,7 @@ static uint8_t interfaceCreate_Display_Ports(uint8_t step) } sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -2726,7 +2726,7 @@ static uint8_t interfaceCreate_Display_OpenFlow(void) } sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -2786,7 +2786,7 @@ static uint8_t interfaceCreate_Display_OpenFlow(void) static uint8_t interfaceCreate_Display_Flows(void) { sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -3284,7 +3284,7 @@ if (iLastFlow > 0) static uint8_t interfaceCreate_Config_Home(void) { sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -3336,7 +3336,7 @@ static uint8_t interfaceCreate_Config_Home(void) static uint8_t interfaceCreate_Config_Network(void) { sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -3404,7 +3404,7 @@ static uint8_t interfaceCreate_Config_VLANs(void) // Opening tags, and base table sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -3522,7 +3522,7 @@ static uint8_t interfaceCreate_Config_VLANs(void) static uint8_t interfaceCreate_Config_OpenFlow(void) { sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ @@ -3660,7 +3660,7 @@ static uint8_t interfaceCreate_Config_OpenFlow(void) static uint8_t interfaceCreate_About(void) { sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: close\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ From bde6d99241d7efbcdf3adb40958d23ea0c072946 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 2 Feb 2017 12:03:09 +1100 Subject: [PATCH 029/163] Add flash offset for project Release config Compiles to run from 0x00420000 (entrypoint through bootloader) --- ZodiacFX/ZodiacFX.cproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZodiacFX/ZodiacFX.cproj b/ZodiacFX/ZodiacFX.cproj index 7168674..e3e4036 100644 --- a/ZodiacFX/ZodiacFX.cproj +++ b/ZodiacFX/ZodiacFX.cproj @@ -368,7 +368,7 @@ True - -Wl,--defsym,__stack_size__=0x1400 -Wl,--entry=Reset_Handler -Wl,--cref -mthumb -T../src/ASF/sam/utils/linker_scripts/sam4e/sam4e8/gcc/flash.ld + -Wl,--defsym,__stack_size__=0x1400 -Wl,--entry=Reset_Handler -Wl,-section-start=.text=0x00420000 -Wl,--cref -mthumb -T../src/ASF/sam/utils/linker_scripts/sam4e/sam4e8/gcc/flash.ld ../src/ASF/sam/drivers/efc From 8dfad907546fcb9e3b80a218be9d0a9c1e924e33 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 2 Feb 2017 13:32:24 +1100 Subject: [PATCH 030/163] Add automatic page refresh on restart Interstitial restart page added to refresh web interface after device reset --- ZodiacFX/src/http.c | 56 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index ed77450..86c1376 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -100,6 +100,7 @@ static uint8_t interfaceCreate_Config_Network(void); static uint8_t interfaceCreate_Config_VLANs(void); static uint8_t interfaceCreate_Config_OpenFlow(void); static uint8_t interfaceCreate_About(void); +static uint8_t interfaceCreate_Restart(void); static uint8_t Config_Network(char *payload, int len); @@ -265,7 +266,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err } // Check resource & serve page - if(http_msg[0] == '\0') + if(http_msg[0] == '\0' || strcmp(http_msg,"frames.html") == 0) { if(interfaceCreate_Frames()) { @@ -506,6 +507,17 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err } else if(strcmp(http_msg,"btn_restart") == 0) { + if(interfaceCreate_Restart()) + { + http_send(&shared_buffer, pcb, 1); + TRACE("http.c: updated page sent successfully - %d bytes", strlen(shared_buffer)); + return SUCCESS; + } + else + { + TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); + return FAILURE; + } TRACE("http.c: restarting the Zodiac FX. Please reconnect."); for(int x = 0;x<100000;x++); // Let the above message get sent to the terminal before detaching udc_detach(); // Detach the USB device before restart @@ -1947,7 +1959,7 @@ static uint8_t interfaceCreate_Header(void) "

Zodiac FX

"\ ""\ "
"\ - "
"\ + ""\ ""\ "
"\ "
"\ @@ -2171,7 +2183,7 @@ static uint8_t interfaceCreate_Upload_Complete(uint8_t sel) "Current version: %s
"\ "Uploaded version: %s

"\ "Zodiac FX will be updated on the next restart.

"\ - "
"\ + ""\ ""\ "
"\ ""\ @@ -3701,3 +3713,41 @@ static uint8_t interfaceCreate_About(void) return 0; } } + +static uint8_t interfaceCreate_Restart(void) +{ + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); + strcat(shared_buffer,"Connection: Keep-Alive\r\n"); + strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + ""\ + ""\ + ""\ + ""\ + ""\ + ""\ + ""\ + "

"\ + "Restarting..."\ + "

"\ + ""\ + ""\ + ) < SHARED_BUFFER_LEN) + { + TRACE("http.c: html written to buffer"); + return 1; + } + else + { + TRACE("http.c: WARNING: html truncated to prevent buffer overflow"); + return 0; + } +} \ No newline at end of file From 8d82e56e8e231dc010d742c8898ac047ec604c3f Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 2 Feb 2017 15:26:51 +1100 Subject: [PATCH 031/163] Improve firmware upload error handling - Error handling functions cleaned up --- ZodiacFX/src/http.c | 112 ++++++++++++++++++++++++++++---------------- ZodiacFX/src/http.h | 2 + 2 files changed, 74 insertions(+), 40 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 86c1376..d9598ae 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -72,7 +72,6 @@ extern int flash_write_page(uint8_t *flash_page); // Local Variables struct tcp_pcb *http_pcb; static char http_msg[64]; // Buffer for HTTP message filtering -static uint8_t upload_handler(char *ppart, int len); static char uploaded_version[5] = {0}; static int page_ctr = 1; static int boundary_start = 1; // Check for start of data @@ -80,11 +79,16 @@ static uint8_t flowBase = 0; // Current set of flows to display // Flag variables static bool reset_required; // Track if any configuration changes are pending a restart +static bool file_upload = false; // Multi-part firmware file upload flag static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err); void http_send(char *buffer, struct tcp_pcb *pcb, bool out); +static uint8_t upload_handler(char *payload, int len); +static uint8_t upload_cleanup(struct tcp_pcb *pcb); + +// HTML resources static uint8_t interfaceCreate_Frames(void); static uint8_t interfaceCreate_Header(void); static uint8_t interfaceCreate_Menu(void); @@ -102,6 +106,7 @@ static uint8_t interfaceCreate_Config_OpenFlow(void); static uint8_t interfaceCreate_About(void); static uint8_t interfaceCreate_Restart(void); +// Configuration functions static uint8_t Config_Network(char *payload, int len); @@ -148,10 +153,7 @@ static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err) * */ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) -{ - // Local static flag variables - static bool file_upload = false; // Multi-part firmware file upload flag - +{ // Local variables int len; int i = 0; @@ -195,19 +197,8 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err } else { - file_upload = false; - boundary_start = 1; - - // upload failed - if(interfaceCreate_Upload_Complete(0)) - { - http_send(&shared_buffer, pcb, 1); - TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); - } - else - { - TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); - } + // Stop upload operation + upload_cleanup(pcb); } } else @@ -242,10 +233,10 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err http_msg[i] = http_payload[i]; i++; } - TRACE("http.c: %s method received", http_msg); if(strcmp(http_msg,"GET") == 0) { + TRACE("http.c: GET method received"); memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array // Specified resource directly follows GET @@ -452,6 +443,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err } else if(strcmp(http_msg,"POST") == 0) { + TRACE("http.c: POST method received"); memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array // Specified resource directly follows POST @@ -1114,7 +1106,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err } else { - TRACE("http.c: WARNING: unknown HTTP method received"); + TRACE("http.c: unknown HTTP method received"); } } } @@ -1137,7 +1129,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err /* * HTTP Send function * -* Parameter: +* Parameters: * out - specify whether TCP packet should be sent */ void http_send(char *buffer, struct tcp_pcb *pcb, bool out) @@ -1167,12 +1159,22 @@ void http_send(char *buffer, struct tcp_pcb *pcb, bool out) return; } -static uint8_t upload_handler(char *ppart, int len) +/* +* Upload handler function +* +* Details: +* Handles part-by-part firmware upload process +* +* Parameters: +* payload - pointer to payload data +* len - length of payload +*/ +static uint8_t upload_handler(char *payload, int len) { static char page[512] = {0}; // Storage for each page of data static uint16_t saved_bytes = 0; // Persistent counter of unwritten data uint16_t handled_bytes = 0; // Counter of handled data - static char boundary_ID[50] = {0}; // Storage for boundary ID + static char boundary_ID[BOUNDARY_MAX_LEN] = {0}; // Storage for boundary ID char *px; // Start address pointer char *py; // End address pointer @@ -1191,7 +1193,7 @@ static uint8_t upload_handler(char *ppart, int len) i = 0; while(i < len) { - shared_buffer[i] = ppart[i]; + shared_buffer[i] = payload[i]; i++; } @@ -1203,6 +1205,7 @@ static uint8_t upload_handler(char *ppart, int len) } else { + memset(&boundary_ID, 0, BOUNDARY_MAX_LEN); // Traverse forward until the ID begins while(*px == '\x2d') { @@ -1210,7 +1213,7 @@ static uint8_t upload_handler(char *ppart, int len) } // Store entirety of boundary ID i = 0; - while(i < 50 && *px != '\x2d' && *px != '\x0d' && *px != '\x0a') + while(i < BOUNDARY_MAX_LEN && *px != '\x2d' && *px != '\x0d' && *px != '\x0a') { boundary_ID[i] = *px; @@ -1223,29 +1226,29 @@ static uint8_t upload_handler(char *ppart, int len) memset(&shared_buffer, 0, SHARED_BUFFER_LEN); // Clear shared_buffer // Search for starting boundary (support MIME types) - if(strstr(ppart, "application/mac-binary") != NULL) + if(strstr(payload, "application/mac-binary") != NULL) { - px = strstr(ppart, "application/mac-binary"); + px = strstr(payload, "application/mac-binary"); px += (strlen("application/mac-binary")); } - else if(strstr(ppart, "application/macbinary") != NULL) + else if(strstr(payload, "application/macbinary") != NULL) { - px = strstr(ppart, "application/macbinary"); + px = strstr(payload, "application/macbinary"); px += (strlen("application/macbinary")); } - else if(strstr(ppart, "application/octet-stream") != NULL) + else if(strstr(payload, "application/octet-stream") != NULL) { - px = strstr(ppart, "application/octet-stream"); + px = strstr(payload, "application/octet-stream"); px += (strlen("application/octet-stream")); } - else if(strstr(ppart, "application/x-binary") != NULL) + else if(strstr(payload, "application/x-binary") != NULL) { - px = strstr(ppart, "application/x-binary"); + px = strstr(payload, "application/x-binary"); px += (strlen("application/x-binary")); } - else if(strstr(ppart, "application/x-macbinary") != NULL) + else if(strstr(payload, "application/x-macbinary") != NULL) { - px = strstr(ppart, "application/x-macbinary"); + px = strstr(payload, "application/x-macbinary"); px += (strlen("application/x-macbinary")); } else @@ -1286,11 +1289,11 @@ static uint8_t upload_handler(char *ppart, int len) else { // Once starting boundary has been handled, the start of each payload is valid - px = ppart; + px = payload; } // Search for ending boundary - py = ppart + len; + py = payload + len; i = 128; while(i>0) @@ -1300,9 +1303,9 @@ static uint8_t upload_handler(char *ppart, int len) if((*(py-1)) == '\x2d' && (*(py-2)) == '\x2d' && (*(py-3)) == '\x2d' && (*(py-4)) == '\x2d') { // Store the discovered boundary - char tmpID[50] = {0}; + char tmpID[BOUNDARY_MAX_LEN] = {0}; int z = 0; - while(z < 50 && *(py+z) != '\x2d' && *(py+z) != '\x0d' && *(py+z) != '\x0a') + while(z < BOUNDARY_MAX_LEN && *(py+z) != '\x2d' && *(py+z) != '\x0d' && *(py+z) != '\x0a') { tmpID[z] = *(py+z); z++; @@ -1326,6 +1329,7 @@ static uint8_t upload_handler(char *ppart, int len) } else { + TRACE("http.c: boundary IDs do not match"); i = 1; // 'i' will be decremented to 0 if this line is run } @@ -1339,7 +1343,7 @@ static uint8_t upload_handler(char *ppart, int len) TRACE("http.c: ending boundary not found - ending data is valid"); // Return ending pointer to the end - py = ppart + len; + py = payload + len; } else { @@ -1568,6 +1572,34 @@ static uint8_t upload_handler(char *ppart, int len) } } +/* +* Upload cleanup function +* +* Details: +* Handles variable cleanup for interrupted or failed firmware uploads +* +* Parameters: +* pcb - TCP protocol control block +*/ +static uint8_t upload_cleanup(struct tcp_pcb *pcb) +{ + file_upload = false; + boundary_start = 1; + + // upload failed + if(interfaceCreate_Upload_Complete(0)) + { + http_send(&shared_buffer, pcb, 1); + TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); + } + else + { + TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); + } + + return; +} + static uint8_t Config_Network(char *payload, int len) { int i = 0; diff --git a/ZodiacFX/src/http.h b/ZodiacFX/src/http.h index fe3cbc9..b81575c 100644 --- a/ZodiacFX/src/http.h +++ b/ZodiacFX/src/http.h @@ -32,6 +32,8 @@ #define HTTP_H_ #define FLOW_LIMIT 4 // Displayable flows per page +#define BOUNDARY_MAX_LEN 70 + #define SUCCESS 0 #define FAILURE 1 void http_init(void); From 394200b829f53ddbe0170f800fdcd4c05a1abf11 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 2 Feb 2017 16:26:05 +1100 Subject: [PATCH 032/163] Use portable page size Hard-coded 512-byte page counter removed --- ZodiacFX/src/http.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index d9598ae..64e66a7 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -503,12 +503,10 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err { http_send(&shared_buffer, pcb, 1); TRACE("http.c: updated page sent successfully - %d bytes", strlen(shared_buffer)); - return SUCCESS; } else { TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); - return FAILURE; } TRACE("http.c: restarting the Zodiac FX. Please reconnect."); for(int x = 0;x<100000;x++); // Let the above message get sent to the terminal before detaching @@ -1171,7 +1169,7 @@ void http_send(char *buffer, struct tcp_pcb *pcb, bool out) */ static uint8_t upload_handler(char *payload, int len) { - static char page[512] = {0}; // Storage for each page of data + static char page[IFLASH_PAGE_SIZE] = {0}; // Storage for each page of data static uint16_t saved_bytes = 0; // Persistent counter of unwritten data uint16_t handled_bytes = 0; // Counter of handled data static char boundary_ID[BOUNDARY_MAX_LEN] = {0}; // Storage for boundary ID @@ -1284,6 +1282,9 @@ static uint8_t upload_handler(char *payload, int len) // Starting boundary has been handled boundary_start = 0; + + // Clear page array before use + memset(&page, 0, IFLASH_PAGE_SIZE); // Clear shared_buffer } } else @@ -1364,7 +1365,7 @@ static uint8_t upload_handler(char *payload, int len) /* Final page needs to be written */ // Fill 512-byte array - while(saved_bytes < 512) + while(saved_bytes < IFLASH_PAGE_SIZE) { if(px < py) { @@ -1393,7 +1394,7 @@ static uint8_t upload_handler(char *payload, int len) TRACE("http.c: final firmware page write FAILED"); } } - else if(saved_bytes + len < 512) + else if(saved_bytes + len < IFLASH_PAGE_SIZE) { int max_len = saved_bytes + len; // Fill existing partially-complete page with new data @@ -1420,7 +1421,7 @@ static uint8_t upload_handler(char *payload, int len) else { // Fill existing partially-complete page with new data - while(saved_bytes < 512 && handled_bytes < len) + while(saved_bytes < IFLASH_PAGE_SIZE && handled_bytes < len) { page[saved_bytes] = *px; if(px < py) @@ -1456,11 +1457,11 @@ static uint8_t upload_handler(char *payload, int len) while(handled_bytes < data_len) { - if(data_len - handled_bytes >= 512) + if(data_len - handled_bytes >= IFLASH_PAGE_SIZE) { // Fill 512-byte array int j = 0; - while(j < 512) + while(j < IFLASH_PAGE_SIZE) { page[j] = *px; if(px < py) @@ -1517,7 +1518,7 @@ static uint8_t upload_handler(char *payload, int len) // Fill 512-byte array int j = 0; - while(j < 512) + while(j < IFLASH_PAGE_SIZE) { if(px < py) { From 8ab07d8df1739d68a0c21d843cb817ee6db64484 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 2 Feb 2017 16:46:12 +1100 Subject: [PATCH 033/163] Add callback to restart Zodiac after displaying page --- ZodiacFX/src/http.c | 96 +++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 69 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 64e66a7..bfe010d 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -78,12 +78,13 @@ static int boundary_start = 1; // Check for start of data static uint8_t flowBase = 0; // Current set of flows to display // Flag variables -static bool reset_required; // Track if any configuration changes are pending a restart +static bool restart_required = false; // Track if any configuration changes are pending a restart static bool file_upload = false; // Multi-part firmware file upload flag static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err); void http_send(char *buffer, struct tcp_pcb *pcb, bool out); +static err_t http_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len); static uint8_t upload_handler(char *payload, int len); static uint8_t upload_cleanup(struct tcp_pcb *pcb); @@ -145,9 +146,32 @@ static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err) tcp_recv(pcb, http_recv); tcp_err(pcb, NULL); tcp_poll(pcb, NULL, 4); + tcp_sent(pcb, http_sent); return ERR_OK; } +/* +* HTTP Sent callback function +* +* @param *arg - pointer the additional TCP args +* @param *tcp_pcb - pointer the TCP session structure. +* +*/ +static err_t http_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len) +{ + TRACE("http.c: [http_sent] %d bytes sent", len); + if(restart_required == true) + { + TRACE("http.c: restarting the Zodiac FX. Please reconnect."); + for(int x = 0;x<100000;x++); // Let the above message get sent to the terminal before detaching + udc_detach(); // Detach the USB device before restart + rstc_start_software_reset(RSTC); // Software reset + while (1); + } + + return ERR_OK; +} + /* * HTTP receive function * @@ -508,11 +532,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err { TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); } - TRACE("http.c: restarting the Zodiac FX. Please reconnect."); - for(int x = 0;x<100000;x++); // Let the above message get sent to the terminal before detaching - udc_detach(); // Detach the USB device before restart - rstc_start_software_reset(RSTC); // Software reset - while (1); + restart_required = true; } else if(strcmp(http_msg,"btn_default") == 0) { @@ -1815,9 +1835,6 @@ static uint8_t Config_Network(char *payload, int len) eeprom_write(); TRACE("http.c: config written to EEPROM"); - // Set update required flag - reset_required = true; - return SUCCESS; // Send updated header page (with restart button) @@ -1882,70 +1899,12 @@ static uint8_t interfaceCreate_Frames(void) */ static uint8_t interfaceCreate_Header(void) { - reset_required = true; // ***** Placeholder until frame refresh targeting is implemented - int hr = (totaltime/2)/3600; int t = (totaltime/2)%3600; int min = t/60; // Send header - if(reset_required == false) - { - sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); - strcat(shared_buffer,"Connection: Keep-Alive\r\n"); - strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); - if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - ""\ - "
"\ - "

Zodiac FX

"\ - "
"\ - "
"\ - "Uptime: %02d:%02d"\ - "
"\ - ""\ - ""\ - , hr, min) < SHARED_BUFFER_LEN) - { - TRACE("http.c: html written to buffer"); - return 1; - } - else - { - TRACE("http.c: WARNING: html truncated to prevent buffer overflow"); - return 0; - } - } - else if(reset_required == true) - { + sprintf(shared_buffer,"HTTP/1.1 200 OK\r\n"); strcat(shared_buffer,"Connection: Keep-Alive\r\n"); strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); @@ -2012,7 +1971,6 @@ static uint8_t interfaceCreate_Header(void) return 0; } } -} /* * Create and format HTML for menu page From 53df340a285bd83a9d8b6535909e52c1775e41e9 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 2 Feb 2017 16:50:55 +1100 Subject: [PATCH 034/163] Increase restart page delay --- ZodiacFX/src/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index bfe010d..9bde18f 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -3712,7 +3712,7 @@ static uint8_t interfaceCreate_Restart(void) strcat(shared_buffer,"Content-Type: text/html; charset=UTF-8\r\n\r\n"); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ - ""\ + ""\ ""\ ""\ ""\ + ""\ + ""\ + "

"\ + "

Meters

"\ + "

"\ + "
"\
+			);
+
+// Begin Meter formatting
+// End Meter formatting
+
+	snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\
+				"
"\ + ); + + + if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + ""\ + ""\ + ) < SHARED_BUFFER_LEN) + { + TRACE("http.c: html written to buffer"); + return 1; + } + else + { + TRACE("http.c: WARNING: html truncated to prevent buffer overflow"); + return 0; + } + +} + /* * Create and format HTML for config help page * From 306d9dcfa7a3bd7c16535cd9d728841824547f3d Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 15:09:26 +1100 Subject: [PATCH 104/163] Add global lastMeter counter Indexes the final configured meter in the meter table --- ZodiacFX/src/http.c | 1 + ZodiacFX/src/openflow/openflow.c | 1 + ZodiacFX/src/openflow/openflow_13.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 01c82b4..8d2748a 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -65,6 +65,7 @@ extern struct flow_tbl_actions *flow_actions10[MAX_FLOWS_13]; extern struct meter_entry13 *meter_entry[MAX_METER_13]; extern struct meter_band_stats_array band_stats_array[MAX_METER_13]; extern int iLastFlow; +extern int iLastMeter; extern struct ofp10_port_stats phys10_port_stats[4]; extern struct ofp13_port_stats phys13_port_stats[4]; extern struct table_counter table_counters[MAX_TABLES]; diff --git a/ZodiacFX/src/openflow/openflow.c b/ZodiacFX/src/openflow/openflow.c index fd3bb9b..f34975b 100644 --- a/ZodiacFX/src/openflow/openflow.c +++ b/ZodiacFX/src/openflow/openflow.c @@ -57,6 +57,7 @@ struct flows_counter flow_counters[MAX_FLOWS_13]; struct flow_tbl_actions *flow_actions10[MAX_FLOWS_10]; struct table_counter table_counters[MAX_TABLES]; int iLastFlow = 0; +int iLastMeter = 0; struct meter_entry13 *meter_entry[MAX_METER_13]; struct meter_band_stats_array band_stats_array[MAX_METER_13]; uint8_t shared_buffer[SHARED_BUFFER_LEN]; diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index 09be814..a1de386 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -49,6 +49,7 @@ extern struct tcp_pcb *tcp_pcb; extern int OF_Version; extern bool rcv_freq; extern int iLastFlow; +extern int iLastMeter; extern int totaltime; extern struct ofp13_flow_mod *flow_match13[MAX_FLOWS_13]; extern struct meter_entry13 *meter_entry[MAX_METER_13]; @@ -2034,6 +2035,8 @@ void meter_add13(struct ofp_header *msg) } // meter_index now holds the next available entry in the meter table + iLastMeter = meter_index; // Store index to last meter + // Find number of bands uint16_t bands_received = ((ntohs(ptr_mm->header.length) - sizeof(struct ofp_header) - METER_PARTIAL))/sizeof(struct ofp13_meter_band_drop); // FIX // Band list length is inferred from the length field in the header @@ -2289,6 +2292,8 @@ void meter_delete13(struct ofp_header *msg) TRACE("openflow_13.c: meter table contains %d meter entries", meter_index); } + iLastMeter--; // Decrement last meter count + return; } From 4b270c4224fa0974cbb81aad272b318a643c4caf Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 15:09:54 +1100 Subject: [PATCH 105/163] Modify 'Display: Meters' function definition --- ZodiacFX/src/http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 8d2748a..8eba911 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -102,7 +102,7 @@ static uint8_t interfaceCreate_Display_Home(void); static uint8_t interfaceCreate_Display_Ports(uint8_t step); static uint8_t interfaceCreate_Display_OpenFlow(void); static uint8_t interfaceCreate_Display_Flows(void); -static uint8_t interfaceCreate_Display_Meters(uint8_t more); +static uint8_t interfaceCreate_Display_Meters(void); static uint8_t interfaceCreate_Config_Home(void); static uint8_t interfaceCreate_Config_Network(void); static uint8_t interfaceCreate_Config_VLANs(void); @@ -3291,7 +3291,7 @@ if (iLastFlow > 0) * Create and format HTML for display meters page * */ -static uint8_t interfaceCreate_Display_Meters(uint8_t more) +static uint8_t interfaceCreate_Display_Meters(void) { sprintf(shared_buffer, http_header); From 92e133b6fb9c8ee37c8d6b2be12a6636a0f84ffe Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 15:10:55 +1100 Subject: [PATCH 106/163] Add side-menu link to 'Display: Meters' --- ZodiacFX/src/http.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 8eba911..e70b978 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -431,6 +431,18 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); } } + else if(strcmp(http_msg,"d_meters.htm") == 0) + { + if(interfaceCreate_Display_Meters()) + { + http_send(&shared_buffer, pcb, 1); + TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); + } + else + { + TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); + } + } else if(strcmp(http_msg,"cfg_home.htm") == 0) { if(interfaceCreate_Config_Home()) @@ -2017,6 +2029,7 @@ static uint8_t interfaceCreate_Menu(void) "
  • Ports
  • "\ "
  • OpenFlow
  • "\ "
  • Flows
  • "\ + "
  • Meters
  • "\ "
  • Config
  • "\ "
  • Network
  • "\ "
  • VLANs
  • "\ From a8e9e2ea1bc6a42cc62519d33405d520dbd8b1c9 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 15:11:57 +1100 Subject: [PATCH 107/163] Add 'Display: Metering' page to web interface --- ZodiacFX/src/http.c | 118 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index e70b978..894e300 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -79,6 +79,7 @@ static char http_msg[64]; // Buffer for HTTP message filtering static int page_ctr = 1; static int boundary_start = 1; // Check for start of data static uint8_t flowBase = 0; // Current set of flows to display +static uint8_t meterBase = 0; // Current set of meters to display // Flag variables static bool restart_required = false; // Track if any configuration changes are pending a restart @@ -3306,6 +3307,38 @@ if (iLastFlow > 0) */ static uint8_t interfaceCreate_Display_Meters(void) { + /* Prepare meter counters */ + + // Find number of meters + int meterCount; + if(meter_entry[0] == NULL) + { + meterCount = 0; + } + else + { + meterCount = iLastMeter+1; + } + + // Find end of display range (exclusive) - meterBase indexes the start of the range + int meterEnd; + if(meterBase == 0) + { + meterEnd = METER_DISPLAY_LIMIT; + } + else + { + if(meterBase + METER_DISPLAY_LIMIT >= iLastMeter) + { + meterEnd = iLastMeter+1; + } + else + { + meterEnd = meterBase + METER_DISPLAY_LIMIT; + } + } + + // Format header sprintf(shared_buffer, http_header); snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ @@ -3325,11 +3358,96 @@ static uint8_t interfaceCreate_Display_Meters(void) ""\ "

    "\ "

    Meters

    "\ + "%d meters configured
    "\ + , meterCount); + + if(meterCount != 0) + { + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + "Showing meters %d - %d
    "\ + , meterBase+1, meterEnd); + } + + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ "

    "\ "
    "\
     			);
     
     // Begin Meter formatting
    +		
    +	// Check that table is populated
    +	if(meter_entry[0] != NULL)
    +	{
    +		int meter_index = meterBase;
    +		while(meter_entry[meter_index] != NULL && meter_index < meterEnd)
    +		{
    +			snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"_______\r\n");
    +			snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\r\nMeter %d\r\n", meter_index+1);
    +			snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"  Meter ID: %d\r\n", meter_entry[meter_index]->meter_id);
    +			snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"  Counters:\r\n");
    +			meter_entry[meter_index]->flow_count = get_bound_flows(meter_entry[meter_index]->meter_id);
    +			snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\tBound Flows:\t%d\tDuration:\t%d sec\r\n", meter_entry[meter_index]->flow_count, (sys_get_ms()-meter_entry[meter_index]->time_added)/1000);
    +			snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\tByte Count:\t%"PRIu64"\tPacket Count:\t%"PRIu64"\r\n", meter_entry[meter_index]->byte_in_count, meter_entry[meter_index]->packet_in_count);
    +			snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\tConfiguration:\t");
    +			if(((meter_entry[meter_index]->flags) & OFPMF13_KBPS) == OFPMF13_KBPS)
    +			{
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"KBPS; ");
    +			}
    +			if(((meter_entry[meter_index]->flags) & OFPMF13_PKTPS) == OFPMF13_PKTPS)
    +			{
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"PKTPS; ");
    +			}
    +			if(((meter_entry[meter_index]->flags) & OFPMF13_BURST) == OFPMF13_BURST)
    +			{
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"BURST; ");
    +			}
    +			if(((meter_entry[meter_index]->flags) & OFPMF13_STATS) == OFPMF13_STATS)
    +			{
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"STATS; ");
    +			}
    +			if(meter_entry[meter_index]->flags == 0)
    +			{
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," NONE;");
    +			}
    +				
    +			snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\r\n\tNumber of bands:\t%d\r\n", meter_entry[meter_index]->band_count);
    +			int bands_processed = 0;
    +			struct ofp13_meter_band_drop * ptr_band;
    +			ptr_band = &(meter_entry[meter_index]->bands);
    +			while(bands_processed < meter_entry[meter_index]->band_count)
    +			{
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\t\tBand %d:\r\n", bands_processed+1);
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\t\t  Type:\t\t");
    +				if(ptr_band->type == OFPMBT13_DROP)
    +				{
    +					snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"DROP\r\n");
    +				}
    +				else if(ptr_band->type == OFPMBT13_DSCP_REMARK)
    +				{
    +					snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"DSCP REMARK (unsupported)\r\n");
    +				}
    +				else
    +				{
    +					snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"unsupported type\r\n");
    +				}
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\t\t  Rate:\t\t%d\t\r\n", ptr_band->rate);
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\t\t  Burst Size:\t%d\t\r\n", ptr_band->burst_size);
    +					
    +				// Find band index
    +				int band_index = ((uint8_t*)ptr_band - (uint8_t*)&(meter_entry[meter_index]->bands)) / sizeof(struct ofp13_meter_band_drop);
    +					
    +				// Display counters
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\t\t  Byte count:\t%"PRIu64"\t\r\n", band_stats_array[meter_index].band_stats[band_index].byte_band_count);
    +				snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\t\t  Packet count:\t%"PRIu64"\t\r\n", band_stats_array[meter_index].band_stats[band_index].packet_band_count);
    +					
    +				ptr_band++;	// Move to next band
    +				bands_processed++;
    +			}
    +			meter_index++;
    +		}
    +		snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\r\n_______\r\n\r\n");
    +	}
    +	
     // End Meter formatting
     
     	snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\
    
    From 8c63e52dabb2675683b192d880f8c209691aee7e Mon Sep 17 00:00:00 2001
    From: Kristopher Chen 
    Date: Mon, 27 Feb 2017 15:12:36 +1100
    Subject: [PATCH 108/163] Add Previous/Next buttons to 'Display: Metering' page
    
    Displays 3 meters at a time in the web interface.
    ---
     ZodiacFX/src/http.c | 69 +++++++++++++++++++++++++++++++++++++++++++++
     1 file changed, 69 insertions(+)
    
    diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c
    index 894e300..e930524 100644
    --- a/ZodiacFX/src/http.c
    +++ b/ZodiacFX/src/http.c
    @@ -813,6 +813,56 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err
     						TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer));
     					}
     				}
    +				else if(strcmp(http_msg,"btn_meterPage") == 0)
    +				{
    +					// Display: Meters, Previous and Next meter page buttons
    +					
    +					if(strstr(http_payload, "btn_meterNext") != NULL)	// Check that element exists
    +					{
    +						TRACE("http.c: request for next page of meters");
    +						TRACE("http.c: current meterBase: %d; current iLastMeter: %d;", meterBase, iLastMeter)
    +						if(meterBase < iLastMeter-METER_DISPLAY_LIMIT)
    +						{
    +							// Increment flow base (display next set on page send)
    +							meterBase += METER_DISPLAY_LIMIT;
    +							TRACE("http.c: new meterBase: %d; current iLastMeter: %d;", meterBase, iLastMeter)
    +						}
    +						else
    +						{
    +							TRACE("http.c: meterBase already reaches end - NOT incremented")
    +						}
    +					}
    +					else if(strstr(http_payload, "btn_meterPrev") != NULL)
    +					{
    +						TRACE("http.c: request for previous page of meters");
    +						TRACE("http.c: current meterBase: %d; current iLastMeter: %d;", meterBase, iLastMeter)
    +						if(meterBase >= METER_DISPLAY_LIMIT)
    +						{
    +							// Decrement meter base (display previous set on page send)
    +							meterBase -= METER_DISPLAY_LIMIT;
    +							TRACE("http.c: new meterBase: %d; current iLastMeter: %d;", meterBase, iLastMeter)
    +						}
    +						else
    +						{
    +							TRACE("http.c: meterBase already at start - NOT decremented")
    +						}
    +					}
    +					else
    +					{
    +						TRACE("http.c: ERROR: invalid request");
    +					}
    +					
    +					// Send updated page
    +					if(interfaceCreate_Display_Meters())
    +					{
    +						http_send(&shared_buffer, pcb, 1);
    +						TRACE("http.c: updated page sent successfully - %d bytes", strlen(shared_buffer));
    +					}
    +					else
    +					{
    +						TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer));
    +					}
    +				}
     				else if(strcmp(http_msg,"save_vlan") == 0)
     				{
     					// Config: VLANs, Add and Delete buttons
    @@ -3452,8 +3502,27 @@ static uint8_t interfaceCreate_Display_Meters(void)
     
     	snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\
     				"
    "\ + "

    "\ ); + // Check if "previous page" button needs to be created + if(meterBase >= METER_DISPLAY_LIMIT) + { + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + ""\ + ); + } + + // Check if "next page" button needs to be created + if(meterEnd < iLastMeter) + { + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + ""\ + ); + } + + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + "
    "); if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ From 06f17c333d47db0b8dd6dd8698bff36d0fb64bc6 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 16:11:21 +1100 Subject: [PATCH 109/163] Fix meter configuration reply bug Request for OFPM_ALL resulted in an infinite loop --- ZodiacFX/src/openflow/openflow_13.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index a1de386..9554aff 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -1344,7 +1344,7 @@ int multi_meter_config_reply13(uint8_t *buffer, struct ofp13_multipart_request * buffer_ptr += sizeof(struct ofp13_multipart_reply); meter_index = 0; - // Loop & format each meter stats reply + // Loop & format each meter config reply while(meter_entry[meter_index] != NULL && meter_index < MAX_METER_13) { // Format reply with specified meter configuration @@ -1377,6 +1377,8 @@ int multi_meter_config_reply13(uint8_t *buffer, struct ofp13_multipart_request * // update buffer pointer buffer_ptr = ptr_buffer_band; + + meter_index++; } return (buffer_ptr - buffer); // return length From 4c7283fc048d4792d2dfd6f0581062cb213c6bfb Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 16:40:31 +1100 Subject: [PATCH 110/163] Clear last meter index on reset --- ZodiacFX/src/openflow/of_helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ZodiacFX/src/openflow/of_helper.c b/ZodiacFX/src/openflow/of_helper.c index 64e098b..db2f6b2 100644 --- a/ZodiacFX/src/openflow/of_helper.c +++ b/ZodiacFX/src/openflow/of_helper.c @@ -49,6 +49,7 @@ // Global variables extern struct zodiac_config Zodiac_Config; extern int iLastFlow; +extern int iLastMeter; extern int OF_Version; extern int totaltime; extern uint8_t last_port_status[4]; @@ -1097,6 +1098,7 @@ void flow_timeouts() void clear_flows(void) { iLastFlow = 0; + iLastMeter = 0; membag_init(); /* Clear OpenFlow 1.0 flow table */ From 403b8e458cd83ea8ea3305058aa38843f46be09a Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 16:42:58 +1100 Subject: [PATCH 111/163] Clear meter display range base when required On disconnect, iLastMeter will be cleared. This additional error-check prevents any mismatch between the web interface's display state, and the actual meters present. --- ZodiacFX/src/http.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index e930524..1feb9ee 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -3359,6 +3359,12 @@ static uint8_t interfaceCreate_Display_Meters(void) { /* Prepare meter counters */ + // Check status of start of range + if(meterBase > iLastMeter) + { + meterBase = 0; + } + // Find number of meters int meterCount; if(meter_entry[0] == NULL) From 9eb057742d049705a656f2a93db8b04d6a188ed6 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 17:03:44 +1100 Subject: [PATCH 112/163] Adjust web interface meter display ranges Fixes display range issues --- ZodiacFX/src/http.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 1feb9ee..3ef84c8 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -3378,20 +3378,13 @@ static uint8_t interfaceCreate_Display_Meters(void) // Find end of display range (exclusive) - meterBase indexes the start of the range int meterEnd; - if(meterBase == 0) + if(meterBase + METER_DISPLAY_LIMIT >= iLastMeter) { - meterEnd = METER_DISPLAY_LIMIT; + meterEnd = iLastMeter+1; } else { - if(meterBase + METER_DISPLAY_LIMIT >= iLastMeter) - { - meterEnd = iLastMeter+1; - } - else - { - meterEnd = meterBase + METER_DISPLAY_LIMIT; - } + meterEnd = meterBase + METER_DISPLAY_LIMIT; } // Format header From 3eee6271dee3988f877ac25fb16e598153acd705 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 17:21:23 +1100 Subject: [PATCH 113/163] Adjust iLastMeter variable usage Make iLastMeter consistent with iLastFlow usage. Now counts the values in the table, rather than indexing the last value. --- ZodiacFX/src/openflow/openflow_13.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index 9554aff..41fde0d 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -2036,9 +2036,7 @@ void meter_add13(struct ofp_header *msg) meter_index++; } // meter_index now holds the next available entry in the meter table - - iLastMeter = meter_index; // Store index to last meter - + // Find number of bands uint16_t bands_received = ((ntohs(ptr_mm->header.length) - sizeof(struct ofp_header) - METER_PARTIAL))/sizeof(struct ofp13_meter_band_drop); // FIX // Band list length is inferred from the length field in the header @@ -2104,6 +2102,8 @@ void meter_add13(struct ofp_header *msg) } while (bands_processed < bands_received); } + iLastMeter++; // Decrement last meter count + return; } From 30339b0b02a76fca30a833ade9dcff75b34d7e9a Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 17:22:14 +1100 Subject: [PATCH 114/163] Update iLastMeter usage Adjust web interface to use iLastMeter as a counter, rather than an index. --- ZodiacFX/src/http.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 3ef84c8..4b5bf18 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -3360,7 +3360,7 @@ static uint8_t interfaceCreate_Display_Meters(void) /* Prepare meter counters */ // Check status of start of range - if(meterBase > iLastMeter) + if(meterBase >= iLastMeter) { meterBase = 0; } @@ -3373,14 +3373,14 @@ static uint8_t interfaceCreate_Display_Meters(void) } else { - meterCount = iLastMeter+1; + meterCount = iLastMeter; } // Find end of display range (exclusive) - meterBase indexes the start of the range int meterEnd; if(meterBase + METER_DISPLAY_LIMIT >= iLastMeter) { - meterEnd = iLastMeter+1; + meterEnd = iLastMeter; } else { From c244290f5cd9bc91662d3aeb42299e90b7e95613 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 17:22:53 +1100 Subject: [PATCH 115/163] Minor web interface formatting improvement --- ZodiacFX/src/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 4b5bf18..02a7ca7 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -3501,7 +3501,7 @@ static uint8_t interfaceCreate_Display_Meters(void) snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ - "

    "\ + ""\ ); // Check if "previous page" button needs to be created From f74eecda0fb2f1914fca3397ec7d9d260a8b3203 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 27 Feb 2017 17:42:00 +1100 Subject: [PATCH 116/163] Consolidate common html styles --- ZodiacFX/src/http.c | 171 ++++++++++++++++---------------------------- 1 file changed, 63 insertions(+), 108 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 02a7ca7..079d657 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -111,7 +111,17 @@ static uint8_t interfaceCreate_Config_OpenFlow(void); static uint8_t interfaceCreate_About(void); static uint8_t interfaceCreate_Restart(void); -static uint8_t http_header[] = "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n"; +static uint8_t http_header[] = "HTTP/1.1 200 OK\r\n"\ + "Connection: Keep-Alive\r\n"\ + "Content-Type: text/html; charset=UTF-8\r\n\r\n"; + +static uint8_t html_style_body[] = "body {"\ + "overflow: auto;"\ + "font-family:Sans-serif;"\ + "line-height: 1.2em;"\ + "font-size: 17px;"\ + "margin-left: 20px;"\ + "}"; // Configuration functions static uint8_t Config_Network(char *payload, int len); @@ -2113,19 +2123,15 @@ static uint8_t interfaceCreate_Home(void) sprintf(shared_buffer, http_header); - if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ ""\ ""\ ""\ ""\ @@ -2162,18 +2168,14 @@ static uint8_t interfaceCreate_Upload(void) { sprintf(shared_buffer, http_header); - if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ ""\ ""\ ""\ @@ -2253,13 +2255,9 @@ static uint8_t interfaceCreate_Upload_Complete(uint8_t sel) ""\ ""\ ""\ ""\ ""\ @@ -2311,18 +2309,14 @@ static uint8_t interfaceCreate_Display_Home(void) { sprintf(shared_buffer, http_header); - if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ ""\ ""\ ""\ @@ -2400,14 +2394,9 @@ static uint8_t interfaceCreate_Display_Ports(uint8_t step) ""\ ""\ ""\ ""\ ""\ @@ -2867,13 +2853,10 @@ static uint8_t interfaceCreate_Display_Flows(void) ""\ ""\ ""\ ""\ ""\ @@ -3395,13 +3378,9 @@ static uint8_t interfaceCreate_Display_Meters(void) ""\ ""\ ""\ ""\ ""\ @@ -3547,18 +3526,14 @@ static uint8_t interfaceCreate_Config_Home(void) { sprintf(shared_buffer, http_header); - if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ ""\ ""\ ""\ @@ -3598,18 +3573,14 @@ static uint8_t interfaceCreate_Config_Network(void) { sprintf(shared_buffer, http_header); - if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ ""\ ""\ ""\ @@ -3670,13 +3641,9 @@ static uint8_t interfaceCreate_Config_VLANs(void) ""\ ""\ ""\ ""\ ""\ @@ -3918,18 +3881,14 @@ static uint8_t interfaceCreate_Config_OpenFlow(void) static uint8_t interfaceCreate_About(void) { sprintf(shared_buffer, http_header); - if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ ""\ ""\ ""\ @@ -3965,19 +3924,15 @@ static uint8_t interfaceCreate_About(void) static uint8_t interfaceCreate_Restart(void) { sprintf(shared_buffer, http_header); - if( snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ ""\ ""\ ""\ ""\ ""\ ""\ ""\ From ca5f335527323d951bda3a8e7eb6600cf9fe8fe7 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 28 Feb 2017 09:51:37 +1100 Subject: [PATCH 117/163] Add meter instruction to CLI 'show flows' command User can now see the meter a flow is bound to --- ZodiacFX/src/command.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index ed8bd21..296d116 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -1155,6 +1155,14 @@ void command_openflow(char *command, char *param1, char *param2, char *param3) printf("\r Instructions:\r\n"); inst_ptr = (struct ofp13_instruction *) ofp13_oxm_inst[i]; inst_size = ntohs(inst_ptr->len); + + // Check for optional metering instruction + if(ntohs(inst_ptr->type) == OFPIT13_METER) + { + struct ofp13_instruction_meter *inst_meter = inst_ptr; + printf(" Meter: %d\r\n", ntohl(inst_meter->meter_id)); + } + if(ntohs(inst_ptr->type) == OFPIT13_APPLY_ACTIONS) { printf(" Apply Actions:\r\n"); From 6c51409e4aa33867fcac25b011e141b3ff35ce86 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 28 Feb 2017 09:53:03 +1100 Subject: [PATCH 118/163] Add meter instruction to web interface ('Display: Flows') --- ZodiacFX/src/http.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 079d657..b7b3ea6 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -3098,6 +3098,14 @@ if (iLastFlow > 0) snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\r Instructions:\r\n"); inst_ptr = (struct ofp13_instruction *) ofp13_oxm_inst[i]; inst_size = ntohs(inst_ptr->len); + + // Check for optional metering instruction + if(ntohs(inst_ptr->type) == OFPIT13_METER) + { + struct ofp13_instruction_meter *inst_meter = inst_ptr; + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer), " Meter: %d\r\n", ntohl(inst_meter->meter_id)); + } + if(ntohs(inst_ptr->type) == OFPIT13_APPLY_ACTIONS) { snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," Apply Actions:\r\n"); From 8d7db2dee75a24e13028eebefe87aa9f6b2f9a94 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 28 Feb 2017 10:37:32 +1100 Subject: [PATCH 119/163] Fix web interface OpenFlow connection check Prevents unknown connection state in certain situations --- ZodiacFX/src/http.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index b7b3ea6..3b9633c 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -54,6 +54,7 @@ extern struct tcp_pcb *tcp_pcb; extern int OF_Version; extern uint8_t shared_buffer[SHARED_BUFFER_LEN]; // SHARED_BUFFER_LEN must never be reduced below 2048 extern struct integrity_check verify; +extern int tcp_con_state; // Check connection state extern struct ofp_flow_mod *flow_match10[MAX_FLOWS_10]; extern struct ofp13_flow_mod *flow_match13[MAX_FLOWS_13]; @@ -2729,11 +2730,7 @@ static uint8_t interfaceCreate_Display_OpenFlow(void) // Status char wi_ofStatus[15] = ""; - if (tcp_pcb->state != ESTABLISHED && Zodiac_Config.OFEnabled == OF_ENABLED) - { - snprintf(wi_ofStatus, 15, "Disconnected"); - } - else if (tcp_pcb->state == ESTABLISHED && Zodiac_Config.OFEnabled == OF_ENABLED) + if (tcp_con_state == 1 && tcp_pcb->state == ESTABLISHED && Zodiac_Config.OFEnabled == OF_ENABLED) { snprintf(wi_ofStatus, 15, "Connected"); } @@ -2743,7 +2740,7 @@ static uint8_t interfaceCreate_Display_OpenFlow(void) } else { - snprintf(wi_ofStatus, 15, "Error: unknown"); + snprintf(wi_ofStatus, 15, "Disconnected"); } // Version, Tables, Flows, Lookups, Matches From 3b5f1cd6fcc268aec947ebdaf48dd4ca5dfc15f2 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 28 Feb 2017 11:11:15 +1100 Subject: [PATCH 120/163] Adjust http receive error debug message FIN,ACK messages were triggering the 'receive error' message --- ZodiacFX/src/http.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 3b9633c..60f58b5 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -1235,7 +1235,10 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err } else { - TRACE("http.c: receive error"); + if(err != ERR_OK) + { + TRACE("http.c: receive error - %d", err); + } } pbuf_free(p); From 356d9c7860256b51d30b907008cfdd311b2b1d24 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 28 Feb 2017 11:52:37 +1100 Subject: [PATCH 121/163] Add support for deleting all meters --- ZodiacFX/src/openflow/openflow_13.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index 41fde0d..7bb1fcc 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -2232,6 +2232,35 @@ void meter_delete13(struct ofp_header *msg) struct ofp13_meter_mod * ptr_mm; ptr_mm = (struct ofp13_meter_mod *) msg; + // Check if all meters need to be deleted + if(ntohl(ptr_mm->meter_id) == OFPM13_ALL) + { + TRACE("openflow_13.c: request to delete all meters"); + + int meter_index = 0; + + // Create temporary empty structure + struct meter_band_stats_array empty_stats_array = {0}; + + // Loop through all meters + while(meter_entry[meter_index] != NULL && meter_index < MAX_METER_13) + { + /* Delete entry */ + // Free allocated memory + membag_free(meter_entry[meter_index]); + // Clear the pointer + meter_entry[meter_index] = NULL; + + /* Delete band counters */ + // Copy over the existing structure + band_stats_array[meter_index] = empty_stats_array; + + meter_index++; + } + + return; + } + TRACE("openflow_13.c: request to DELETE meter_id %d", ntohl(ptr_mm->meter_id)); int meter_index = 0; From f1c584d21f80b15b2aa5317ccb3c50e307f5aea5 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 28 Feb 2017 12:12:51 +1100 Subject: [PATCH 122/163] Fix band processing debug messages Counters now align --- ZodiacFX/src/openflow/openflow_13.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index 7bb1fcc..bf97447 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -2093,12 +2093,13 @@ void meter_add13(struct ofp_header *msg) ptr_band->rate = ntohl(ptr_rxband->rate); ptr_band->burst_size = ntohl(ptr_rxband->burst_size); - // ***** TODO : add error checking for band processing - TRACE("openflow_13.c: %d of %d bands processed", bands_processed, bands_received); - ptr_band++; // Move to next band storage location ptr_rxband++; // Move to next received band bands_processed++; + + // ***** TODO : add error checking for band processing + TRACE("openflow_13.c: %d of %d bands processed", bands_processed, bands_received); + } while (bands_processed < bands_received); } From 6afe9c471e69bb29d025c9a39b96b2a9fd9ec290 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 28 Feb 2017 12:31:58 +1100 Subject: [PATCH 123/163] Update firmware upload page details --- ZodiacFX/src/http.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 60f58b5..8c54931 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -2187,8 +2187,7 @@ static uint8_t interfaceCreate_Upload(void) "

    Firmware Update

    "\ "

    "\ ""\ - "

    Browser firmware update is currently supported in the following browsers:
    - Chrome (Windows & macOS)
    - Firefox (Windows & macOS)
    - Edge (Windows)
    - Internet Explorer 11 (Windows)

    "\ - "Do not attempt an update with an unsupported browser.

    "\ + "

    Browser firmware update supports official binaries (version 0.80 and later).

    Please find the latest version in the forums.

    "\ ""\ "

    "\ ""\ From c48e04dea791fe2a3c12819b516476619e8393a6 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 28 Feb 2017 12:33:20 +1100 Subject: [PATCH 124/163] Update web interface display help page --- ZodiacFX/src/http.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 8c54931..d567fef 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -2338,6 +2338,10 @@ static uint8_t interfaceCreate_Display_Home(void) "

    "\ "View the current flows in the flow table. 4 flows are displayed per page."\ "

    "\ + "

    Meters

    "\ + "

    "\ + "View the current meters in the meter table. 3 meters are displayed per page. Up to 8 meters can be configured, with up to 3 meter bands each."\ + "

    "\ ""\ ""\ ) < SHARED_BUFFER_LEN) From 8c0397f8e5dd9d8daf7ec0849b87d0d14365d520 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Thu, 2 Mar 2017 15:10:25 +1100 Subject: [PATCH 125/163] Prevent firmware upload from being interrupted (WIP) --- ZodiacFX/src/http.c | 100 +++++++++++++++++++++++--------------------- ZodiacFX/src/http.h | 1 + 2 files changed, 53 insertions(+), 48 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index d567fef..4caa04b 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -81,6 +81,8 @@ static int page_ctr = 1; static int boundary_start = 1; // Check for start of data static uint8_t flowBase = 0; // Current set of flows to display static uint8_t meterBase = 0; // Current set of meters to display +static struct tcp_pcb * upload_pcb; // Firmware upload connection check (pcb pointer) +static int upload_timer = 0; // Timer for firmware upload timeout // Flag variables static bool restart_required = false; // Track if any configuration changes are pending a restart @@ -208,7 +210,8 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err http_payload = (char*)p->payload; len = p->tot_len; - TRACE("http.c: -- HTTP recv received %d payload bytes", len) + TRACE("http.c: -- HTTP recv received %d payload bytes", len); + TRACE("http.c: -> pcb @ addr: 0x%08x, remote port %d", pcb, pcb->remote_port); if(file_upload == true) { @@ -220,24 +223,15 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err i++; } - if(strcmp(http_msg,"GET") == 0) + if(upload_pcb != pcb) { - memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array - - // Specified resource directly follows GET - i = 0; - while(i < 63 && (http_payload[i+5] != ' ')) - { - http_msg[i] = http_payload[i+5]; // Offset http_payload to isolate resource - i++; - } + TRACE("http.c: incoming connection ignored - upload currently in progress"); - if(strcmp(http_msg,"header.htm") == 0) - { - return ERR_OK; - } - else + // Check 10-second timeout + if(sys_get_ms() - upload_timer > UPLOAD_TIMEOUT) { + TRACE("http.c: firmware upload has timed out"); + // Stop upload operation upload_handler(NULL, 0); // Clean up upload operation if(interfaceCreate_Upload_Complete(2)) @@ -250,43 +244,47 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); } } + + return ERR_OK; } - else + + TRACE("http.c: %d seconds since last firmware packet received", (sys_get_ms() - upload_timer)); + // Set timer value + upload_timer = sys_get_ms(); + + int ret = 0; + // Handle multi-part file data + ret = upload_handler(http_payload, len); + if(ret == 2) { - int ret = 0; - // Handle multi-part file data - ret = upload_handler(http_payload, len); - if(ret == 2) - { - file_upload = false; - boundary_start = 1; - //flash_clear_gpnvm(1); - // upload check - if(verification_check() == 0) - { - upload_handler(NULL, 0); // Clean up upload operation - if(interfaceCreate_Upload_Complete(1)) - { - http_send(&shared_buffer, pcb, 1); - TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); - } - else - { - TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); - } + file_upload = false; + boundary_start = 1; + //flash_clear_gpnvm(1); + // upload check + if(verification_check() == 0) + { + upload_handler(NULL, 0); // Clean up upload operation + if(interfaceCreate_Upload_Complete(1)) + { + http_send(&shared_buffer, pcb, 1); + TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); } else { - upload_handler(NULL, 0); // Clean up upload operation - if(interfaceCreate_Upload_Complete(3)) - { - http_send(&shared_buffer, pcb, 1); - TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); - } - else - { - TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); - } + TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); + } + } + else + { + upload_handler(NULL, 0); // Clean up upload operation + if(interfaceCreate_Upload_Complete(3)) + { + http_send(&shared_buffer, pcb, 1); + TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); + } + else + { + TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); } } } @@ -549,6 +547,10 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err // All following packets will contain multi-part file data file_upload = true; + // Store pcb pointer value for this connection + upload_pcb = pcb; + // Initialise timeout value + upload_timer = sys_get_ms(); upload_handler(http_payload, len); } @@ -1310,6 +1312,8 @@ static uint8_t upload_handler(char *payload, int len) saved_bytes = 0; // Clear saved byte counter file_upload = false; // Clear file upload flag boundary_start = 1; // Set starting boundary required flag + upload_pcb = NULL; // Clear pcb connection pointer + upload_timer = 0; // Clear upload timeout return 1; } diff --git a/ZodiacFX/src/http.h b/ZodiacFX/src/http.h index b1efdc4..6724625 100644 --- a/ZodiacFX/src/http.h +++ b/ZodiacFX/src/http.h @@ -34,6 +34,7 @@ #define FLOW_DISPLAY_LIMIT 4 // Displayable flows per page #define METER_DISPLAY_LIMIT 3 // Displayable meters per page #define BOUNDARY_MAX_LEN 70 +#define UPLOAD_TIMEOUT 20000 // (ms) timeout window between each firmware update packet void http_init(void); From 35420592a3dab77249b517f21bed9dac0751643b Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 3 Mar 2017 09:13:09 +1100 Subject: [PATCH 126/163] Reduce firmware web upload timeout value --- ZodiacFX/src/http.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ZodiacFX/src/http.h b/ZodiacFX/src/http.h index 6724625..b1efdc4 100644 --- a/ZodiacFX/src/http.h +++ b/ZodiacFX/src/http.h @@ -34,7 +34,6 @@ #define FLOW_DISPLAY_LIMIT 4 // Displayable flows per page #define METER_DISPLAY_LIMIT 3 // Displayable meters per page #define BOUNDARY_MAX_LEN 70 -#define UPLOAD_TIMEOUT 20000 // (ms) timeout window between each firmware update packet void http_init(void); From abd8c97c7f119d52da3d36b4095a5ba2c8993386 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 3 Mar 2017 09:23:08 +1100 Subject: [PATCH 127/163] Modify upload status page declaration --- ZodiacFX/src/http.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 4caa04b..968d32a 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -101,7 +101,7 @@ static uint8_t interfaceCreate_Header(void); static uint8_t interfaceCreate_Menu(void); static uint8_t interfaceCreate_Home(void); static uint8_t interfaceCreate_Upload(void); -static uint8_t interfaceCreate_Upload_Complete(uint8_t sel); +static uint8_t interfaceCreate_Upload_Status(uint8_t sel); static uint8_t interfaceCreate_Display_Home(void); static uint8_t interfaceCreate_Display_Ports(uint8_t step); static uint8_t interfaceCreate_Display_OpenFlow(void); @@ -234,7 +234,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err // Stop upload operation upload_handler(NULL, 0); // Clean up upload operation - if(interfaceCreate_Upload_Complete(2)) + if(interfaceCreate_Upload_Status(2)) { http_send(&shared_buffer, pcb, 1); TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); @@ -264,7 +264,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err if(verification_check() == 0) { upload_handler(NULL, 0); // Clean up upload operation - if(interfaceCreate_Upload_Complete(1)) + if(interfaceCreate_Upload_Status(1)) { http_send(&shared_buffer, pcb, 1); TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); @@ -277,7 +277,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err else { upload_handler(NULL, 0); // Clean up upload operation - if(interfaceCreate_Upload_Complete(3)) + if(interfaceCreate_Upload_Status(3)) { http_send(&shared_buffer, pcb, 1); TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); @@ -2211,10 +2211,10 @@ static uint8_t interfaceCreate_Upload(void) } /* -* Create and format HTML for firmware update complete page +* Create and format HTML for firmware update status page * */ -static uint8_t interfaceCreate_Upload_Complete(uint8_t sel) +static uint8_t interfaceCreate_Upload_Status(uint8_t sel) { if(sel == 1) { From b620f756c21cecb4181a1a2b04af8d63afab3ac7 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 3 Mar 2017 09:23:40 +1100 Subject: [PATCH 128/163] Reduce web upload timeout window Worst-case upload is well below this threshold --- ZodiacFX/src/http.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ZodiacFX/src/http.h b/ZodiacFX/src/http.h index b1efdc4..2b8ef5a 100644 --- a/ZodiacFX/src/http.h +++ b/ZodiacFX/src/http.h @@ -34,6 +34,7 @@ #define FLOW_DISPLAY_LIMIT 4 // Displayable flows per page #define METER_DISPLAY_LIMIT 3 // Displayable meters per page #define BOUNDARY_MAX_LEN 70 +#define UPLOAD_TIMEOUT 12000 // (ms) timeout window between each firmware update packet void http_init(void); From d1cbf6ab8db65941099b4a8e617a7cf3510b1bba Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 3 Mar 2017 09:29:07 +1100 Subject: [PATCH 129/163] Add "update in progress" reply to non-firmware requests --- ZodiacFX/src/http.c | 63 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 968d32a..91e7838 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -227,11 +227,53 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err { TRACE("http.c: incoming connection ignored - upload currently in progress"); - // Check 10-second timeout - if(sys_get_ms() - upload_timer > UPLOAD_TIMEOUT) + /* Header request check */ + memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array + + // Specified resource directly follows GET + i = 0; + while(i < 63 && (http_payload[i+5] != ' ')) + { + http_msg[i] = http_payload[i+5]; // Offset http_payload to isolate resource + i++; + } + + // The "upload in progress" message does not need to show up in the header + if(strcmp(http_msg,"header.htm") != 0) + { + if(interfaceCreate_Upload_Status(4)) + { + http_send(&shared_buffer, pcb, 1); + TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); + } + else + { + TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); + } + } + + return ERR_OK; + } + + // Check upload timeout + if(sys_get_ms() - upload_timer > UPLOAD_TIMEOUT) + { + TRACE("http.c: firmware upload has timed out"); + + /* Header request check */ + memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array + + // Specified resource directly follows GET + i = 0; + while(i < 63 && (http_payload[i+5] != ' ')) + { + http_msg[i] = http_payload[i+5]; // Offset http_payload to isolate resource + i++; + } + + // The "upload failed" message does not need to show up in the header + if(strcmp(http_msg,"header.htm") != 0) { - TRACE("http.c: firmware upload has timed out"); - // Stop upload operation upload_handler(NULL, 0); // Clean up upload operation if(interfaceCreate_Upload_Status(2)) @@ -244,12 +286,11 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); } } - - return ERR_OK; } - TRACE("http.c: %d seconds since last firmware packet received", (sys_get_ms() - upload_timer)); - // Set timer value + TRACE("http.c: %d ms since last firmware packet received", (sys_get_ms() - upload_timer)); + + // Update timer value upload_timer = sys_get_ms(); int ret = 0; @@ -2285,6 +2326,12 @@ static uint8_t interfaceCreate_Upload_Status(uint8_t sel) "

    Firmware upload failed. Unable to verify firmware. Please try again, or check the integrity of the firmware.

    "\ ); } + else if(sel == 4) + { + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ + "

    Firmware upload in progress. Please try again in 30 seconds.

    "\ + ); + } else { snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),\ From 0e9cf6f5da030dac3af46a12d7341ca006384323 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 6 Mar 2017 14:37:41 +1100 Subject: [PATCH 130/163] Remove legacy signature checks --- ZodiacFX/src/flash.c | 60 -------------------------------------------- ZodiacFX/src/flash.h | 1 - 2 files changed, 61 deletions(-) diff --git a/ZodiacFX/src/flash.c b/ZodiacFX/src/flash.c index 39d1bd9..9c866a9 100644 --- a/ZodiacFX/src/flash.c +++ b/ZodiacFX/src/flash.c @@ -166,73 +166,13 @@ void cli_update(void) return; } -/* -* Check test verification value in flash -* -*/ -int get_verification(void) -{ - char* pflash = (char*)(FLASH_BUFFER_END-1); - char* buffer_start = (char*)FLASH_BUFFER; - - while(((*pflash) == '\xFF' || (*pflash) == '\0') && pflash > buffer_start) - { - pflash--; - } - - if(pflash > buffer_start) - { - pflash-=7; - - //memcpy(value, pflash, 8); - memcpy(&verify, pflash, 8); - - return 1; - } - else - { - return 0; - } -} - /* * Verify firmware data * */ int verification_check(void) { - // Populate integrity_check verify structure variable - get_verification(); - - if(!(verify.signature[0] == 'N' && verify.signature[1] == 'N')) - { - return 1; - } - else if(!(verify.device[0] == 'F' && verify.device[1] == 'X')) - { - return 2; - } - else - { - // Compare specified length and uploaded binary length - char* pflash = (char*)(FLASH_BUFFER_END-1); - char* buffer_start = (char*)FLASH_BUFFER; - - while(*(pflash-1) == '\xFF' || *(pflash-1) == '\0') - { - if(pflash == buffer_start) - { - return 3; - } - pflash--; - } - if((pflash-buffer_start) != (char*)verify.length) - { - return 4; - } - - } return 0; diff --git a/ZodiacFX/src/flash.h b/ZodiacFX/src/flash.h index 88fc010..7e2a06f 100644 --- a/ZodiacFX/src/flash.h +++ b/ZodiacFX/src/flash.h @@ -40,7 +40,6 @@ __no_inline RAMFUNC void firmware_update(void); int xmodem_xfer(void); void xmodem_clear_padding(uint8_t *buff); -int get_verification(void); int verification_check(void); #define X_EOT 0x04 From 5157276a9e4389e8f7b46379022af2fa0dcc2e8d Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 6 Mar 2017 14:39:48 +1100 Subject: [PATCH 131/163] Update CRC check process --- ZodiacFX/src/flash.c | 68 ++++++++++++++++++++++++++++++++++++++++++-- ZodiacFX/src/flash.h | 6 ++++ 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/ZodiacFX/src/flash.c b/ZodiacFX/src/flash.c index 9c866a9..68061ba 100644 --- a/ZodiacFX/src/flash.c +++ b/ZodiacFX/src/flash.c @@ -39,7 +39,7 @@ // Global variables extern uint8_t shared_buffer[SHARED_BUFFER_LEN]; -extern struct integrity_check verify; +extern struct verification_data verify; // Static variables static uint32_t page_addr; @@ -172,10 +172,72 @@ void cli_update(void) */ int verification_check(void) { - + char* fw_end_pmem = (char*)FLASH_BUFFER_END; // Buffer pointer to store the last address + char* fw_step_pmem = (char*)FLASH_BUFFER; // Buffer pointer to the starting address + uint32_t crc_sum = 0; // Store CRC sum + uint8_t pad_error = 0; // Set when padding is not found - return 0; + /* Add all bytes of the uploaded firmware */ + // Decrement the pointer until the previous address has data in it (not 0xFF) + while(*(fw_end_pmem-1) == '\xFF' && fw_end_pmem > FLASH_BUFFER) + { + fw_end_pmem--; + } + for(int sig=1; sig<=4; sig++) + { + if(*(fw_end_pmem-sig) != NULL) + { + TRACE("signature padding %d not found - last address: %08x\r\n", sig, fw_end_pmem); + pad_error = 1; + } + else + { + TRACE("signature padding %d found\r\n", sig); + } + } + + // Start summing all bytes + if(pad_error) + { + // Calculate CRC for debug + while(fw_step_pmem < fw_end_pmem) + { + crc_sum += *fw_step_pmem; + fw_step_pmem++; + } + } + else + { + // Exclude CRC & padding from calculation + while(fw_step_pmem < (fw_end_pmem-8)) + { + crc_sum += *fw_step_pmem; + fw_step_pmem++; + } + } + + TRACE("fw_step_pmem %08x; fw_end_pmem %08x;\r\n", fw_step_pmem, fw_end_pmem); + + // Update structure entry + TRACE("CRC sum: %04x\r\n", crc_sum); + verify.calculated = crc_sum; + + /* Compare with last 4 bytes of firmware */ + // Get last 4 bytes of firmware (4-byte CRC, 4-byte padding) + verify.found = *(uint32_t*)(fw_end_pmem - 8); + + TRACE("CRC found: %04x\r\n", verify.found); + + // Compare calculated and found CRC + if(verify.found == verify.calculated) + { + return SUCCESS; + } + else + { + return FAILURE; + } } /* diff --git a/ZodiacFX/src/flash.h b/ZodiacFX/src/flash.h index 7e2a06f..7c25a9e 100644 --- a/ZodiacFX/src/flash.h +++ b/ZodiacFX/src/flash.h @@ -42,6 +42,12 @@ void xmodem_clear_padding(uint8_t *buff); int verification_check(void); +struct verification_data +{ + uint32_t calculated; // Last 4 bytes from summed data + uint32_t found; // 4 bytes at the end of uploaded firmware +}; + #define X_EOT 0x04 #define X_ACK 0x06 #define X_NAK 0x15 From 17326506b9a398e47d0fca999bd8f45be8055e4a Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 6 Mar 2017 14:49:08 +1100 Subject: [PATCH 132/163] Adjust return value check --- ZodiacFX/src/flash.c | 2 +- ZodiacFX/src/http.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ZodiacFX/src/flash.c b/ZodiacFX/src/flash.c index 68061ba..ce38e1d 100644 --- a/ZodiacFX/src/flash.c +++ b/ZodiacFX/src/flash.c @@ -149,7 +149,7 @@ void cli_update(void) { printf("Error: failed to write firmware to memory\r\n"); } - if(verification_check() == 0) + if(verification_check() == SUCCESS) { printf("Firmware upload complete - Restarting the Zodiac FX.\r\n"); for(int x = 0;x<100000;x++); // Let the above message get send to the terminal before detaching diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 91e7838..3aec620 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -302,7 +302,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err boundary_start = 1; //flash_clear_gpnvm(1); // upload check - if(verification_check() == 0) + if(verification_check() == SUCCESS) { upload_handler(NULL, 0); // Clean up upload operation if(interfaceCreate_Upload_Status(1)) From 0aa7a6975c67269953e6cf53ce8027bb2511ea79 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 6 Mar 2017 16:47:35 +1100 Subject: [PATCH 133/163] Remove newlines in debug output --- ZodiacFX/src/flash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ZodiacFX/src/flash.c b/ZodiacFX/src/flash.c index ce38e1d..d1bd633 100644 --- a/ZodiacFX/src/flash.c +++ b/ZodiacFX/src/flash.c @@ -188,12 +188,12 @@ int verification_check(void) { if(*(fw_end_pmem-sig) != NULL) { - TRACE("signature padding %d not found - last address: %08x\r\n", sig, fw_end_pmem); + TRACE("signature padding %d not found - last address: %08x", sig, fw_end_pmem); pad_error = 1; } else { - TRACE("signature padding %d found\r\n", sig); + TRACE("signature padding %d found", sig); } } @@ -217,17 +217,17 @@ int verification_check(void) } } - TRACE("fw_step_pmem %08x; fw_end_pmem %08x;\r\n", fw_step_pmem, fw_end_pmem); + TRACE("fw_step_pmem %08x; fw_end_pmem %08x;", fw_step_pmem, fw_end_pmem); // Update structure entry - TRACE("CRC sum: %04x\r\n", crc_sum); + TRACE("CRC sum: %04x", crc_sum); verify.calculated = crc_sum; /* Compare with last 4 bytes of firmware */ // Get last 4 bytes of firmware (4-byte CRC, 4-byte padding) verify.found = *(uint32_t*)(fw_end_pmem - 8); - TRACE("CRC found: %04x\r\n", verify.found); + TRACE("CRC found: %04x", verify.found); // Compare calculated and found CRC if(verify.found == verify.calculated) From 114f9799e7f90c259bf881563503aa1b684f3039 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 6 Mar 2017 17:19:03 +1100 Subject: [PATCH 134/163] Clean up unused signature check code --- ZodiacFX/src/command.c | 1 - ZodiacFX/src/command.h | 9 --------- ZodiacFX/src/flash.c | 2 +- ZodiacFX/src/http.c | 1 - ZodiacFX/src/main.c | 1 - 5 files changed, 1 insertion(+), 13 deletions(-) diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index 296d116..504448b 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -48,7 +48,6 @@ // Global variables extern struct zodiac_config Zodiac_Config; -extern struct integrity_check verify; extern bool debug_output; extern int charcount, charcount_last; diff --git a/ZodiacFX/src/command.h b/ZodiacFX/src/command.h index 9967d28..b2d0f36 100644 --- a/ZodiacFX/src/command.h +++ b/ZodiacFX/src/command.h @@ -75,15 +75,6 @@ struct zodiac_config { } PACK_STRUCT_STRUCT; PACK_STRUCT_END -PACK_STRUCT_BEGIN -struct integrity_check -{ - uint8_t signature[2]; - uint32_t length; - uint8_t device[2]; -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END - typedef struct arp_header { uint8_t et_dest[6]; /**< Destination node */ uint8_t et_src[6]; /**< Source node */ diff --git a/ZodiacFX/src/flash.c b/ZodiacFX/src/flash.c index d1bd633..84add07 100644 --- a/ZodiacFX/src/flash.c +++ b/ZodiacFX/src/flash.c @@ -39,7 +39,7 @@ // Global variables extern uint8_t shared_buffer[SHARED_BUFFER_LEN]; -extern struct verification_data verify; +struct verification_data verify; // Static variables static uint32_t page_addr; diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 3aec620..5a399ca 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -53,7 +53,6 @@ extern uint32_t uid_buf[4]; // Unique identifier extern struct tcp_pcb *tcp_pcb; extern int OF_Version; extern uint8_t shared_buffer[SHARED_BUFFER_LEN]; // SHARED_BUFFER_LEN must never be reduced below 2048 -extern struct integrity_check verify; extern int tcp_con_state; // Check connection state extern struct ofp_flow_mod *flow_match10[MAX_FLOWS_10]; diff --git a/ZodiacFX/src/main.c b/ZodiacFX/src/main.c index 256291e..95494ae 100644 --- a/ZodiacFX/src/main.c +++ b/ZodiacFX/src/main.c @@ -50,7 +50,6 @@ // Global variables struct netif gs_net_if; struct zodiac_config Zodiac_Config; -struct integrity_check verify; int charcount, charcount_last; bool masterselect; bool stackenabled; From a4feb6aae0bcf50e1559eea7ec1e453dc1b523a9 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 6 Mar 2017 18:04:45 +1100 Subject: [PATCH 135/163] Add timeout to CLI firmware upload --- ZodiacFX/src/flash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ZodiacFX/src/flash.c b/ZodiacFX/src/flash.c index 84add07..25ac197 100644 --- a/ZodiacFX/src/flash.c +++ b/ZodiacFX/src/flash.c @@ -247,7 +247,8 @@ int verification_check(void) int xmodem_xfer(void) { char ch; - int timeout_clock = 0; + int timeout_clock = 0; // protocol (NAK) timeout counter + int timeout_upload = 0; // upload timeout counter int buff_ctr = 1; int byte_ctr = 1; int block_ctr = 0; @@ -325,10 +326,15 @@ int xmodem_xfer(void) byte_ctr++; } timeout_clock++; - if (timeout_clock > 1000000) // Timeout, send + if(timeout_upload > 6) + { + return; + } + else if (timeout_clock > 1000000) // Timeout, send { printf("%c", X_NAK); timeout_clock = 0; + timeout_upload++; } } } From 97f690850b81044a1eed105455aad0d65c031e88 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 6 Mar 2017 18:23:23 +1100 Subject: [PATCH 136/163] Add get crc command to CLI Outputs the required CRC signature for a firmware update --- ZodiacFX/src/command.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index 504448b..85af4f2 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -48,6 +48,7 @@ // Global variables extern struct zodiac_config Zodiac_Config; +extern struct verification_data verify; extern bool debug_output; extern int charcount, charcount_last; @@ -442,6 +443,15 @@ void command_root(char *command, char *param1, char *param2, char *param3) while (1); } + // Get CRC + if (strcmp(command, "get")==0 && strcmp(param1, "crc")==0) + { + verification_check(); + printf("Calculated verification: %08x\r\n", verify.calculated); + printf("Append [%08x 00000000] to the binary\r\n", ntohl(verify.calculated)); + return; + } + // Unknown Command printf("Unknown command\r\n"); return; From 61eff480075af2578467163c4b9b50b1e7cfb4fa Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 7 Mar 2017 10:11:24 +1100 Subject: [PATCH 137/163] Tweak upload timeout handling --- ZodiacFX/src/http.c | 43 +++++++++++++++++++------------------------ ZodiacFX/src/http.h | 2 +- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 5a399ca..d987e20 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -81,6 +81,7 @@ static int boundary_start = 1; // Check for start of data static uint8_t flowBase = 0; // Current set of flows to display static uint8_t meterBase = 0; // Current set of meters to display static struct tcp_pcb * upload_pcb; // Firmware upload connection check (pcb pointer) +static int upload_port = 0; static int upload_timer = 0; // Timer for firmware upload timeout // Flag variables @@ -213,18 +214,13 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: -> pcb @ addr: 0x%08x, remote port %d", pcb, pcb->remote_port); if(file_upload == true) - { - // Check HTTP method - i = 0; - while(i < 63 && (http_payload[i] != ' ')) - { - http_msg[i] = http_payload[i]; - i++; - } + { + TRACE("http.c: %d ms since last firmware packet received", (sys_get_ms() - upload_timer)); - if(upload_pcb != pcb) + // Check upload timeout + if(upload_timer != 0 && sys_get_ms() - upload_timer > UPLOAD_TIMEOUT) { - TRACE("http.c: incoming connection ignored - upload currently in progress"); + TRACE("http.c: firmware upload has timed out"); /* Header request check */ memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array @@ -237,10 +233,12 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err i++; } - // The "upload in progress" message does not need to show up in the header + // The "upload failed" message does not need to show up in the header if(strcmp(http_msg,"header.htm") != 0) { - if(interfaceCreate_Upload_Status(4)) + // Stop upload operation + upload_handler(NULL, 0); // Clean up upload operation + if(interfaceCreate_Upload_Status(2)) { http_send(&shared_buffer, pcb, 1); TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); @@ -250,14 +248,11 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); } } - - return ERR_OK; } - // Check upload timeout - if(sys_get_ms() - upload_timer > UPLOAD_TIMEOUT) + if(upload_pcb != pcb && upload_port != pcb->remote_port) { - TRACE("http.c: firmware upload has timed out"); + TRACE("http.c: incoming connection ignored - upload currently in progress"); /* Header request check */ memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array @@ -270,12 +265,10 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err i++; } - // The "upload failed" message does not need to show up in the header + // The "upload in progress" message does not need to show up in the header if(strcmp(http_msg,"header.htm") != 0) { - // Stop upload operation - upload_handler(NULL, 0); // Clean up upload operation - if(interfaceCreate_Upload_Status(2)) + if(interfaceCreate_Upload_Status(4)) { http_send(&shared_buffer, pcb, 1); TRACE("http.c: Page sent successfully - %d bytes", strlen(shared_buffer)); @@ -285,11 +278,11 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: Unable to serve page - buffer at %d bytes", strlen(shared_buffer)); } } + + return ERR_OK; } - TRACE("http.c: %d ms since last firmware packet received", (sys_get_ms() - upload_timer)); - - // Update timer value + // Update timer value (new firmware packet received) upload_timer = sys_get_ms(); int ret = 0; @@ -589,6 +582,8 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err file_upload = true; // Store pcb pointer value for this connection upload_pcb = pcb; + // Store remote port + upload_port = pcb->remote_port; // Initialise timeout value upload_timer = sys_get_ms(); diff --git a/ZodiacFX/src/http.h b/ZodiacFX/src/http.h index 2b8ef5a..945d856 100644 --- a/ZodiacFX/src/http.h +++ b/ZodiacFX/src/http.h @@ -34,7 +34,7 @@ #define FLOW_DISPLAY_LIMIT 4 // Displayable flows per page #define METER_DISPLAY_LIMIT 3 // Displayable meters per page #define BOUNDARY_MAX_LEN 70 -#define UPLOAD_TIMEOUT 12000 // (ms) timeout window between each firmware update packet +#define UPLOAD_TIMEOUT 25000 // (ms) timeout window between each firmware update packet void http_init(void); From 8956a7947f487b5493a74131f2f68914dd0bd294 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 10 Mar 2017 17:47:37 +1100 Subject: [PATCH 138/163] Adjust LwIP MSS --- ZodiacFX/src/config/lwipopts.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ZodiacFX/src/config/lwipopts.h b/ZodiacFX/src/config/lwipopts.h index dbfc636..8c7d60b 100644 --- a/ZodiacFX/src/config/lwipopts.h +++ b/ZodiacFX/src/config/lwipopts.h @@ -126,7 +126,7 @@ * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. * (requires the LWIP_TCP option) */ -#define MEMP_NUM_TCP_SEG 16 +#define MEMP_NUM_TCP_SEG 25 /** * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for @@ -223,7 +223,7 @@ * when opening a connection. For the transmit size, this MSS sets * an upper limit on the MSS advertised by the remote host. */ -#define TCP_MSS 1460 +#define TCP_MSS 536 /** * TCP_WND: The size of a TCP window. This must be at least @@ -235,7 +235,7 @@ * TCP_SND_BUF: TCP sender buffer space (bytes). * To achieve good performance, this should be at least 2 * TCP_MSS. */ -#define TCP_SND_BUF (2 * TCP_MSS) +#define TCP_SND_BUF (6 * TCP_MSS) /** * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least From c1119bb4974c123d07dfb57f0387ecda7da57cbe Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 10 Mar 2017 18:19:56 +1100 Subject: [PATCH 139/163] Modify debug messages - pbuf length counters - total uploaded byte counter --- ZodiacFX/src/http.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index d987e20..d208048 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -210,7 +210,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err http_payload = (char*)p->payload; len = p->tot_len; - TRACE("http.c: -- HTTP recv received %d payload bytes", len); + TRACE("http.c: -- HTTP recv received %d/%d payload bytes in this pbuf", p->len, p->tot_len); TRACE("http.c: -> pcb @ addr: 0x%08x, remote port %d", pcb, pcb->remote_port); if(file_upload == true) @@ -1337,6 +1337,7 @@ static uint8_t upload_handler(char *payload, int len) static char page[IFLASH_PAGE_SIZE] = {0}; // Storage for each page of data static uint16_t saved_bytes = 0; // Persistent counter of unwritten data uint16_t handled_bytes = 0; // Counter of handled data + static uint32_t total_handled_bytes = 0; // Counter of total handled data static char boundary_ID[BOUNDARY_MAX_LEN] = {0}; // Storage for boundary ID if(payload == NULL || len == 0) @@ -1349,6 +1350,7 @@ static uint8_t upload_handler(char *payload, int len) boundary_start = 1; // Set starting boundary required flag upload_pcb = NULL; // Clear pcb connection pointer upload_timer = 0; // Clear upload timeout + total_handled_bytes = 0; return 1; } @@ -1594,6 +1596,8 @@ static uint8_t upload_handler(char *payload, int len) // Handle edge-case TRACE("http.c: unable to fill a complete page - skipping page write"); TRACE("http.c: %d bytes saved", saved_bytes); + + total_handled_bytes += handled_bytes; return 1; } else @@ -1728,7 +1732,10 @@ static uint8_t upload_handler(char *payload, int len) TRACE("http.c: handled_bytes: %04d, data_len: %04d", handled_bytes, data_len); } - + + total_handled_bytes += handled_bytes; + TRACE("http.c: total_handled_bytes: %d", total_handled_bytes); + if(final) { return 2; From 07dac6aaa403ceeb871fb93230c8d439faf2443d Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Sun, 12 Mar 2017 14:41:04 +1100 Subject: [PATCH 140/163] Fixed POST methods --- ZodiacFX/ZodiacFX.cproj | 4 +- ZodiacFX/ZodiacFX_6_2.cproj | 1647 ----------------------------------- ZodiacFX_6_2.atsln | 20 - 3 files changed, 2 insertions(+), 1669 deletions(-) delete mode 100644 ZodiacFX/ZodiacFX_6_2.cproj delete mode 100644 ZodiacFX_6_2.atsln diff --git a/ZodiacFX/ZodiacFX.cproj b/ZodiacFX/ZodiacFX.cproj index e3e4036..2f76e38 100644 --- a/ZodiacFX/ZodiacFX.cproj +++ b/ZodiacFX/ZodiacFX.cproj @@ -274,11 +274,11 @@ JTAG com.atmel.avrdbg.tool.atmelice - J41800058832 + J41800009874 Atmel-ICE JTAG - J41800058832 + J41800009874 0xA3CC0CE0 7500000 diff --git a/ZodiacFX/ZodiacFX_6_2.cproj b/ZodiacFX/ZodiacFX_6_2.cproj deleted file mode 100644 index 879842d..0000000 --- a/ZodiacFX/ZodiacFX_6_2.cproj +++ /dev/null @@ -1,1647 +0,0 @@ - - - - 2.0 - 6.2 - com.Atmel.ARMGCC.C - {d48aa523-b6fa-4608-b329-ef580ba58eba} - ATSAM4E8C - sam4e - Executable - C - $(MSBuildProjectName) - .elf - $(MSBuildProjectDirectory)\$(Configuration) - ZodiacFX - ZodiacFX - ZodiacFX - Native - true - false - true - true - 0x20000000 - - true - exception_table - 2 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - com.atmel.avrdbg.tool.atmelice - - - - - JTAG - - com.atmel.avrdbg.tool.atmelice - J41800009874 - Atmel-ICE - - JTAG - - - - - True - True - True - True - True - - - NDEBUG - scanf=iscanf - BOARD=USER_BOARD - ARM_MATH_CM4=true - printf=iprintf - UDD_ENABLE - - - False - - - ../common/applications/user_application/user_board/config - ../src/config - ../src/ASF/thirdparty/CMSIS/Lib/GCC - ../src/ASF/common/utils - ../src - ../src/ASF/sam/utils/fpu - ../src/ASF/sam/utils - ../src/ASF/sam/utils/preprocessor - ../src/ASF/sam/utils/cmsis/sam4e/include - ../src/ASF/common/boards - ../src/ASF/sam/utils/header_files - ../src/ASF/common/boards/user_board - ../src/ASF/thirdparty/CMSIS/Include - ../src/ASF/sam/utils/cmsis/sam4e/source/templates - ../src/ASF/sam/drivers/pmc - ../src/ASF/common/services/clock - ../src/ASF/common/services/ioport - ../src/ASF/common/services/spi/sam_usart_spi - ../src/ASF/common/services/spi - ../src/ASF/common/services/twi - ../src/ASF/sam/drivers/twi - ../src/ASF/sam/drivers/usart - ../src/ASF/sam/drivers/gmac - ../src/ASF/sam/drivers/matrix - ../src/ASF/sam/drivers/pio - ../src/ASF/sam/drivers/rtc - ../src/ASF/common/services/sleepmgr - ../src/ASF/common/services/usb - ../src/ASF/common/services/usb/class/cdc - ../src/ASF/common/services/usb/class/cdc/device - ../src/ASF/common/services/usb/udc - ../src/ASF/common/utils/stdio/stdio_usb - ../src/ASF/sam/drivers/udp - ../src/ASF/sam/drivers/tc - ../src/ASF/common/services/spi/sam_spi - ../src/ASF/sam/drivers/spi - ../src/ASF/sam/drivers/rstc - ../src/lwip/include - ../src/lwip - ../src/lwip/include/ipv4 - ../src/ASF/sam/drivers/afec - ../src/ASF/common/utils/membag - - - Optimize (-O1) - -fdata-sections - True - True - -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 - - - libarm_cortexM4lf_math_softfp - libm - - - - - ../cmsis/linkerScripts - ../src/ASF/thirdparty/CMSIS/Lib/GCC - - - True - - -Wl,--entry=Reset_Handler -Wl,--cref -mthumb -T../src/ASF/sam/utils/linker_scripts/sam4e/sam4e8/gcc/flash.ld - -DARM_MATH_CM4=true -DBOARD=USER_BOARD -Dprintf=iprintf -Dscanf=iscanf -DUDD_ENABLE - False - - - ../common/applications/user_application/user_board/config - ../src/config - ../src/ASF/thirdparty/CMSIS/Lib/GCC - ../src/ASF/common/utils - ../src - ../src/ASF/sam/utils/fpu - ../src/ASF/sam/utils - ../src/ASF/sam/utils/preprocessor - ../src/ASF/sam/utils/cmsis/sam4e/include - ../src/ASF/common/boards - ../src/ASF/sam/utils/header_files - ../src/ASF/common/boards/user_board - ../src/ASF/thirdparty/CMSIS/Include - ../src/ASF/sam/utils/cmsis/sam4e/source/templates - ../src/ASF/sam/drivers/pmc - ../src/ASF/common/services/clock - ../src/ASF/common/services/ioport - ../src/ASF/common/services/spi/sam_usart_spi - ../src/ASF/common/services/spi - ../src/ASF/common/services/twi - ../src/ASF/sam/drivers/twi - ../src/ASF/sam/drivers/usart - ../src/ASF/sam/drivers/gmac - ../src/ASF/sam/drivers/matrix - ../src/ASF/sam/drivers/pio - ../src/ASF/sam/drivers/rtc - ../src/ASF/common/services/sleepmgr - ../src/ASF/common/services/usb - ../src/ASF/common/services/usb/class/cdc - ../src/ASF/common/services/usb/class/cdc/device - ../src/ASF/common/services/usb/udc - ../src/ASF/common/utils/stdio/stdio_usb - ../src/ASF/sam/drivers/udp - ../src/ASF/sam/drivers/tc - ../src/ASF/common/services/spi/sam_spi - ../src/ASF/sam/drivers/spi - ../src/ASF/sam/drivers/rstc - ../src/ASF/sam/drivers/afec - ../src/ASF/common/utils/membag - - - - - - - - - True - True - True - True - True - - - DEBUG - scanf=iscanf - BOARD=USER_BOARD - ARM_MATH_CM4=true - printf=iprintf - UDD_ENABLE - - - False - - - ../common/applications/user_application/user_board/config - ../src/config - ../src/ASF/thirdparty/CMSIS/Lib/GCC - ../src/ASF/common/utils - ../src - ../src/ASF/sam/utils/fpu - ../src/ASF/sam/utils - ../src/ASF/sam/utils/preprocessor - ../src/ASF/sam/utils/cmsis/sam4e/include - ../src/ASF/common/boards - ../src/ASF/sam/utils/header_files - ../src/ASF/common/boards/user_board - ../src/ASF/thirdparty/CMSIS/Include - ../src/ASF/sam/utils/cmsis/sam4e/source/templates - ../src/ASF/sam/drivers/pmc - ../src/ASF/common/services/clock - ../src/ASF/common/services/ioport - ../src/ASF/common/services/spi/sam_usart_spi - ../src/ASF/common/services/spi - ../src/ASF/common/services/twi - ../src/ASF/sam/drivers/twi - ../src/ASF/sam/drivers/usart - ../src/ASF/sam/drivers/gmac - ../src/ASF/sam/drivers/matrix - ../src/ASF/sam/drivers/pio - ../src/ASF/sam/drivers/rtc - ../src/ASF/common/services/sleepmgr - ../src/ASF/common/services/usb - ../src/ASF/common/services/usb/class/cdc - ../src/ASF/common/services/usb/class/cdc/device - ../src/ASF/common/services/usb/udc - ../src/ASF/common/utils/stdio/stdio_usb - ../src/ASF/sam/drivers/udp - ../src/lwip - ../src/lwip/include - ../src/lwip/include/ipv4 - ../src/ASF/sam/drivers/tc - ../src/ASF/common/services/spi/sam_spi - ../src/ASF/sam/drivers/spi - ../src/ASF/sam/drivers/rstc - ../src/ASF/sam/drivers/afec - ../src/ASF/common/utils/membag - - - -fdata-sections - True - Maximum (-g3) - True - -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 - - - libarm_cortexM4lf_math_softfp - libm - - - - - ../cmsis/linkerScripts - ../src/ASF/thirdparty/CMSIS/Lib/GCC - - - True - - -Wl,--entry=Reset_Handler -Wl,--cref -mthumb -T../src/ASF/sam/utils/linker_scripts/sam4e/sam4e8/gcc/flash.ld - Default (-g) - -DARM_MATH_CM4=true -DBOARD=USER_BOARD -Dprintf=iprintf -Dscanf=iscanf -DUDD_ENABLE - False - - - ../common/applications/user_application/user_board/config - ../src/config - ../src/ASF/thirdparty/CMSIS/Lib/GCC - ../src/ASF/common/utils - ../src - ../src/ASF/sam/utils/fpu - ../src/ASF/sam/utils - ../src/ASF/sam/utils/preprocessor - ../src/ASF/sam/utils/cmsis/sam4e/include - ../src/ASF/common/boards - ../src/ASF/sam/utils/header_files - ../src/ASF/common/boards/user_board - ../src/ASF/thirdparty/CMSIS/Include - ../src/ASF/sam/utils/cmsis/sam4e/source/templates - ../src/ASF/sam/drivers/pmc - ../src/ASF/common/services/clock - ../src/ASF/common/services/ioport - ../src/ASF/common/services/spi/sam_usart_spi - ../src/ASF/common/services/spi - ../src/ASF/common/services/twi - ../src/ASF/sam/drivers/twi - ../src/ASF/sam/drivers/usart - ../src/ASF/sam/drivers/gmac - ../src/ASF/sam/drivers/matrix - ../src/ASF/sam/drivers/pio - ../src/ASF/sam/drivers/rtc - ../src/ASF/common/services/sleepmgr - ../src/ASF/common/services/usb - ../src/ASF/common/services/usb/class/cdc - ../src/ASF/common/services/usb/class/cdc/device - ../src/ASF/common/services/usb/udc - ../src/ASF/common/utils/stdio/stdio_usb - ../src/ASF/sam/drivers/udp - ../src/ASF/sam/drivers/tc - ../src/ASF/common/services/spi/sam_spi - ../src/ASF/sam/drivers/spi - ../src/ASF/sam/drivers/rstc - ../src/ASF/sam/drivers/afec - ../src/ASF/common/utils/membag - - - Default (-Wa,-g) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - compile - - - - \ No newline at end of file diff --git a/ZodiacFX_6_2.atsln b/ZodiacFX_6_2.atsln deleted file mode 100644 index 09d4d81..0000000 --- a/ZodiacFX_6_2.atsln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Atmel Studio Solution File, Format Version 11.00 -Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "ZodiacFX", "ZodiacFX\ZodiacFX_6_2.cproj", "{D48AA523-B6FA-4608-B329-EF580BA58EBA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Release|ARM = Release|ARM - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D48AA523-B6FA-4608-B329-EF580BA58EBA}.Debug|ARM.ActiveCfg = Debug|ARM - {D48AA523-B6FA-4608-B329-EF580BA58EBA}.Debug|ARM.Build.0 = Debug|ARM - {D48AA523-B6FA-4608-B329-EF580BA58EBA}.Release|ARM.ActiveCfg = Release|ARM - {D48AA523-B6FA-4608-B329-EF580BA58EBA}.Release|ARM.Build.0 = Release|ARM - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal From 6eec8d845b5bd2c3b23c91c89f1bce8c5f4946be Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Sun, 12 Mar 2017 14:42:13 +1100 Subject: [PATCH 141/163] Updated Config calls --- ZodiacFX/src/http.c | 82 +++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index d208048..f9a06b1 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -76,6 +76,7 @@ extern int flash_write_page(uint8_t *flash_page); // Local Variables struct tcp_pcb *http_pcb; static char http_msg[64]; // Buffer for HTTP message filtering +static char post_msg[64]; // Buffer for HTTP message filtering static int page_ctr = 1; static int boundary_start = 1; // Check for start of data static uint8_t flowBase = 0; // Current set of flows to display @@ -87,11 +88,15 @@ static int upload_timer = 0; // Timer for firmware upload timeout // Flag variables static bool restart_required = false; // Track if any configuration changes are pending a restart static bool file_upload = false; // Multi-part firmware file upload flag +static int http_waiting_ack = 0; +static struct tcp_pcb *close_ready = NULL; +static bool post_pending = false; static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err); void http_send(char *buffer, struct tcp_pcb *pcb, bool out); static err_t http_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len); +void http_close(struct tcp_pcb *pcb); static uint8_t upload_handler(char *payload, int len); @@ -179,6 +184,8 @@ static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err) static err_t http_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len) { TRACE("http.c: [http_sent] %d bytes sent", len); + http_waiting_ack -= len; + if (http_waiting_ack == 0 && close_ready != NULL) http_close(close_ready); if(restart_required == true) { TRACE("http.c: restarting the Zodiac FX. Please reconnect."); @@ -551,7 +558,8 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: resource doesn't exist:\"%s\"", http_msg); } } - else if(strcmp(http_msg,"POST") == 0) + + else if(strcmp(http_msg,"POST") == 0 && post_pending == false) { TRACE("http.c: POST method received"); memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array @@ -563,12 +571,24 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err http_msg[i] = http_payload[i+6]; // Offset http_payload to isolate resource i++; } + memcpy(post_msg, http_msg, 64); + TRACE("http.c: request for %s", post_msg); + post_pending = true; + pbuf_free(p); + return ERR_OK; + } + else + { + TRACE("http.c: unknown HTTP method received"); + } - TRACE("http.c: request for %s", http_msg); - - if(strcmp(http_msg,"upload") == 0) + + if(post_pending == true) + { + post_pending = false; + if(strcmp(post_msg,"upload") == 0) { - // Initialise flash programming + // Initialize flash programming if(firmware_update_init()) { TRACE("http.c: firmware update initialisation successful"); @@ -584,14 +604,14 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err upload_pcb = pcb; // Store remote port upload_port = pcb->remote_port; - // Initialise timeout value + // Initialize timeout value upload_timer = sys_get_ms(); upload_handler(http_payload, len); } - else if(strcmp(http_msg,"save_config") == 0) + else if(strcmp(post_msg,"save_config") == 0) { - if(Config_Network(&http_payload, len) == SUCCESS) + if(Config_Network(http_payload, len) == SUCCESS) { TRACE("http.c: network configuration successful"); @@ -613,7 +633,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: ERROR: network configuration failed"); } } - else if(strcmp(http_msg,"btn_restart") == 0) + else if(strcmp(post_msg,"btn_restart") == 0) { if(interfaceCreate_Restart()) { @@ -626,7 +646,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err } restart_required = true; } - else if(strcmp(http_msg,"btn_default") == 0) + else if(strcmp(post_msg,"btn_default") == 0) { TRACE("http.c: restoring factory settings"); @@ -683,7 +703,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err rstc_start_software_reset(RSTC); // Software reset while (1); } - else if(strcmp(http_msg,"save_ports") == 0) + else if(strcmp(post_msg,"save_ports") == 0) { // Save VLAN port associations @@ -793,7 +813,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); } } - else if(strcmp(http_msg,"btn_ofPage") == 0) + else if(strcmp(post_msg,"btn_ofPage") == 0) { // Display: Flows, Previous and Next flow page buttons @@ -843,7 +863,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); } } - else if(strcmp(http_msg,"btn_ofClear") == 0) + else if(strcmp(post_msg,"btn_ofClear") == 0) { // Display: Flows // Clear the flow table @@ -861,7 +881,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); } } - else if(strcmp(http_msg,"btn_meterPage") == 0) + else if(strcmp(post_msg,"btn_meterPage") == 0) { // Display: Meters, Previous and Next meter page buttons @@ -911,7 +931,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); } } - else if(strcmp(http_msg,"save_vlan") == 0) + else if(strcmp(post_msg,"save_vlan") == 0) { // Config: VLANs, Add and Delete buttons @@ -1092,7 +1112,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: unable to serve updated page - buffer at %d bytes", strlen(shared_buffer)); } } - else if(strcmp(http_msg,"save_of") == 0) + else if(strcmp(post_msg,"save_of") == 0) { // Config: OpenFlow, Save OpenFlow configuration @@ -1264,10 +1284,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: unknown request: \"%s\"", http_msg); } } - else - { - TRACE("http.c: unknown HTTP method received"); - } + } } else @@ -1285,7 +1302,6 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err TRACE("http.c: Closing TCP connection."); tcp_close(pcb); } - return ERR_OK; } @@ -1310,18 +1326,31 @@ void http_send(char *buffer, struct tcp_pcb *pcb, bool out) err = tcp_write(pcb, buffer, len, TCP_WRITE_FLAG_COPY + TCP_WRITE_FLAG_MORE); TRACE("http.c: tcp buffer %d/%d", len, buf_size); - // Check if more data needs to be written - if(out == true) + // Set to be closed after all the data has been sent + if(out == true) { - if (err == ERR_OK) tcp_output(pcb); - TRACE("http.c: calling tcp_output & closing connection"); - tcp_close(pcb); + http_waiting_ack = len; + close_ready = pcb; } } return; } +/* +* HTTP Close function +* +* Parameters: +* pcb - pcb of the connection to close +*/ +void http_close(struct tcp_pcb *pcb) +{ + tcp_output(pcb); + TRACE("http.c: calling tcp_output & closing connection"); + tcp_close(pcb); + close_ready = NULL; + return; +} /* * Upload handler function * @@ -1750,6 +1779,7 @@ static uint8_t Config_Network(char *payload, int len) { int i = 0; char *pdat; + payload[len] = '&'; memset(&http_msg, 0, sizeof(http_msg)); // Clear HTTP message array From ca7e548743d4df426d0beb58ab80fbd8911e70dd Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Sun, 12 Mar 2017 14:42:56 +1100 Subject: [PATCH 142/163] Revert "Fixed POST methods" This reverts commit 07dac6aaa403ceeb871fb93230c8d439faf2443d. --- ZodiacFX/ZodiacFX.cproj | 4 +- ZodiacFX/ZodiacFX_6_2.cproj | 1647 +++++++++++++++++++++++++++++++++++ ZodiacFX_6_2.atsln | 20 + 3 files changed, 1669 insertions(+), 2 deletions(-) create mode 100644 ZodiacFX/ZodiacFX_6_2.cproj create mode 100644 ZodiacFX_6_2.atsln diff --git a/ZodiacFX/ZodiacFX.cproj b/ZodiacFX/ZodiacFX.cproj index 2f76e38..e3e4036 100644 --- a/ZodiacFX/ZodiacFX.cproj +++ b/ZodiacFX/ZodiacFX.cproj @@ -274,11 +274,11 @@ JTAG com.atmel.avrdbg.tool.atmelice - J41800009874 + J41800058832 Atmel-ICE JTAG - J41800009874 + J41800058832 0xA3CC0CE0 7500000 diff --git a/ZodiacFX/ZodiacFX_6_2.cproj b/ZodiacFX/ZodiacFX_6_2.cproj new file mode 100644 index 0000000..879842d --- /dev/null +++ b/ZodiacFX/ZodiacFX_6_2.cproj @@ -0,0 +1,1647 @@ + + + + 2.0 + 6.2 + com.Atmel.ARMGCC.C + {d48aa523-b6fa-4608-b329-ef580ba58eba} + ATSAM4E8C + sam4e + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + ZodiacFX + ZodiacFX + ZodiacFX + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + + + + + JTAG + + com.atmel.avrdbg.tool.atmelice + J41800009874 + Atmel-ICE + + JTAG + + + + + True + True + True + True + True + + + NDEBUG + scanf=iscanf + BOARD=USER_BOARD + ARM_MATH_CM4=true + printf=iprintf + UDD_ENABLE + + + False + + + ../common/applications/user_application/user_board/config + ../src/config + ../src/ASF/thirdparty/CMSIS/Lib/GCC + ../src/ASF/common/utils + ../src + ../src/ASF/sam/utils/fpu + ../src/ASF/sam/utils + ../src/ASF/sam/utils/preprocessor + ../src/ASF/sam/utils/cmsis/sam4e/include + ../src/ASF/common/boards + ../src/ASF/sam/utils/header_files + ../src/ASF/common/boards/user_board + ../src/ASF/thirdparty/CMSIS/Include + ../src/ASF/sam/utils/cmsis/sam4e/source/templates + ../src/ASF/sam/drivers/pmc + ../src/ASF/common/services/clock + ../src/ASF/common/services/ioport + ../src/ASF/common/services/spi/sam_usart_spi + ../src/ASF/common/services/spi + ../src/ASF/common/services/twi + ../src/ASF/sam/drivers/twi + ../src/ASF/sam/drivers/usart + ../src/ASF/sam/drivers/gmac + ../src/ASF/sam/drivers/matrix + ../src/ASF/sam/drivers/pio + ../src/ASF/sam/drivers/rtc + ../src/ASF/common/services/sleepmgr + ../src/ASF/common/services/usb + ../src/ASF/common/services/usb/class/cdc + ../src/ASF/common/services/usb/class/cdc/device + ../src/ASF/common/services/usb/udc + ../src/ASF/common/utils/stdio/stdio_usb + ../src/ASF/sam/drivers/udp + ../src/ASF/sam/drivers/tc + ../src/ASF/common/services/spi/sam_spi + ../src/ASF/sam/drivers/spi + ../src/ASF/sam/drivers/rstc + ../src/lwip/include + ../src/lwip + ../src/lwip/include/ipv4 + ../src/ASF/sam/drivers/afec + ../src/ASF/common/utils/membag + + + Optimize (-O1) + -fdata-sections + True + True + -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 + + + libarm_cortexM4lf_math_softfp + libm + + + + + ../cmsis/linkerScripts + ../src/ASF/thirdparty/CMSIS/Lib/GCC + + + True + + -Wl,--entry=Reset_Handler -Wl,--cref -mthumb -T../src/ASF/sam/utils/linker_scripts/sam4e/sam4e8/gcc/flash.ld + -DARM_MATH_CM4=true -DBOARD=USER_BOARD -Dprintf=iprintf -Dscanf=iscanf -DUDD_ENABLE + False + + + ../common/applications/user_application/user_board/config + ../src/config + ../src/ASF/thirdparty/CMSIS/Lib/GCC + ../src/ASF/common/utils + ../src + ../src/ASF/sam/utils/fpu + ../src/ASF/sam/utils + ../src/ASF/sam/utils/preprocessor + ../src/ASF/sam/utils/cmsis/sam4e/include + ../src/ASF/common/boards + ../src/ASF/sam/utils/header_files + ../src/ASF/common/boards/user_board + ../src/ASF/thirdparty/CMSIS/Include + ../src/ASF/sam/utils/cmsis/sam4e/source/templates + ../src/ASF/sam/drivers/pmc + ../src/ASF/common/services/clock + ../src/ASF/common/services/ioport + ../src/ASF/common/services/spi/sam_usart_spi + ../src/ASF/common/services/spi + ../src/ASF/common/services/twi + ../src/ASF/sam/drivers/twi + ../src/ASF/sam/drivers/usart + ../src/ASF/sam/drivers/gmac + ../src/ASF/sam/drivers/matrix + ../src/ASF/sam/drivers/pio + ../src/ASF/sam/drivers/rtc + ../src/ASF/common/services/sleepmgr + ../src/ASF/common/services/usb + ../src/ASF/common/services/usb/class/cdc + ../src/ASF/common/services/usb/class/cdc/device + ../src/ASF/common/services/usb/udc + ../src/ASF/common/utils/stdio/stdio_usb + ../src/ASF/sam/drivers/udp + ../src/ASF/sam/drivers/tc + ../src/ASF/common/services/spi/sam_spi + ../src/ASF/sam/drivers/spi + ../src/ASF/sam/drivers/rstc + ../src/ASF/sam/drivers/afec + ../src/ASF/common/utils/membag + + + + + + + + + True + True + True + True + True + + + DEBUG + scanf=iscanf + BOARD=USER_BOARD + ARM_MATH_CM4=true + printf=iprintf + UDD_ENABLE + + + False + + + ../common/applications/user_application/user_board/config + ../src/config + ../src/ASF/thirdparty/CMSIS/Lib/GCC + ../src/ASF/common/utils + ../src + ../src/ASF/sam/utils/fpu + ../src/ASF/sam/utils + ../src/ASF/sam/utils/preprocessor + ../src/ASF/sam/utils/cmsis/sam4e/include + ../src/ASF/common/boards + ../src/ASF/sam/utils/header_files + ../src/ASF/common/boards/user_board + ../src/ASF/thirdparty/CMSIS/Include + ../src/ASF/sam/utils/cmsis/sam4e/source/templates + ../src/ASF/sam/drivers/pmc + ../src/ASF/common/services/clock + ../src/ASF/common/services/ioport + ../src/ASF/common/services/spi/sam_usart_spi + ../src/ASF/common/services/spi + ../src/ASF/common/services/twi + ../src/ASF/sam/drivers/twi + ../src/ASF/sam/drivers/usart + ../src/ASF/sam/drivers/gmac + ../src/ASF/sam/drivers/matrix + ../src/ASF/sam/drivers/pio + ../src/ASF/sam/drivers/rtc + ../src/ASF/common/services/sleepmgr + ../src/ASF/common/services/usb + ../src/ASF/common/services/usb/class/cdc + ../src/ASF/common/services/usb/class/cdc/device + ../src/ASF/common/services/usb/udc + ../src/ASF/common/utils/stdio/stdio_usb + ../src/ASF/sam/drivers/udp + ../src/lwip + ../src/lwip/include + ../src/lwip/include/ipv4 + ../src/ASF/sam/drivers/tc + ../src/ASF/common/services/spi/sam_spi + ../src/ASF/sam/drivers/spi + ../src/ASF/sam/drivers/rstc + ../src/ASF/sam/drivers/afec + ../src/ASF/common/utils/membag + + + -fdata-sections + True + Maximum (-g3) + True + -pipe -fno-strict-aliasing -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -std=gnu99 -ffunction-sections -fdata-sections -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int -Wmain -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef -Wshadow -Wbad-function-cast -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-declarations -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations -Wpacked -Wredundant-decls -Wnested-externs -Wlong-long -Wunreachable-code -Wcast-align --param max-inline-insns-single=500 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 + + + libarm_cortexM4lf_math_softfp + libm + + + + + ../cmsis/linkerScripts + ../src/ASF/thirdparty/CMSIS/Lib/GCC + + + True + + -Wl,--entry=Reset_Handler -Wl,--cref -mthumb -T../src/ASF/sam/utils/linker_scripts/sam4e/sam4e8/gcc/flash.ld + Default (-g) + -DARM_MATH_CM4=true -DBOARD=USER_BOARD -Dprintf=iprintf -Dscanf=iscanf -DUDD_ENABLE + False + + + ../common/applications/user_application/user_board/config + ../src/config + ../src/ASF/thirdparty/CMSIS/Lib/GCC + ../src/ASF/common/utils + ../src + ../src/ASF/sam/utils/fpu + ../src/ASF/sam/utils + ../src/ASF/sam/utils/preprocessor + ../src/ASF/sam/utils/cmsis/sam4e/include + ../src/ASF/common/boards + ../src/ASF/sam/utils/header_files + ../src/ASF/common/boards/user_board + ../src/ASF/thirdparty/CMSIS/Include + ../src/ASF/sam/utils/cmsis/sam4e/source/templates + ../src/ASF/sam/drivers/pmc + ../src/ASF/common/services/clock + ../src/ASF/common/services/ioport + ../src/ASF/common/services/spi/sam_usart_spi + ../src/ASF/common/services/spi + ../src/ASF/common/services/twi + ../src/ASF/sam/drivers/twi + ../src/ASF/sam/drivers/usart + ../src/ASF/sam/drivers/gmac + ../src/ASF/sam/drivers/matrix + ../src/ASF/sam/drivers/pio + ../src/ASF/sam/drivers/rtc + ../src/ASF/common/services/sleepmgr + ../src/ASF/common/services/usb + ../src/ASF/common/services/usb/class/cdc + ../src/ASF/common/services/usb/class/cdc/device + ../src/ASF/common/services/usb/udc + ../src/ASF/common/utils/stdio/stdio_usb + ../src/ASF/sam/drivers/udp + ../src/ASF/sam/drivers/tc + ../src/ASF/common/services/spi/sam_spi + ../src/ASF/sam/drivers/spi + ../src/ASF/sam/drivers/rstc + ../src/ASF/sam/drivers/afec + ../src/ASF/common/utils/membag + + + Default (-Wa,-g) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + + \ No newline at end of file diff --git a/ZodiacFX_6_2.atsln b/ZodiacFX_6_2.atsln new file mode 100644 index 0000000..09d4d81 --- /dev/null +++ b/ZodiacFX_6_2.atsln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Atmel Studio Solution File, Format Version 11.00 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "ZodiacFX", "ZodiacFX\ZodiacFX_6_2.cproj", "{D48AA523-B6FA-4608-B329-EF580BA58EBA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Release|ARM = Release|ARM + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D48AA523-B6FA-4608-B329-EF580BA58EBA}.Debug|ARM.ActiveCfg = Debug|ARM + {D48AA523-B6FA-4608-B329-EF580BA58EBA}.Debug|ARM.Build.0 = Debug|ARM + {D48AA523-B6FA-4608-B329-EF580BA58EBA}.Release|ARM.ActiveCfg = Release|ARM + {D48AA523-B6FA-4608-B329-EF580BA58EBA}.Release|ARM.Build.0 = Release|ARM + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From daf026777d094fb0969ec4b7f2c6c58b1e4ad186 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 14 Mar 2017 14:45:32 +1100 Subject: [PATCH 143/163] Add http connection handling --- ZodiacFX/src/http.c | 41 +++++++++++++++++++++++++++++++++-------- ZodiacFX/src/http.h | 7 +++++++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index f9a06b1..a4e55dd 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -84,12 +84,11 @@ static uint8_t meterBase = 0; // Current set of meters to display static struct tcp_pcb * upload_pcb; // Firmware upload connection check (pcb pointer) static int upload_port = 0; static int upload_timer = 0; // Timer for firmware upload timeout +static struct http_conns http_conn[MAX_CONN]; // http connection status // Flag variables static bool restart_required = false; // Track if any configuration changes are pending a restart static bool file_upload = false; // Multi-part firmware file upload flag -static int http_waiting_ack = 0; -static struct tcp_pcb *close_ready = NULL; static bool post_pending = false; static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); @@ -184,8 +183,16 @@ static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err) static err_t http_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len) { TRACE("http.c: [http_sent] %d bytes sent", len); - http_waiting_ack -= len; - if (http_waiting_ack == 0 && close_ready != NULL) http_close(close_ready); + for(int i=0; i Date: Tue, 14 Mar 2017 15:13:05 +1100 Subject: [PATCH 144/163] Adjust http connection management --- ZodiacFX/src/http.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index a4e55dd..d9c2882 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -189,6 +189,11 @@ static err_t http_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len) { TRACE("http.c: pcb 0x%08x waiting on (%d down to %d) bytes", http_conn[i].attached_pcb, http_conn[i].bytes_waiting, http_conn[i].bytes_waiting - len); http_conn[i].bytes_waiting -= len; + if(http_conn[i].bytes_waiting < 0) + { + TRACE("http.c: ERROR - illegal bytes_waiting value. Connection will be closed."); + http_close(http_conn[i].attached_pcb); + } if (http_conn[i].bytes_waiting == 0 && http_conn[i].attached_pcb != NULL) http_close(http_conn[i].attached_pcb); break; } @@ -1333,19 +1338,26 @@ void http_send(char *buffer, struct tcp_pcb *pcb, bool out) err = tcp_write(pcb, buffer, len, TCP_WRITE_FLAG_COPY + TCP_WRITE_FLAG_MORE); TRACE("http.c: tcp buffer %d/%d", len, buf_size); - // Set to be closed after all the data has been sent - if(out == true) + // Check if data is a part of a larger write + for(int i=0; i Date: Tue, 14 Mar 2017 16:02:51 +1100 Subject: [PATCH 145/163] Add outer restart flag --- ZodiacFX/src/command.c | 10 ++++++++++ ZodiacFX/src/http.c | 12 +++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index 85af4f2..29dccd1 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -74,6 +74,7 @@ extern int totaltime; extern int32_t ul_temp; extern int OF_Version; extern uint32_t uid_buf[4]; +extern bool restart_required_outer; // Local Variables bool showintro = true; @@ -138,6 +139,15 @@ void task_command(char *str, char *str_last) char *param3; char *pch; + if(restart_required_outer == true) + { + printf("Restarting the Zodiac FX, please reopen your terminal application.\r\n"); + for(int x = 0;x<100000;x++); // Let the above message get sent to the terminal before detaching + udc_detach(); // Detach the USB device before restart + rstc_start_software_reset(RSTC); // Software reset + while (1); + } + while(udi_cdc_is_rx_ready()){ ch = udi_cdc_getc(); diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index d9c2882..a6c354a 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -87,6 +87,7 @@ static int upload_timer = 0; // Timer for firmware upload timeout static struct http_conns http_conn[MAX_CONN]; // http connection status // Flag variables +bool restart_required_outer = false; static bool restart_required = false; // Track if any configuration changes are pending a restart static bool file_upload = false; // Multi-part firmware file upload flag static bool post_pending = false; @@ -200,11 +201,12 @@ static err_t http_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len) } if(restart_required == true) { - TRACE("http.c: restarting the Zodiac FX. Please reconnect."); - for(int x = 0;x<100000;x++); // Let the above message get sent to the terminal before detaching - udc_detach(); // Detach the USB device before restart - rstc_start_software_reset(RSTC); // Software reset - while (1); + restart_required_outer = true; + //TRACE("http.c: restarting the Zodiac FX. Please reconnect."); + //for(int x = 0;x<100000;x++); // Let the above message get sent to the terminal before detaching + //udc_detach(); // Detach the USB device before restart + //rstc_start_software_reset(RSTC); // Software reset + //while (1); } return ERR_OK; From 95554a99d01588597c571236877fb25f6fc608c3 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 14 Mar 2017 16:25:13 +1100 Subject: [PATCH 146/163] Add connection timeout --- ZodiacFX/src/http.c | 10 ++++++++++ ZodiacFX/src/http.h | 1 + 2 files changed, 11 insertions(+) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index a6c354a..a9cc389 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -195,9 +195,19 @@ static err_t http_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len) TRACE("http.c: ERROR - illegal bytes_waiting value. Connection will be closed."); http_close(http_conn[i].attached_pcb); } + http_conn[i].timeout = sys_get_ms(); // Update timeout timer if (http_conn[i].bytes_waiting == 0 && http_conn[i].attached_pcb != NULL) http_close(http_conn[i].attached_pcb); break; } + + if(http_conn[i].attached_pcb != NULL) + { + if(sys_get_ms() - http_conn[i].timeout > 3000) // 3s connection timeout + { + TRACE("http.c: pcb 0x%08x has timed out. Connection will be closed.", http_conn[i].attached_pcb); + http_close(http_conn[i].attached_pcb); + } + } } if(restart_required == true) { diff --git a/ZodiacFX/src/http.h b/ZodiacFX/src/http.h index ed114ec..fac8f53 100644 --- a/ZodiacFX/src/http.h +++ b/ZodiacFX/src/http.h @@ -41,6 +41,7 @@ struct http_conns { int bytes_waiting; struct tcp_pcb *attached_pcb; + uint32_t timeout; }; void http_init(void); From f61794a8687ea652c5654884e320534b37d5673f Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 17 Mar 2017 13:59:53 +1100 Subject: [PATCH 147/163] Update ZodiacFX Readme --- README.md | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 843da31..ad27095 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,111 @@ -# ZodiacFX -Firmware for the Northbound Networks Zodiac FX OpenFlow Switch +# Zodiac FX + +## Background + +The Zodiac FX began as a [Kickstarter campaign](https://www.kickstarter.com/projects/northboundnetworks/zodiac-fx-the-worlds-smallest-openflow-sdn-switch) in 2015, with the goal of providing affordable Software Defined Networking (SDN) tools for developers, researchers, and networking hobbyists. To learn more about SDN, visit the [Northbound Networks Blog](https://northboundnetworks.com/blogs/sdn). + +The device is an SDN switch that supports the [OpenFlow protocol](https://www.opennetworking.org/sdn-resources/openflow), an open standard for communication in an SDN architecture. OpenFlow allows communication between the SDN controller (where applications can be run) and OpenFlow switches in the network. These switches use application-generated "Flows" to determine how network data processed. + +This repository contains the open-source firmware for the Zodiac FX. The firmware is constantly being updated to add support for the features of the OpenFlow specification, and to improve support for the various SDN controllers. OpenFlow version 1.0 and version 1.3 are currently supported. + +## Flashing/Updating the Firmware + +The latest firmware is available in the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0). + +Starting from version 0.80, Zodiac FX supports firmware updates via the CLI and web interface. In order to make this possible, major changes were made to the firmware flashing process. Follow the update process below, based on your current firmware version. + +##### For firmware versions BEFORE version 0.80 + +To update to version 0.80 or later, a full upgrade firmware needs to be flashed. + +Download the latest full upgrade firmware from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.xx) - ZodiacFX_v0_xx.bin' + +Follow the firmware update process detailed in Section 2. Updating Firmware in the [Zodiac FX User Guide](http://forums.northboundnetworks.com/downloads/zodiac_fx/guides/ZodiacFX_UserGuide_0216.pdf). + +##### For firmware versions AFTER version 0.80 + +The update process has been simplified for the newer releases. + +Download the latest update firmware from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_v0_xx.bin' + +* To update via the CLI: + • In the root context, type the 'update' command + • When prompted, begin the firmware update via the XMODEM protocol + • Note: not all serial terminal applications support XMODEM + • If the firmware update is successful, Zodiac FX will automatically restart to complete the update + +* To update via the web interface: + • Go to the 'Update f/w' page in the Zodiac FX web interface + • Note: the web interface is available by going to the Zodiac FX IP address in a web browser on the controller + • This feature is currently fully supported in Google Chrome + • Browse and select the downloaded firmware + • Click 'Upload File' and wait for a confirmation page to appear + • Click 'Restart' in the web interface header to complete the update + +* [Advanced] To update via cURL: + • Run 'Zodiac_FX_update.sh ZodiacFX_v0_xx.bin' + • If the firmware upload fails, you may need to run 'Zodiac_FX_update_compatibility.sh ZodiacFX_v0_xx.bin' instead + • Note: on some platforms, a manual restart may be required after uploading the firmware + +## Building the Project + +If you want to modify the firmware for your own project, either download this project or fork the repository. + +[Atmel Studio 7](https://www.atmel.com/Microsite/atmel-studio/) is required to build the project. + +##### Debugging the project + +For full source-level debugging, a [Zodiac FX Hardware Debugger](https://northboundnetworks.com/products/zodiac-fx-hardware-debugger) is required. + +* Ensure that the hardware debugger appears in Project -> ZodiacFX Properties -> Tool -> Selected debugger/programmer + * Zodiac FX uses the JTAG interface +* Select the 'Debug' Solution Configuration in the Atmel Studio Standard toolbar + * The 'Release' configuration is designed for building firmware updates, and will not run directly from Atmel Studio +* Select the 'Start Debugging and Break' option in the Debug menu to begin stepping through the source + +The firmware will continue to run by cycling power to the Zodiac FX (after removing the hardware debugger). However, firmware updating will not function correctly until a full upgrade firmware is flashed. The modified firmware can be written to the Zodiac FX by following the steps outlined below - running the code without a hardware debugger. + +##### Running the code without a hardware debugger + +Modified firmware can be tested without the Zodiac FX Hardware Debugger, however source-level debugging is not possible. + +* Build the 'Release' configuration of the ZodiacFX solution +* Navigate to the compiled binary + * \ZodiacFX\Release\ZodiacFX.bin +* Follow the steps in Signing Binaries to allow the Zodiac FX to update to the modified firmware + +## Signing Binaries + +The Zodiac FX uses a simple additive checksum to verify the integrity of the uploaded firmware. + +To sign your own modified firmware, follow the steps below: + • Build a 'Release' binary of the modified firmware + • Update the Zodiac FX with the modified firmware + • Follow the instructions outlined in Flashing/Updating the Firmware - For firmware versions AFTER version 0.80 + • The firmware will fail the verification check, but will still be stored inside the Zodiac FX flash memory + • In the root context of the CLI, type in the hidden command 'get crc' + • Open the ZodiacFX.bin file in a hex editor, and append the 8 bytes to the end of the firmware file + • For example, if 'get crc' provides [A05A1201 00000000], append 'A0 5A 12 01 00 00 00 00' to the end of the firmware file + • Update the Zodiac FX with the (now signed) modified firmware + • The firmware update should be successful, and the Zodiac FX will run the new firmware after restarting + +Reporting Bugs and Issues + +Any bugs and issues can be brought up in the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?board=3.0). + +Issues can also be [raised](https://github.com/NorthboundNetworks/ZodiacFX/issues) in this repository. + +## Release Notes + +Version 0.80 +* Firmware upload via CLI and web interface added +* Metering added to OpenFlow 1.3 + +## Authors + +* Paul Zanna - creator +* Kristopher Chen - firmware developer + +## License + +GPL 3.0 From a4d0c59fb08f4df2299091787dff3850bdd3a900 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 17 Mar 2017 14:03:53 +1100 Subject: [PATCH 148/163] Update Readme --- README.md | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index ad27095..4ade71f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Zodiac FX +Firmware for the Northbound Networks Zodiac FX OpenFlow Switch + ## Background The Zodiac FX began as a [Kickstarter campaign](https://www.kickstarter.com/projects/northboundnetworks/zodiac-fx-the-worlds-smallest-openflow-sdn-switch) in 2015, with the goal of providing affordable Software Defined Networking (SDN) tools for developers, researchers, and networking hobbyists. To learn more about SDN, visit the [Northbound Networks Blog](https://northboundnetworks.com/blogs/sdn). @@ -14,7 +16,7 @@ The latest firmware is available in the [Northbound Networks Forums](http://foru Starting from version 0.80, Zodiac FX supports firmware updates via the CLI and web interface. In order to make this possible, major changes were made to the firmware flashing process. Follow the update process below, based on your current firmware version. -##### For firmware versions BEFORE version 0.80 +#### For firmware versions BEFORE version 0.80 To update to version 0.80 or later, a full upgrade firmware needs to be flashed. @@ -22,30 +24,30 @@ Download the latest full upgrade firmware from the [Northbound Networks Forums]( Follow the firmware update process detailed in Section 2. Updating Firmware in the [Zodiac FX User Guide](http://forums.northboundnetworks.com/downloads/zodiac_fx/guides/ZodiacFX_UserGuide_0216.pdf). -##### For firmware versions AFTER version 0.80 +#### For firmware versions AFTER version 0.80 The update process has been simplified for the newer releases. Download the latest update firmware from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_v0_xx.bin' * To update via the CLI: - • In the root context, type the 'update' command - • When prompted, begin the firmware update via the XMODEM protocol - • Note: not all serial terminal applications support XMODEM - • If the firmware update is successful, Zodiac FX will automatically restart to complete the update + * In the root context, type the 'update' command + * When prompted, begin the firmware update via the XMODEM protocol + * Note: not all serial terminal applications support XMODEM + * If the firmware update is successful, Zodiac FX will automatically restart to complete the update * To update via the web interface: - • Go to the 'Update f/w' page in the Zodiac FX web interface - • Note: the web interface is available by going to the Zodiac FX IP address in a web browser on the controller - • This feature is currently fully supported in Google Chrome - • Browse and select the downloaded firmware - • Click 'Upload File' and wait for a confirmation page to appear - • Click 'Restart' in the web interface header to complete the update + * Go to the 'Update f/w' page in the Zodiac FX web interface + * Note: the web interface is available by going to the Zodiac FX IP address in a web browser on the controller + * This feature is currently fully supported in Google Chrome + * Browse and select the downloaded firmware + * Click 'Upload File' and wait for a confirmation page to appear + * Click 'Restart' in the web interface header to complete the update * [Advanced] To update via cURL: - • Run 'Zodiac_FX_update.sh ZodiacFX_v0_xx.bin' - • If the firmware upload fails, you may need to run 'Zodiac_FX_update_compatibility.sh ZodiacFX_v0_xx.bin' instead - • Note: on some platforms, a manual restart may be required after uploading the firmware + * Run 'Zodiac_FX_update.sh ZodiacFX_v0_xx.bin' + * If the firmware upload fails, you may need to run 'Zodiac_FX_update_compatibility.sh ZodiacFX_v0_xx.bin' instead + * Note: on some platforms, a manual restart may be required after uploading the firmware ## Building the Project @@ -53,7 +55,7 @@ If you want to modify the firmware for your own project, either download this pr [Atmel Studio 7](https://www.atmel.com/Microsite/atmel-studio/) is required to build the project. -##### Debugging the project +#### Debugging the project For full source-level debugging, a [Zodiac FX Hardware Debugger](https://northboundnetworks.com/products/zodiac-fx-hardware-debugger) is required. @@ -65,7 +67,7 @@ For full source-level debugging, a [Zodiac FX Hardware Debugger](https://northbo The firmware will continue to run by cycling power to the Zodiac FX (after removing the hardware debugger). However, firmware updating will not function correctly until a full upgrade firmware is flashed. The modified firmware can be written to the Zodiac FX by following the steps outlined below - running the code without a hardware debugger. -##### Running the code without a hardware debugger +#### Running the code without a hardware debugger Modified firmware can be tested without the Zodiac FX Hardware Debugger, however source-level debugging is not possible. @@ -79,15 +81,15 @@ Modified firmware can be tested without the Zodiac FX Hardware Debugger, however The Zodiac FX uses a simple additive checksum to verify the integrity of the uploaded firmware. To sign your own modified firmware, follow the steps below: - • Build a 'Release' binary of the modified firmware - • Update the Zodiac FX with the modified firmware - • Follow the instructions outlined in Flashing/Updating the Firmware - For firmware versions AFTER version 0.80 - • The firmware will fail the verification check, but will still be stored inside the Zodiac FX flash memory - • In the root context of the CLI, type in the hidden command 'get crc' - • Open the ZodiacFX.bin file in a hex editor, and append the 8 bytes to the end of the firmware file - • For example, if 'get crc' provides [A05A1201 00000000], append 'A0 5A 12 01 00 00 00 00' to the end of the firmware file - • Update the Zodiac FX with the (now signed) modified firmware - • The firmware update should be successful, and the Zodiac FX will run the new firmware after restarting + * Build a 'Release' binary of the modified firmware + * Update the Zodiac FX with the modified firmware + * Follow the instructions outlined in Flashing/Updating the Firmware - For firmware versions AFTER version 0.80 + * The firmware will fail the verification check, but will still be stored inside the Zodiac FX flash memory + * In the root context of the CLI, type in the hidden command 'get crc' + * Open the ZodiacFX.bin file in a hex editor, and append the 8 bytes to the end of the firmware file + * For example, if 'get crc' provides [A05A1201 00000000], append 'A0 5A 12 01 00 00 00 00' to the end of the firmware file + * Update the Zodiac FX with the (now signed) modified firmware + * The firmware update should be successful, and the Zodiac FX will run the new firmware after restarting Reporting Bugs and Issues From f949d036231607a8e982bbd3dbd0079c9d086ba7 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Fri, 17 Mar 2017 14:18:08 +1100 Subject: [PATCH 149/163] Update README.md --- README.md | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 4ade71f..ee8554a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Firmware for the Northbound Networks Zodiac FX OpenFlow Switch The Zodiac FX began as a [Kickstarter campaign](https://www.kickstarter.com/projects/northboundnetworks/zodiac-fx-the-worlds-smallest-openflow-sdn-switch) in 2015, with the goal of providing affordable Software Defined Networking (SDN) tools for developers, researchers, and networking hobbyists. To learn more about SDN, visit the [Northbound Networks Blog](https://northboundnetworks.com/blogs/sdn). -The device is an SDN switch that supports the [OpenFlow protocol](https://www.opennetworking.org/sdn-resources/openflow), an open standard for communication in an SDN architecture. OpenFlow allows communication between the SDN controller (where applications can be run) and OpenFlow switches in the network. These switches use application-generated "Flows" to determine how network data processed. +The Zodiac FX is an SDN switch that supports the [OpenFlow protocol](https://www.opennetworking.org/sdn-resources/openflow), an open standard for communication in an SDN architecture. OpenFlow allows communication between the SDN controller (where applications can be run) and OpenFlow switches in the network. These switches use application-generated "Flows" to determine how network data is processed. This repository contains the open-source firmware for the Zodiac FX. The firmware is constantly being updated to add support for the features of the OpenFlow specification, and to improve support for the various SDN controllers. OpenFlow version 1.0 and version 1.3 are currently supported. @@ -18,25 +18,25 @@ Starting from version 0.80, Zodiac FX supports firmware updates via the CLI and #### For firmware versions BEFORE version 0.80 -To update to version 0.80 or later, a full upgrade firmware needs to be flashed. +To update to version 0.80 or later, a **full upgrade firmware** needs to be flashed. -Download the latest full upgrade firmware from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.xx) - ZodiacFX_v0_xx.bin' +Download the latest **full upgrade firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.xx) - ZodiacFX_v0_xx.bin' -Follow the firmware update process detailed in Section 2. Updating Firmware in the [Zodiac FX User Guide](http://forums.northboundnetworks.com/downloads/zodiac_fx/guides/ZodiacFX_UserGuide_0216.pdf). +Follow the firmware update process detailed in **Section 2. Updating Firmware** in the [Zodiac FX User Guide](http://forums.northboundnetworks.com/downloads/zodiac_fx/guides/ZodiacFX_UserGuide_0216.pdf). #### For firmware versions AFTER version 0.80 The update process has been simplified for the newer releases. -Download the latest update firmware from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_v0_xx.bin' +Download the latest **update firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_v0_xx.bin' -* To update via the CLI: +* **To update via the CLI**: * In the root context, type the 'update' command * When prompted, begin the firmware update via the XMODEM protocol * Note: not all serial terminal applications support XMODEM * If the firmware update is successful, Zodiac FX will automatically restart to complete the update -* To update via the web interface: +* **To update via the web interface**: * Go to the 'Update f/w' page in the Zodiac FX web interface * Note: the web interface is available by going to the Zodiac FX IP address in a web browser on the controller * This feature is currently fully supported in Google Chrome @@ -44,14 +44,14 @@ Download the latest update firmware from the [Northbound Networks Forums](http:/ * Click 'Upload File' and wait for a confirmation page to appear * Click 'Restart' in the web interface header to complete the update -* [Advanced] To update via cURL: - * Run 'Zodiac_FX_update.sh ZodiacFX_v0_xx.bin' - * If the firmware upload fails, you may need to run 'Zodiac_FX_update_compatibility.sh ZodiacFX_v0_xx.bin' instead +* **[Advanced] To update via cURL**: + * Run ['Zodiac_FX_update.sh ZodiacFX_v0_xx.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) + * If the firmware upload fails, you may need to run ['Zodiac_FX_update_compatibility.sh ZodiacFX_v0_xx.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) instead * Note: on some platforms, a manual restart may be required after uploading the firmware ## Building the Project -If you want to modify the firmware for your own project, either download this project or fork the repository. +If you want to modify the firmware for your own project, either download this project or fork this repository. [Atmel Studio 7](https://www.atmel.com/Microsite/atmel-studio/) is required to build the project. @@ -62,10 +62,10 @@ For full source-level debugging, a [Zodiac FX Hardware Debugger](https://northbo * Ensure that the hardware debugger appears in Project -> ZodiacFX Properties -> Tool -> Selected debugger/programmer * Zodiac FX uses the JTAG interface * Select the 'Debug' Solution Configuration in the Atmel Studio Standard toolbar - * The 'Release' configuration is designed for building firmware updates, and will not run directly from Atmel Studio + * The 'Release' configuration has been modified to build firmware updates, and will not run directly in Atmel Studio * Select the 'Start Debugging and Break' option in the Debug menu to begin stepping through the source -The firmware will continue to run by cycling power to the Zodiac FX (after removing the hardware debugger). However, firmware updating will not function correctly until a full upgrade firmware is flashed. The modified firmware can be written to the Zodiac FX by following the steps outlined below - running the code without a hardware debugger. +The firmware will continue to run by cycling power to the Zodiac FX (after removing the hardware debugger). However, firmware updating will not function until a **full upgrade firmware** is flashed. The modified firmware can be written to the Zodiac FX by following the steps outlined below: **running the code without a hardware debugger**. #### Running the code without a hardware debugger @@ -81,17 +81,17 @@ Modified firmware can be tested without the Zodiac FX Hardware Debugger, however The Zodiac FX uses a simple additive checksum to verify the integrity of the uploaded firmware. To sign your own modified firmware, follow the steps below: - * Build a 'Release' binary of the modified firmware - * Update the Zodiac FX with the modified firmware - * Follow the instructions outlined in Flashing/Updating the Firmware - For firmware versions AFTER version 0.80 - * The firmware will fail the verification check, but will still be stored inside the Zodiac FX flash memory - * In the root context of the CLI, type in the hidden command 'get crc' - * Open the ZodiacFX.bin file in a hex editor, and append the 8 bytes to the end of the firmware file - * For example, if 'get crc' provides [A05A1201 00000000], append 'A0 5A 12 01 00 00 00 00' to the end of the firmware file - * Update the Zodiac FX with the (now signed) modified firmware - * The firmware update should be successful, and the Zodiac FX will run the new firmware after restarting - -Reporting Bugs and Issues +* Build a 'Release' binary of the modified firmware +* Update the Zodiac FX with the modified firmware + * Follow the instructions outlined in Flashing/Updating the Firmware - For firmware versions AFTER version 0.80 +* The firmware will fail the verification check, but will still be stored inside the Zodiac FX flash memory +* In the root context of the CLI, type in the hidden command 'get crc' +* Open the ZodiacFX.bin file in a hex editor, and append the 8 bytes to the end of the firmware file + * For example, if 'get crc' provides [A05A1201 00000000], append 'A0 5A 12 01 00 00 00 00' to the end of the firmware file +* Update the Zodiac FX again with the (now signed) modified firmware +* The firmware update should be successful, and the Zodiac FX will run the new firmware after restarting + +## Reporting Bugs and Issues Any bugs and issues can be brought up in the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?board=3.0). @@ -99,14 +99,14 @@ Issues can also be [raised](https://github.com/NorthboundNetworks/ZodiacFX/issue ## Release Notes -Version 0.80 +**Version 0.80** * Firmware upload via CLI and web interface added * Metering added to OpenFlow 1.3 ## Authors -* Paul Zanna - creator -* Kristopher Chen - firmware developer +* **Paul Zanna** - creator +* **Kristopher Chen** - firmware developer ## License From 1c6a659a42fa401f89015e44b2fb39dfafadf86b Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Sat, 18 Mar 2017 23:24:03 +1100 Subject: [PATCH 150/163] Update README.md --- README.md | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 843da31..e292b63 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,113 @@ -# ZodiacFX -Firmware for the Northbound Networks Zodiac FX OpenFlow Switch +# Zodiac FX + +Firmware for the [Northbound Networks](https://northboundnetworks.com/) Zodiac FX OpenFlow Switch + +## Background + +The Zodiac FX began as a [Kickstarter campaign](https://www.kickstarter.com/projects/northboundnetworks/zodiac-fx-the-worlds-smallest-openflow-sdn-switch) in 2015, with the goal of providing an affordable Software Defined Networking (SDN) platform for developers, researchers, and networking hobbyists. To learn more about SDN, visit the [Northbound Networks Blog](https://northboundnetworks.com/blogs/sdn). + +The Zodiac FX is an SDN switch that supports the [OpenFlow protocol](https://www.opennetworking.org/sdn-resources/openflow), an open standard for communication in an SDN architecture. OpenFlow allows communication between the SDN controller (where applications can be run) and OpenFlow switches in the network. These switches use application-generated "Flows" to determine how network data is processed. + +This repository contains the open-source firmware for the Zodiac FX. The firmware is constantly being updated to add support for the features of the OpenFlow specification, and to improve support for the various SDN controllers. OpenFlow version 1.0 and version 1.3 are currently supported. + +## Flashing/Updating the Firmware + +The latest firmware is available in the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0). + +Starting from version 0.80, Zodiac FX supports firmware updates via the CLI and web interface. In order to make this possible, major changes were made to the firmware flashing process. Follow the update process below, based on your current firmware version. + +#### For firmware versions BEFORE version 0.80 + +To update to version 0.80 or later, a **full upgrade firmware** needs to be flashed. + +Download the latest **full upgrade firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.xx) - ZodiacFX_v0_xx.bin' + +Follow the firmware update process detailed in **Section 2. Updating Firmware** in the [Zodiac FX User Guide](http://forums.northboundnetworks.com/downloads/zodiac_fx/guides/ZodiacFX_UserGuide_0216.pdf). + +#### For firmware versions AFTER version 0.80 + +The update process has been simplified for the newer releases. + +Download the latest **update firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_v0_xx.bin' + +* **To update via the CLI**: + * In the root context, type the 'update' command + * When prompted, begin the firmware update via the XMODEM protocol + * Note: not all serial terminal applications support XMODEM + * If the firmware update is successful, Zodiac FX will automatically restart to complete the update + +* **To update via the web interface**: + * Go to the 'Update f/w' page in the Zodiac FX web interface + * Note: the web interface is available by going to the Zodiac FX IP address in a web browser on the controller + * This feature is currently fully supported in Google Chrome + * Browse and select the downloaded firmware + * Click 'Upload File' and wait for a confirmation page to appear + * Click 'Restart' in the web interface header to complete the update + +* **[Advanced] To update via cURL**: + * Run ['Zodiac_FX_update.sh ZodiacFX_v0_xx.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) + * If the firmware upload fails, you may need to run ['Zodiac_FX_update_compatibility.sh ZodiacFX_v0_xx.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) instead + * Note: on some platforms, a manual restart may be required after uploading the firmware + +## Building the Project + +If you want to modify the firmware for your own project, either download this project or fork this repository. + +[Atmel Studio 7](https://www.atmel.com/Microsite/atmel-studio/) is required to build the project. + +#### Debugging the project + +For full source-level debugging, a [Zodiac FX Hardware Debugger](https://northboundnetworks.com/products/zodiac-fx-hardware-debugger) is required. + +* Ensure that the hardware debugger appears in Project -> ZodiacFX Properties -> Tool -> Selected debugger/programmer + * Zodiac FX uses the JTAG interface +* Select the 'Debug' Solution Configuration in the Atmel Studio Standard toolbar + * The 'Release' configuration has been modified to build firmware updates, and will not run directly in Atmel Studio +* Select the 'Start Debugging and Break' option in the Debug menu to begin stepping through the source + +The firmware will continue to run by cycling power to the Zodiac FX (after removing the hardware debugger). However, firmware updating will not function until a **full upgrade firmware** is flashed. The modified firmware can be written to the Zodiac FX by following the steps outlined below: **running the code without a hardware debugger**. + +#### Running the code without a hardware debugger + +Modified firmware can be tested without the Zodiac FX Hardware Debugger, however source-level debugging is not possible. + +* Build the 'Release' configuration of the ZodiacFX solution +* Navigate to the compiled binary + * \ZodiacFX\Release\ZodiacFX.bin +* Follow the steps in Signing Binaries to allow the Zodiac FX to update to the modified firmware + +## Signing Binaries + +The Zodiac FX uses a simple additive checksum to verify the integrity of the uploaded firmware. + +To sign your own modified firmware, follow the steps below: +* Build a 'Release' binary of the modified firmware +* Update the Zodiac FX with the modified firmware + * Follow the instructions outlined in Flashing/Updating the Firmware - For firmware versions AFTER version 0.80 +* The firmware will fail the verification check, but will still be stored inside the Zodiac FX flash memory +* In the root context of the CLI, type in the hidden command 'get crc' +* Open the ZodiacFX.bin file in a hex editor, and append the 8 bytes to the end of the firmware file + * For example, if 'get crc' provides [A05A1201 00000000], append 'A0 5A 12 01 00 00 00 00' to the end of the firmware file +* Update the Zodiac FX again with the (now signed) modified firmware +* The firmware update should be successful, and the Zodiac FX will run the new firmware after restarting + +## Reporting Bugs and Issues + +Any bugs and issues can be brought up in the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?board=3.0). + +Issues can also be [raised](https://github.com/NorthboundNetworks/ZodiacFX/issues) in this repository. + +## Release Notes + +**Version 0.80** +* Firmware upload via CLI and web interface added +* Metering added to OpenFlow 1.3 + +## Authors + +* **Paul Zanna** - creator +* **Kristopher Chen** - firmware developer + +## License + +GPL 3.0 From d8b70ec0bf1e3b9148f6f2ac4dc7b7b18b48d681 Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Sat, 18 Mar 2017 23:34:11 +1100 Subject: [PATCH 151/163] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e292b63..1509fa1 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -# Zodiac FX +# Zodiac FX Firmware -Firmware for the [Northbound Networks](https://northboundnetworks.com/) Zodiac FX OpenFlow Switch +This is the firmware for the [Northbound Networks](https://northboundnetworks.com/) Zodiac FX OpenFlow Switch. ## Background The Zodiac FX began as a [Kickstarter campaign](https://www.kickstarter.com/projects/northboundnetworks/zodiac-fx-the-worlds-smallest-openflow-sdn-switch) in 2015, with the goal of providing an affordable Software Defined Networking (SDN) platform for developers, researchers, and networking hobbyists. To learn more about SDN, visit the [Northbound Networks Blog](https://northboundnetworks.com/blogs/sdn). -The Zodiac FX is an SDN switch that supports the [OpenFlow protocol](https://www.opennetworking.org/sdn-resources/openflow), an open standard for communication in an SDN architecture. OpenFlow allows communication between the SDN controller (where applications can be run) and OpenFlow switches in the network. These switches use application-generated "Flows" to determine how network data is processed. +The Zodiac FX SDN switch uses the [OpenFlow protocol](https://www.opennetworking.org/sdn-resources/openflow), an open standard for communication in an SDN architecture. OpenFlow allows communication between the SDN controller (where applications can be run) and OpenFlow switches in the network. These switches use application-generated "Flows" to determine how network data is processed. -This repository contains the open-source firmware for the Zodiac FX. The firmware is constantly being updated to add support for the features of the OpenFlow specification, and to improve support for the various SDN controllers. OpenFlow version 1.0 and version 1.3 are currently supported. +This repository contains the entire open-source firmware for the Zodiac FX including OpenFlow libraries. The firmware is constantly being updated with support for features of the OpenFlow specification, and to improve compatability with the various SDN controllers. OpenFlow version 1.0 and version 1.3 are currently supported. ## Flashing/Updating the Firmware @@ -105,9 +105,9 @@ Issues can also be [raised](https://github.com/NorthboundNetworks/ZodiacFX/issue ## Authors -* **Paul Zanna** - creator -* **Kristopher Chen** - firmware developer +* **Paul Zanna** - Creator +* **Kristopher Chen** - Firmware Developer ## License -GPL 3.0 +[GPL 3.0](LICENSE) From a41e950b8be10c4ab4ef0d8670be796b5888ae5c Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 20 Mar 2017 12:27:07 +1100 Subject: [PATCH 152/163] Fix CLI instruction list output --- ZodiacFX/src/command.c | 45 ++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index 29dccd1..799eff5 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -1043,7 +1043,6 @@ void command_openflow(char *command, char *param1, char *param2, char *param3) int match_size; int inst_size; int act_size; - struct ofp13_instruction *inst_ptr; struct ofp13_instruction_actions *inst_actions; struct oxm_header13 oxm_header; uint8_t oxm_value8; @@ -1168,29 +1167,38 @@ void command_openflow(char *command, char *param1, char *param2, char *param3) int min = t/60; int sec = t%60; printf(" Last Match: %02d:%02d:%02d\r\n", hr, min, sec); + // Print instruction list if (ofp13_oxm_inst[i] != NULL) { + // Get a list of all instructions for this flow + void *insts[8] = {0}; + inst_size = 0; + while(inst_size < ofp13_oxm_inst_size[i]){ + struct ofp13_instruction *inst_ptr = (struct ofp13_instruction *)(ofp13_oxm_inst[i] + inst_size); + insts[ntohs(inst_ptr->type)] = inst_ptr; + inst_size += ntohs(inst_ptr->len); + } + printf("\r Instructions:\r\n"); - inst_ptr = (struct ofp13_instruction *) ofp13_oxm_inst[i]; - inst_size = ntohs(inst_ptr->len); // Check for optional metering instruction - if(ntohs(inst_ptr->type) == OFPIT13_METER) + if(insts[OFPIT13_METER] != NULL) { - struct ofp13_instruction_meter *inst_meter = inst_ptr; + struct ofp13_instruction_meter *inst_meter = insts[OFPIT13_METER]; printf(" Meter: %d\r\n", ntohl(inst_meter->meter_id)); } - if(ntohs(inst_ptr->type) == OFPIT13_APPLY_ACTIONS) + if(insts[OFPIT13_APPLY_ACTIONS] != NULL) { printf(" Apply Actions:\r\n"); struct ofp13_action_header *act_hdr; act_size = 0; - if (inst_size == sizeof(struct ofp13_instruction_actions)) printf(" DROP \r\n"); // No actions - while (act_size < (inst_size - sizeof(struct ofp13_instruction_actions))) + inst_actions = insts[OFPIT13_APPLY_ACTIONS]; + if (ntohs(inst_actions->len) == sizeof(struct ofp13_instruction_actions)) printf(" DROP \r\n"); // No actions + while (act_size < (ntohs(inst_actions->len) - sizeof(struct ofp13_instruction_actions))) { - inst_actions = ofp13_oxm_inst[i] + act_size; + inst_actions = insts[OFPIT13_APPLY_ACTIONS] + act_size; act_hdr = &inst_actions->actions; if (htons(act_hdr->type) == OFPAT13_OUTPUT) { @@ -1334,26 +1342,11 @@ void command_openflow(char *command, char *param1, char *param2, char *param3) } } // Print goto table instruction - if(ntohs(inst_ptr->type) == OFPIT13_GOTO_TABLE) + if(insts[OFPIT13_GOTO_TABLE] != NULL) { struct ofp13_instruction_goto_table *inst_goto_ptr; - inst_goto_ptr = (struct ofp13_instruction_goto_table *) inst_ptr; + inst_goto_ptr = (struct ofp13_instruction_goto_table *) insts[OFPIT13_METER]; printf(" Goto Table: %d\r\n", inst_goto_ptr->table_id); - continue; - } - // Is there more then one instruction? - if (ofp13_oxm_inst_size[i] > inst_size) - { - uint8_t *nxt_inst; - nxt_inst = ofp13_oxm_inst[i] + inst_size; - inst_ptr = (struct ofp13_instruction *) nxt_inst; - inst_size = ntohs(inst_ptr->len); - if(ntohs(inst_ptr->type) == OFPIT13_GOTO_TABLE) - { - struct ofp13_instruction_goto_table *inst_goto_ptr; - inst_goto_ptr = (struct ofp13_instruction_goto_table *) inst_ptr; - printf(" Goto Table: %d\r\n", inst_goto_ptr->table_id); - } } } else { // No instructions From 34efb5fcf7e011720530c5a25686ba0760f83973 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 20 Mar 2017 12:38:27 +1100 Subject: [PATCH 153/163] Fix web interface instruction list output --- ZodiacFX/src/http.c | 50 ++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index a9cc389..a2c7c33 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -3226,29 +3226,38 @@ if (iLastFlow > 0) int min = t/60; int sec = t%60; snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," Last Match: %02d:%02d:%02d\r\n", hr, min, sec); + // Print instruction list if (ofp13_oxm_inst[i] != NULL) { + // Get a list of all instructions for this flow + void *insts[8] = {0}; + inst_size = 0; + while(inst_size < ofp13_oxm_inst_size[i]){ + struct ofp13_instruction *inst_ptr = (struct ofp13_instruction *)(ofp13_oxm_inst[i] + inst_size); + insts[ntohs(inst_ptr->type)] = inst_ptr; + inst_size += ntohs(inst_ptr->len); + } + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer),"\r Instructions:\r\n"); - inst_ptr = (struct ofp13_instruction *) ofp13_oxm_inst[i]; - inst_size = ntohs(inst_ptr->len); - + // Check for optional metering instruction - if(ntohs(inst_ptr->type) == OFPIT13_METER) + if(insts[OFPIT13_METER] != NULL) { - struct ofp13_instruction_meter *inst_meter = inst_ptr; - snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer), " Meter: %d\r\n", ntohl(inst_meter->meter_id)); + struct ofp13_instruction_meter *inst_meter = insts[OFPIT13_METER]; + snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," Meter: %d\r\n", ntohl(inst_meter->meter_id)); } - - if(ntohs(inst_ptr->type) == OFPIT13_APPLY_ACTIONS) + + if(insts[OFPIT13_APPLY_ACTIONS] != NULL) { snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," Apply Actions:\r\n"); struct ofp13_action_header *act_hdr; act_size = 0; - if (inst_size == sizeof(struct ofp13_instruction_actions)) snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," DROP \r\n"); // No actions - while (act_size < (inst_size - sizeof(struct ofp13_instruction_actions))) + inst_actions = insts[OFPIT13_APPLY_ACTIONS]; + if (ntohs(inst_actions->len) == sizeof(struct ofp13_instruction_actions)) snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," DROP \r\n"); // No actions + while (act_size < (ntohs(inst_actions->len) - sizeof(struct ofp13_instruction_actions))) { - inst_actions = ofp13_oxm_inst[i] + act_size; + inst_actions = insts[OFPIT13_APPLY_ACTIONS] + act_size; act_hdr = &inst_actions->actions; if (htons(act_hdr->type) == OFPAT13_OUTPUT) { @@ -3392,26 +3401,11 @@ if (iLastFlow > 0) } } // Print goto table instruction - if(ntohs(inst_ptr->type) == OFPIT13_GOTO_TABLE) + if(insts[OFPIT13_GOTO_TABLE] != NULL) { struct ofp13_instruction_goto_table *inst_goto_ptr; - inst_goto_ptr = (struct ofp13_instruction_goto_table *) inst_ptr; + inst_goto_ptr = (struct ofp13_instruction_goto_table *) insts[OFPIT13_METER]; snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," Goto Table: %d\r\n", inst_goto_ptr->table_id); - continue; - } - // Is there more then one instruction? - if (ofp13_oxm_inst_size[i] > inst_size) - { - uint8_t *nxt_inst; - nxt_inst = ofp13_oxm_inst[i] + inst_size; - inst_ptr = (struct ofp13_instruction *) nxt_inst; - inst_size = ntohs(inst_ptr->len); - if(ntohs(inst_ptr->type) == OFPIT13_GOTO_TABLE) - { - struct ofp13_instruction_goto_table *inst_goto_ptr; - inst_goto_ptr = (struct ofp13_instruction_goto_table *) inst_ptr; - snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," Goto Table: %d\r\n", inst_goto_ptr->table_id); - } } } else { // No instructions From 8bfe304c3b68e0600cb9504b3f8e4c4f319e659c Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 20 Mar 2017 12:38:58 +1100 Subject: [PATCH 154/163] Fix action instruction length check --- ZodiacFX/src/openflow/openflow_13.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZodiacFX/src/openflow/openflow_13.c b/ZodiacFX/src/openflow/openflow_13.c index bf97447..7de7391 100644 --- a/ZodiacFX/src/openflow/openflow_13.c +++ b/ZodiacFX/src/openflow/openflow_13.c @@ -158,7 +158,7 @@ void nnOF13_tablelookup(uint8_t *p_uc_data, uint32_t *ul_size, int port) bool recalculate_ip_checksum = false; struct ofp13_instruction_actions *inst_actions = insts[OFPIT13_APPLY_ACTIONS]; int act_size = 0; - while (act_size < (inst_size - sizeof(struct ofp13_instruction_actions))) + while (act_size < (ntohs(inst_actions->len) - sizeof(struct ofp13_instruction_actions))) { struct ofp13_action_header *act_hdr = (struct ofp13_action_header*)((uintptr_t)inst_actions->actions + act_size); switch (htons(act_hdr->type)) From daf9bddec3ec1ae6873d8bd3771ac5554bed24a8 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 20 Mar 2017 14:39:49 +1100 Subject: [PATCH 155/163] Fix goto table output --- ZodiacFX/src/command.c | 2 +- ZodiacFX/src/http.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index 799eff5..8c83271 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -1345,7 +1345,7 @@ void command_openflow(char *command, char *param1, char *param2, char *param3) if(insts[OFPIT13_GOTO_TABLE] != NULL) { struct ofp13_instruction_goto_table *inst_goto_ptr; - inst_goto_ptr = (struct ofp13_instruction_goto_table *) insts[OFPIT13_METER]; + inst_goto_ptr = (struct ofp13_instruction_goto_table *) insts[OFPIT13_GOTO_TABLE]; printf(" Goto Table: %d\r\n", inst_goto_ptr->table_id); } } else { diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index a2c7c33..299b6ef 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -3404,7 +3404,7 @@ if (iLastFlow > 0) if(insts[OFPIT13_GOTO_TABLE] != NULL) { struct ofp13_instruction_goto_table *inst_goto_ptr; - inst_goto_ptr = (struct ofp13_instruction_goto_table *) insts[OFPIT13_METER]; + inst_goto_ptr = (struct ofp13_instruction_goto_table *) insts[OFPIT13_GOTO_TABLE]; snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," Goto Table: %d\r\n", inst_goto_ptr->table_id); } } else { From bd7e44345eb3f4105e0088b976832f6275630905 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 20 Mar 2017 14:59:18 +1100 Subject: [PATCH 156/163] Fix multiple action output --- ZodiacFX/src/command.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index 8c83271..864f33d 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -1198,8 +1198,7 @@ void command_openflow(char *command, char *param1, char *param2, char *param3) if (ntohs(inst_actions->len) == sizeof(struct ofp13_instruction_actions)) printf(" DROP \r\n"); // No actions while (act_size < (ntohs(inst_actions->len) - sizeof(struct ofp13_instruction_actions))) { - inst_actions = insts[OFPIT13_APPLY_ACTIONS] + act_size; - act_hdr = &inst_actions->actions; + act_hdr = (struct ofp13_action_header*)((uintptr_t)inst_actions->actions + act_size); if (htons(act_hdr->type) == OFPAT13_OUTPUT) { struct ofp13_action_output *act_output = act_hdr; From 138a9376d934889a62d8c652d79b369550ab00f0 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Mon, 20 Mar 2017 15:14:08 +1100 Subject: [PATCH 157/163] Fix multiple action output (web) --- ZodiacFX/src/http.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index 299b6ef..fca726f 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -3257,8 +3257,7 @@ if (iLastFlow > 0) if (ntohs(inst_actions->len) == sizeof(struct ofp13_instruction_actions)) snprintf(shared_buffer+strlen(shared_buffer), SHARED_BUFFER_LEN-strlen(shared_buffer)," DROP \r\n"); // No actions while (act_size < (ntohs(inst_actions->len) - sizeof(struct ofp13_instruction_actions))) { - inst_actions = insts[OFPIT13_APPLY_ACTIONS] + act_size; - act_hdr = &inst_actions->actions; + act_hdr = (struct ofp13_action_header*)((uintptr_t)inst_actions->actions + act_size); if (htons(act_hdr->type) == OFPAT13_OUTPUT) { struct ofp13_action_output *act_output = act_hdr; From 98e7780e7a02b516b0fbe125ddac1b1878c81a6a Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Mon, 20 Mar 2017 15:28:45 +1100 Subject: [PATCH 158/163] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index f0b63bd..4b572c1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -<<<<<<< HEAD # Zodiac FX Firmware for the Northbound Networks Zodiac FX OpenFlow Switch @@ -22,7 +21,6 @@ The Zodiac FX began as a [Kickstarter campaign](https://www.kickstarter.com/proj The Zodiac FX SDN switch uses the [OpenFlow protocol](https://www.opennetworking.org/sdn-resources/openflow), an open standard for communication in an SDN architecture. OpenFlow allows communication between the SDN controller (where applications can be run) and OpenFlow switches in the network. These switches use application-generated "Flows" to determine how network data is processed. This repository contains the entire open-source firmware for the Zodiac FX including OpenFlow libraries. The firmware is constantly being updated with support for features of the OpenFlow specification, and to improve compatability with the various SDN controllers. OpenFlow version 1.0 and version 1.3 are currently supported. ->>>>>>> refs/remotes/pzanna/Dev_80 ## Flashing/Updating the Firmware @@ -119,7 +117,6 @@ Issues can also be [raised](https://github.com/NorthboundNetworks/ZodiacFX/issue ## Authors -<<<<<<< HEAD * **Paul Zanna** - creator * **Kristopher Chen** - firmware developer @@ -133,4 +130,3 @@ GPL 3.0 ## License [GPL 3.0](LICENSE) ->>>>>>> refs/remotes/pzanna/Dev_80 From 96f1bb2913d68e7ea71ecf91eec3301570e4d910 Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Mon, 20 Mar 2017 15:30:52 +1100 Subject: [PATCH 159/163] Update README.md --- README.md | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/README.md b/README.md index 4b572c1..1509fa1 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,3 @@ -# Zodiac FX - -Firmware for the Northbound Networks Zodiac FX OpenFlow Switch - -## Background - -The Zodiac FX began as a [Kickstarter campaign](https://www.kickstarter.com/projects/northboundnetworks/zodiac-fx-the-worlds-smallest-openflow-sdn-switch) in 2015, with the goal of providing affordable Software Defined Networking (SDN) tools for developers, researchers, and networking hobbyists. To learn more about SDN, visit the [Northbound Networks Blog](https://northboundnetworks.com/blogs/sdn). - -The Zodiac FX is an SDN switch that supports the [OpenFlow protocol](https://www.opennetworking.org/sdn-resources/openflow), an open standard for communication in an SDN architecture. OpenFlow allows communication between the SDN controller (where applications can be run) and OpenFlow switches in the network. These switches use application-generated "Flows" to determine how network data is processed. - -This repository contains the open-source firmware for the Zodiac FX. The firmware is constantly being updated to add support for the features of the OpenFlow specification, and to improve support for the various SDN controllers. OpenFlow version 1.0 and version 1.3 are currently supported. -======= # Zodiac FX Firmware This is the firmware for the [Northbound Networks](https://northboundnetworks.com/) Zodiac FX OpenFlow Switch. @@ -117,13 +105,6 @@ Issues can also be [raised](https://github.com/NorthboundNetworks/ZodiacFX/issue ## Authors -* **Paul Zanna** - creator -* **Kristopher Chen** - firmware developer - -## License - -GPL 3.0 -======= * **Paul Zanna** - Creator * **Kristopher Chen** - Firmware Developer From 22dabb8832c83477c50366ec5aff6f81ba7328c6 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 21 Mar 2017 09:50:40 +1100 Subject: [PATCH 160/163] Update README.md Differentiate between _update binary and _base binary --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1509fa1..9c64b90 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Starting from version 0.80, Zodiac FX supports firmware updates via the CLI and To update to version 0.80 or later, a **full upgrade firmware** needs to be flashed. -Download the latest **full upgrade firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.xx) - ZodiacFX_v0_xx.bin' +Download the latest **full upgrade firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.xx) - ZodiacFX_v0_xx_base.bin' Follow the firmware update process detailed in **Section 2. Updating Firmware** in the [Zodiac FX User Guide](http://forums.northboundnetworks.com/downloads/zodiac_fx/guides/ZodiacFX_UserGuide_0216.pdf). @@ -28,7 +28,7 @@ Follow the firmware update process detailed in **Section 2. Updating Firmware** The update process has been simplified for the newer releases. -Download the latest **update firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_v0_xx.bin' +Download the latest **update firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_v0_xx_update.bin' * **To update via the CLI**: * In the root context, type the 'update' command @@ -45,8 +45,8 @@ Download the latest **update firmware** from the [Northbound Networks Forums](ht * Click 'Restart' in the web interface header to complete the update * **[Advanced] To update via cURL**: - * Run ['Zodiac_FX_update.sh ZodiacFX_v0_xx.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) - * If the firmware upload fails, you may need to run ['Zodiac_FX_update_compatibility.sh ZodiacFX_v0_xx.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) instead + * Run ['Zodiac_FX_update.sh ZodiacFX_v0_xx_update.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) + * If the firmware upload fails, you may need to run ['Zodiac_FX_update_compatibility.sh ZodiacFX_v0_xx_update.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) instead * Note: on some platforms, a manual restart may be required after uploading the firmware ## Building the Project From 5bad008a7e0b7b37a58030fdf00b04ed42fd5968 Mon Sep 17 00:00:00 2001 From: Kristopher Chen Date: Tue, 21 Mar 2017 11:00:12 +1100 Subject: [PATCH 161/163] Update README.md Update binary naming. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c64b90..a74f526 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Starting from version 0.80, Zodiac FX supports firmware updates via the CLI and To update to version 0.80 or later, a **full upgrade firmware** needs to be flashed. -Download the latest **full upgrade firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.xx) - ZodiacFX_v0_xx_base.bin' +Download the latest **full upgrade firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.xx) - ZodiacFX_vxx_full_install.bin' Follow the firmware update process detailed in **Section 2. Updating Firmware** in the [Zodiac FX User Guide](http://forums.northboundnetworks.com/downloads/zodiac_fx/guides/ZodiacFX_UserGuide_0216.pdf). @@ -28,7 +28,7 @@ Follow the firmware update process detailed in **Section 2. Updating Firmware** The update process has been simplified for the newer releases. -Download the latest **update firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_v0_xx_update.bin' +Download the latest **update firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_vxx_update.bin' * **To update via the CLI**: * In the root context, type the 'update' command @@ -45,8 +45,8 @@ Download the latest **update firmware** from the [Northbound Networks Forums](ht * Click 'Restart' in the web interface header to complete the update * **[Advanced] To update via cURL**: - * Run ['Zodiac_FX_update.sh ZodiacFX_v0_xx_update.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) - * If the firmware upload fails, you may need to run ['Zodiac_FX_update_compatibility.sh ZodiacFX_v0_xx_update.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) instead + * Run ['Zodiac_FX_update.sh ZodiacFX_vxx_update.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) + * If the firmware upload fails, you may need to run ['Zodiac_FX_update_compatibility.sh ZodiacFX_vxx_update.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) instead * Note: on some platforms, a manual restart may be required after uploading the firmware ## Building the Project From 36bf1c1567ecf218ed76205d6a8c4d9e843cb339 Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Tue, 21 Mar 2017 11:21:46 +1100 Subject: [PATCH 162/163] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a74f526..eb3132d 100644 --- a/README.md +++ b/README.md @@ -20,15 +20,15 @@ Starting from version 0.80, Zodiac FX supports firmware updates via the CLI and To update to version 0.80 or later, a **full upgrade firmware** needs to be flashed. -Download the latest **full upgrade firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.xx) - ZodiacFX_vxx_full_install.bin' +Download the latest **full upgrade firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Full Upgrade Firmware (v0.XX) - ZodiacFX_vXX_full_install.bin' -Follow the firmware update process detailed in **Section 2. Updating Firmware** in the [Zodiac FX User Guide](http://forums.northboundnetworks.com/downloads/zodiac_fx/guides/ZodiacFX_UserGuide_0216.pdf). +Follow the firmware update process detailed in **Section 2. Updating Firmware** in the [Zodiac FX User Guide](http://forums.northboundnetworks.com/downloads/zodiac_fx/guides/ZodiacFX_UserGuide_0317.pdf). #### For firmware versions AFTER version 0.80 The update process has been simplified for the newer releases. -Download the latest **update firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.xx) - ZodiacFX_vxx_update.bin' +Download the latest **update firmware** from the [Northbound Networks Forums](http://forums.northboundnetworks.com/index.php?topic=52.0) - 'Update Firmware (v0.XX) - ZodiacFX_vXX_update.bin' * **To update via the CLI**: * In the root context, type the 'update' command @@ -45,8 +45,8 @@ Download the latest **update firmware** from the [Northbound Networks Forums](ht * Click 'Restart' in the web interface header to complete the update * **[Advanced] To update via cURL**: - * Run ['Zodiac_FX_update.sh ZodiacFX_vxx_update.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) - * If the firmware upload fails, you may need to run ['Zodiac_FX_update_compatibility.sh ZodiacFX_vxx_update.bin'](http://forums.northboundnetworks.com/index.php?topic=52.0) instead + * Run the following command: #curl --verbose -0 --form "file=@ZodiacFX_vXX_update.bin" + * If the firmware upload fails, you may need to use the multipart/related content type like so: #curl -H "Content-Type: multipart/related" --verbose -0 --form "file=@ZodiacFX_vXX_update.bin" * Note: on some platforms, a manual restart may be required after uploading the firmware ## Building the Project From ca30f91c2b0914eb692cb6a33e39792f2a93aec1 Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Tue, 21 Mar 2017 11:24:59 +1100 Subject: [PATCH 163/163] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb3132d..6f35202 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,9 @@ Download the latest **update firmware** from the [Northbound Networks Forums](ht * Click 'Restart' in the web interface header to complete the update * **[Advanced] To update via cURL**: - * Run the following command: #curl --verbose -0 --form "file=@ZodiacFX_vXX_update.bin" - * If the firmware upload fails, you may need to use the multipart/related content type like so: #curl -H "Content-Type: multipart/related" --verbose -0 --form "file=@ZodiacFX_vXX_update.bin" - * Note: on some platforms, a manual restart may be required after uploading the firmware + * Run the following command: **curl --verbose -0 --form "file=@ZodiacFX_vXX_update.bin"** + * If the firmware upload fails, you may need to use the multipart/related content type like so: **curl -H "Content-Type: multipart/related" --verbose -0 --form "file=@ZodiacFX_vXX_update.bin"** + * Note: a restart is required after the update to load the new firmware. ## Building the Project