Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

#!/usr/bin/env python 

# -*- coding: utf-8 -*- 

""" GSM system information packets. 

 

""" 

 

import sys 

import logging 

 

__copyright__ = "Finding Ray" 

__license__ = "gpl3" 

 

_logger = logging.getLogger(__name__) 

 

from antikythera.packets.packet import Packet 

 

class System(Packet): 

""" System information packet attributes and factory. 

 

""" 

def __init__(self): 

super().__init__() 

 

class Factory: 

""" System information packet factory. 

 

""" 

@staticmethod 

def create(type, data): 

""" Create a system packet of the given type. 

 

Args: 

type (str): the type of packet subclass to create. 

data: the data to construct the packet with. 

 

""" 

if type == "Type1": return Type1(data) 

elif type == "Type2": return Type2(data) 

elif type == "Type3": return Type3(data) 

elif type == "Type4": return Type4(data) 

elif type == "Type2ter": return Type2ter(data) 

elif type == "Type2quarter": return Type2quarter(data) 

43 ↛ 45line 43 didn't jump to line 45, because the condition on line 43 was never false elif type == "Type13": return Type13(data) 

else: 

_logger.critical("Bad packet creation of type: " + type) 

sys.exit(127) 

 

class Type1(System): 

""" Type1 GSM System Information Packet. 

 

Args: 

data: the data to construct the packet with. 

 

Attributes: 

self_arfcns: Absolute Radio Frequency Channel Numbers of the 

broadcasting cell. 

 

""" 

def __init__(self, data): 

super().__init__() 

self.data = self.decode(data) 

self.arfcns = None 

def __str__(self): 

return "Type1 system information packet" 

def decode(self, data): 

return data 

 

class Type2(System): 

""" Type2 GSM System Information Packet. 

 

Args: 

data: the data to construct the packet with. 

 

Attributes: 

neighbor_arfcns: Absolute Radio Frequency Channel Numbers of 

neighboring cells. 

 

""" 

def __init__(self, data): 

super().__init__() 

self.data = self.decode(data) 

self.neighbor_arfcns = None 

def __str__(self): 

return "Type2 system information packet" 

def decode(self, data): 

return data 

 

class Type3(System): 

""" Type3 GSM System Information Packet. 

 

Args: 

data: the data to construct the packet with. 

 

Attributes: 

cell_id: The broadcasting base stations Cell ID (CID). 

lai: Location Area Identity (LAI) this consists of the Mobile. 

Country Code (MCC) the Mobile Network Code (MNC) and the 

Location Area Code (LAC). They are concatenated together 

in that order. 

gprs: General Radio Packet Service (GRPS) information. 

 

""" 

def __init__(self, data): 

super().__init__() 

self.data = self.decode(data) 

self.cell_id = None 

self.lai = None 

self.gprs = None 

def __str__(self): 

return "Type3 system information packet" 

def decode(self, data): 

return data 

 

class Type4(System): 

""" Type4 GSM System Information Packet. 

 

Args: 

data: the data to construct the packet with. 

 

Attributes: 

lai: Location Area Identity (LAI) this consists of the Mobile. 

Country Code (MCC) the Mobile Network Code (MNC) and the 

Location Area Code (LAC). They are concatenated together 

in that order. 

select_params: Cell selection parameters. 

gprs: General Radio Packet Service (GRPS) information. 

 

""" 

def __init__(self, data): 

super().__init__() 

self.data = self.decode(data) 

self.lai = None 

self.select_params = None 

self.gprs = None 

def __str__(self): 

return "Type4 system information packet" 

def decode(self, data): 

return data 

 

class Type2ter(System): 

""" Type4 GSM System Information Packet. 

 

Args: 

data: the data to construct the packet with. 

 

Attributes: 

neighbor_disc: Verbose neighboring cell description. 

neighbor_arfcns: Absolute Radio Frequency Channel Numbers of 

neighboring cells. 

bcch_freqs: List of BCCH frequencies 

 

""" 

def __init__(self, data): 

super().__init__() 

self.data = self.decode(data) 

self.neighbor_arfcns = None 

self.bcch_freqs = None 

def __str__(self): 

return "Type2ter system information packet" 

def decode(self, data): 

return data 

 

class Type2quarter(System): 

""" Type2quarter GSM System Information Packet. 

 

Args: 

data: the data to construct the packet with. 

 

Attributes: 

neighbor_3g: 3G neighbor cell description 

 

""" 

def __init__(self, data): 

super().__init__() 

self.data = self.decode(data) 

self.neighbor_3g = None 

def __str__(self): 

return "Type2quarter system information packet" 

def decode(self, data): 

return data 

 

class Type13(System): 

""" Type4 GSM System Information Packet. 

 

Args: 

data: the data to construct the packet with. 

 

Attributes: 

gprs: General Radio Packet Service (GRPS) information. 

 

""" 

def __init__(self, data): 

super().__init__() 

self.data = self.decode(data) 

self.gprs = None 

def __str__(self): 

return "Type13 system information packet" 

def decode(self, data): 

return data