1*94d3b452SApple OSS Distributionsfrom xnu import * 2*94d3b452SApple OSS Distributionsfrom utils import * 3*94d3b452SApple OSS Distributionsimport ctypes 4*94d3b452SApple OSS Distributions 5*94d3b452SApple OSS DistributionsMBSHIFT = 20 6*94d3b452SApple OSS DistributionsMSIZE = 256 7*94d3b452SApple OSS DistributionsMCLBYTES = 2048 8*94d3b452SApple OSS DistributionsMBIGCLBYTES = 4096 9*94d3b452SApple OSS DistributionsM16KCLBYTES = 16384 10*94d3b452SApple OSS Distributions 11*94d3b452SApple OSS DistributionsMB_INUSE = 1 12*94d3b452SApple OSS DistributionsMB_COMP_INUSE = 2 13*94d3b452SApple OSS DistributionsMB_SCVALID = 4 14*94d3b452SApple OSS Distributions 15*94d3b452SApple OSS DistributionsSLF_MAPPED = 0x0001 16*94d3b452SApple OSS DistributionsSLF_PARTIAL = 0x0002 17*94d3b452SApple OSS DistributionsSLF_DETACHED = 0x0004 18*94d3b452SApple OSS Distributions 19*94d3b452SApple OSS DistributionsINTP = ctypes.POINTER(ctypes.c_int) 20*94d3b452SApple OSS Distributions 21*94d3b452SApple OSS DistributionsMCF_NOCPUCACHE = 0x10 22*94d3b452SApple OSS Distributions 23*94d3b452SApple OSS Distributionsdef enum(*sequential, **named): 24*94d3b452SApple OSS Distributions enums = dict(zip(sequential, range(len(sequential))), **named) 25*94d3b452SApple OSS Distributions reverse = dict((value, key) for key, value in enums.items()) 26*94d3b452SApple OSS Distributions enums['reverse_mapping'] = reverse 27*94d3b452SApple OSS Distributions return type('Enum', (), enums) 28*94d3b452SApple OSS Distributions 29*94d3b452SApple OSS DistributionsMbuf_Type = enum( 30*94d3b452SApple OSS Distributions 'MT_FREE', 31*94d3b452SApple OSS Distributions 'MT_DATA', 32*94d3b452SApple OSS Distributions 'MT_HEADER', 33*94d3b452SApple OSS Distributions 'MT_SOCKET', 34*94d3b452SApple OSS Distributions 'MT_PCB', 35*94d3b452SApple OSS Distributions 'MT_RTABLE', 36*94d3b452SApple OSS Distributions 'MT_HTABLE', 37*94d3b452SApple OSS Distributions 'MT_ATABLE', 38*94d3b452SApple OSS Distributions 'MT_SONAME', 39*94d3b452SApple OSS Distributions 'MT_SOOPTS', 40*94d3b452SApple OSS Distributions 'MT_FTABLE', 41*94d3b452SApple OSS Distributions 'MT_RIGHTS', 42*94d3b452SApple OSS Distributions 'MT_IFADDR', 43*94d3b452SApple OSS Distributions 'MT_CONTROL', 44*94d3b452SApple OSS Distributions 'MT_OOBDATA', 45*94d3b452SApple OSS Distributions 'MT_TAG', 46*94d3b452SApple OSS Distributions 'MT_LAST') 47*94d3b452SApple OSS Distributions 48*94d3b452SApple OSS DistributionsM_EXT = 0x0001 49*94d3b452SApple OSS DistributionsM_PKTHDR = 0x0002 50*94d3b452SApple OSS DistributionsM_EOR = 0x0004 51*94d3b452SApple OSS DistributionsM_PROTO1 = 0x0008 52*94d3b452SApple OSS DistributionsM_PROTO2 = 0x0010 53*94d3b452SApple OSS DistributionsM_PROTO3 = 0x0020 54*94d3b452SApple OSS DistributionsM_LOOP = 0x0040 55*94d3b452SApple OSS DistributionsM_PROTO5 = 0x0080 56*94d3b452SApple OSS Distributions 57*94d3b452SApple OSS DistributionsM_BCAST = 0x0100 58*94d3b452SApple OSS DistributionsM_MCAST = 0x0200 59*94d3b452SApple OSS DistributionsM_FRAG = 0x0400 60*94d3b452SApple OSS DistributionsM_FIRSTFRAG = 0x0800 61*94d3b452SApple OSS DistributionsM_LASTFRAG = 0x1000 62*94d3b452SApple OSS DistributionsM_PROMISC = 0x2000 63*94d3b452SApple OSS DistributionsM_HASFCS = 0x4000 64*94d3b452SApple OSS DistributionsM_TAGHDR = 0x8000 65*94d3b452SApple OSS Distributions 66*94d3b452SApple OSS Distributionsmbuf_flags_strings = [ 67*94d3b452SApple OSS Distributions "EXT", 68*94d3b452SApple OSS Distributions "PKTHDR", 69*94d3b452SApple OSS Distributions "EOR", 70*94d3b452SApple OSS Distributions "PROTO1", 71*94d3b452SApple OSS Distributions "PROTO2", 72*94d3b452SApple OSS Distributions "PROTO3", 73*94d3b452SApple OSS Distributions "LOOP", 74*94d3b452SApple OSS Distributions "PROTO5", 75*94d3b452SApple OSS Distributions 76*94d3b452SApple OSS Distributions "BCAST", 77*94d3b452SApple OSS Distributions "MCAST", 78*94d3b452SApple OSS Distributions "FRAG", 79*94d3b452SApple OSS Distributions "FIRSTFRAG", 80*94d3b452SApple OSS Distributions "LASTFRAG", 81*94d3b452SApple OSS Distributions "PROMISC", 82*94d3b452SApple OSS Distributions "HASFCS", 83*94d3b452SApple OSS Distributions "TAGHDR"] 84*94d3b452SApple OSS Distributions 85*94d3b452SApple OSS Distributionsmbuf_pkt_crumb_strings = [ 86*94d3b452SApple OSS Distributions "TS_COMP_REQ", 87*94d3b452SApple OSS Distributions "TS_COMP_CB", 88*94d3b452SApple OSS Distributions "DLIL_OUTPUT", 89*94d3b452SApple OSS Distributions "FLOW_TX", 90*94d3b452SApple OSS Distributions "FQ_ENQUEUE", 91*94d3b452SApple OSS Distributions "FQ_DEQUEUE", 92*94d3b452SApple OSS Distributions "SK_PKT_COPY", 93*94d3b452SApple OSS Distributions "TCP_OUTPUT", 94*94d3b452SApple OSS Distributions "UDP_OUTPUT", 95*94d3b452SApple OSS Distributions "SOSEND", 96*94d3b452SApple OSS Distributions "DLIL_INPUT", 97*94d3b452SApple OSS Distributions "IP_INPUT", 98*94d3b452SApple OSS Distributions "TCP_INPUT", 99*94d3b452SApple OSS Distributions "UDP_INPUT"] 100