void handlesession(){ //handle a session once it's established unsigned int rsize,strncmpval; rsize=recv_size(); printf("**rsz=%d\n",rsize); if (rsize>0){ thisip.l=getip(); if (recv0(buf,min(24,rsize))>0){ //get enough characters to distinguish the request printf("%s\n",buf); if (strncmp((char *)buf,"POST /",6)==0){ bagelsinit(); //initialize game, send the form uptime+=311; //250ms allowed for initialization } else if (strncmp((char *)buf,"GET /favicon",12)==0){ sendnak(); //no favicon here uptime+=100; //100ms allowed for nak } else if (strncmp((char *)buf,"GET /?G=",8)==0){ bagelsturn(); //give player his turn uptime+=376; //200ms allowed for each turn } else if (strncmp((char *)buf,"GET /",5)==0){ bagelsinit(0); //initialize game, send the form uptime+=311; //250ms allowed for initialization } else{ printf("\nmystery meat\n"); bagelsinit(0); //initialize game, send the form uptime+=311; //250ms allowed for initialization } } } if (rsize>0) flush(rsize); //get rid of the received data disconnect0(); //in any case, we're done here printf("done\n>\n"); }
void handlesession(){ //handle a session once it's established unsigned int rsize,strncmpval; //printf("\ngetting received size\n"); rsize=recv_size(); printf("**rsz=%d\n",rsize); if (rsize>0){ if (recv0(buf,min(12,rsize))>0){ //buf[12]=0; printf("%s\n",buf); strncmpval=strncmp((char *)buf,"POST /",6); if (strncmp((char *)buf,"POST /",6)==0){ handlepost(); //handle a button press } else if (strncmp((char *)buf,"GET /favicon",12)==0){ sendnak(); //no favicon here } else if (strncmp((char *)buf,"GET /",5)>=0){ sendform(); //send the form } else{ printf("\nmystery meat\n"); } //flush(rsize); //get rid of the received data //disconnect0(); //in any case, we're done here } } if (rsize>0) flush(rsize); //get rid of the received data disconnect0(); //in any case, we're done here printf("done\n>\n"); }
void handlesession(){ //handle a session once it's established unsigned int rsize,strncmpval; rsize=recv_size(); printf("**rsz=%d\n",rsize); if (rsize>0){ if (recv0(buf,rsize/*min(24,rsize)*/)>0){ //get enough characters to distinguish the request buf[rsize]=0; printf("%s\n",buf); if (strncmp((char *)buf,"POST /",6)==0){ bagelspturn(); //players turn with type=post } else if (strncmp((char *)buf,"GET /favicon",12)==0){ sendnak(); //no favicon here } else if (strncmp((char *)buf,"GET /?G=",8)==0){ bagelsturn(); //give player his turn } else if (strncmp((char *)buf,"GET /",5)==0){ bagelsinit(0); //initialize game, send the form } else{ printf("\nmystery meat\n"); bagelsinit(0); //initialize game, send the form } } } if (rsize>0) flush(rsize); //get rid of the received data disconnect0(); //in any case, we're done here printf("done\n>\n"); }
BOOST_FIXTURE_TEST_CASE(get_correct_payload, F) { logsvc::prot::ClientHandle ch0(0x1234); logsvc::prot::Disconnect disconnect0(ch0); BOOST_CHECK_EQUAL(ch0.get_payload(), disconnect0.get_payload()); logsvc::prot::ClientHandle ch1(0x12345678); logsvc::prot::Disconnect disconnect1(ch1); BOOST_CHECK_EQUAL(ch1.get_payload(), disconnect1.get_payload()); }
unsigned int send0(unsigned char *buf,unsigned int buflen){ unsigned int ptr,offaddr,realaddr,txsize,timeout; //printf("send0 %d\n",buflen); if (buflen <= 0) return 0; // Make sure the TX Free Size Register is available txsize=SPI_Read(SO_TX_FSR); txsize=(((txsize & 0x00FF) << 8 ) + SPI_Read(SO_TX_FSR + 1)); timeout=0; while (txsize < buflen) { delay(1); txsize=SPI_Read(SO_TX_FSR); txsize=(((txsize & 0x00FF) << 8 ) + SPI_Read(SO_TX_FSR + 1)); // Timeout for approx 1000 ms if (timeout++ > 1000) { printf("TX Free Size Error!\n"); // Disconnect the connection disconnect0(); return 0; } } // Read the Tx Write Pointer ptr = SPI_Read(S0_TX_WR); offaddr = (((ptr & 0x00FF) << 8 ) + SPI_Read(S0_TX_WR + 1)); while(buflen) { buflen--; // Calculate the real W5100 physical Tx Buffer Address realaddr = TXBUFADDR + (offaddr & TX_BUF_MASK); // Copy the application data to the W5100 Tx Buffer SPI_Write(realaddr,*buf); offaddr++; buf++; } // Increase the S0_TX_WR value, so it point to the next transmit SPI_Write(S0_TX_WR,(offaddr & 0xFF00) >> 8 ); SPI_Write(S0_TX_WR + 1,(offaddr & 0x00FF)); // Now Send the SEND command SPI_Write(S0_CR,CR_SEND); // Wait for Sending Process while(SPI_Read(S0_CR)); return 1; }