• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Sample code for sending raw packets?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sample code for sending raw packets?


  • Subject: Sample code for sending raw packets?
  • From: Dave Camp <email@hidden>
  • Date: Fri, 13 Oct 2006 11:03:15 -0700

The list search engine seems to be down at the moment....

I'm working on a utility for a networked laser printer. The printer will default to an IP address of 192.0.0.192 if it cannot get a DHCP address. Given that the printer also has no front panel display or controls, the only way for the user to change the IP address will be to use my utility.

I will caveat what I'm about to write with: I'm just the poor guy writing the utility, I have no control over the firmware implementation.

The documentation I have been given indicates they change the IP address of the printer in this case by performing the following on Windows:

- Add a static entry to the ARP table for x.x.x.x -> Printer MAC Address, where x.x.x.x is the new IP address they want to set the printer to and the Printer MAC address is the MAC address of the printer.
- Send an ICMP ping to the printer.
- Remove the ARP entry


Yes, they set the IP address of the printer by pinging it. I'll wait here for a bit while you cry.

I'm going to guess that fiddling with the local ARP table is probably not such a swell idea and that I'd be better off hand rolling my own raw ICMP ping packet at the ethernet level to get the job done. I think it would have to be at the ethernet level as I need to specify the IP address and destination MAC address myself. I know I will have to have a SUID root helper tool to do this.

Assuming that is the case, I was wondering if someone could point me to some sample code illustrating how to build a raw ethernet packet. I've looked in the Unix Programming Book, but it only covers raw IPv4/6 packets, not raw ethernet packets. Most of the sample code I've found on the net is for Linux which appears to use different AF_ and protocol constants than BSD.

Thoughts?

Thanks,
Dave


---
Among the chief weapons of UNIX: Fear, surprise and ruthless efficiency.


_______________________________________________
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


  • Follow-Ups:
    • Re: Sample code for sending raw packets?
      • From: "Peter Sichel" <email@hidden>
    • Re: Sample code for sending raw packets?
      • From: Dalton Hamilton <email@hidden>
    • Re: Sample code for sending raw packets?
      • From: "Justin C. Walker" <email@hidden>
  • Prev by Date: is there a list of recent changes to mac networking?
  • Next by Date: Re: Sample code for sending raw packets?
  • Previous by thread: is there a list of recent changes to mac networking?
  • Next by thread: Re: Sample code for sending raw packets?
  • Index(es):
    • Date
    • Thread