39 static char* httpHeader =
"HTTP/1.1 ";
40 static char* generalHeaderBegin =
"Cache-Control: private\r\nContent-Type: text/plain; charset=utf-8\r\nServer: cloudFPGA/";
41 static char* httpNL =
"\r\n";
42 static char* contentLengthHeader =
"Content-Length: ";
44 static char* status200 =
"200 OK";
45 static char* status400 =
"400 Bad Request";
46 static char* status403 =
"403 Forbidden";
47 static char* status404 =
"404 Not Found";
48 static char* status422 =
"422 Unprocessable Entity";
49 static char* status500 =
"500 Internal Server Error";
95 unsigned char temp, len=0, i=0;
97 if(
str ==
'\0' || !(*
str) )
100 while(
str[len] !=
'\0')
121 unsigned char i=0,rem=0;
130 while (num != 0 && i<=64)
133 arr[i++] = (rem > 9)? (rem-10) +
'A' : rem +
'0';
141 for(
int p = 0; p<i; p++)
146 printf(
"written unsigned long %s of length %d with basis %d\n",arr,i, (
int) base);
153 void my_itoa(
unsigned long num,
char *arr,
unsigned char base)
155 unsigned char i=0,rem=0;
168 arr[i++] = (rem > 9)? (rem-10) +
'A' : rem +
'0';
181 for (
int i = 0; i < strlen; ++i)
183 res = res*10 + (
str[i] -
'0');
249 while(*tmp1 && tmp2[cnt])
251 if(*tmp1== tmp2[cnt])
268 if (cnt == max_length )
278 static char *statusPath =
"GET /status ";
279 static char *configurePath =
"POST /configure ";
280 static char *putRank =
"PUT /rank/";
281 static char *putSize =
"PUT /size/";
282 static char *postRouting =
"POST /routing ";
295 char c1 = 0, c2 = 0, c3 = 0, c4 = 0;
296 c1 = (char)
bufferIn[offset + 0 + 0];
297 c2 = (char)
bufferIn[offset + 0 + 1];
298 c3 = (char)
bufferIn[offset + 0 + 2];
299 c4 = (char)
bufferIn[offset + 0 + 3];
301 while( (c1 !=
'\r' || c2 !=
'\n' || c3 !=
'\r' || c4 !=
'\n' ) && sum < maxLength)
305 c1 = (char)
bufferIn[offset + sum + 0];
306 c2 = (char)
bufferIn[offset + sum + 1];
307 c3 = (char)
bufferIn[offset + sum + 2];
308 c4 = (char)
bufferIn[offset + sum + 3];
312 if (sum >= maxLength)
327 printf(
"stringlen: %d\n",(
int) stringlen);
336 printf(
"requestLen: %d\n",(
int) requestLen);
368 ap_uint<32> newRank = (
unsigned int)
my_atoi(intStart, intLen);
381 ap_uint<32> newSize = (
unsigned int)
my_atoi(intStart, intLen);
401 void parseHttpInput(
bool transferErr, ap_uint<1> wasAbort,
bool invalidPayload,
bool rx_done)
452 }
else if (transferErr ==
true || invalidPayload ==
true)
482 printf(
"parseHttpInput returns with state %d\n",
httpState);
#define CFDK_VERSION_STRING
uint16_t bufferOutContentLength
#define HTTP_REQUEST_COMPLETE
#define HTTP_HEADER_PARSED
int8_t writeHttpStatus(int status, uint16_t content_length)
int my_atoi(char *str, int strlen)
#define HTTP_SEND_RESPONSE
void setRank(ap_uint< 32 > newRank)
void parseHttpInput(bool transferErr, ap_uint< 1 > wasAbort, bool invalidPayload, bool rx_done)
int writeUnsignedLong(unsigned long num, uint8_t base)
#define HTTP_PARSE_HEADER
#define PAYLOAD_BYTES_PER_PAGE
int my_strcmp(char *tmp1, volatile uint8_t tmp2[4096], int max_length)
uint16_t bufferOutPtrWrite
uint32_t writeDisplaysToOutBuffer()
int8_t extract_path(bool rx_done)
uint32_t bufferInPtrNextRead
int request_len(ap_uint< 16 > offset, int maxLength)
void my_itoa(unsigned long num, char *arr, unsigned char base)
void setSize(ap_uint< 32 > newSize)
#define HTTP_READ_PAYLOAD
#define HTTP_INVALID_REQUEST
: The HTTP parsing functions for the FMC.