Skip to content

Instantly share code, notes, and snippets.

@georgik
Created July 1, 2014 13:48
Show Gist options
  • Save georgik/75c1974af9aa0ccfd1d3 to your computer and use it in GitHub Desktop.
Save georgik/75c1974af9aa0ccfd1d3 to your computer and use it in GitHub Desktop.
DHCP LPR detection
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SCDynamicStoreCopyDHCPInfo.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
CFDictionaryRef info = SCDynamicStoreCopyDHCPInfo(NULL, NULL);
if (info != NULL) {
// code RFC 2132 - http://www.ietf.org/rfc/rfc2132.txt
// 1 - netmask
// 2 - time offset
// 3 - router
// 4 - time server
// 5 - nameserver
// 6 - DNS
// 7 - Log server
// 8 - Cookie server
// 9 - LPR server
// 15 - domain name
CFDataRef data = DHCPInfoGetOptionData(info, 9);
NSData *my_nsdata = (__bridge NSData*)data;
NSLog(@"Hello, World!");
NSLog(@"%@\n", my_nsdata);
} else {
NSLog(@"No DHCP information\n");
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment