'********************************* ' Very basic IP implementation ' ' by john.timmins@link.co.nz ' ' This file is ETHERNET.BAS ' ' Please let me know the bugs! ' '********************************* ' ' $regfile = "8052.dat" $baud = 9600 $crystal = 11059200 'My monitor requires the $romstart, normally you will leave this out. $romstart = &H4000 'I used an upper RAM limit of &H3FFF once again, because of my monitor's CODE space. $ramstart = &H0000 'This IP implementation **REQUIRES** about 4kb XRAM - Check the compile report. $ramsize = &H3FFF $large 'Yes, the program is large. $default Xram 'All variables are in XRAM Config Lcd = 40 * 2 Cursor Off ' 'IP Address. Make this unique on your network... 'IP= 192.168.1.2 Const Ip1c = 192 Const Ip2c = 168 Const Ip3c = 1 Const Ip4c = 2 ' 'MAC Address. Make this unique on your network. Make the first 'bit' a ZERO. 'MAC= 0E-63-FF-FF-00-01 MSB -> LSB Const Mac1 = &H0E63 Const Mac2 = &HFFFF Const Mac3 = &H0001 ' 'Hardware I/O port base address (Chip Enable) of the CS8900. 'The CS8900 needs 16 bytes of address space starting at this address. Const Cs8900base = &HC000 ' Goto Start_of_program 'Skip over the $include's ' $include IP_Generic.bas 'Add basic IP routines $include IP_ICMP_Reply.bas 'Add PING reply routine '$include ip_debug.bas 'Frame debugging routines 'Add other include's here. '$includes make compiler errors difficult to locate,. 'The compiler will usually report errors in the wrong file so be careful! ' ' Start_of_program: ' 'Set default Packet receive options 'These are written to the CS8900 in InitCs8900 Individual_address_enable = 1 Broadcast_enable = 1 Promiscuous_enable = 0 Chipver 'Check for CS8900 version Gosub Set_ip_address 'Copy IP Address from ROM to RAM Restart_cs8900: Resetcs8900 'Send software reset Initcs8900 'Initialise ethernet parameters ' ' Wff1: Wait_for_frame 'Wait for a frame Receive_frame 'Recieve it to XRAM Frame_type = Rx_packet(offset_frame_type) 'Get frame type Select Case Frame_type Case 2054: 'ARP &H0806 Arp_reply 'Send ARP reply Case 2048: 'IP frame (type &H0800) Value16 = Rx_packet(offset_ip_ttl_proto) Ip_protocol = Low(value16) Select Case Ip_protocol Case 1: 'ICMP Print "ICMP" Gosub Icmp_reply 'Send PING reply Case 6: Print "TCP" Case 17: Print "UDP" 'Now, get the destination port number Udp_port = Rx_packet(offset_udp_dst_port) Print "Port "; Print Udp_port Select Case Udp_port Case 520: Print "Novell SAP" Case 1000: Gosub Lcd_udp_data End Select End Select End Select Goto Wff1 Lcd_udp_data: 'Displays UDP data to LCD Temp16 = Frame_length 'Get entire frame length Temp16 = Temp16 / 2 'in words Temp16 = Temp16 - 1 'Set up for possible odd number of bytes Cls For Word_count = Offset_udp_data To Temp16 Value16 = Rx_packet(word_count) Value8 = High(value16) S = Chr(value8) Lcd S Value8 = Low(value16) S = Chr(value8) Lcd S Next Word_count Incr Word_count Value16 = Rx_packet(word_count) Value8 = High(value16) 'Get last 'real' data byte If Value8 <> 32 Then 'Is it NOT a space? If Value8 <> 0 Then 'Is it NOT a Zero? S = Chr(value8) Lcd S End If End If Return