bool __plugin_setting_dataxserver(void *class_ptr, char *method_name, void *input_pack) { uint8_t *arg_ptr = (uint8_t *)input_pack; char *ip; bool res = true; memcpy(&ip, arg_ptr, sizeof(char *)); arg_ptr += sizeof(char *); Serial1.printf("%s\r\n", ip); if (extract_ip(ip, EEPROM.getDataPtr() + EEP_DATA_SERVER_IP)) { memcpy(EEPROM.getDataPtr() + EEP_DATA_SERVER_ADDR, ip, strlen(ip)); memset(EEPROM.getDataPtr() + EEP_DATA_SERVER_ADDR + strlen(ip) , 0, 1); EEPROM.commit(); stream_print(STREAM_CMD, TYPE_STRING, "\"ok\""); response_msg_close(STREAM_CMD); delay(100); fire_reboot(NULL); } else { stream_print(STREAM_CMD, TYPE_STRING, "\"failed, bad ip format.\""); return false; } return true; }
int call_status(struct re_printf *pf, const struct call *call) { struct le *le; int err; if (!call) return EINVAL; switch (call->state) { case STATE_EARLY: case STATE_ESTABLISHED: break; default: return 0; } err = re_hprintf(pf, "\r[%H]", print_duration, call); FOREACH_STREAM err |= stream_print(pf, le->data); err |= re_hprintf(pf, " (bit/s)"); #ifdef USE_VIDEO if (call->video) err |= video_print(pf, call->video); #endif return err; }
void disrupt_stream_detection(struct iphdr * ip_hdr, struct udphdr * udp_hdr){ stream = stream_get(stream_head, ip_hdr->saddr, udp_hdr->source, ip_hdr->daddr, udp_hdr->dest); if( !stream ){ stream = stream_head = stream_add(stream_head, ip_hdr->saddr, udp_hdr->source, ip_hdr->daddr, udp_hdr->dest); stream->scenario.qh = d_nfq.qh; struct timeval t; gettimeofday(&t,NULL); stream->start = t; stream->scenario.filename=scenario_filename; scenario_init_xml(stream); log_info("********** new stream detected *********"); stream_print(stream_head); log_info("****************************************"); } packet.stream = stream; }
int main( int argc, char *argv[] ) { if( argc == 4 ) { stream_t *in = stream_string( argv[2] ); stream_t *gen = stream_string( argv[3] ); /** Process the transmit option */ if( 0 == strncmp( argv[1], "transmit", 8 ) ) { stream_t *out = transmit( in, gen ); stream_print( out ); printf( "\n" ); } /** Process the check option */ else if( 0 == strncmp( argv[1], "check", 5 ) ) { printf( "%s\n", check( in, gen )? "error detected" : "no error detected" ); } else { usage(); } } else if( argc == 2 ) { /** Process the test option */ if( 0 == strncmp( argv[1], "test", 4 ) ) { stream_t *gen = stream_string( CRC32_GEN ); srand( time( NULL ) ); int errorslt = 0; int countlt = 0; int errorseq = 0; int counteq = 0; int errorsgt = 0; int countgt = 0; /** Generate test cases */ for( int i = 0; i < NTEST; i++ ) { stream_t *in = stream_random( FRAME_SIZE * 8 ); stream_t *out = transmit( in, gen ); /** mod by 3 to resolve the <, =, > 32 cases */ int cat = i % 3; switch( cat ) { case 0: countlt++; burst( out, 1 + ( rand() % 31 ) ); errorslt += check( out, gen )? 1 : 0; break; case 1: counteq++; burst( out, 32 ); errorseq += check( out, gen )? 1 : 0; break; case 2: countgt++; burst( out, 33 + ( rand() % ( FRAME_SIZE * 8 - 34 ) ) ); errorsgt += check( out, gen )? 1 : 0; break; } free( in ); free( out ); } printf( "%d/%d burst errors < 32 were detected.\n", errorslt, countlt ); printf( "%d/%d burst errors = 32 were detected.\n", errorseq, counteq ); printf( "%d/%d burst errors > 32 were detected.\n", errorsgt, countgt ); } else { usage(); } } else { usage(); } }
void writer_print(type_t type, const void *data, bool append_comma) { stream_print(STREAM_DATA, type, data, append_comma); }