summaryrefslogtreecommitdiff
path: root/src/user/app/netstack
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/netstack')
-rw-r--r--src/user/app/netstack/arp.c6
-rw-r--r--src/user/app/netstack/ether.c4
-rw-r--r--src/user/app/netstack/fs.c50
-rw-r--r--src/user/app/netstack/netstack.c4
-rw-r--r--src/user/app/netstack/proto.h6
5 files changed, 35 insertions, 35 deletions
diff --git a/src/user/app/netstack/arp.c b/src/user/app/netstack/arp.c
index 6c230b3..3a1c8da 100644
--- a/src/user/app/netstack/arp.c
+++ b/src/user/app/netstack/arp.c
@@ -107,7 +107,7 @@ int arpcache_get(uint32_t ip, mac_t *mac) {
return -1;
}
-void arp_fsread(handle_t h, long offset) {
+void arp_fsread(hid_t h, long offset) {
const char *fmt = "%08x\t%02x:%02x:%02x:%02x:%02x:%02x\n";
long linelen = snprintf(NULL, 0, fmt, 0, 1, 2, 3, 4, 5, 6) + 1;
char buf[28];
@@ -129,10 +129,10 @@ void arp_fsread(handle_t h, long offset) {
cur->mac[3],
cur->mac[4],
cur->mac[5]);
- _syscall_fs_respond(h, buf + offset, linelen - offset, 0);
+ _sys_fs_respond(h, buf + offset, linelen - offset, 0);
return;
err:
- _syscall_fs_respond(h, NULL, -1, 0);
+ _sys_fs_respond(h, NULL, -1, 0);
}
long arp_fswrite(const char *buf, long len, long offset) {
diff --git a/src/user/app/netstack/ether.c b/src/user/app/netstack/ether.c
index 20d16ab..52abac2 100644
--- a/src/user/app/netstack/ether.c
+++ b/src/user/app/netstack/ether.c
@@ -19,7 +19,7 @@ void ether_parse(const uint8_t *buf, size_t len) {
for (struct ethq **iter = &ether_queue; iter && *iter; ) {
struct ethq *qe = *iter;
- _syscall_fs_respond(qe->h, buf, len, 0);
+ _sys_fs_respond(qe->h, buf, len, 0);
/* remove entry */
/* yes, doing it this way here doesn't make sense. i'm preparing for filtering */
*iter = qe->next;
@@ -54,6 +54,6 @@ uint8_t *ether_start(size_t len, struct ethernet ether) {
void ether_finish(uint8_t *pkt) {
uint8_t *buf = pkt - Payload - fhoff;
size_t len = *(size_t*)buf;
- _syscall_write(state.raw_h, buf + fhoff, len, 0, 0);
+ _sys_write(state.raw_h, buf + fhoff, len, 0, 0);
free(buf);
}
diff --git a/src/user/app/netstack/fs.c b/src/user/app/netstack/fs.c
index ad6c23c..6d51c35 100644
--- a/src/user/app/netstack/fs.c
+++ b/src/user/app/netstack/fs.c
@@ -43,14 +43,14 @@ struct handle {
size_t readcap;
} tcp;
bool dead;
- handle_t reqh;
+ hid_t reqh;
};
static void tcp_listen_callback(struct tcp_conn *c, void *arg) {
struct handle *h = arg;
h->tcp.c = c;
- _syscall_fs_respond(h->reqh, h, 0, 0);
+ _sys_fs_respond(h->reqh, h, 0, 0);
h->reqh = -1;
}
@@ -63,7 +63,7 @@ static void tcp_recv_callback(void *arg) {
h->tcp.readcap = sizeof buf;
size_t len = tcpc_tryread(h->tcp.c, buf, h->tcp.readcap);
if (len > 0) {
- _syscall_fs_respond(h->reqh, buf, len, 0);
+ _sys_fs_respond(h->reqh, buf, len, 0);
h->reqh = -1;
}
}
@@ -73,7 +73,7 @@ static void tcp_close_callback(void *arg) {
struct handle *h = arg;
h->dead = true;
if (h->reqh >= 0) {
- _syscall_fs_respond(h->reqh, NULL, -ECONNRESET, 0);
+ _sys_fs_respond(h->reqh, NULL, -ECONNRESET, 0);
h->reqh = -1;
return;
}
@@ -82,14 +82,14 @@ static void tcp_close_callback(void *arg) {
static void udp_listen_callback(struct udp_conn *c, void *arg) {
struct handle *h = arg;
h->udp.c = c;
- _syscall_fs_respond(h->reqh, h, 0, 0);
+ _sys_fs_respond(h->reqh, h, 0, 0);
h->reqh = -1;
}
static void udp_recv_callback(const void *buf, size_t len, void *arg) {
struct handle *h = arg;
if (h->reqh >= 0) {
- _syscall_fs_respond(h->reqh, buf, len, 0);
+ _sys_fs_respond(h->reqh, buf, len, 0);
h->reqh = -1;
return;
}
@@ -106,14 +106,14 @@ static void udp_recv_callback(const void *buf, size_t len, void *arg) {
}
}
-static void recv_enqueue(struct handle *h, handle_t reqh, size_t readcap) {
+static void recv_enqueue(struct handle *h, hid_t reqh, size_t readcap) {
if (h->reqh > 0) {
// TODO queue
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
return;
}
if (h->type == H_UDP && h->udp.rx) {
- _syscall_fs_respond(reqh, h->udp.rx->buf, h->udp.rx->len, 0);
+ _sys_fs_respond(reqh, h->udp.rx->buf, h->udp.rx->len, 0);
h->udp.rx = h->udp.rx->next;
free(h->udp.rx);
return;
@@ -125,8 +125,8 @@ static void recv_enqueue(struct handle *h, handle_t reqh, size_t readcap) {
}
}
-static void fs_open(handle_t reqh, char *path, int flags) {
-#define respond(buf, val) do{ _syscall_fs_respond(reqh, buf, val, 0); return; }while(0)
+static void fs_open(hid_t reqh, char *path, int flags) {
+#define respond(buf, val) do{ _sys_fs_respond(reqh, buf, val, 0); return; }while(0)
struct handle *h;
if (*path != '/') respond(NULL, -1);
path++;
@@ -241,7 +241,7 @@ void fs_thread(void *arg) { (void)arg;
char *buf = malloc(buflen);
for (;;) {
struct ufs_request res;
- handle_t reqh = _syscall_fs_wait(buf, buflen, &res);
+ hid_t reqh = _sys_fs_wait(buf, buflen, &res);
if (reqh < 0) break;
struct handle *h = res.id;
long ret;
@@ -251,12 +251,12 @@ void fs_thread(void *arg) { (void)arg;
buf[res.len] = '\0';
fs_open(reqh, buf, res.flags);
} else {
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
}
break;
case VFSOP_READ:
if (h->dead) {
- _syscall_fs_respond(reqh, NULL, -ECONNRESET, 0);
+ _sys_fs_respond(reqh, NULL, -ECONNRESET, 0);
break;
}
switch (h->type) {
@@ -275,44 +275,44 @@ void fs_thread(void *arg) { (void)arg;
arp_fsread(reqh, res.offset);
break;
default:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
}
break;
case VFSOP_WRITE:
if (h->dead) {
- _syscall_fs_respond(reqh, NULL, -ECONNRESET, 0);
+ _sys_fs_respond(reqh, NULL, -ECONNRESET, 0);
break;
}
switch (h->type) {
case H_ETHER:
- ret = _syscall_write(state.raw_h, buf, res.len, 0, 0);
- _syscall_fs_respond(reqh, NULL, ret, 0);
+ ret = _sys_write(state.raw_h, buf, res.len, 0, 0);
+ _sys_fs_respond(reqh, NULL, ret, 0);
break;
case H_TCP:
tcpc_send(h->tcp.c, buf, res.len);
- _syscall_fs_respond(reqh, NULL, res.len, 0);
+ _sys_fs_respond(reqh, NULL, res.len, 0);
break;
case H_UDP:
udpc_send(h->udp.c, buf, res.len);
- _syscall_fs_respond(reqh, NULL, res.len, 0);
+ _sys_fs_respond(reqh, NULL, res.len, 0);
break;
case H_ARP:
- _syscall_fs_respond(reqh, NULL, arp_fswrite(buf, res.len, res.offset), 0);
+ _sys_fs_respond(reqh, NULL, arp_fswrite(buf, res.len, res.offset), 0);
break;
default:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
}
break;
case VFSOP_CLOSE:
// TODO remove entries in queue
- // TODO why does close even have _syscall_fs_respond?
+ // TODO why does close even have _sys_fs_respond?
if (h->type == H_TCP) tcpc_close(h->tcp.c);
if (h->type == H_UDP) udpc_close(h->udp.c);
free(h);
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
default:
- _syscall_fs_respond(reqh, NULL, -1, 0);
+ _sys_fs_respond(reqh, NULL, -1, 0);
break;
}
}
diff --git a/src/user/app/netstack/netstack.c b/src/user/app/netstack/netstack.c
index 405be09..c2e9223 100644
--- a/src/user/app/netstack/netstack.c
+++ b/src/user/app/netstack/netstack.c
@@ -17,7 +17,7 @@ void network_thread(void *arg) { (void)arg;
const size_t buflen = 4096;
char *buf = malloc(buflen);
for (;;) {
- long ret = _syscall_read(state.raw_h, buf, buflen, -1);
+ long ret = _sys_read(state.raw_h, buf, buflen, -1);
if (ret < 0) break;
ether_parse((void*)buf, ret);
}
@@ -49,6 +49,6 @@ int main(int argc, char **argv) {
arp_request(state.gateway);
thread_create(0, network_thread, NULL);
thread_create(0, fs_thread, NULL);
- _syscall_await();
+ _sys_await();
return 0;
}
diff --git a/src/user/app/netstack/proto.h b/src/user/app/netstack/proto.h
index 4d881ca..8ea11ac 100644
--- a/src/user/app/netstack/proto.h
+++ b/src/user/app/netstack/proto.h
@@ -10,7 +10,7 @@ extern struct net_state {
mac_t mac;
uint32_t ip, gateway;
- handle_t raw_h;
+ hid_t raw_h;
} state;
enum { /* ethertype */
@@ -51,7 +51,7 @@ struct icmp {
* will break if i implement a scheduler*/
struct ethq {
struct ethq *next;
- handle_t h;
+ hid_t h;
};
extern struct ethq *ether_queue;
@@ -59,7 +59,7 @@ void arp_parse(const uint8_t *buf, size_t len);
void arp_request(uint32_t ip);
/* 0 on success, -1 on failure */
int arpcache_get(uint32_t ip, mac_t *mac);
-void arp_fsread(handle_t h, long offset);
+void arp_fsread(hid_t h, long offset);
long arp_fswrite(const char *buf, long len, long offset);
void icmp_parse(const uint8_t *buf, size_t len, struct ipv4 ip);