Skip to content

Instantly share code, notes, and snippets.

@zengcity
Created September 15, 2019 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zengcity/ed710ff963ce7038d4c3d43d545d6ea6 to your computer and use it in GitHub Desktop.
Save zengcity/ed710ff963ce7038d4c3d43d545d6ea6 to your computer and use it in GitHub Desktop.
public init(payload: NSData) {
let vl = UnsafePointer<UInt8>(payload.bytes).memory
version = IPVersion(rawValue: vl >> 4)!
IPHeaderLength = Int(vl & 0x0F) * 4
let p = UnsafePointer<UInt8>(payload.bytes.advancedBy(9)).memory
proto = TransportType(rawValue: p)!
self.payload = NSMutableData(data: payload)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment