MCPcopy Index your code
hub / github.com/secdev/scapy / scope_cmp

Function scope_cmp

scapy/utils6.py:109–133  ·  view source on GitHub ↗

Given two addresses, returns -1, 0 or 1 based on comparison of their scope

(a, b)

Source from the content-addressed store, hash-verified

107 """
108
109 def scope_cmp(a, b):
110 # type: (str, str) -> int
111 """
112 Given two addresses, returns -1, 0 or 1 based on comparison of
113 their scope
114 """
115 scope_mapper = {IPV6_ADDR_GLOBAL: 4,
116 IPV6_ADDR_SITELOCAL: 3,
117 IPV6_ADDR_LINKLOCAL: 2,
118 IPV6_ADDR_LOOPBACK: 1}
119 sa = in6_getscope(a)
120 if sa == -1:
121 sa = IPV6_ADDR_LOOPBACK
122 sb = in6_getscope(b)
123 if sb == -1:
124 sb = IPV6_ADDR_LOOPBACK
125
126 sa = scope_mapper[sa]
127 sb = scope_mapper[sb]
128
129 if sa == sb:
130 return 0
131 if sa > sb:
132 return 1
133 return -1
134
135 def rfc3484_cmp(source_a, source_b):
136 # type: (str, str) -> int

Callers 1

rfc3484_cmpFunction · 0.85

Calls 1

in6_getscopeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…