1

I download the Mac OS network ping source code from Apple: http://www.opensource.apple.com/tarballs/network_cmds/network_cmds-356.8.tar.gz

and compile it in xcode, but get errors in both 10.7 and 10.6,

'IP_NO_IFT_CELLULAR' undeclared (first use in this function)
'SO_TRAFFIC_CLASS' undeclared (first use in this function)
'SO_RECV_TRAFFIC_CLASS' undeclared (first use in this function)
'SO_TRAFFIC_CLASS' undeclared (first use in this function)

Did I miss something?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
timy
  • 501
  • 1
  • 6
  • 17
  • Which version of XCode are you using? (If I open the project in XCode 4.2.1, I get errors as well, but those are different from yours). – Frank Schmitt Jan 08 '12 at 09:49

1 Answers1

1

I thought it was possible that you needed to import a networking framework into your project, but Apple doesn't provide any description or information about the project you've downloaded.

For posterity's sake: To add frameworks, select the project in the top left, then click your target, pick 'Build Phases' from the top of the resulting page, 'Link Binary With Libraries', '+'.

I finally managed to get it to build after exhaustive googling by adding the following to the ping.c file (the one flagged with the errors):

#define IP_NO_IFT_CELLULAR  6969 /* for internal use only */
#define IP_NO_IFT_PDP       IP_NO_IFT_CELLULAR /* deprecated */
#define SO_TRAFFIC_CLASS        0x1086      /* Traffic class (int)*/
#define SO_RECV_TRAFFIC_CLASS   0x1087      /* Receive traffic class (bool)*/

Which amusingly came from other open source Apple projects that Google had indexed.