From c2573cae1e211519edd822a26cbec738c0e17104 Mon Sep 17 00:00:00 2001 From: Evgeniy Kapralov Date: Wed, 17 Sep 2014 16:55:13 +0400 Subject: [PATCH] Add project to git --- .gitignore | 20 + ArpMac.xcodeproj/project.pbxproj | 507 ++++++++++++++++++ ArpMac/AppDelegate.h | 15 + ArpMac/AppDelegate.m | 46 ++ ArpMac/ArpMac-Info.plist | 49 ++ ArpMac/ArpMac-Prefix.pch | 16 + ArpMac/Base.lproj/Main_iPad.storyboard | 65 +++ ArpMac/Base.lproj/Main_iPhone.storyboard | 65 +++ .../AppIcon.appiconset/Contents.json | 53 ++ .../LaunchImage.launchimage/Contents.json | 51 ++ ArpMac/Network/if_arp.h | 149 +++++ ArpMac/Network/if_ether.h | 145 +++++ ArpMac/Network/if_types.h | 151 ++++++ ArpMac/Network/route.h | 248 +++++++++ ArpMac/Utils.h | 15 + ArpMac/Utils.m | 102 ++++ ArpMac/ViewController.h | 13 + ArpMac/ViewController.m | 40 ++ ArpMac/en.lproj/InfoPlist.strings | 2 + ArpMac/main.m | 18 + ArpMacTests/ArpMacTests-Info.plist | 22 + ArpMacTests/ArpMacTests.m | 34 ++ ArpMacTests/en.lproj/InfoPlist.strings | 2 + 23 files changed, 1828 insertions(+) create mode 100644 .gitignore create mode 100644 ArpMac.xcodeproj/project.pbxproj create mode 100644 ArpMac/AppDelegate.h create mode 100644 ArpMac/AppDelegate.m create mode 100644 ArpMac/ArpMac-Info.plist create mode 100644 ArpMac/ArpMac-Prefix.pch create mode 100644 ArpMac/Base.lproj/Main_iPad.storyboard create mode 100644 ArpMac/Base.lproj/Main_iPhone.storyboard create mode 100644 ArpMac/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 ArpMac/Images.xcassets/LaunchImage.launchimage/Contents.json create mode 100644 ArpMac/Network/if_arp.h create mode 100644 ArpMac/Network/if_ether.h create mode 100644 ArpMac/Network/if_types.h create mode 100644 ArpMac/Network/route.h create mode 100644 ArpMac/Utils.h create mode 100644 ArpMac/Utils.m create mode 100644 ArpMac/ViewController.h create mode 100644 ArpMac/ViewController.m create mode 100644 ArpMac/en.lproj/InfoPlist.strings create mode 100644 ArpMac/main.m create mode 100644 ArpMacTests/ArpMacTests-Info.plist create mode 100644 ArpMacTests/ArpMacTests.m create mode 100644 ArpMacTests/en.lproj/InfoPlist.strings diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d7f9c52 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# Xcode +.DS_Store +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +!default.xcworkspace +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ +# Pods - for those of you who use CocoaPods +Pods \ No newline at end of file diff --git a/ArpMac.xcodeproj/project.pbxproj b/ArpMac.xcodeproj/project.pbxproj new file mode 100644 index 0000000..5e6de2f --- /dev/null +++ b/ArpMac.xcodeproj/project.pbxproj @@ -0,0 +1,507 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + BBEAF22419C9AB2F00EB72F0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBEAF22319C9AB2F00EB72F0 /* Foundation.framework */; }; + BBEAF22619C9AB2F00EB72F0 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBEAF22519C9AB2F00EB72F0 /* CoreGraphics.framework */; }; + BBEAF22819C9AB2F00EB72F0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBEAF22719C9AB2F00EB72F0 /* UIKit.framework */; }; + BBEAF22E19C9AB2F00EB72F0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BBEAF22C19C9AB2F00EB72F0 /* InfoPlist.strings */; }; + BBEAF23019C9AB2F00EB72F0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BBEAF22F19C9AB2F00EB72F0 /* main.m */; }; + BBEAF23419C9AB2F00EB72F0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = BBEAF23319C9AB2F00EB72F0 /* AppDelegate.m */; }; + BBEAF23719C9AB2F00EB72F0 /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BBEAF23519C9AB2F00EB72F0 /* Main_iPhone.storyboard */; }; + BBEAF23A19C9AB2F00EB72F0 /* Main_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BBEAF23819C9AB2F00EB72F0 /* Main_iPad.storyboard */; }; + BBEAF23D19C9AB2F00EB72F0 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BBEAF23C19C9AB2F00EB72F0 /* ViewController.m */; }; + BBEAF23F19C9AB2F00EB72F0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BBEAF23E19C9AB2F00EB72F0 /* Images.xcassets */; }; + BBEAF24619C9AB2F00EB72F0 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBEAF24519C9AB2F00EB72F0 /* XCTest.framework */; }; + BBEAF24719C9AB2F00EB72F0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBEAF22319C9AB2F00EB72F0 /* Foundation.framework */; }; + BBEAF24819C9AB2F00EB72F0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBEAF22719C9AB2F00EB72F0 /* UIKit.framework */; }; + BBEAF25019C9AB2F00EB72F0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BBEAF24E19C9AB2F00EB72F0 /* InfoPlist.strings */; }; + BBEAF25219C9AB2F00EB72F0 /* ArpMacTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BBEAF25119C9AB2F00EB72F0 /* ArpMacTests.m */; }; + BBEAF25D19C9AB5900EB72F0 /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = BBEAF25C19C9AB5900EB72F0 /* Utils.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + BBEAF24919C9AB2F00EB72F0 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = BBEAF21819C9AB2F00EB72F0 /* Project object */; + proxyType = 1; + remoteGlobalIDString = BBEAF21F19C9AB2F00EB72F0; + remoteInfo = ArpMac; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + BBEAF22019C9AB2F00EB72F0 /* ArpMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ArpMac.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BBEAF22319C9AB2F00EB72F0 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + BBEAF22519C9AB2F00EB72F0 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + BBEAF22719C9AB2F00EB72F0 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + BBEAF22B19C9AB2F00EB72F0 /* ArpMac-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ArpMac-Info.plist"; sourceTree = ""; }; + BBEAF22D19C9AB2F00EB72F0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + BBEAF22F19C9AB2F00EB72F0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + BBEAF23119C9AB2F00EB72F0 /* ArpMac-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ArpMac-Prefix.pch"; sourceTree = ""; }; + BBEAF23219C9AB2F00EB72F0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + BBEAF23319C9AB2F00EB72F0 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + BBEAF23619C9AB2F00EB72F0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPhone.storyboard; sourceTree = ""; }; + BBEAF23919C9AB2F00EB72F0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPad.storyboard; sourceTree = ""; }; + BBEAF23B19C9AB2F00EB72F0 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + BBEAF23C19C9AB2F00EB72F0 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + BBEAF23E19C9AB2F00EB72F0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + BBEAF24419C9AB2F00EB72F0 /* ArpMacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ArpMacTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + BBEAF24519C9AB2F00EB72F0 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + BBEAF24D19C9AB2F00EB72F0 /* ArpMacTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ArpMacTests-Info.plist"; sourceTree = ""; }; + BBEAF24F19C9AB2F00EB72F0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + BBEAF25119C9AB2F00EB72F0 /* ArpMacTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ArpMacTests.m; sourceTree = ""; }; + BBEAF25B19C9AB5900EB72F0 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utils.h; sourceTree = ""; }; + BBEAF25C19C9AB5900EB72F0 /* Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utils.m; sourceTree = ""; }; + BBEAF25F19C9B17700EB72F0 /* if_ether.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = if_ether.h; sourceTree = ""; }; + BBEAF26019C9B17700EB72F0 /* if_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = if_types.h; sourceTree = ""; }; + BBEAF26119C9B17700EB72F0 /* route.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = route.h; sourceTree = ""; }; + BBEAF26219C9B1D900EB72F0 /* if_arp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = if_arp.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + BBEAF21D19C9AB2F00EB72F0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + BBEAF22619C9AB2F00EB72F0 /* CoreGraphics.framework in Frameworks */, + BBEAF22819C9AB2F00EB72F0 /* UIKit.framework in Frameworks */, + BBEAF22419C9AB2F00EB72F0 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BBEAF24119C9AB2F00EB72F0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + BBEAF24619C9AB2F00EB72F0 /* XCTest.framework in Frameworks */, + BBEAF24819C9AB2F00EB72F0 /* UIKit.framework in Frameworks */, + BBEAF24719C9AB2F00EB72F0 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + BBEAF21719C9AB2F00EB72F0 = { + isa = PBXGroup; + children = ( + BBEAF22919C9AB2F00EB72F0 /* ArpMac */, + BBEAF24B19C9AB2F00EB72F0 /* ArpMacTests */, + BBEAF22219C9AB2F00EB72F0 /* Frameworks */, + BBEAF22119C9AB2F00EB72F0 /* Products */, + ); + sourceTree = ""; + }; + BBEAF22119C9AB2F00EB72F0 /* Products */ = { + isa = PBXGroup; + children = ( + BBEAF22019C9AB2F00EB72F0 /* ArpMac.app */, + BBEAF24419C9AB2F00EB72F0 /* ArpMacTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + BBEAF22219C9AB2F00EB72F0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + BBEAF22319C9AB2F00EB72F0 /* Foundation.framework */, + BBEAF22519C9AB2F00EB72F0 /* CoreGraphics.framework */, + BBEAF22719C9AB2F00EB72F0 /* UIKit.framework */, + BBEAF24519C9AB2F00EB72F0 /* XCTest.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + BBEAF22919C9AB2F00EB72F0 /* ArpMac */ = { + isa = PBXGroup; + children = ( + BBEAF25E19C9B17700EB72F0 /* Network */, + BBEAF23219C9AB2F00EB72F0 /* AppDelegate.h */, + BBEAF23319C9AB2F00EB72F0 /* AppDelegate.m */, + BBEAF23519C9AB2F00EB72F0 /* Main_iPhone.storyboard */, + BBEAF23819C9AB2F00EB72F0 /* Main_iPad.storyboard */, + BBEAF23B19C9AB2F00EB72F0 /* ViewController.h */, + BBEAF23C19C9AB2F00EB72F0 /* ViewController.m */, + BBEAF23E19C9AB2F00EB72F0 /* Images.xcassets */, + BBEAF22A19C9AB2F00EB72F0 /* Supporting Files */, + BBEAF25B19C9AB5900EB72F0 /* Utils.h */, + BBEAF25C19C9AB5900EB72F0 /* Utils.m */, + ); + path = ArpMac; + sourceTree = ""; + }; + BBEAF22A19C9AB2F00EB72F0 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + BBEAF22B19C9AB2F00EB72F0 /* ArpMac-Info.plist */, + BBEAF22C19C9AB2F00EB72F0 /* InfoPlist.strings */, + BBEAF22F19C9AB2F00EB72F0 /* main.m */, + BBEAF23119C9AB2F00EB72F0 /* ArpMac-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + BBEAF24B19C9AB2F00EB72F0 /* ArpMacTests */ = { + isa = PBXGroup; + children = ( + BBEAF25119C9AB2F00EB72F0 /* ArpMacTests.m */, + BBEAF24C19C9AB2F00EB72F0 /* Supporting Files */, + ); + path = ArpMacTests; + sourceTree = ""; + }; + BBEAF24C19C9AB2F00EB72F0 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + BBEAF24D19C9AB2F00EB72F0 /* ArpMacTests-Info.plist */, + BBEAF24E19C9AB2F00EB72F0 /* InfoPlist.strings */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + BBEAF25E19C9B17700EB72F0 /* Network */ = { + isa = PBXGroup; + children = ( + BBEAF26219C9B1D900EB72F0 /* if_arp.h */, + BBEAF25F19C9B17700EB72F0 /* if_ether.h */, + BBEAF26019C9B17700EB72F0 /* if_types.h */, + BBEAF26119C9B17700EB72F0 /* route.h */, + ); + path = Network; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + BBEAF21F19C9AB2F00EB72F0 /* ArpMac */ = { + isa = PBXNativeTarget; + buildConfigurationList = BBEAF25519C9AB2F00EB72F0 /* Build configuration list for PBXNativeTarget "ArpMac" */; + buildPhases = ( + BBEAF21C19C9AB2F00EB72F0 /* Sources */, + BBEAF21D19C9AB2F00EB72F0 /* Frameworks */, + BBEAF21E19C9AB2F00EB72F0 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ArpMac; + productName = ArpMac; + productReference = BBEAF22019C9AB2F00EB72F0 /* ArpMac.app */; + productType = "com.apple.product-type.application"; + }; + BBEAF24319C9AB2F00EB72F0 /* ArpMacTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = BBEAF25819C9AB2F00EB72F0 /* Build configuration list for PBXNativeTarget "ArpMacTests" */; + buildPhases = ( + BBEAF24019C9AB2F00EB72F0 /* Sources */, + BBEAF24119C9AB2F00EB72F0 /* Frameworks */, + BBEAF24219C9AB2F00EB72F0 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + BBEAF24A19C9AB2F00EB72F0 /* PBXTargetDependency */, + ); + name = ArpMacTests; + productName = ArpMacTests; + productReference = BBEAF24419C9AB2F00EB72F0 /* ArpMacTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + BBEAF21819C9AB2F00EB72F0 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0510; + ORGANIZATIONNAME = "Kapralos Software"; + TargetAttributes = { + BBEAF24319C9AB2F00EB72F0 = { + TestTargetID = BBEAF21F19C9AB2F00EB72F0; + }; + }; + }; + buildConfigurationList = BBEAF21B19C9AB2F00EB72F0 /* Build configuration list for PBXProject "ArpMac" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = BBEAF21719C9AB2F00EB72F0; + productRefGroup = BBEAF22119C9AB2F00EB72F0 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + BBEAF21F19C9AB2F00EB72F0 /* ArpMac */, + BBEAF24319C9AB2F00EB72F0 /* ArpMacTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + BBEAF21E19C9AB2F00EB72F0 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BBEAF23A19C9AB2F00EB72F0 /* Main_iPad.storyboard in Resources */, + BBEAF23F19C9AB2F00EB72F0 /* Images.xcassets in Resources */, + BBEAF23719C9AB2F00EB72F0 /* Main_iPhone.storyboard in Resources */, + BBEAF22E19C9AB2F00EB72F0 /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BBEAF24219C9AB2F00EB72F0 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BBEAF25019C9AB2F00EB72F0 /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + BBEAF21C19C9AB2F00EB72F0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BBEAF23D19C9AB2F00EB72F0 /* ViewController.m in Sources */, + BBEAF23419C9AB2F00EB72F0 /* AppDelegate.m in Sources */, + BBEAF23019C9AB2F00EB72F0 /* main.m in Sources */, + BBEAF25D19C9AB5900EB72F0 /* Utils.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BBEAF24019C9AB2F00EB72F0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BBEAF25219C9AB2F00EB72F0 /* ArpMacTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + BBEAF24A19C9AB2F00EB72F0 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = BBEAF21F19C9AB2F00EB72F0 /* ArpMac */; + targetProxy = BBEAF24919C9AB2F00EB72F0 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + BBEAF22C19C9AB2F00EB72F0 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + BBEAF22D19C9AB2F00EB72F0 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + BBEAF23519C9AB2F00EB72F0 /* Main_iPhone.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BBEAF23619C9AB2F00EB72F0 /* Base */, + ); + name = Main_iPhone.storyboard; + sourceTree = ""; + }; + BBEAF23819C9AB2F00EB72F0 /* Main_iPad.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BBEAF23919C9AB2F00EB72F0 /* Base */, + ); + name = Main_iPad.storyboard; + sourceTree = ""; + }; + BBEAF24E19C9AB2F00EB72F0 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + BBEAF24F19C9AB2F00EB72F0 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + BBEAF25319C9AB2F00EB72F0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + BBEAF25419C9AB2F00EB72F0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + BBEAF25619C9AB2F00EB72F0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "ArpMac/ArpMac-Prefix.pch"; + INFOPLIST_FILE = "ArpMac/ArpMac-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + BBEAF25719C9AB2F00EB72F0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "ArpMac/ArpMac-Prefix.pch"; + INFOPLIST_FILE = "ArpMac/ArpMac-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + BBEAF25919C9AB2F00EB72F0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ArpMac.app/ArpMac"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "ArpMac/ArpMac-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = "ArpMacTests/ArpMacTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Debug; + }; + BBEAF25A19C9AB2F00EB72F0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ArpMac.app/ArpMac"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "ArpMac/ArpMac-Prefix.pch"; + INFOPLIST_FILE = "ArpMacTests/ArpMacTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + BBEAF21B19C9AB2F00EB72F0 /* Build configuration list for PBXProject "ArpMac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BBEAF25319C9AB2F00EB72F0 /* Debug */, + BBEAF25419C9AB2F00EB72F0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BBEAF25519C9AB2F00EB72F0 /* Build configuration list for PBXNativeTarget "ArpMac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BBEAF25619C9AB2F00EB72F0 /* Debug */, + BBEAF25719C9AB2F00EB72F0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; + BBEAF25819C9AB2F00EB72F0 /* Build configuration list for PBXNativeTarget "ArpMacTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BBEAF25919C9AB2F00EB72F0 /* Debug */, + BBEAF25A19C9AB2F00EB72F0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = BBEAF21819C9AB2F00EB72F0 /* Project object */; +} diff --git a/ArpMac/AppDelegate.h b/ArpMac/AppDelegate.h new file mode 100644 index 0000000..15ddca7 --- /dev/null +++ b/ArpMac/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// ArpMac +// +// Created by Evgeniy Kapralov on 17/09/14. +// Copyright (c) 2014 Kapralos Software. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/ArpMac/AppDelegate.m b/ArpMac/AppDelegate.m new file mode 100644 index 0000000..bd8dc53 --- /dev/null +++ b/ArpMac/AppDelegate.m @@ -0,0 +1,46 @@ +// +// AppDelegate.m +// ArpMac +// +// Created by Evgeniy Kapralov on 17/09/14. +// Copyright (c) 2014 Kapralos Software. All rights reserved. +// + +#import "AppDelegate.h" +#import "Utils.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/ArpMac/ArpMac-Info.plist b/ArpMac/ArpMac-Info.plist new file mode 100644 index 0000000..36fc81d --- /dev/null +++ b/ArpMac/ArpMac-Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.kapralos.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Main_iPhone + UIMainStoryboardFile~ipad + Main_iPad + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/ArpMac/ArpMac-Prefix.pch b/ArpMac/ArpMac-Prefix.pch new file mode 100644 index 0000000..82a2bb4 --- /dev/null +++ b/ArpMac/ArpMac-Prefix.pch @@ -0,0 +1,16 @@ +// +// Prefix header +// +// The contents of this file are implicitly included at the beginning of every source file. +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/ArpMac/Base.lproj/Main_iPad.storyboard b/ArpMac/Base.lproj/Main_iPad.storyboard new file mode 100644 index 0000000..2c1fec8 --- /dev/null +++ b/ArpMac/Base.lproj/Main_iPad.storyboard @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ArpMac/Base.lproj/Main_iPhone.storyboard b/ArpMac/Base.lproj/Main_iPhone.storyboard new file mode 100644 index 0000000..48df20d --- /dev/null +++ b/ArpMac/Base.lproj/Main_iPhone.storyboard @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ArpMac/Images.xcassets/AppIcon.appiconset/Contents.json b/ArpMac/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..91bf9c1 --- /dev/null +++ b/ArpMac/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,53 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ArpMac/Images.xcassets/LaunchImage.launchimage/Contents.json b/ArpMac/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..6f870a4 --- /dev/null +++ b/ArpMac/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,51 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "subtype" : "retina4", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ArpMac/Network/if_arp.h b/ArpMac/Network/if_arp.h new file mode 100644 index 0000000..0eff367 --- /dev/null +++ b/ArpMac/Network/if_arp.h @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2000-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_arp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/net/if_arp.h,v 1.14.2.1 2000/07/11 20:46:55 archie Exp $ + */ + +#ifndef _NET_IF_ARP_H_ +#define _NET_IF_ARP_H_ +#include +#include +#include + +/* + * Address Resolution Protocol. + * + * See RFC 826 for protocol description. ARP packets are variable + * in size; the arphdr structure defines the fixed-length portion. + * Protocol type values are the same as those for 10 Mb/s Ethernet. + * It is followed by the variable-sized fields ar_sha, arp_spa, + * arp_tha and arp_tpa in that order, according to the lengths + * specified. Field names used correspond to RFC 826. + */ +struct arphdr { + u_short ar_hrd; /* format of hardware address */ +#define ARPHRD_ETHER 1 /* ethernet hardware format */ +#define ARPHRD_IEEE802 6 /* token-ring hardware format */ +#define ARPHRD_FRELAY 15 /* frame relay hardware format */ +#define ARPHRD_IEEE1394 24 /* IEEE1394 hardware address */ +#define ARPHRD_IEEE1394_EUI64 27 /* IEEE1394 EUI-64 */ + u_short ar_pro; /* format of protocol address */ + u_char ar_hln; /* length of hardware address */ + u_char ar_pln; /* length of protocol address */ + u_short ar_op; /* one of: */ +#define ARPOP_REQUEST 1 /* request to resolve address */ +#define ARPOP_REPLY 2 /* response to previous request */ +#define ARPOP_REVREQUEST 3 /* request protocol address given hardware */ +#define ARPOP_REVREPLY 4 /* response giving protocol address */ +#define ARPOP_INVREQUEST 8 /* request to identify peer */ +#define ARPOP_INVREPLY 9 /* response identifying peer */ +/* + * The remaining fields are variable in size, + * according to the sizes above. + */ +#ifdef COMMENT_ONLY + u_char ar_sha[]; /* sender hardware address */ + u_char ar_spa[]; /* sender protocol address */ + u_char ar_tha[]; /* target hardware address */ + u_char ar_tpa[]; /* target protocol address */ +#endif +}; + +/* + * ARP ioctl request + */ +struct arpreq { + struct sockaddr arp_pa; /* protocol address */ + struct sockaddr arp_ha; /* hardware address */ + int arp_flags; /* flags */ +}; +/* arp_flags and at_flags field values */ +#define ATF_INUSE 0x01 /* entry in use */ +#define ATF_COM 0x02 /* completed entry (enaddr valid) */ +#define ATF_PERM 0x04 /* permanent entry */ +#define ATF_PUBL 0x08 /* publish entry (respond for other host) */ +#define ATF_USETRAILERS 0x10 /* has requested trailers */ + +struct arpstat { + /* Normal things that happen: */ + uint32_t txrequests; /* # of ARP requests sent by this host. */ + uint32_t txreplies; /* # of ARP replies sent by this host. */ + uint32_t txannounces; /* # of ARP announcements sent by this host. */ + uint32_t rxrequests; /* # of ARP requests received by this host. */ + uint32_t rxreplies; /* # of ARP replies received by this host. */ + uint32_t received; /* # of ARP packets received by this host. */ + + /* Abnormal event and error counting: */ + uint32_t txconflicts; /* # of ARP conflict probes sent */ + uint32_t invalidreqs; /* # of invalid ARP resolve requests */ + uint32_t reqnobufs; /* # of failed requests due to no memory */ + uint32_t dropped; /* # of packets dropped waiting for a reply. */ + uint32_t purged; /* # of packets purged while removing entries */ + uint32_t timeouts; /* # of times with entries removed */ + /* due to timeout. */ + uint32_t dupips; /* # of duplicate IPs detected. */ + + /* General statistics */ + uint32_t inuse; /* # of ARP entries in routing table */ + uint32_t txurequests; /* # of ARP requests sent (unicast) */ +}; + + +#endif /* !_NET_IF_ARP_H_ */ diff --git a/ArpMac/Network/if_ether.h b/ArpMac/Network/if_ether.h new file mode 100644 index 0000000..7284f37 --- /dev/null +++ b/ArpMac/Network/if_ether.h @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2000-2011 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 + * $FreeBSD: src/sys/netinet/if_ether.h,v 1.24 1999/12/29 04:40:58 peter Exp $ + */ + +#ifndef _NETINET_IF_ETHER_H_ +#define _NETINET_IF_ETHER_H_ +#include + +#include + +#include +#include "if_arp.h" +#define ea_byte ether_addr_octet + +/* + * Macro to map an IP multicast address to an Ethernet multicast address. + * The high-order 25 bits of the Ethernet address are statically assigned, + * and the low-order 23 bits are taken from the low end of the IP address. + */ +#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ + /* struct in_addr *ipaddr; */ \ + /* u_char enaddr[ETHER_ADDR_LEN]; */ \ +{ \ + (enaddr)[0] = 0x01; \ + (enaddr)[1] = 0x00; \ + (enaddr)[2] = 0x5e; \ + (enaddr)[3] = ((const u_char *)ipaddr)[1] & 0x7f; \ + (enaddr)[4] = ((const u_char *)ipaddr)[2]; \ + (enaddr)[5] = ((const u_char *)ipaddr)[3]; \ +} +/* + * Macro to map an IP6 multicast address to an Ethernet multicast address. + * The high-order 16 bits of the Ethernet address are statically assigned, + * and the low-order 32 bits are taken from the low end of the IP6 address. + */ +#define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr) \ +/* struct in6_addr *ip6addr; */ \ +/* u_char enaddr[ETHER_ADDR_LEN]; */ \ +{ \ + (enaddr)[0] = 0x33; \ + (enaddr)[1] = 0x33; \ + (enaddr)[2] = ((const u_char *)ip6addr)[12]; \ + (enaddr)[3] = ((const u_char *)ip6addr)[13]; \ + (enaddr)[4] = ((const u_char *)ip6addr)[14]; \ + (enaddr)[5] = ((const u_char *)ip6addr)[15]; \ +} + +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is adapted + * to resolving internet addresses. Field names used correspond to + * RFC 826. + */ +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + u_char arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */ + u_char arp_spa[4]; /* sender protocol address */ + u_char arp_tha[ETHER_ADDR_LEN]; /* target hardware address */ + u_char arp_tpa[4]; /* target protocol address */ +}; +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +struct sockaddr_inarp { + u_char sin_len; + u_char sin_family; + u_short sin_port; + struct in_addr sin_addr; + struct in_addr sin_srcaddr; + u_short sin_tos; + u_short sin_other; +#define SIN_PROXY 0x1 +#define SIN_ROUTER 0x2 +}; +/* + * IP and ethernet specific routing flags + */ +#define RTF_USETRAILERS RTF_PROTO1 /* use trailers */ +#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */ + + +#endif /* _NETINET_IF_ETHER_H_ */ diff --git a/ArpMac/Network/if_types.h b/ArpMac/Network/if_types.h new file mode 100644 index 0000000..4d96972 --- /dev/null +++ b/ArpMac/Network/if_types.h @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2000-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_types.h 8.2 (Berkeley) 4/20/94 + * $FreeBSD: src/sys/net/if_types.h,v 1.8.2.3 2001/07/03 11:01:41 ume Exp $ + */ + +#ifndef _NET_IF_TYPES_H_ +#define _NET_IF_TYPES_H_ +#include + +/* + * Interface types for benefit of parsing media address headers. + * This list is derived from the SNMP list of ifTypes, currently + * documented in RFC1573. + * The current list of assignments is maintained at: + * http://www.iana.org/assignments/smi-numbers + */ + +#define IFT_OTHER 0x1 /* none of the following */ +#define IFT_1822 0x2 /* old-style arpanet imp */ +#define IFT_HDH1822 0x3 /* HDH arpanet imp */ +#define IFT_X25DDN 0x4 /* x25 to imp */ +#define IFT_X25 0x5 /* PDN X25 interface (RFC877) */ +#define IFT_ETHER 0x6 /* Ethernet CSMACD */ +#define IFT_ISO88023 0x7 /* CMSA CD */ +#define IFT_ISO88024 0x8 /* Token Bus */ +#define IFT_ISO88025 0x9 /* Token Ring */ +#define IFT_ISO88026 0xa /* MAN */ +#define IFT_STARLAN 0xb +#define IFT_P10 0xc /* Proteon 10MBit ring */ +#define IFT_P80 0xd /* Proteon 80MBit ring */ +#define IFT_HY 0xe /* Hyperchannel */ +#define IFT_FDDI 0xf +#define IFT_LAPB 0x10 +#define IFT_SDLC 0x11 +#define IFT_T1 0x12 +#define IFT_CEPT 0x13 /* E1 - european T1 */ +#define IFT_ISDNBASIC 0x14 +#define IFT_ISDNPRIMARY 0x15 +#define IFT_PTPSERIAL 0x16 /* Proprietary PTP serial */ +#define IFT_PPP 0x17 /* RFC 1331 */ +#define IFT_LOOP 0x18 /* loopback */ +#define IFT_EON 0x19 /* ISO over IP */ +#define IFT_XETHER 0x1a /* obsolete 3MB experimental ethernet */ +#define IFT_NSIP 0x1b /* XNS over IP */ +#define IFT_SLIP 0x1c /* IP over generic TTY */ +#define IFT_ULTRA 0x1d /* Ultra Technologies */ +#define IFT_DS3 0x1e /* Generic T3 */ +#define IFT_SIP 0x1f /* SMDS */ +#define IFT_FRELAY 0x20 /* Frame Relay DTE only */ +#define IFT_RS232 0x21 +#define IFT_PARA 0x22 /* parallel-port */ +#define IFT_ARCNET 0x23 +#define IFT_ARCNETPLUS 0x24 +#define IFT_ATM 0x25 /* ATM cells */ +#define IFT_MIOX25 0x26 +#define IFT_SONET 0x27 /* SONET or SDH */ +#define IFT_X25PLE 0x28 +#define IFT_ISO88022LLC 0x29 +#define IFT_LOCALTALK 0x2a +#define IFT_SMDSDXI 0x2b +#define IFT_FRELAYDCE 0x2c /* Frame Relay DCE */ +#define IFT_V35 0x2d +#define IFT_HSSI 0x2e +#define IFT_HIPPI 0x2f +#define IFT_MODEM 0x30 /* Generic Modem */ +#define IFT_AAL5 0x31 /* AAL5 over ATM */ +#define IFT_SONETPATH 0x32 +#define IFT_SONETVT 0x33 +#define IFT_SMDSICIP 0x34 /* SMDS InterCarrier Interface */ +#define IFT_PROPVIRTUAL 0x35 /* Proprietary Virtual/internal */ +#define IFT_PROPMUX 0x36 /* Proprietary Multiplexing */ +/* + * IFT_GIF, IFT_FAITH and IFT_FAITH are not based on IANA assignments. + * Note: IFT_STF has a defined ifType: 0xd7 (215), but we use 0x39. + */ +#define IFT_GIF 0x37 /*0xf0*/ +#define IFT_FAITH 0x38 /*0xf2*/ +#define IFT_STF 0x39 /*0xf3*/ + +#define IFT_L2VLAN 0x87 /* Layer 2 Virtual LAN using 802.1Q */ +#define IFT_IEEE8023ADLAG 0x88 /* IEEE802.3ad Link Aggregate */ +#define IFT_IEEE1394 0x90 /* IEEE1394 High Performance SerialBus*/ +#define IFT_BRIDGE 0xd1 /* Transparent bridge interface */ + +#define IFT_ENC 0xf4 /* Encapsulation */ +#define IFT_PFLOG 0xf5 /* Packet filter logging */ +#define IFT_PFSYNC 0xf6 /* Packet filter state syncing */ +#define IFT_CARP 0xf8 /* Common Address Redundancy Protocol */ +#define IFT_PKTAP 0xfe /* Packet tap pseudo interface */ +#define IFT_CELLULAR 0xff /* Packet Data over Cellular */ +#define IFT_PDP IFT_CELLULAR /* deprecated; use IFT_CELLULAR */ + +#endif diff --git a/ArpMac/Network/route.h b/ArpMac/Network/route.h new file mode 100644 index 0000000..c51d895 --- /dev/null +++ b/ArpMac/Network/route.h @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2000-2013 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1980, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)route.h 8.3 (Berkeley) 4/19/94 + * $FreeBSD: src/sys/net/route.h,v 1.36.2.1 2000/08/16 06:14:23 jayanth Exp $ + */ + +#ifndef _NET_ROUTE_H_ +#define _NET_ROUTE_H_ +#include +#include +#include +#include + +/* + * These numbers are used by reliable protocols for determining + * retransmission behavior and are included in the routing structure. + */ +struct rt_metrics { + u_int32_t rmx_locks; /* Kernel leaves these values alone */ + u_int32_t rmx_mtu; /* MTU for this path */ + u_int32_t rmx_hopcount; /* max hops expected */ + int32_t rmx_expire; /* lifetime for route, e.g. redirect */ + u_int32_t rmx_recvpipe; /* inbound delay-bandwidth product */ + u_int32_t rmx_sendpipe; /* outbound delay-bandwidth product */ + u_int32_t rmx_ssthresh; /* outbound gateway buffer limit */ + u_int32_t rmx_rtt; /* estimated round trip time */ + u_int32_t rmx_rttvar; /* estimated rtt variance */ + u_int32_t rmx_pksent; /* packets sent using this route */ + u_int32_t rmx_filler[4]; /* will be used for T/TCP later */ +}; + +/* + * rmx_rtt and rmx_rttvar are stored as microseconds; + */ +#define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */ + + + +#define RTF_UP 0x1 /* route usable */ +#define RTF_GATEWAY 0x2 /* destination is a gateway */ +#define RTF_HOST 0x4 /* host entry (net otherwise) */ +#define RTF_REJECT 0x8 /* host or net unreachable */ +#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */ +#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */ +#define RTF_DONE 0x40 /* message confirmed */ +#define RTF_DELCLONE 0x80 /* delete cloned route */ +#define RTF_CLONING 0x100 /* generate new routes on use */ +#define RTF_XRESOLVE 0x200 /* external daemon resolves name */ +#define RTF_LLINFO 0x400 /* generated by link layer (e.g. ARP) */ +#define RTF_STATIC 0x800 /* manually added */ +#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */ +#define RTF_NOIFREF 0x2000 /* not eligible for RTF_IFREF */ +#define RTF_PROTO2 0x4000 /* protocol specific routing flag */ +#define RTF_PROTO1 0x8000 /* protocol specific routing flag */ + +#define RTF_PRCLONING 0x10000 /* protocol requires cloning */ +#define RTF_WASCLONED 0x20000 /* route generated through cloning */ +#define RTF_PROTO3 0x40000 /* protocol specific routing flag */ + /* 0x80000 unused */ +#define RTF_PINNED 0x100000 /* future use */ +#define RTF_LOCAL 0x200000 /* route represents a local address */ +#define RTF_BROADCAST 0x400000 /* route represents a bcast address */ +#define RTF_MULTICAST 0x800000 /* route represents a mcast address */ +#define RTF_IFSCOPE 0x1000000 /* has valid interface scope */ +#define RTF_CONDEMNED 0x2000000 /* defunct; no longer modifiable */ +#define RTF_IFREF 0x4000000 /* route holds a ref to interface */ +#define RTF_PROXY 0x8000000 /* proxying, no interface scope */ +#define RTF_ROUTER 0x10000000 /* host is a router */ + /* 0x20000000 and up unassigned */ + +#define RTF_BITS \ + "\020\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE" \ + "\10DELCLONE\11CLONING\12XRESOLVE\13LLINFO\14STATIC\15BLACKHOLE" \ + "\16NOIFREF\17PROTO2\20PROTO1\21PRCLONING\22WASCLONED\23PROTO3" \ + "\25PINNED\26LOCAL\27BROADCAST\30MULTICAST\31IFSCOPE\32CONDEMNED" \ + "\33IFREF\34PROXY\35ROUTER" + +/* + * Routing statistics. + */ +struct rtstat { + short rts_badredirect; /* bogus redirect calls */ + short rts_dynamic; /* routes created by redirects */ + short rts_newgateway; /* routes modified by redirects */ + short rts_unreach; /* lookups which failed */ + short rts_wildcard; /* lookups satisfied by a wildcard */ +}; + +/* + * Structures for routing messages. + */ +struct rt_msghdr { + u_short rtm_msglen; /* to skip over non-understood messages */ + u_char rtm_version; /* future binary compatibility */ + u_char rtm_type; /* message type */ + u_short rtm_index; /* index for associated ifp */ + int rtm_flags; /* flags, incl. kern & message, e.g. DONE */ + int rtm_addrs; /* bitmask identifying sockaddrs in msg */ + pid_t rtm_pid; /* identify sender */ + int rtm_seq; /* for sender to identify action */ + int rtm_errno; /* why failed */ + int rtm_use; /* from rtentry */ + u_int32_t rtm_inits; /* which metrics we are initializing */ + struct rt_metrics rtm_rmx; /* metrics themselves */ +}; + +struct rt_msghdr2 { + u_short rtm_msglen; /* to skip over non-understood messages */ + u_char rtm_version; /* future binary compatibility */ + u_char rtm_type; /* message type */ + u_short rtm_index; /* index for associated ifp */ + int rtm_flags; /* flags, incl. kern & message, e.g. DONE */ + int rtm_addrs; /* bitmask identifying sockaddrs in msg */ + int32_t rtm_refcnt; /* reference count */ + int rtm_parentflags; /* flags of the parent route */ + int rtm_reserved; /* reserved field set to 0 */ + int rtm_use; /* from rtentry */ + u_int32_t rtm_inits; /* which metrics we are initializing */ + struct rt_metrics rtm_rmx; /* metrics themselves */ +}; + + +#define RTM_VERSION 5 /* Up the ante and ignore older versions */ + +/* + * Message types. + */ +#define RTM_ADD 0x1 /* Add Route */ +#define RTM_DELETE 0x2 /* Delete Route */ +#define RTM_CHANGE 0x3 /* Change Metrics or flags */ +#define RTM_GET 0x4 /* Report Metrics */ +#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */ +#define RTM_REDIRECT 0x6 /* Told to use different route */ +#define RTM_MISS 0x7 /* Lookup failed on this address */ +#define RTM_LOCK 0x8 /* fix specified metrics */ +#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */ +#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */ +#define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */ +#define RTM_NEWADDR 0xc /* address being added to iface */ +#define RTM_DELADDR 0xd /* address being removed from iface */ +#define RTM_IFINFO 0xe /* iface going up/down etc. */ +#define RTM_NEWMADDR 0xf /* mcast group membership being added to if */ +#define RTM_DELMADDR 0x10 /* mcast group membership being deleted */ +#define RTM_IFINFO2 0x12 /* */ +#define RTM_NEWMADDR2 0x13 /* */ +#define RTM_GET2 0x14 /* */ + +/* + * Bitmask values for rtm_inits and rmx_locks. + */ +#define RTV_MTU 0x1 /* init or lock _mtu */ +#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ +#define RTV_EXPIRE 0x4 /* init or lock _expire */ +#define RTV_RPIPE 0x8 /* init or lock _recvpipe */ +#define RTV_SPIPE 0x10 /* init or lock _sendpipe */ +#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */ +#define RTV_RTT 0x40 /* init or lock _rtt */ +#define RTV_RTTVAR 0x80 /* init or lock _rttvar */ + +/* + * Bitmask values for rtm_addrs. + */ +#define RTA_DST 0x1 /* destination sockaddr present */ +#define RTA_GATEWAY 0x2 /* gateway sockaddr present */ +#define RTA_NETMASK 0x4 /* netmask sockaddr present */ +#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */ +#define RTA_IFP 0x10 /* interface name sockaddr present */ +#define RTA_IFA 0x20 /* interface addr sockaddr present */ +#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */ +#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */ + +/* + * Index offsets for sockaddr array for alternate internal encoding. + */ +#define RTAX_DST 0 /* destination sockaddr present */ +#define RTAX_GATEWAY 1 /* gateway sockaddr present */ +#define RTAX_NETMASK 2 /* netmask sockaddr present */ +#define RTAX_GENMASK 3 /* cloning mask sockaddr present */ +#define RTAX_IFP 4 /* interface name sockaddr present */ +#define RTAX_IFA 5 /* interface addr sockaddr present */ +#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */ +#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */ +#define RTAX_MAX 8 /* size of array to allocate */ + +struct rt_addrinfo { + int rti_addrs; + struct sockaddr *rti_info[RTAX_MAX]; +}; + + +#endif /* _NET_ROUTE_H_ */ diff --git a/ArpMac/Utils.h b/ArpMac/Utils.h new file mode 100644 index 0000000..5d34632 --- /dev/null +++ b/ArpMac/Utils.h @@ -0,0 +1,15 @@ +// +// Utils.h +// ArpMac +// +// Created by Evgeniy Kapralov on 17/09/14. +// Copyright (c) 2014 Kapralos Software. All rights reserved. +// + +#import + +@interface Utils : NSObject + ++ (NSString*)ipToMac:(NSString*)ipAddress; + +@end diff --git a/ArpMac/Utils.m b/ArpMac/Utils.m new file mode 100644 index 0000000..8a629f5 --- /dev/null +++ b/ArpMac/Utils.m @@ -0,0 +1,102 @@ +// +// Utils.m +// ArpMac +// +// Created by Evgeniy Kapralov on 17/09/14. +// Copyright (c) 2014 Kapralos Software. All rights reserved. +// + +#import "Utils.h" + +#if (TARGET_IPHONE_SIMULATOR) +#import +#import +#import +#else +#import "if_types.h" +#import "route.h" +#import "if_ether.h" +#endif + +#import +#import +#import +#import +#import + +@interface Utils() + ++ (void)logSockaddrInarp:(struct sockaddr_inarp)sockaddr; + +@end + +@implementation Utils + ++ (NSString*)ipToMac:(NSString*)ipAddress +{ + NSString* res = nil; + + in_addr_t addr = inet_addr([ipAddress UTF8String]); + + size_t needed; + char *buf, *next; + + struct rt_msghdr *rtm; + struct sockaddr_inarp *sin; + struct sockaddr_dl *sdl; + + int mib[6]; + + mib[0] = CTL_NET; + mib[1] = PF_ROUTE; + mib[2] = 0; + mib[3] = AF_INET; + mib[4] = NET_RT_FLAGS; + mib[5] = RTF_LLINFO; + + if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &needed, NULL, 0) < 0) + NSLog(@"route-sysctl-estimate"); + + if ((buf = (char*)malloc(needed)) == NULL) + NSLog(@"malloc"); + + if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &needed, NULL, 0) < 0) + NSLog(@"retrieval of routing table"); + + for (next = buf; next < buf + needed; next += rtm->rtm_msglen) { + + rtm = (struct rt_msghdr *)next; + sin = (struct sockaddr_inarp *)(rtm + 1); + sdl = (struct sockaddr_dl *)(sin + 1); + + [Utils logSockaddrInarp:*sin]; + + if (addr != sin->sin_addr.s_addr || sdl->sdl_alen < 6) + continue; + + u_char *cp = (u_char*)LLADDR(sdl); + + res = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X", + cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]]; + + break; + } + + free(buf); + + return res; +} + ++ (void)logSockaddrInarp:(struct sockaddr_inarp)sockaddr +{ + printf("sockaddr_inarp:\n"); + printf(" sin_addr = %s\n", inet_ntoa(sockaddr.sin_addr)); + printf(" sin_family = %uc\n", sockaddr.sin_family); + printf(" sin_len = %uc\n", sockaddr.sin_len); + printf(" sin_other = %us\n", sockaddr.sin_other); + printf(" sin_port = %us\n", sockaddr.sin_port); + printf(" sin_srcaddr = %s\n", inet_ntoa(sockaddr.sin_srcaddr)); + printf(" sin_tos = %us\n", sockaddr.sin_tos); +} + +@end diff --git a/ArpMac/ViewController.h b/ArpMac/ViewController.h new file mode 100644 index 0000000..ac14617 --- /dev/null +++ b/ArpMac/ViewController.h @@ -0,0 +1,13 @@ +// +// ViewController.h +// ArpMac +// +// Created by Evgeniy Kapralov on 17/09/14. +// Copyright (c) 2014 Kapralos Software. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + +@end diff --git a/ArpMac/ViewController.m b/ArpMac/ViewController.m new file mode 100644 index 0000000..e820d2f --- /dev/null +++ b/ArpMac/ViewController.m @@ -0,0 +1,40 @@ +// +// ViewController.m +// ArpMac +// +// Created by Evgeniy Kapralov on 17/09/14. +// Copyright (c) 2014 Kapralos Software. All rights reserved. +// + +#import "ViewController.h" +#import "Utils.h" + +@interface ViewController () + +@property (weak) IBOutlet UITextField* ipAddressTextField; +@property (weak) IBOutlet UILabel* macAddrLabel; + +- (IBAction)findPressed:(id)sender; + +@end + +@implementation ViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (IBAction)findPressed:(id)sender +{ + self.macAddrLabel.text = [Utils ipToMac:self.ipAddressTextField.text]; +} + +@end diff --git a/ArpMac/en.lproj/InfoPlist.strings b/ArpMac/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/ArpMac/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/ArpMac/main.m b/ArpMac/main.m new file mode 100644 index 0000000..b76013b --- /dev/null +++ b/ArpMac/main.m @@ -0,0 +1,18 @@ +// +// main.m +// ArpMac +// +// Created by Evgeniy Kapralov on 17/09/14. +// Copyright (c) 2014 Kapralos Software. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char * argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/ArpMacTests/ArpMacTests-Info.plist b/ArpMacTests/ArpMacTests-Info.plist new file mode 100644 index 0000000..90bc586 --- /dev/null +++ b/ArpMacTests/ArpMacTests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.kapralos.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/ArpMacTests/ArpMacTests.m b/ArpMacTests/ArpMacTests.m new file mode 100644 index 0000000..e0209e2 --- /dev/null +++ b/ArpMacTests/ArpMacTests.m @@ -0,0 +1,34 @@ +// +// ArpMacTests.m +// ArpMacTests +// +// Created by Evgeniy Kapralov on 17/09/14. +// Copyright (c) 2014 Kapralos Software. All rights reserved. +// + +#import + +@interface ArpMacTests : XCTestCase + +@end + +@implementation ArpMacTests + +- (void)setUp +{ + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown +{ + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample +{ + XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); +} + +@end diff --git a/ArpMacTests/en.lproj/InfoPlist.strings b/ArpMacTests/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/ArpMacTests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ +