Re: How to read/write raw ether packet in application?
Re: How to read/write raw ether packet in application?
- Subject: Re: How to read/write raw ether packet in application?
- From: "Duane Murphy" <email@hidden>
- Date: Mon, 21 Aug 2006 23:00:40 -0700
--- At Mon, 21 Aug 2006 22:30:09 -0700, Justin C. Walker wrote:
>
>On Aug 21, 2006, at 20:06 , Robin wrote:
>
>> Hi , all
>>
>> Is there any way to read/write raw ethernet(802.3) data packets
>> in user application layer on OSX ?
>>
>> We have developed a tartget embended platform with Linux, and
>> we want to communicate with it by ethernet port, I think we can run
>> a Carbon application in our iMac host to do this, is it possible?
>> Or we need write a application/kext pair to realize it?
>
>If by this, you mean "raw ethernet packets with a new type", then you
>can do this in a couple of ways: BPF or raw ethernet (PF_NDRV).
>FWIW, the system does not take kindly to you siphoning off TCP
>packets. I suspect that isn't what you want to do, however.
>
>The BPF approach is probably simplest and most portable, and there
>are several applications in the darwin source tree that show how it's
>done (see the bootp project, for example).
>
>I don't know what shape the PF_NDRV code is in now. This is a
>"protocol" handler that is a kext, and so requires kernel
>programming. The SharedIP kext uses this to get ethernet packets to
>and from the Classic Mac OS environment.
We use both BPF and PF_NDRV. We only use BPF in older systems that have
a broken implementation of PF_NDRV. Otherwise we use PF_NDRV to access
raw ethernet sockets.
However, BPF also has a problem on older systems. BPF is a fixed
resource on older systems. As I recall there are only 6 sockets
available shared in the entire system.
The only "complication" is that opening a BPF or PF_NDRV socket requires
root access. There is a good example of how to transfer a socket from
one program to another so that your root tool only does one simple
action; open a socket and pass it back to the parent application.
If there is a problem with PF_NDRV I'd love to know. I have been chasing
system cores (like restart the system crashes) for a while. I'm assuming
that it's my code. I'd love to know that some change (or non-change) to
PF_NDRV is making this happen.
...Duane
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden