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

Class FlagValue

scapy/fields.py:3022–3180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3020
3021
3022class FlagValue(object):
3023 __slots__ = ["value", "names", "multi"]
3024
3025 def _fixvalue(self, value):
3026 # type: (Any) -> int
3027 if not value:
3028 return 0
3029 if isinstance(value, str):
3030 value = value.split('+') if self.multi else list(value)
3031 if isinstance(value, list):
3032 y = 0
3033 for i in value:
3034 y |= 1 << self.names.index(i)
3035 value = y
3036 return int(value)
3037
3038 def __init__(self, value, names):
3039 # type: (Union[List[str], int, str], Union[List[str], str]) -> None
3040 self.multi = isinstance(names, list)
3041 self.names = names
3042 self.value = self._fixvalue(value)
3043
3044 def __hash__(self):
3045 # type: () -> int
3046 return hash(self.value)
3047
3048 def __int__(self):
3049 # type: () -> int
3050 return self.value
3051
3052 def __eq__(self, other):
3053 # type: (Any) -> bool
3054 return self.value == self._fixvalue(other)
3055
3056 def __lt__(self, other):
3057 # type: (Any) -> bool
3058 return self.value < self._fixvalue(other)
3059
3060 def __le__(self, other):
3061 # type: (Any) -> bool
3062 return self.value <= self._fixvalue(other)
3063
3064 def __gt__(self, other):
3065 # type: (Any) -> bool
3066 return self.value > self._fixvalue(other)
3067
3068 def __ge__(self, other):
3069 # type: (Any) -> bool
3070 return self.value >= self._fixvalue(other)
3071
3072 def __ne__(self, other):
3073 # type: (Any) -> bool
3074 return self.value != self._fixvalue(other)
3075
3076 def __and__(self, other):
3077 # type: (int) -> FlagValue
3078 return self.__class__(self.value & self._fixvalue(other), self.names)
3079 __rand__ = __and__

Callers 4

load_winpcapyFunction · 0.90
extractDataMethod · 0.90
_fixup_valMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…