我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用socket.IP_HDRINCL。
def init_func(self, creator_fd): self.__creator_fd = creator_fd self.__sent = [] family = socket.AF_INET s = socket.socket(family, socket.SOCK_RAW, socket.IPPROTO_UDP | socket.IPPROTO_ICMP | socket.IPPROTO_UDP | 136) s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1) s.setblocking(0) self.__socket = s self.set_fileno(s.fileno()) self.register(self.fileno) self.add_evt_read(self.fileno) return self.fileno
def __init__(self, hostID, logFile,sharedBufferArray): threading.Thread.__init__(self) self.threadCmdLock = threading.Lock() self.threadCallbackQueue = {} self.threadCallbackLock = threading.Lock() self.nPendingCallbacks = 0 self.threadCmdQueue = [] self.hostID = hostID self.sharedBufferArray = sharedBufferArray self.log = logger.Logger(logFile, "Host " + str(hostID) + " IPC Thread") self.hostIDtoPowerSimID = None self.powerSimIDtohostID = None self.attackLayer = None self.raw_sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW) self.init_shared_ipc_buffer() # self.raw_sock.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
def __init__(self, type = ETH_P_IP, filter=None, iface=None, promisc=None, nofilter=0): self.outs = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW) self.outs.setsockopt(socket.SOL_IP, socket.IP_HDRINCL, 1) self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type)) if iface is not None: self.ins.bind((iface, type))
def __init__(self, type = ETH_P_IP, filter=None, iface=None, promisc=None, nofilter=0): self.outs = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW) self.outs.setsockopt(socket.SOL_IP, socket.IP_HDRINCL, 1) self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))