void Debugger::Run() { pc_modified_ = false; while (pc_ != kEndOfSimAddress) { if (pending_request()) RunDebuggerShell(); ExecuteInstruction(); } }
/* processing with map-request */ int generic_process_request(uint32_t request_id, struct communication_fct * fct){ struct db_table * table; struct db_node * rn = NULL; struct prefix p; int is_ddt; struct db_node *node = NULL, *np; int rt; /* look for the eid */ fct->request_get_eid(request_id, &p); table = ms_get_db_table(ms_db,&p); rn = db_node_match_prefix(table, &p); if(!rn){ _request_reply_negative(request_id, fct, rn, &p, 900, 0, 1, 0); fct->request_terminate(request_id); return (FALSE); } fct->request_is_ddt(request_id, &is_ddt); /* Received DDT request */ if(is_ddt){ /*function of {map-register-with-DDT|DDT-node}*/ node = rn; if( !rn->flags || !((struct mapping_flags *)rn->flags)->range){ node = ms_get_target(rn); } if (ms_node_is_type(node, _MAPP)){ /* Only send map-referrel for EDI-prefix auth */ if( !((struct mapping_flags *)node->flags)->referral){ if(ms_node_is_proxy_reply(node)){ rt = _request_reply(request_id, fct, node, NULL); fct->request_terminate(request_id); return rt; } else{ fprintf(OUTPUT_STREAM, "Forwarding to ETR\n"); _request_referral(request_id, fct, node); rt = _forward_to_etr(request_id,node); fct->request_terminate(request_id); return rt; } } if( ((struct mapping_flags *)node->flags)->referral && ((struct mapping_flags *)node->flags)->A){ rt = _request_referral(request_id, fct, node); fct->request_terminate(request_id); return rt; } if( ((struct mapping_flags *)node->flags)->referral && !((struct mapping_flags *)node->flags)->A){ np = node; while(np != table->top){ if (((struct mapping_flags *)np->flags)->referral && ((struct mapping_flags *)np->flags)->A) break; np = np->parent; } if ( (np != table->top) && ((struct mapping_flags *)np->flags)->referral && ((struct mapping_flags *)np->flags)->A){ rt = _request_referral(request_id, fct, np); fct->request_terminate(request_id); return rt; } } } else{ if ( ms_node_is_type(node,_EID) || ms_node_is_type(node,_GEID)){ rt = _request_referral_negative(request_id, fct, node, &p, 60, 1, LISP_REFERRAL_MS_NOT_REGISTERED, 0, 1); fct->request_terminate(request_id); return rt; } else{ if ( ms_node_is_type(node,_GREID) ){ rt = _request_referral_negative(request_id, fct, rn, &p, 60, 0, LISP_REFERRAL_DELEGATION_HOLE,0, 1 ); fct->request_terminate(request_id); return rt; } else{ rt = _request_reply_negative(request_id, fct, node, &p, 900, 0, 1, 0); fct->request_terminate(request_id); return rt; } } } printf("Not process\n"); return (0); } /* Received non DDT request */ else{ //function of {map-resolver |map-register-with-no-DDD-function} node = rn; if(!(rn->flags) || !((struct mapping_flags *)rn->flags)->range){ node = ms_get_target(rn); } if ( ms_node_is_type(node, _MAPP)){ if( !ms_node_is_referral(node)){ if(ms_node_is_proxy_reply(node)){ rt = _request_reply(request_id, fct, node, NULL); fct->request_terminate(request_id); return rt; } else{ fprintf(OUTPUT_STREAM, "Forwarding to ETR\n"); rt = _forward_to_etr(request_id,node); fct->request_terminate(request_id); return rt; } } else{ pending_request(request_id, fct, node); fct->request_terminate(request_id); return 1; } } else{ if ( ms_node_is_type(node,_EID) || ms_node_is_type(node,_GEID)){ if ( ms_node_is_type(node,_EID)) rt = _request_reply_negative(request_id, fct, node, &p, 60, 1, 1, 0); else rt = _request_reply_negative(request_id, fct, node, &p, 900, 1, 1, 0); fct->request_terminate(request_id); return rt; } else{ if ( ms_node_is_type(node,_GREID) ) { rt = _request_reply_negative(request_id, fct, node, &p, 900, 0, 1, 0); fct->request_terminate(request_id); return rt; } else{ rt = _request_reply_negative(request_id, fct, node, &p, 900, 0, 1, 0); fct->request_terminate(request_id); return rt; } } } } printf("Not process\n"); return (0); assert(FALSE); }
void EXTI4_IRQHandler (void) { if (ptr_ITHandler_ext) (*ptr_ITHandler_ext) (); pending_request(4); }
/* ------------------------------------------- afp over dsi. this never returns. */ void afp_over_dsi(AFPObj *obj) { DSI *dsi = (DSI *) obj->handle; int rc_idx; u_int32_t err, cmd; u_int8_t function; AFPobj = obj; obj->exit = afp_dsi_die; obj->reply = (int (*)()) dsi_cmdreply; obj->attention = (int (*)(void *, AFPUserBytes)) dsi_attention; dsi->tickle = 0; afp_over_dsi_sighandlers(obj); if (dircache_init(obj->options.dircachesize) != 0) afp_dsi_die(EXITERR_SYS); /* set TCP snd/rcv buf */ if (obj->options.tcp_rcvbuf) { if (setsockopt(dsi->socket, SOL_SOCKET, SO_RCVBUF, &obj->options.tcp_rcvbuf, sizeof(obj->options.tcp_rcvbuf)) != 0) { LOG(log_error, logtype_dsi, "afp_over_dsi: setsockopt(SO_RCVBUF): %s", strerror(errno)); } } if (obj->options.tcp_sndbuf) { if (setsockopt(dsi->socket, SOL_SOCKET, SO_SNDBUF, &obj->options.tcp_sndbuf, sizeof(obj->options.tcp_sndbuf)) != 0) { LOG(log_error, logtype_dsi, "afp_over_dsi: setsockopt(SO_SNDBUF): %s", strerror(errno)); } } /* set TCP_NODELAY */ int flag = 1; setsockopt(dsi->socket, SOL_TCP, TCP_NODELAY, &flag, sizeof(flag)); /* get stuck here until the end */ while (1) { if (sigsetjmp(recon_jmp, 1) != 0) /* returning from SIGALARM handler for a primary reconnect */ continue; /* Blocking read on the network socket */ cmd = dsi_stream_receive(dsi); if (cmd == 0) { /* cmd == 0 is the error condition */ if (dsi->flags & DSI_RECONSOCKET) { /* we just got a reconnect so we immediately try again to receive on the new fd */ dsi->flags &= ~DSI_RECONSOCKET; continue; } /* the client sometimes logs out (afp_logout) but doesn't close the DSI session */ if (dsi->flags & DSI_AFP_LOGGED_OUT) { LOG(log_note, logtype_afpd, "afp_over_dsi: client logged out, terminating DSI session"); afp_dsi_close(obj); exit(0); } #if 0 /* got ECONNRESET in read from client => exit*/ if (dsi->flags & DSI_GOT_ECONNRESET) { LOG(log_note, logtype_afpd, "afp_over_dsi: client connection reset"); afp_dsi_close(obj); exit(0); } #endif if (dsi->flags & DSI_RECONINPROG) { LOG(log_note, logtype_afpd, "afp_over_dsi: failed reconnect"); afp_dsi_close(obj); exit(0); } /* Some error on the client connection, enter disconnected state */ if (dsi_disconnect(dsi) != 0) afp_dsi_die(EXITERR_CLNT); while (dsi->flags & DSI_DISCONNECTED) pause(); /* gets interrupted by SIGALARM or SIGURG tickle */ continue; /* continue receiving until disconnect timer expires * or a primary reconnect succeeds */ } if (!(dsi->flags & DSI_EXTSLEEP) && (dsi->flags & DSI_SLEEPING)) { LOG(log_debug, logtype_afpd, "afp_over_dsi: got data, ending normal sleep"); dsi->flags &= ~DSI_SLEEPING; dsi->tickle = 0; } if (reload_request) { reload_request = 0; load_volumes(AFPobj); } /* The first SIGINT enables debugging, the next restores the config */ if (debug_request) { static int debugging = 0; debug_request = 0; dircache_dump(); uuidcache_dump(); if (debugging) { if (obj->options.logconfig) setuplog(obj->options.logconfig); else setuplog("default log_note"); debugging = 0; } else { char logstr[50]; debugging = 1; sprintf(logstr, "default log_maxdebug /tmp/afpd.%u.XXXXXX", getpid()); setuplog(logstr); } } dsi->flags |= DSI_DATA; dsi->tickle = 0; switch(cmd) { case DSIFUNC_CLOSE: LOG(log_debug, logtype_afpd, "DSI: close session request"); afp_dsi_close(obj); LOG(log_note, logtype_afpd, "done"); exit(0); case DSIFUNC_TICKLE: dsi->flags &= ~DSI_DATA; /* thats no data in the sense we use it in alarm_handler */ LOG(log_debug, logtype_afpd, "DSI: client tickle"); /* timer is not every 30 seconds anymore, so we don't get killed on the client side. */ if ((dsi->flags & DSI_DIE)) dsi_tickle(dsi); break; case DSIFUNC_CMD: #ifdef AFS if ( writtenfork ) { if ( flushfork( writtenfork ) < 0 ) { LOG(log_error, logtype_afpd, "main flushfork: %s", strerror(errno) ); } writtenfork = NULL; } #endif /* AFS */ function = (u_char) dsi->commands[0]; /* AFP replay cache */ rc_idx = dsi->clientID % REPLAYCACHE_SIZE; LOG(log_debug, logtype_dsi, "DSI request ID: %u", dsi->clientID); if (replaycache[rc_idx].DSIreqID == dsi->clientID && replaycache[rc_idx].AFPcommand == function) { LOG(log_note, logtype_afpd, "AFP Replay Cache match: id: %u / cmd: %s", dsi->clientID, AfpNum2name(function)); err = replaycache[rc_idx].result; /* AFP replay cache end */ } else { /* send off an afp command. in a couple cases, we take advantage * of the fact that we're a stream-based protocol. */ if (afp_switch[function]) { dsi->datalen = DSI_DATASIZ; dsi->flags |= DSI_RUNNING; LOG(log_debug, logtype_afpd, "<== Start AFP command: %s", AfpNum2name(function)); err = (*afp_switch[function])(obj, (char *)&dsi->commands, dsi->cmdlen, (char *)&dsi->data, &dsi->datalen); LOG(log_debug, logtype_afpd, "==> Finished AFP command: %s -> %s", AfpNum2name(function), AfpErr2name(err)); dir_free_invalid_q(); #ifdef FORCE_UIDGID /* bring everything back to old euid, egid */ if (obj->force_uid) restore_uidgid ( &obj->uidgid ); #endif /* FORCE_UIDGID */ dsi->flags &= ~DSI_RUNNING; /* Add result to the AFP replay cache */ replaycache[rc_idx].DSIreqID = dsi->clientID; replaycache[rc_idx].AFPcommand = function; replaycache[rc_idx].result = err; } else { LOG(log_error, logtype_afpd, "bad function %X", function); dsi->datalen = 0; err = AFPERR_NOOP; } } /* single shot toggle that gets set by dsi_readinit. */ if (dsi->flags & DSI_NOREPLY) { dsi->flags &= ~DSI_NOREPLY; break; } else if (!dsi_cmdreply(dsi, err)) { LOG(log_error, logtype_afpd, "dsi_cmdreply(%d): %s", dsi->socket, strerror(errno) ); if (dsi_disconnect(dsi) != 0) afp_dsi_die(EXITERR_CLNT); } break; case DSIFUNC_WRITE: /* FPWrite and FPAddIcon */ function = (u_char) dsi->commands[0]; if ( afp_switch[ function ] != NULL ) { dsi->datalen = DSI_DATASIZ; dsi->flags |= DSI_RUNNING; LOG(log_debug, logtype_afpd, "<== Start AFP command: %s", AfpNum2name(function)); err = (*afp_switch[function])(obj, (char *)&dsi->commands, dsi->cmdlen, (char *)&dsi->data, &dsi->datalen); LOG(log_debug, logtype_afpd, "==> Finished AFP command: %s -> %s", AfpNum2name(function), AfpErr2name(err)); dsi->flags &= ~DSI_RUNNING; #ifdef FORCE_UIDGID /* bring everything back to old euid, egid */ if (obj->force_uid) restore_uidgid ( &obj->uidgid ); #endif /* FORCE_UIDGID */ } else { LOG(log_error, logtype_afpd, "(write) bad function %x", function); dsi->datalen = 0; err = AFPERR_NOOP; } if (!dsi_wrtreply(dsi, err)) { LOG(log_error, logtype_afpd, "dsi_wrtreply: %s", strerror(errno) ); if (dsi_disconnect(dsi) != 0) afp_dsi_die(EXITERR_CLNT); } break; case DSIFUNC_ATTN: /* attention replies */ break; /* error. this usually implies a mismatch of some kind * between server and client. if things are correct, * we need to flush the rest of the packet if necessary. */ default: LOG(log_info, logtype_afpd,"afp_dsi: spurious command %d", cmd); dsi_writeinit(dsi, dsi->data, DSI_DATASIZ); dsi_writeflush(dsi); break; } pending_request(dsi); fce_pending_events(obj); } /* error */ afp_dsi_die(EXITERR_CLNT); }
/* processing with map-request - only MS|NODE|MR function*/ int generic_process_request(void *data, struct communication_fct * fct){ struct db_table * table; struct db_node * rn = NULL; struct prefix p; int is_ddt; struct db_node *node = NULL; int rt; struct pk_req_entry *pke = data; /* look for the eid */ fct->request_get_eid(pke, &p); table = ms_get_db_table(ms_db,&p); rn = db_node_match_prefix(table, &p); fct->request_is_ddt(pke, &is_ddt); /* Received DDT request */ if(is_ddt){ /*function of {map-register-with-DDT|DDT-node}*/ if(!rn){ /*If the requested XEID did not match either a configured delegation or an authoritative XEID-prefix, then the request is dropped and a negative Map-Referral with action code NOT-AUTHORITATIVE is returned. */ if(_fncs & _FNC_NODE){ rt = _request_referral_negative(pke, fct, node, &p, 0, 0, LISP_REFERRAL_NOT_AUTHORITATIVE, 0, 1); } return (TRUE); } node = rn; if( !rn->flags || !((struct mapping_flags *)rn->flags)->range){ node = ms_get_target(rn); } /* existing mapping for request */ if (ms_node_is_type(node, _MAPP)){ /* not referral node, it must belong to MS */ if( !((struct mapping_flags *)node->flags)->referral){ /* do ms function: reply or foward to ETR */ if(_fncs & _FNC_MS){ if(ms_node_is_proxy_reply(node)){ rt = _request_reply(pke, fct, node, NULL); return (TRUE); } cp_log(LDEBUG, "Forwarding to ETR\n"); _request_referral(pke, fct, node); rt = _forward_to_etr(pke,node); return (TRUE); } /*it not be here: it is not MS but is has normal mapping */ return FALSE; } /* referral node, must belong to NODE or MR*/ if ( _fncs & _FNC_NODE){ /*Auth EID referral - return with map-referral*/ if( ((struct mapping_flags *)node->flags)->A ){ rt = _request_referral(pke, fct, node); return (TRUE); }else{ while(node != table->top && (!node->flags || !((struct mapping_flags *)node->flags)->A)) node = node->parent; if(node == table->top){ rt = _request_referral_negative(pke, fct, node, &p, 0, 0, LISP_REFERRAL_NOT_AUTHORITATIVE, 0, 1); return TRUE; } rt = _request_referral(pke, fct, node); return TRUE; } } } else{//not exist mapping if ( _fncs & _FNC_MS || _fncs & _FNC_NODE){ /* node has type */ while (node != table->top && ( !node->flags || !( ((struct mapping_flags *)node->flags)->range & (_EID | _GEID | _GREID)) )) node = node->parent; if(node == table->top){ rt = _request_referral_negative(pke, fct, node, &p, 0, 0, LISP_REFERRAL_NOT_AUTHORITATIVE, 0, 1); return TRUE; }else{ switch (((struct mapping_flags *)node->flags)->range){ case _EID: /* EID not is registered */ if ( _fncs & _FNC_MS){ rt = _request_referral_negative(pke, fct, node, &p, 60, 1, LISP_REFERRAL_MS_NOT_REGISTERED, 0, 1); return TRUE; } break; case _GEID:/* EID not assign for any ETR */ if ( _fncs & _FNC_MS){ /* in ieft, this case is same as _EID, but it think TTL must longer*/ rt = _request_referral_negative(pke, fct, node, &p, 900, 1, LISP_REFERRAL_MS_NOT_REGISTERED, 0, 1); return TRUE; } break; case _GREID:/* EID not delegated */ if ( _fncs & _FNC_NODE){ rt = _request_referral_negative(pke, fct, rn, &p, 60, 0, LISP_REFERRAL_DELEGATION_HOLE,0, 1 ); return TRUE; } break; } /*can not here or database has problem */ return FALSE; } } } cp_log(LDEBUG, "Not process...ignore packet\n"); return FALSE; } /* Received non DDT request */ else{ /*function of {map-resolver |map-register-with-no-DDD-function} */ node = rn; if(!(rn->flags) || !((struct mapping_flags *)rn->flags)->range){ node = ms_get_target(rn); } if ( ms_node_is_type(node, _MAPP)){ /* node is MAPP, must belong to MS */ if( !ms_node_is_referral(node)){ if(_fncs & _FNC_MS){ if(ms_node_is_proxy_reply(node)){ rt = _request_reply(pke, fct, node, NULL); return rt; } else{ cp_log(LDEBUG, "Forwarding to ETR\n"); rt = _forward_to_etr(pke,node); return rt; } } return FALSE; } else{ /* do MR function */ if(_fncs & _FNC_MR){ pending_request(pke, fct, node); return 1; } } } else{/*node is not mapping */ while (node != table->top && ( !node->flags || !( ((struct mapping_flags *)node->flags)->range & (_EID | _GEID)) )) node = node->parent; if(_fncs & _FNC_MS){ if(node == table->top) return FALSE; if ( ms_node_is_type(node,_EID)) rt = _request_reply_negative(pke, fct, node, &p, 60, 1, 1, 0); else rt = _request_reply_negative(pke, fct, node, &p, 900, 1, 1, 0); return TRUE; } if(_fncs & _FNC_MR){ pending_request(pke, fct, node); return TRUE; } } } cp_log(LDEBUG, "Not process...ignore packet\n"); return FALSE; }