int main(void) { /* initialization */ gnrc_pktbuf_init(); msg_init_queue(_main_msg_queue, _MAIN_MSG_QUEUE_SIZE); netdev2_test_setup(&_dev, NULL); netdev2_test_set_isr_cb(&_dev, _dev_isr); netdev2_test_set_recv_cb(&_dev, _dev_recv); netdev2_test_set_send_cb(&_dev, _dev_send); netdev2_test_set_get_cb(&_dev, NETOPT_ADDRESS, _dev_get_addr); netdev2_test_set_set_cb(&_dev, NETOPT_ADDRESS, _dev_set_addr); gnrc_netdev2_eth_init(&_gnrc_dev, (netdev2_t *)(&_dev)); _mac_pid = gnrc_netdev2_init(_mac_stack, _MAC_STACKSIZE, _MAC_PRIO, "gnrc_netdev_eth_test", &_gnrc_dev); if (_mac_pid <= KERNEL_PID_UNDEF) { puts("Could not start MAC thread\n"); return 1; } /* test execution */ EXECUTE(test_get_addr); EXECUTE(test_send); EXECUTE(test_receive); EXECUTE(test_set_addr); puts("ALL TESTS SUCCESSFUL"); return 0; }
/* * function registered to HOOK_DISPATCHER * check the regex (if present) and log packets */ static void log_packet(struct packet_object *po) { /* * skip packet sent (spoofed) by us * else we will get duplicated hosts with our mac address * this is necessary because check_forwarded() is executed * in ec_ip.c, but here we are getting even arp packets... */ EXECUTE(EC_GBL_SNIFF->check_forwarded, po); if (po->flags & PO_FORWARDED) return; /* * recheck if the packet is compliant with the visualization filters. * we need to redo the test, because here we are hooked to ARP and ICMP * packets that are before the test in ec_decode.c */ po->flags |= PO_IGNORE; EXECUTE(EC_GBL_SNIFF->interesting, po); if ( po->flags & PO_IGNORE ) return; /* the regex is set, respect it */ if (EC_GBL_OPTIONS->regex) { if (regexec(EC_GBL_OPTIONS->regex, (const char*)po->DATA.disp_data, 0, NULL, 0) == 0) log_write_packet(&fdp, po); } else { /* if no regex is set, dump all the packets */ log_write_packet(&fdp, po); } }
/* * function registered to HOOK_DISPATCHER * it is a wrapper to the real one */ static void log_info(struct packet_object *po) { /* * skip packet sent (spoofed) by us * else we will get duplicated hosts with our mac address * this is necessary because check_forwarded() is executed * in ec_ip.c, but here we are getting even arp packets... */ EXECUTE(EC_GBL_SNIFF->check_forwarded, po); if (po->flags & PO_FORWARDED) return; /* * recheck if the packet is compliant with the visualization filters. * we need to redo the test, because here we are hooked to ARP and ICMP * packets that are before the test in ec_decode.c */ po->flags |= PO_IGNORE; EXECUTE(EC_GBL_SNIFF->interesting, po); if ( po->flags & PO_IGNORE ) return; /* if all the tests are ok, write it to the disk */ if (po->L4.proto == NL_TYPE_ICMP || po->L3.proto == htons(LL_TYPE_ARP)) log_write_info_arp_icmp(&fdi, po); else log_write_info(&fdi, po); }
void daemon_interface(void) { DEBUG_MSG("daemon_interface"); /* check if the plugin exists */ if (GBL_OPTIONS->plugin && search_plugin(GBL_OPTIONS->plugin) != ESUCCESS) FATAL_ERROR("%s plugin can not be found !", GBL_OPTIONS->plugin); /* build the list of active hosts */ build_hosts_list(); /* start the mitm attack */ mitm_start(); /* initialize the sniffing method */ EXECUTE(GBL_SNIFF->start); /* if we have to activate a plugin */ if (GBL_OPTIONS->plugin && plugin_init(GBL_OPTIONS->plugin) != PLUGIN_RUNNING) /* end the interface */ return; /* discard the messages */ LOOP { CANCELLATION_POINT(); sleep(1); ui_msg_flush(MSG_ALL); } /* NOT REACHED */ }
static void curses_start_sniffing(void) { DEBUG_MSG("curses_start_sniffing"); /* start the sniffing method */ EXECUTE(GBL_SNIFF->start); }
static void curses_stop_sniffing(void) { DEBUG_MSG("curses_stop_sniffing"); /* terminate the sniffing engine */ EXECUTE(GBL_SNIFF->cleanup); }
int csSelPoint_Volume( char *action, double *lo, double *hi ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv[ 4 ]; assert( md->edit == NULL ); argv[ 0 ].type = DY_STRING; argv[ 0 ].str.buf = action; argv[ 0 ].str.bufLen = 0; argv[ 1 ].type = DY_STRING; argv[ 1 ].str.buf = "VOLUME"; argv[ 1 ].str.bufLen = 0; argv[ 2 ].type = DY_VFLOAT; argv[ 2 ].fvec.val[ 0 ] = lo[ 0 ]; argv[ 2 ].fvec.val[ 1 ] = lo[ 1 ]; argv[ 2 ].fvec.val[ 2 ] = lo[ 2 ]; argv[ 3 ].type = DY_VFLOAT; argv[ 3 ].fvec.val[ 0 ] = hi[ 0 ]; argv[ 3 ].fvec.val[ 1 ] = hi[ 1 ]; argv[ 3 ].fvec.val[ 2 ] = hi[ 2 ]; LOOKUP( "SEL_POINT" ); EXECUTE( 4, argv ); return OK; }
int csSelPolygon_Nonplanar( char *action, double limit ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv[ 3 ]; assert( md->edit == NULL ); argv[ 0 ].type = DY_STRING; argv[ 0 ].str.buf = action; argv[ 0 ].str.bufLen = 0; argv[ 1 ].type = DY_STRING; argv[ 1 ].str.buf = "NONPLANAR"; argv[ 1 ].str.bufLen = 0; if ( limit >= 0.0 ) { argv[ 2 ].type = DY_FLOAT; argv[ 2 ].flt.value = limit; } else argv[ 2 ].type = DY_NULL; LOOKUP( "SEL_POLYGON" ); EXECUTE( 3, argv ); return OK; }
int csAxisDrill( char *operation, char *axis, char *surface ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv[ 3 ]; assert( md->edit == NULL ); argv[ 0 ].type = DY_STRING; argv[ 0 ].str.buf = operation; argv[ 0 ].str.bufLen = 0; argv[ 1 ].type = DY_STRING; argv[ 1 ].str.buf = axis; argv[ 1 ].str.bufLen = 0; if ( surface ) { argv[ 2 ].type = DY_STRING; argv[ 2 ].str.buf = surface; argv[ 2 ].str.bufLen = 0; } else argv[ 2 ].type = DY_NULL; LOOKUP( "AXISDRILL" ); EXECUTE( 3, argv ); return OK; }
/* * the redirect function. * * redirect all the traffic that goes thru the gateway * check the dst mac address and the dst ip address. * * respect the TARGETs for the redirections */ static void icmp_redirect(struct packet_object *po) { struct ip_list *i; char tmp[MAX_ASCII_ADDR_LEN]; /* retrieve the gw ip */ i = LIST_FIRST(&redirected_gw.ips); /* the packet must be directed to the gateway */ if (memcmp(po->L2.dst, redirected_gw.mac, MEDIA_ADDR_LEN)) return; /* * if the packet endpoint is the gateway, skip it. * we are interested only in packet going THRU the * gateway, not TO the gateway */ if (!ip_addr_cmp(&po->L3.dst, &i->ip)) return; /* redirect only the connection that match the TARGETS */ EXECUTE(GBL_SNIFF->interesting, po); /* the packet is not interesting */ if ( po->flags & PO_IGNORE ) return; USER_MSG("ICMP redirected %s:%d -> ", ip_addr_ntoa(&po->L3.src, tmp), ntohs(po->L4.src)); USER_MSG("%s:%d\n", ip_addr_ntoa(&po->L3.dst, tmp), ntohs(po->L4.dst)); /* send the ICMP redirect */ send_icmp_redir(ICMP_REDIRECT_HOST, &i->ip, &GBL_IFACE->ip, po); }
void clean_exit(int errcode) { DEBUG_MSG("clean_exit: %d", errcode); INSTANT_USER_MSG("\nTerminating %s...\n", GBL_PROGRAM); #ifdef HAVE_EC_LUA /* Cleanup lua */ ec_lua_fini(); #endif /* flush the exit message */ ui_msg_flush(MSG_ALL); /* stop the mitm attack */ mitm_stop(); /* terminate the sniffing engine */ EXECUTE(GBL_SNIFF->cleanup); /* kill all the running threads but the current */ ec_thread_kill_all(); /* close the UI */ ui_cleanup(); /* call all the ATEXIT functions */ exit(errcode); }
void _ro_SETUP_rc_() // (SETUP) { Push(0x01b8); _2_at_(); // 2@ Push(Pop() | Pop()); // OR Push(Pop()==0?1:0); // 0= if (Pop() == 0) return; Push(0x001b); _ro__ex_OLD_rc_(); // (!OLD) Push(0x01b8); _2_ex__2(); // 2!_2 _ro_CS_ask__rc_(); // (CS?) Push(0x08a0); Push(0x001b); _ro__ex_SET_rc_(); // (!SET) Push(0x001c); _ro__ex_OLD_rc_(); // (!OLD) Push(0x01bc); _2_ex__2(); // 2!_2 _ro_CS_ask__rc_(); // (CS?) Push(0x018e); Push(0x001c); _ro__ex_SET_rc_(); // (!SET) Push(0); _ro__ex_OLD_rc_(); // (!OLD) Push(0x01c0); _2_ex__2(); // 2!_2 SET0_slash_(); // SET0/ Push(Read16(pp__i_SETUP_plus_)); // 'SETUP+ @ if (Read16(regsp) != 0) Push(Read16(regsp)); // ?DUP if (Pop() == 0) return; EXECUTE(); // EXECUTE }
void ui_cleanup(void) { if (GBL_UI->initialized) { DEBUG_MSG("ui_cleanup"); EXECUTE(GBL_UI->cleanup); GBL_UI->initialized = 0; } }
void ui_init(void) { DEBUG_MSG("ui_init"); EXECUTE(GBL_UI->init); GBL_UI->initialized = 1; }
CmCError Run(CmCParser *script) { //define and initialize parameter table void *(paramTable)[PARAM_NUM + 2*CUST_CURVE_NUM]; int i; for(i = 0; i < PARAM_NUM + 2*CUST_CURVE_NUM; i++) paramTable[i] = (void *) NULL; //parse script, setting parameters and //running commands along the way... int tokenId, error; CmCToken *token; while(token = script->GetToken()) { //determine type of token (parameter or command) tokenId = Command(token->token_); //token is a command, so run it if(tokenId != UNKNOWN_COMMAND) { error = EXECUTE(tokenId, script, paramTable); if(error) { if(error == EXE_MISSING_PARAM) { CmCToken *ertok = new CmCToken((char *) PARAM_LIST[findMissing(paramTable, Command(token->token_))], token->lineNumber_); return CmCError(ertok, error); } else { return CmCError(token, error); } } } //token is a parameter, so set its value else { tokenId = Parameter(token->token_); if(tokenId != UNKNOWN_PARAMETER) { error = SET(tokenId, script, paramTable); if(error) return CmCError(token, error); //token is custum curve list, so read it } else { tokenId = CustomCurve(token->token_); error = READLIST(tokenId, script, paramTable); if(error) return CmCError(token, error); } } } //done running script... //de-allocate parameter table DEALLOCATE(paramTable); //reset script parser script->StartOver(); //script has been run succesfully! return CmCError((CmCToken *) NULL, NO_ERRORS); }
void ui_start(void) { DEBUG_MSG("ui_start"); if (GBL_UI->initialized) EXECUTE(GBL_UI->start); else DEBUG_MSG("ui_start called initialized"); }
int csMakeText( char *text, int index, char *cornertype, double spacing, double scale, char *axis, double *pos ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv[ 7 ]; assert( md->edit == NULL ); argv[ 0 ].type = DY_STRING; argv[ 0 ].str.buf = text; argv[ 0 ].str.bufLen = 0; argv[ 1 ].type = DY_INTEGER; argv[ 1 ].intv.value = index; if ( cornertype ) { argv[ 2 ].type = DY_STRING; argv[ 2 ].str.buf = cornertype; argv[ 2 ].str.bufLen = 0; } else argv[ 2 ].type = DY_NULL; if ( spacing != 0.0 ) { argv[ 3 ].type = DY_FLOAT; argv[ 3 ].flt.value = spacing; } else argv[ 3 ].type = DY_NULL; if ( scale != 0.0 ) { argv[ 4 ].type = DY_FLOAT; argv[ 4 ].flt.value = scale; } else argv[ 4 ].type = DY_NULL; if ( axis ) { argv[ 5 ].type = DY_STRING; argv[ 5 ].str.buf = axis; argv[ 5 ].str.bufLen = 0; } else argv[ 5 ].type = DY_NULL; if ( pos ) { argv[ 6 ].type = DY_VFLOAT; argv[ 6 ].fvec.val[ 0 ] = pos[ 0 ]; argv[ 6 ].fvec.val[ 1 ] = pos[ 1 ]; argv[ 6 ].fvec.val[ 2 ] = pos[ 2 ]; } else argv[ 6 ].type = DY_NULL; LOOKUP( "MAKETEXT" ); EXECUTE( 7, argv ); return OK; }
int csInvertHide( void ) { static LWCommandCode ccode; ModData *md = getModData(); assert( md->edit == NULL ); LOOKUP( "INVERT_HIDE" ); EXECUTE( 0, NULL ); return OK; }
int csSelUnhide( void ) { static LWCommandCode ccode; ModData *md = getModData(); assert( md->edit == NULL ); LOOKUP( "SEL_UNHIDE" ); EXECUTE( 0, NULL ); return OK; }
int csSelInvert( void ) { static LWCommandCode ccode; ModData *md = getModData(); assert( md->edit == NULL ); LOOKUP( "SEL_INVERT" ); EXECUTE( 0, NULL ); return OK; }
void _stdcall VFP2C_Destroy_Marshal() { if (ghHeap) HeapDestroy(ghHeap); #ifdef _DEBUG FreeDebugAlloc(); #endif EXECUTE("CLEAR DLLS 'WriteChar','WritePChar','WriteInt8','WritePInt8','WriteUInt8','WritePUInt8','WriteShort'," "'WritePShort','WriteUShort','WritePUShort','WriteInt','WritePInt','WriteUInt','WritePUInt','WritePointer','WritePPointer'," "'WriteFloat','WritePFloat','WriteDouble','WritePDouble','ReadInt8','ReadPInt8','ReadUInt8','ReadPUInt8','ReadShort'," "'ReadPShort','ReadUShort','ReadPUShort','ReadInt','ReadPInt','ReadFloat','ReadPFloat','ReadDouble','ReadPDouble'"); }
int csSmoothScale( double offset ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv; assert( md->edit == NULL ); argv.type = DY_FLOAT; argv.flt.value = offset; LOOKUP( "SMOOTHSCALE" ); EXECUTE( 1, &argv ); return OK; }
/* * the FATAL_ERROR error handling function */ void ui_fatal_error(const char *msg) { /* * call the function * make sure that the globals have been alloc'd */ if (GBLS && GBL_UI && GBL_UI->fatal_error && GBL_UI->initialized) EXECUTE(GBL_UI->fatal_error, msg); /* the interface is not yet initialized */ else { fprintf(stderr, "\n%s\n\n", msg); exit(-1); } }
int csChangeSurface( char *surface ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv; assert( md->edit == NULL ); argv.type = DY_STRING; argv.str.buf = surface; argv.str.bufLen = 0; LOOKUP( "CHANGESURFACE" ); EXECUTE( 1, &argv ); return OK; }
int csShapeBevel( int npairs, double *insh ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv; assert( md->edit == NULL ); argv.type = DY_CUSTOM; argv.cust.val[ 0 ] = npairs; argv.cust.val[ 1 ] = ( int ) insh; LOOKUP( "SHAPEBEVEL" ); EXECUTE( 1, &argv ); return OK; }
int csBoolean( char *operation ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv; assert( md->edit == NULL ); argv.type = DY_STRING; argv.str.buf = operation; argv.str.bufLen = 0; LOOKUP( "BOOLEAN" ); EXECUTE( 1, &argv ); return OK; }
int csSelHide( char *state ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv; assert( md->edit == NULL ); argv.type = DY_STRING; argv.str.buf = state; argv.str.bufLen = 0; LOOKUP( "SEL_HIDE" ); EXECUTE( 1, &argv ); return OK; }
int csSetDefaultSurface( char *surfname ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv; assert( md->edit == NULL ); argv.type = DY_SURFACE; argv.str.buf = surfname; argv.str.bufLen = 0; LOOKUP( "SURFACE" ); EXECUTE( 1, &argv ); return OK; }
/* * the FATAL_MSG error handling function */ void ui_error(const char *fmt, ...) { va_list ap; int n; size_t size = 50; char *msg; /* * we hope the message is shorter * than 'size', else realloc it */ SAFE_CALLOC(msg, size, sizeof(char)); while (1) { /* Try to print in the allocated space. */ va_start(ap, fmt); n = vsnprintf (msg, size, fmt, ap); va_end(ap); /* If that worked, we have finished. */ if (n > -1 && (size_t)n < size) break; /* Else try again with more space. */ if (n > -1) /* glibc 2.1 */ size = n+1; /* precisely what is needed */ else /* glibc 2.0 */ size *= 2; /* twice the old size */ SAFE_REALLOC(msg, size); } /* dump the error in the debug file */ DEBUG_MSG("%s", msg); /* call the function */ if (GBL_UI->error) EXECUTE(GBL_UI->error, msg); /* the interface is not yet initialized */ else fprintf(stderr, "\n%s\n", msg); /* free the message */ SAFE_FREE(msg); }
int csBevel( double inset, double shift ) { static LWCommandCode ccode; ModData *md = getModData(); DynaValue argv[ 2 ]; assert( md->edit == NULL ); argv[ 0 ].type = DY_DISTANCE; argv[ 0 ].flt.value = inset; argv[ 1 ].type = DY_DISTANCE; argv[ 1 ].flt.value = shift; LOOKUP( "BEVEL" ); EXECUTE( 2, argv ); return OK; }