fix bugs
This commit is contained in:
parent
c58d6d456d
commit
1883b2ce7a
8
driver.c
8
driver.c
|
@ -2,6 +2,7 @@
|
||||||
#include <gno/kerntool.h>
|
#include <gno/kerntool.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include "s16debug.h"
|
||||||
|
|
||||||
#pragma noroot
|
#pragma noroot
|
||||||
#pragma optimize 79
|
#pragma optimize 79
|
||||||
|
@ -13,12 +14,12 @@ int block(int sem)
|
||||||
return xerrno;
|
return xerrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int queue_command(Entry *e, word command, LongWord cookie, LongWord timeout)
|
int queue_command(Entry *e, Word command, LongWord cookie, LongWord timeout)
|
||||||
{
|
{
|
||||||
int xerrno;
|
int xerrno;
|
||||||
|
|
||||||
SEI();
|
SEI();
|
||||||
e->command = kCommandRead;
|
e->command = command;
|
||||||
e->cookie = cookie;
|
e->cookie = cookie;
|
||||||
e->timeout = timeout;
|
e->timeout = timeout;
|
||||||
CLI();
|
CLI();
|
||||||
|
@ -44,6 +45,9 @@ int driver(
|
||||||
int rv;
|
int rv;
|
||||||
Entry *e;
|
Entry *e;
|
||||||
|
|
||||||
|
s16_debug_printf("driver: %04x : %04x", socknum, req);
|
||||||
|
|
||||||
|
|
||||||
if (req == PRU_ATTACH)
|
if (req == PRU_ATTACH)
|
||||||
{
|
{
|
||||||
return mattach(socknum, p1, p2, p3, p4, p5);
|
return mattach(socknum, p1, p2, p3, p4, p5);
|
||||||
|
|
|
@ -63,7 +63,7 @@ typedef struct xsockaddr_in {
|
||||||
#define CLI() asm { cli }
|
#define CLI() asm { cli }
|
||||||
|
|
||||||
int block(int sem);
|
int block(int sem);
|
||||||
int queue_command(Entry *e, word command, LongWord cookie, LongWord timeout);
|
int queue_command(Entry *e, Word command, LongWord cookie, LongWord timeout);
|
||||||
|
|
||||||
void init_table(void);
|
void init_table(void);
|
||||||
void destroy_table(void);
|
void destroy_table(void);
|
||||||
|
|
|
@ -18,7 +18,7 @@ int mattach(int type, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||||
int protocol = *(int *)p3;
|
int protocol = *(int *)p3;
|
||||||
|
|
||||||
if (type != SOCK_STREAM) return ESOCKTNOSUPPORT;
|
if (type != SOCK_STREAM) return ESOCKTNOSUPPORT;
|
||||||
if (protocol != 6) return EPROTONOSUPPORT;
|
//if (protocol != 6) return EPROTONOSUPPORT;
|
||||||
// TODO -- check protocol? 6 = tcp, 1 = icmp, 17 = udp.
|
// TODO -- check protocol? 6 = tcp, 1 = icmp, 17 = udp.
|
||||||
|
|
||||||
IncBusy();
|
IncBusy();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <gno/kerntool.h>
|
#include <gno/kerntool.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <misctool.h>
|
#include <misctool.h>
|
||||||
|
#include "s16debug.h"
|
||||||
|
|
||||||
#pragma noroot
|
#pragma noroot
|
||||||
#pragma optimize 79
|
#pragma optimize 79
|
||||||
|
@ -76,6 +77,9 @@ int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||||
|
|
||||||
xerrno = queue_command(e, kCommandConnect, 0, timeout);
|
xerrno = queue_command(e, kCommandConnect, 0, timeout);
|
||||||
|
|
||||||
|
s16_debug_printf("mconnect: %d - %d - %d",
|
||||||
|
e->semaphore, xerrno, e->command);
|
||||||
|
|
||||||
// hmmm .. should these abort?
|
// hmmm .. should these abort?
|
||||||
if (xerrno == EINTR)
|
if (xerrno == EINTR)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +102,7 @@ int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||||
// todo -- differentiate ECONNREFUSED vs EHOSTUNREACH
|
// todo -- differentiate ECONNREFUSED vs EHOSTUNREACH
|
||||||
return ECONNREFUSED;
|
return ECONNREFUSED;
|
||||||
|
|
||||||
if (timeout && timeout > GetTick())
|
if (timeout && timeout <= GetTick())
|
||||||
{
|
{
|
||||||
IncBusy();
|
IncBusy();
|
||||||
TCPIPAbortTCP(e->ipid);
|
TCPIPAbortTCP(e->ipid);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "marignotti.h"
|
#include "marignotti.h"
|
||||||
#include <gno/kerntool.h>
|
#include <gno/kerntool.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <misctool.h>
|
||||||
|
|
||||||
#pragma noroot
|
#pragma noroot
|
||||||
#pragma optimize 79
|
#pragma optimize 79
|
||||||
|
@ -11,11 +11,13 @@ int mdetach(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||||
{
|
{
|
||||||
|
|
||||||
// TODO -- SO_LINGER/SO_LINGER_SEC
|
// TODO -- SO_LINGER/SO_LINGER_SEC
|
||||||
|
LongWord timeout;
|
||||||
|
|
||||||
|
timeout = GetTick() + 5 * 60;
|
||||||
SEI();
|
SEI();
|
||||||
e->command = kCommandDisconnectAndLogout;
|
e->command = kCommandDisconnectAndLogout;
|
||||||
e->cookie = 0;
|
e->cookie = 0;
|
||||||
e->timeout = 0;
|
e->timeout = timeout;
|
||||||
CLI();
|
CLI();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
2
mread.c
2
mread.c
|
@ -104,7 +104,7 @@ int mread(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout && timeout > GetTick())
|
if (timeout && timeout <= GetTick())
|
||||||
return EAGAIN;
|
return EAGAIN;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
40
table.c
40
table.c
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <misctool.h>
|
#include <misctool.h>
|
||||||
|
#include "s16debug.h"
|
||||||
|
|
||||||
|
|
||||||
#pragma optimize 79
|
#pragma optimize 79
|
||||||
#pragma noroot
|
#pragma noroot
|
||||||
|
@ -109,7 +111,6 @@ void process_table(void)
|
||||||
Entry *next;
|
Entry *next;
|
||||||
Entry *prev;
|
Entry *prev;
|
||||||
|
|
||||||
tick = GetTick();
|
|
||||||
|
|
||||||
for (i = 0; i < TABLE_SIZE; ++i)
|
for (i = 0; i < TABLE_SIZE; ++i)
|
||||||
{
|
{
|
||||||
|
@ -117,18 +118,21 @@ void process_table(void)
|
||||||
e = table[i];
|
e = table[i];
|
||||||
while (e)
|
while (e)
|
||||||
{
|
{
|
||||||
|
Word command;
|
||||||
next = e->next;
|
next = e->next;
|
||||||
|
|
||||||
if (e->command)
|
command = e->command;
|
||||||
|
if (command)
|
||||||
{
|
{
|
||||||
Word expired = 0;
|
Word expired;
|
||||||
Word sig = 0;
|
Word sig;
|
||||||
Word state;
|
Word state;
|
||||||
|
|
||||||
|
tick = GetTick();
|
||||||
IncBusy();
|
IncBusy();
|
||||||
|
|
||||||
|
|
||||||
if (e->timeout && tick > e->timeout)
|
expired = 0;
|
||||||
|
if (e->timeout != 0 && tick > e->timeout)
|
||||||
expired = 1;
|
expired = 1;
|
||||||
|
|
||||||
terr = TCPIPStatusTCP(e->ipid, &e->sr);
|
terr = TCPIPStatusTCP(e->ipid, &e->sr);
|
||||||
|
@ -136,9 +140,15 @@ void process_table(void)
|
||||||
if (t) terr = t;
|
if (t) terr = t;
|
||||||
e->terr = terr;
|
e->terr = terr;
|
||||||
|
|
||||||
state = e->sr.srState;
|
s16_debug_printf("process: %04x : %04x : expired: %d",
|
||||||
|
e->ipid, command, expired);
|
||||||
|
|
||||||
|
s16_debug_srbuff(&e->sr);
|
||||||
|
|
||||||
switch(e->command)
|
state = e->sr.srState;
|
||||||
|
sig = 0;
|
||||||
|
|
||||||
|
switch(command)
|
||||||
{
|
{
|
||||||
case kCommandRead:
|
case kCommandRead:
|
||||||
if (e->sr.srRcvQueued >= e->cookie
|
if (e->sr.srRcvQueued >= e->cookie
|
||||||
|
@ -154,6 +164,10 @@ void process_table(void)
|
||||||
{
|
{
|
||||||
sig = 1;
|
sig = 1;
|
||||||
}
|
}
|
||||||
|
if (expired)
|
||||||
|
{
|
||||||
|
sig = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kCommandDisconnect:
|
case kCommandDisconnect:
|
||||||
|
@ -165,7 +179,14 @@ void process_table(void)
|
||||||
|
|
||||||
case kCommandDisconnectAndLogout:
|
case kCommandDisconnectAndLogout:
|
||||||
// logout and remove entry.
|
// logout and remove entry.
|
||||||
if (state == TCPSCLOSED)
|
if (expired)
|
||||||
|
{
|
||||||
|
// sweet 16 link layer?
|
||||||
|
TCPIPAbortTCP(e->ipid);
|
||||||
|
state = TCPSCLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == TCPSCLOSED || state == TCPSTIMEWAIT)
|
||||||
{
|
{
|
||||||
TCPIPLogout(e->ipid);
|
TCPIPLogout(e->ipid);
|
||||||
sdelete(e->semaphore);
|
sdelete(e->semaphore);
|
||||||
|
@ -186,6 +207,7 @@ void process_table(void)
|
||||||
|
|
||||||
if (sig)
|
if (sig)
|
||||||
{
|
{
|
||||||
|
s16_debug_printf("sending signal to %d", e->semaphore);
|
||||||
e->command = kCommandNone;
|
e->command = kCommandNone;
|
||||||
ssignal(e->semaphore);
|
ssignal(e->semaphore);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue