-- (c) William Welch 2004 -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; -- you must not claim that you wrote the original software. -- If you use this software in a product, an acknowledgment in -- the product documentation would be appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must -- not be misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source distribution. -- -- This license is commonly known as the zlib/libpng License. -- -- icmp.jal bvwelch 19 may 2004 -- revised 18 march 2005 -- See RFC 792 for details function icmp_is_echo return bit is if (MemRdEx(ip_off , 9) != 1) | (MemRd(icmp_off) != 8) then return false end if return true end function procedure icmp_echo_reply is var byte n, sum_hi, sum_lo, cnt_hi, cnt_lo -- echo reply opcode is 0 MemWr(icmp_off, 0) -- do icmp checksum -- note byte swap I16_SVL ( IP_LEN , cnt_lo , cnt_hi) I16_LDL ( L16 , cnt_hi , cnt_lo ) I16_SUB8 ( L16, ip_hdrsize ) I16_SVL ( L16 , cnt_hi , cnt_lo) chksum_write(icmp_off, 0, 2, cnt_hi , cnt_lo) -- swap IP src and dest ip_swap_addr -- now do the IP chksum n = ( MemRd(ip_off) & 0x0F ) << 2 chksum_write(ip_off, 0, 10, 0, n) -- swap ethernet source and dest net_swap_addr -- now send pkt -- note byte swap I16_SVL ( IP_LEN , cnt_lo , cnt_hi) I16_LDL ( L16 , cnt_hi , cnt_lo ) I16_ADD8 ( L16, 14 ) I16_SVL ( L16 , cnt_hi , cnt_lo) net_txpkt(cnt_hi , cnt_lo) end procedure