int S_COMPUTE (void) { int res; if ((res = sipcout(envid, IPC_USER, COMPUTE, 0, 0)) != 0) return -1; return res; }
int arp_remove_ip(char ip_addr[4]) { unsigned int ip; int status; unsigned int arp_envid; arp_envid = get_arp_envid(); if (arp_envid == 0) { printf("Arp daemon not running\n"); return -1; } /* make sure is word aligned */ memcpy(&ip ,ip_addr, 4); printf("ARP_ENVID: %d. SIPCOUT ip: %s\n",arp_envid,pripaddr((char *)&ip)); status = sipcout(arp_envid,IPC_ARP_DELETE,ip,0,0); switch(status) { case -1: printf("SIPCOUT ERROR: %d, arp_envid: %d\n",status,arp_envid); return -1; case ARP_SUCCESS: return 0; case ARP_NOTFOUND: printf("Entry %s not found\n",pripaddr(ip_addr)); return -1; default: assert(0); /* bad return code */ return 0; } }
int S_PUSH (byte *buf, int num_bytes) { if (num_bytes > MAX_LEN) return -1; shared_state->nbytes = num_bytes; memcpy (shared_state->buf, buf, num_bytes); return (sipcout(envid, IPC_USER, PUSH, 0, 0)); }
int S_POP (int num_bytes, byte *buf) { if (num_bytes > MAX_LEN) return -1; shared_state->nbytes = num_bytes; if (sipcout(envid, IPC_USER, POP, 0, 0) != 0) return -1; if (shared_state->nbytes != num_bytes) return -1; memcpy (buf, shared_state->buf, num_bytes); return 0; }
int arp_resolve_ip(char ip_addr[4], char eth_addr[6], int ifnum) { unsigned int ip; int status; int retry = 0; unsigned int arp_envid; arp_entry_p e = NULL; /* Search the arp table */ retry: if (retry > 2) { kprintf("TOO MANY RETRIES SOMETHING WRONG WITH IMPLEMENTATION\n"); if (e) arp_print_entry(e); return -2; } if ((e = arp_search_entry_by_ip(ip_addr)) != NULL) { if (arp_entry_valid(e)) { if (EISRESOLVED(e)) {memcpy(eth_addr,e->eth,6);return 0;} if (EISTIMEOUT(e)) {return -1;} /* entry is pending */ wk_waitfor_value_neq((int *)&e->status,PENDING,CAP_ROOT); // arp_print_entry(e); retry++; goto retry; } } arp_envid = get_arp_envid(); if (arp_envid == 0) { printf("Arp daemon not running\n"); return -1; } /* make sure is word aligned */ memcpy(&ip ,ip_addr, 4); // kprintf("ARP_ENVID: %d. SIPCOUT\n",arp_envid); status = sipcout(arp_envid,IPC_ARP_ADD,ip,ifnum,0); if (status == ARP_TIMEDOUT) return -1; if (status == ARP_RETRY) { printf("NO FREE ENTRIES, sleeping a little then retrying (table full)\n"); sleep(1); goto retry; } retry++; goto retry; return 0; }
int S_INIT (uint pte) { return (sipcout(envid, IPC_USER, INIT, pte, 0)); }
int S_EMPTY (int unused) { if (sipcout(envid, IPC_USER, EMPTY, 0, 0) != 0) return -1; return 0; }