LINKER = lwlink
CFLAGS = -I../../Library/include -I../../Library/include/6809
CFLAGS += -O0 -msoft-reg-count=0 -mfar-stack-param -fomit-frame-pointer
+CFLAGS += -DNETD_BIG_ENDIAN
LINKER_OPT = --format=raw -L../../Library/libs -lc6809
LIBGCCDIR = $(dir $(shell $(CC) -print-libgcc-file-name))
LINKER_OPT += -L$(LIBGCCDIR) -lgcc
-all:
+.SUFFIXES: .c .rel
+
+SRCS = netd.c uip.c uiplib.c timer.c clock-arch.c uip_arp.c telnet.c slip.c
+SRCS += echoping.c dig.c gethostbyname.c httpd.c ping.c ntpdate.c
+
+OBJS = $(SRCS:.c=.rel)
+
+APPS = netd-slip telnet echoping dig httpd ping ntpdate
+
+OPTS = -O2 -DNETD_LITTLE_ENDIAN
+
+all: $(APPS)
+
+netd-slip: $(OBJS)
+ fcc -o netd netd.rel uip.rel uiplib.rel timer.rel clock-arch.rel \
+ uip_arp.rel slip.rel
+
+$(OBJS): %.rel: %.c
+
+.c.rel:
+ fcc $(PLATFORM) $(OPTS) -c $<
+
+telnet: telnet.rel gethostbyname.rel
+ fcc -o $@ $^
+
+echoping: echoping.rel
+ fcc -o $@ $^
+
+dig: dig.rel
+ fcc -o $@ $^
+
+httpd: httpd.rel
+ fcc -o $@ $^
+
+ping: ping.rel gethostbyname.rel
+ fcc -o $@ $^
+
+ntpdate: ntpdate.rel gethostbyname.rel
+ fcc -o $@ $^
+
clean:
+ rm -f *.rel *.lst *.asm *.noi *.map *.lk *.sym *~ *.ihx *.bin
struct header *p=( struct header *)buf;
struct RRtail *t;
+ char *i = name;
+ char *o = buf + sizeof(struct header);
+ char *l = o++;
+
memset( p, 0, sizeof(buf) );
p->id = 42; /* "random" query ID */
p->cntl = 0x1; /* request a recursive query */
p->qdcount = 1; /* one question */
/* fill out name string */
- char *i = name;
- char *o = buf + sizeof(struct header);
- char *l = o++;
while(1){
if( ! *i )
#define UIP_CONF_LLH_LEN 14
-#define UIP_CONF_BYTE_ORDER UIP_BIG_ENDIAN
+
+#if defined(NETD_LITTLE_ENDIAN)
+#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
+#elif defined(NETD_BIG_ENDIAN)
+#define UIP_CONF_BYTE_ORDER UIP_BIG_ENDIAN
+#else
+#error "Must -D the correct endianness"
+#endif
#define UIP_CONF_ACTIVE_OPEN 1
static int send_question( char *name ){
struct header *p=( struct header *)buf;
struct RRtail *t;
-
+ char *i = name;
+ char *o = buf + sizeof(struct header);
+ char *l = o++;
+
memset( p, 0, sizeof(buf) );
p->id = 42; /* "random" query ID */
p->cntl = 0x1; /* request a recursive query */
p->qdcount = 1; /* one question */
/* fill out name string */
- char *i = name;
- char *o = buf + sizeof(struct header);
- char *l = o++;
-
+
while(1){
if( ! *i )
break;
exit(1);
}
- if( bind( lfd, &addr, sizeof(addr) ) ){
+ if( bind( lfd, (struct sockaddr *)&addr, sizeof(addr) ) ){
perror("bind");
exit(1);
}
if ( i < 0 ){
return 0;
}
- else if ( i == sizeof( sm ) && sm.sd.event & 127 ){
- /* debug
+ else if ( i == sizeof( sm ) && (sm.sd.event & 127)){
+ /* debug*/
fprintf(stderr,"read size: %d ", i );
fprintf(stderr,"knet lcn: %d ", sm.sd.lcn );
fprintf(stderr,"event: %x ", sm.sd.event );
fprintf(stderr,"newstat: %x\n", sm.sd.newstate );
- */
+ /**/
m = & map[sm.sd.lcn];
if ( sm.sd.event & NEV_STATE ){
ne.socket = sm.s.s_num;
/* initialize our map */
init_map();
-
/*
* Set up uIP
*/
ethaddr.addr[5] = 0x05;
uip_setethaddr(ethaddr);
-
parse_rcfile();
if( device_init() ){
exit_err( "cannot init net device\n");
}
-
while(1) {
int a,b;
a = dokernel();
/* sends query to remote */
void sendq( void ){
- memset( buf, 0, MAXBUF );
struct ntp_t *i = (struct ntp_t *)buf;
+ memset( buf, 0, MAXBUF );
i->lvm = 0xe3;
write(fd, buf, 48);
}
static int fd; /* fd of the tty */
static char ibuf[297];
-static char *iptr;
+static char *iptr = ibuf;
#define SLIP_END 0xC0
#define SLIP_ESC 0xDB
static void slip_begin(void)
{
/* Should send an end mark if idle for a bit */
+ slip_outbuf(SLIP_END);
}
static void slip_end(void)
b[13] = 0x00;
memcpy(b+14, ibuf, len);
iptr = ibuf;
+ return len;
}
/* send packet to net device */
int device_read( char *buf, int len )
{
if (slip_poll() == 0)
- return 0;
+ return -1;
return slip_recv(buf, len);
}
int device_init(void)
{
/* FIXME: don't hard code */
- fd=open( "/dev/tty3", O_RDWR);
+ fd=open( "/dev/tty4", O_RDWR|O_NOCTTY);
if( fd < 0 || tcgetattr(fd, &t) < 0) {
- perror("/dev/tty3");
+ perror("/dev/tty4");
return -1;
}
t.c_iflag = IGNBRK;
t.c_cc[VTIME] = 3; /* 0.3 seconds */
if (tcsetattr(fd, 0, &t) < 0) {
- perror("/dev/tty3");
+ perror("/dev/tty4");
return -1;
}
return 0;