(table, chain, rule_d, position=0, ipv6=False)
Add a rule to a chain in a given position. 0=append, 1=first, n=nth position
Add a rule to a chain in a given position. 0=append, 1=first, n=nth position
Add a rule to a chain in a given position . 0 = append 1 = first n = nth position
def add_rule(table, chain, rule_d, position=0, ipv6=False):
    """ Add a rule to a chain in a given position. 0=append, 1=first, n=nth position """
    iptc_chain = _iptc_getchain(table, chain, ipv6)
    iptc_rule  = encode_iptc_rule(rule_d, ipv6)
    if position == 0:
        # Insert rule in last position -> append
        iptc_chain.append_rule(iptc_rule)
    elif position > 0:
        # Insert rule in given position -> adjusted as iptables CLI
        iptc_chain.insert_rule(iptc_rule, position - 1)
    elif position < 0:
        # Insert rule in given position starting from bottom -> not available in iptables CLI
        nof_rules = len(iptc_chain.rules)
        _position = position + nof_rules
        # Insert at the top if the position has looped over
        if _position <= 0:
            _position = 0
        iptc_chain.insert_rule(iptc_rule, _position)
def add_rule ( table , chain , rule_d , position = 0 , ipv6 = False ) : iptc_chain = _iptc_getchain ( table , chain , ipv6 ) iptc_rule = encode_iptc_rule ( rule_d , ipv6 ) if position == 0 : # Insert rule in last position -> append iptc_chain . append_rule ( iptc_rule ) elif position > 0 : # Insert rule in given position -> adjusted as iptables CLI iptc_chain . insert_rule ( iptc_rule , position - 1 ) elif position < 0 : # Insert rule in given position starting from bottom -> not available in iptables CLI nof_rules = len ( iptc_chain . rules ) _position = position + nof_rules # Insert at the top if the position has looped over if _position <= 0 : _position = 0 iptc_chain . insert_rule ( iptc_rule , _position )