Given two addresses, returns -1, 0 or 1 based on comparison of their scope
(a, b)
| 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 |
no test coverage detected
searching dependent graphs…