Direct packet socket programming?
Rick Murray (539) 13840 posts |
Can RISC OS do this?
Do not try this – it crashes. If you take out the request to include headers (the HDRINCL bit), it will spit out a packet that has a standard-looking IP header apparently with some data being an ARP request to locate 192.168.1.1 (according to WireShark). None of the identifying data in the payload is present, whatever is sent is something else. I need to use AF_PACKET. This doesn’t appear to be supported by RISC OS. I suspect the IP header is added because I am using AF_INET, but then, no other AF option seems to want to open a socket in raw mode. Trust me, I’ve tried ’em ALL. Boring! ;-) What I want to appear on the wire is this:
and receive something very similar. In all cases, the first six bytes are the MAC address of the receiver (all ff = broadcast), and the next six bytes are the MAC address of the sender. The next two bytes are always &88 &88, then follows data. The reply to the above would be:
The communication works like that. No IP addresses or any of that high-level stuff. Can RISC OS do this? |
Steve Pampling (1551) 8170 posts |
Hmmm? ARP is ethertype 0806
broken?
yup.
No, sorry, checked a few references rather than the memory and the reference to ethertype 8888 says protocol unavailable http://standards.ieee.org/develop/regauth/ethertype/eth.txt http://wiki.wireshark.org/SampleCaptures will give you decent example captures |
Steve Pampling (1551) 8170 posts |
Rick:
Now back to planning the swap of this to this Edit: note the nice 42 bytes on the wire (which is a message you will see in the Wireshark panel…) |
Rick Murray (539) 13840 posts |
Custom. Unfortunately.
No, sorry, I have a capture of an entire transaction between my PC and the device I want to use with RISC OS. It uses exactly this (non-standard) protocol. It looks to me as if this may work – http://en.wikipedia.org/wiki/Ethernet_frame#Ethernet_II – by simply setting the EtherType bytes to 88 88. I’m guessing the short preamble/start-frame is not shown by WireShark? Can RISC OS’s internet stack send/receive Ethernet II frames?
Want to see my capture? It is exactly as described. ;-) |
Sprow (202) 1158 posts |
AF_PACKET, I believe, is the Linux synonym for AF_LINK which would be what BSD and therefore RISC OS uses. Even so, I’m reasonably sure AF_LINK isn’t what you want either as that’s for configuring or retrieving configuration information about the link layer – things like the driver name, the media type, etc. The basic stumbling block here is you’re trying to open a socket (which is handled by the Internet module, a handler of IP) and send something that’s not IP, and that’s never going to work. Now, it’s certainly possible to do what you want – after all that’s what the Internet module must do when it wants to send a packet. Ignoring address resolution and routing for a moment, Internet maintains a list of DCI4 drivers that have declared themselves on the system, and then registers filters with them to hook out packets of interest for itself. *ExINFO (where ‘x’ is the driver) will normally give a listing of the registered filters – one of those will be the Internet module itself. To send raw packets you’ll need to enumerate the DCI4 drivers (or, if you’re a module, you could listen for the service call when one starts like Internet does) pick whichever one you fancy and use the DCI4 transmit SWI to send the raw packet. To receive raw packets you’ll need to register a filter using the DCI4 filter SWI, if it’s always &8888 then a specific one, or IEEE filter if it’s not EthernetII, pick it off with the sink filter, or be rude and use a monitor filter so nobody else gets any packets at all. |