当前位置: 首页>>代码示例>>Python>>正文


Python ATMT.state方法代码示例

本文整理汇总了Python中scapy.automaton.ATMT.state方法的典型用法代码示例。如果您正苦于以下问题:Python ATMT.state方法的具体用法?Python ATMT.state怎么用?Python ATMT.state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scapy.automaton.ATMT的用法示例。


在下文中一共展示了ATMT.state方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reset

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def reset(self, iface=None, client_mac=None, xid=None, scriptfile=None):
        """Reset object attributes when state is INIT."""
        logger.debug('Reseting attributes.')
        if iface is None:
            iface = conf.iface
        if client_mac is None:
            # scapy for python 3 returns byte, not tuple
            tempmac = get_if_raw_hwaddr(iface)
            if isinstance(tempmac, tuple) and len(tempmac) == 2:
                mac = tempmac[1]
            else:
                mac = tempmac
            client_mac = str2mac(mac)
        self.client = DHCPCAP(iface=iface, client_mac=client_mac, xid=xid)
        if scriptfile is not None:
            self.script = ClientScript(scriptfile)
        else:
            self.script = None
        self.time_sent_request = None
        self.discover_attempts = 0
        self.request_attempts = 0
        self.current_state = STATE_PREINIT
        self.offers = list() 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:25,代码来源:dhcpcapfsm.py

示例2: BOUND

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def BOUND(self):
        """BOUND state."""
        logger.debug('In state: BOUND')
        logger.info('(%s) state changed %s -> bound', self.client.iface,
                    STATES2NAMES[self.current_state])
        self.current_state = STATE_BOUND
        self.client.lease.info_lease()
        if self.script is not None:
            self.script.script_init(self.client.lease, self.current_state)
            self.script.script_go()
        else:
            try:
                set_net(self.client.lease)
            except Exception as e:
                logger.error('Can not set IP', exc_info=True)
                # raise self.END()
        # TODO: go daemon? 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:19,代码来源:dhcpcapfsm.py

示例3: timeout_requesting

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def timeout_requesting(self):
        """Timeout requesting in REQUESTING state.

        Not specifiyed in [:rfc:`7844`]

        [:rfc:`2131#section-3.1`]::

            might retransmit the
            DHCPREQUEST message four times, for a total delay of 60 seconds

        """
        logger.debug("C3.2: T. In %s, timeout receiving response to request, ",
                     self.current_state)
        if self.discover_requests >= MAX_ATTEMPTS_REQUEST:
            logger.debug('C2.3: T. Maximum number %s of REQUESTs '
                         'reached, already sent %s, raise ERROR.',
                         MAX_ATTEMPTS_REQUEST, self.disover_requests)
            raise self.ERROR()
        logger.debug("C2.3: F. Maximum number of REQUESTs retries not reached,"
                     "raise REQUESTING.")
        raise self.REQUESTING() 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:23,代码来源:dhcpcapfsm.py

示例4: timeout_request_renewing

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def timeout_request_renewing(self):
        """Timeout of renewing on RENEWING state.

        Same comments as in
        :func:`dhcpcapfsm.DHCPCAPFSM.timeout_requesting`.

        """
        logger.debug("C5.2:T In %s, timeout receiving response to request.",
                     self.current_state)
        if self.request_attempts >= MAX_ATTEMPTS_REQUEST:
            logger.debug('C2.3: T Maximum number %s of REQUESTs '
                         'reached, already sent %s, wait to rebinding time.',
                         MAX_ATTEMPTS_REQUEST, self.disover_requests)
            # raise self.ERROR()
        logger.debug("C2.3: F. Maximum number of REQUESTs retries not reached,"
                     "raise RENEWING.")
        raise self.RENEWING() 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:19,代码来源:dhcpcapfsm.py

示例5: lease_expires

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def lease_expires(self):
        """Timeout lease time, transition to INIT.

        Not sending DHCPRELEASE to minimize deanonymization

        [:rfc:`2131#section-4.4.6`]::

            Note that the correct operation
            of DHCP does not depend on the transmission of DHCPRELEASE.

        """
        logger.debug("C6.3. Timeout lease time, in REBINDING state, "
                     "raise INIT.")
        raise self.STATE_INIT()

    # RECEIVE CONDITIONS
    #################### 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:19,代码来源:dhcpcapfsm.py

示例6: receive_offer

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def receive_offer(self, pkt):
        """Receive offer on SELECTING state."""
        logger.debug("C2. Received OFFER?, in SELECTING state.")
        if isoffer(pkt):
            logger.debug("C2: T, OFFER received")
            self.offers.append(pkt)
            if len(self.offers) >= MAX_OFFERS_COLLECTED:
                logger.debug("C2.5: T, raise REQUESTING.")
                self.select_offer()
                raise self.REQUESTING()
            logger.debug("C2.5: F, raise SELECTING.")
            raise self.SELECTING()

    # same as:, but would can not be overloaded
    # @ATMT.receive_condition(RENEWING)
    # @ATMT.receive_condition(REBINDING) 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:18,代码来源:dhcpcapfsm.py

示例7: get_timeout

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def get_timeout(self, state, function):
        """Workaround to get timeout in the ATMT.timeout class method."""
        state = STATES2NAMES[state]
        for timeout_fn_t in self.timeout[state]:
            # access the function name
            if timeout_fn_t[1] is not None and \
               timeout_fn_t[1].atmt_condname == function.atmt_condname:
                logger.debug('Timeout for state %s, function %s, is %s',
                             state, function.atmt_condname, timeout_fn_t[0])
                return timeout_fn_t[0]
        return None 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:13,代码来源:dhcpcapfsm.py

示例8: set_timeout

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def set_timeout(self, state, function, newtimeout):
        """
        Workaround to change timeout values in the ATMT.timeout class method.

        self.timeout format is::

            {'STATE': [
                (TIMEOUT0, <function foo>),
                (TIMEOUT1, <function bar>)),
                (None, None)
                ],
            }


        """
        state = STATES2NAMES[state]
        for timeout_fn_t in self.timeout[state]:
            # access the function name
            if timeout_fn_t[1] is not None and \
               timeout_fn_t[1].atmt_condname == function.atmt_condname:
                # convert list to tuple to make it mutable
                timeout_l = list(timeout_fn_t)
                # modify the timeout
                timeout_l[0] = newtimeout
                # set the new timeoute to self.timeout
                i = self.timeout[state].index(timeout_fn_t)
                self.timeout[state][i] = tuple(timeout_l)
                logger.debug('Set state %s, function %s, to timeout %s',
                             state, function.atmt_condname, newtimeout) 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:31,代码来源:dhcpcapfsm.py

示例9: process_received_ack

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def process_received_ack(self, pkt):
        """Process a received ACK packet.

        Not specifiyed in [:rfc:`7844`].
        Probe the offered IP in [:rfc:`2131#section-2.2.`]::

            the allocating
            server SHOULD probe the reused address before allocating the
            address, e.g., with an ICMP echo request, and the client SHOULD
            probe the newly received address, e.g., with ARP.

            The client SHOULD broadcast an ARP
            reply to announce the client's new IP address and clear any
            outdated ARP cache entries in hosts on the client's subnet.

        It is also not specifiyed in [:rfc:`7844`] nor [:rfc:`2131`] how to
        check that the offered IP is valid.

        .. todo::
           - Check that nor ``dhclient`` nor ``systemd-networkd`` send an ARP.
           - Check how other implementations check that the ACK paremeters
             are valid, ie, if the ACK fields match the fields in the OFFER.
           - Check to which state the client should go back to when the
             offered parameters are not valid.

        """
        if isack(pkt):
            try:
                self.event = self.client.handle_ack(pkt,
                                                    self.time_sent_request)
            except AddrFormatError as err:
                logger.error(err)
                # NOTE: see previous TODO, maybe should go back to other state.
                raise self.SELECTING()
            # NOTE: see previous TODO, not checking address with ARP.
            logger.info('DHCPACK of %s from %s' %
                        (self.client.client_ip, self.client.server_ip))
            return True
        return False 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:41,代码来源:dhcpcapfsm.py

示例10: SELECTING

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def SELECTING(self):
        """SELECTING state."""
        logger.debug('In state: SELECTING')
        self.current_state = STATE_SELECTING 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:6,代码来源:dhcpcapfsm.py

示例11: REQUESTING

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def REQUESTING(self):
        """REQUESTING state."""
        logger.debug('In state: REQUESTING')
        self.current_state = STATE_REQUESTING 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:6,代码来源:dhcpcapfsm.py

示例12: RENEWING

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def RENEWING(self):
        """RENEWING state."""
        logger.debug('In state: RENEWING')
        self.current_state = STATE_RENEWING
        if self.script is not None:
            self.script.script_init(self.client.lease, self.current_state)
            self.script.script_go()
        else:
            set_net(self.client.lease) 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:11,代码来源:dhcpcapfsm.py

示例13: REBINDING

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def REBINDING(self):
        """REBINDING state."""
        logger.debug('In state: REBINDING')
        self.current_state = STATE_REBINDING
        if self.script is not None:
            self.script.script_init(self.client.lease, self.current_state)
            self.script.script_go()
        else:
            set_net(self.client.lease) 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:11,代码来源:dhcpcapfsm.py

示例14: ERROR

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def ERROR(self):
        """ERROR state."""
        logger.debug('In state: ERROR')
        self.current_state = STATE_ERROR
        if self.script is not None:
            self.script.script_init(self.client.lease, self.current_state)
            self.script.script_go()
        set_net(self.client.lease)
        raise self.INIT()

    # TIMEOUTS
    ###########

    # TIMEOUTS: retransmissions
    # ---------------------------- 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:17,代码来源:dhcpcapfsm.py

示例15: timeout_delay_before_selecting

# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import state [as 别名]
def timeout_delay_before_selecting(self):
        """Timeout delay selecting in INIT state."""
        logger.debug('C1:T. In %s, timeout delay selecting, raise SELECTING',
                     self.current_state)
        raise self.SELECTING() 
开发者ID:juga0,项目名称:dhcpcanon,代码行数:7,代码来源:dhcpcapfsm.py


注:本文中的scapy.automaton.ATMT.state方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。