/** @brief helper function to send task */ int process_send_call(reg_s * reg, process_descriptor_t * proc, process_descriptor_t * remote_proc, void * data) { XBT_DEBUG("Entering process_send_call"); if (socket_registered(proc, (int) reg->arg[0]) != -1) { if (!socket_netlink(proc, (int) reg->arg[0])) { XBT_DEBUG("%d This is not a netlink socket", (int) reg->arg[0]); // compute_computation_time(proc); // cree la computation task struct infos_socket *is = get_infos_socket(proc, (int) reg->arg[0]); struct infos_socket *s = comm_get_peer(is); is->ref_nb++; s->ref_nb++; XBT_DEBUG("%d->%d", (int) reg->arg[0], (int) reg->ret); XBT_DEBUG("Sending data(%d) on socket %d", (int) reg->ret, s->fd.fd); handle_new_send(reg, is, data); msg_task_t task = create_send_communication_task(proc, is, (int) reg->ret, proc->host, s->fd.proc->host); XBT_DEBUG("hosts: %s send to %s (size: %d)", MSG_host_get_name(proc->host), MSG_host_get_name(s->fd.proc->host), (int) reg->ret); MSG_task_set_bytes_amount(task, (int) reg->ret); MSG_task_set_data(task, data); send_task(s->fd.proc->host, task); is->ref_nb--; s->ref_nb--; return 1; } return 0; } else xbt_die("The socket is not registered"); return 0; }
/** @brief handles shutdown syscall at the exit in case of address translation */ void syscall_shutdown_post(reg_s * reg, process_descriptor_t * proc) { XBT_DEBUG("shutdown_post"); proc_outside(proc); struct infos_socket *is = get_infos_socket(proc, (int) reg->arg[0]); if (is == NULL) { reg->ret = -EBADF; return; } comm_shutdown(is); if (strace_option) print_shutdown_syscall(reg, proc); }
/** @brief translate the port and address of the exiting accept syscall * * We take the arguments in the registers, which correspond to the * real local address and port we obtained. We translate them into * global simulated ones and put the result back in the registers, so * that the application gets wronged. */ void sys_translate_accept_out(process_descriptor_t * proc, syscall_arg_u * sysarg) { accept_arg_t arg = &(sysarg->accept); pid_t pid = proc->pid; reg_s reg; ptrace_get_register(pid, ®); int port = ntohs(arg->sai.sin_port); struct infos_socket *is = get_infos_socket(proc, arg->sockfd); comm_get_ip_port_accept(is, &(arg->sai)); msg_host_t host; if (arg->sai.sin_addr.s_addr == inet_addr("127.0.0.1")) host = proc->host; else host = get_host_by_ip(arg->sai.sin_addr.s_addr); set_real_port(host, ntohs(arg->sai.sin_port), port); add_new_translation(port, ntohs(arg->sai.sin_port), arg->sai.sin_addr.s_addr); ptrace_poke(pid, (void *) reg.arg2, &(arg->sai), sizeof(struct sockaddr_in)); }