Imported gammu 0.90.7
[gammu.git] / common / service / gsmnet.c
blob85aebb5c1224e92307fbcda846764686e530c7f1
1 #include <string.h>
3 #include "gsmnet.h"
4 #include "../misc/coding/coding.h"
6 unsigned char *GSM_Countries[] = {
7 "202", "Greece",
8 "204", "Netherlands",
9 "206", "Belgium",
10 "208", "France",
11 "213", "Andorra" ,
12 "214", "Spain",
13 "216", "Hungary",
14 "218", "Bosnia Herzegovina",
15 "219", "Croatia",
16 "220", "Yugoslavia",
17 "222", "Italy",
18 "226", "Romania",
19 "228", "Switzerland",
20 "230", "Czech Republic",
21 "231", "Slovak Republic",
22 "232", "Austria",
23 "234", "United Kingdom",
24 "238", "Denmark",
25 "240", "Sweden",
26 "242", "Norway",
27 "244", "Finland",
28 "246", "Lithuania",
29 "247", "Latvia",
30 "248", "Estonia",
31 "250", "Russia",
32 "255", "Ukraine",
33 "259", "Moldova",
34 "260", "Poland",
35 "262", "Germany",
36 "266", "Gibraltar",
37 "268", "Portugal",
38 "270", "Luxembourg",
39 "272", "Ireland",
40 "274", "Iceland",
41 "276", "Albania",
42 "278", "Malta",
43 "280", "Cyprus",
44 "282", "Georgia",
45 "283", "Armenia",
46 "284", "Bulgaria",
47 "286", "Turkey",
48 "290", "Greenland",
49 "293", "Slovenia",
50 "294", "Macedonia",
51 "302", "Canada",
52 "310", "U.S.A.",
53 "340", "French West Indies",
54 "400", "Azerbaijan",
55 "404", "India",
56 "410", "Pakistan",
57 "413", "Sri Lanka",
58 "415", "Lebanon",
59 "416", "Jordan",
60 "417", "Syria",
61 "418", "Iraq",
62 "419", "Kuwait",
63 "420", "Saudi Arabia",
64 "422", "Oman",
65 "424", "United Arab Emirates",
66 "425", "Israel",
67 "426", "Bahrain",
68 "427", "Qatar",
69 "432", "Iran",
70 "434", "Uzbekistan",
71 "437", "Kyrgyz Republic",
72 "452", "Vietnam",
73 "454", "Hong Kong",
74 "455", "Macau",
75 "456", "Cambodia",
76 "457", "Lao",
77 "460", "China",
78 "466", "Taiwan",
79 "470", "Bangladesh",
80 "502", "Malaysia",
81 "505", "Australia",
82 "510", "Indonesia",
83 "515", "Philippines",
84 "520", "Thailand",
85 "525", "Singapore",
86 "528", "Brunei Darussalam",
87 "530", "New Zealand",
88 "542", "Fiji",
89 "546", "New Caledonia",
90 "547", "French Polynesia",
91 "602", "Egypt",
92 "603", "Algeria",
93 "604", "Morocco",
94 "605", "Tunisia",
95 "608", "Senegal",
96 "611", "Guinea",
97 "612", "Cote d'Ivoire",
98 "615", "Togo",
99 "617", "Mauritius",
100 "618", "Liberia",
101 "620", "Ghana",
102 "624", "Cameroon",
103 "625", "Cape Verde",
104 "633", "Seychelles",
105 "634", "Mozambique",
106 "634", "Sudan",
107 "635", "Rwanda",
108 "636", "Ethiopia",
109 "640", "Tanzania",
110 "641", "Uganda",
111 "645", "Zambia",
112 "646", "Madagascar",
113 "647", "Reunion",
114 "648", "Zimbabwe",
115 "649", "Namibia",
116 "650", "Malawi",
117 "651", "Lesotho",
118 "652", "Botswana",
119 "655", "South Africa",
120 "730", "Chile",
121 "734", "Venezuela",
123 NULL
126 unsigned char *GSM_Networks[] = {
127 "202 01", "Cosmote",
128 "202 05", "PANAFON",
129 "202 10", "TELESTET",
130 "204 04", "LIBERTEL",
131 "204 08", "KPN Telecom",
132 "204 12", "O2",
133 "204 16", "BEN",
134 "204 20", "Dutchtone NV",
135 "206 01", "PROXIMUS",
136 "206 10", "Mobistar",
137 "206 20", "Base",
138 "208 01", "ITINERIS",
139 "208 10", "SFR",
140 "208 20", "Bouygues Telecom",
141 "213 03", "MOBILAND",
142 "214 01", "Airtel GSM 900-Spain",
143 "214 03", "Retevision Movil",
144 "214 07", "MOVISTAR",
145 "216 01", "Pannon GSM",
146 "216 70", "Vodafone",
147 "216 30", "Westel 900",
148 "218 90", "GSMBIH",
149 "219 01", "CRONET",
150 "219 10", "VIP",
151 "220 01", "MOBTEL",
152 "220 02", "ProMonte GSM",
153 "220 03", "Telekom Srbije",
154 "222 01", "Telecom Italia Mobile",
155 "222 10", "OMNITEL",
156 "222 88", "Wind Telecomunicazioni SpA",
157 "226 01", "CONNEX GSM",
158 "226 10", "DIALOG",
159 "228 01", "NATEL International",
160 "228 02", "diAx Mobile AG",
161 "230 01", "T-Mobile CZ",
162 "230 02", "EuroTel",
163 "230 03", "Oskar",
164 "231 01", "Orange",
165 "231 02", "EuroTel GSM",
166 "232 01", "A1",
167 "232 03", "T-Mobile AT",
168 "232 05", "ONE",
169 "232 07", "tele.ring",
170 "234 10", "Cellnet",
171 "234 15", "Vodafone",
172 "234 30", "T-Mobile UK",
173 "234 33", "ORANGE",
174 "234 50", "Jersey Telecoms GSM",
175 "234 55", "Guernsey Telecoms GSM",
176 "234 58", "PRONTO GSM",
177 "238 01", "TDK-MOBIL",
178 "238 02", "SONOFON",
179 "238 20", "TELIA DK",
180 "238 30", "Mobilix",
181 "240 01", "Telia AB",
182 "240 07", "COMVIQ",
183 "240 08", "EUROPOLITAN",
184 "242 01", "Telenor Mobil",
185 "242 02", "NetCom GSM",
186 "244 03", "Telia City (Finland)",
187 "244 05", "Radiolinja",
188 "244 09", "Finnet",
189 "244 12", "DNA (FI2G)",
190 "244 14", "Alands Mobiltelefon",
191 "244 91", "Sonera",
192 "246 01", "OMNITEL",
193 "246 02", "Bite GSM",
194 "247 01", "LMT LV",
195 "247 02", "BALTCOM GSM",
196 "248 01", "EMT GSM",
197 "248 02", "Radiolinja Eesti AS",
198 "248 03", "Q GSM",
199 "250 01", "Mobile Telesystems",
200 "250 02", "North-West GSM",
201 "250 05", "Siberian Cellular Systems 900",
202 "250 07", "BM Telecom",
203 "250 10", "Don Telecom",
204 "250 12", "FECS-900",
205 "250 13", "Kuban GSM",
206 "250 39", "Uraltel",
207 "250 44", "North Caucasian GSM",
208 "250 99", "BeeLine",
209 "255 01", "UMC",
210 "255 02", "WellCOM",
211 "255 03", "Kyivstar",
212 "255 05", "Golden Telecom",
213 "259 01", "VOXTEL",
214 "260 01", "PLUS GSM",
215 "260 02", "ERA GSM",
216 "260 03", "IDEA Centertel",
217 "262 01", "T-Mobile D",
218 "262 02", "D2 PRIVAT",
219 "262 03", "E-Plus",
220 "262 07", "Interkom",
221 "266 01", "Gibtel GSM",
222 "268 01", "TELECEL",
223 "268 03", "OPTIMUS",
224 "268 06", "TMN",
225 "270 01", "LUXGSM",
226 "270 77", "TANGO",
227 "272 01", "EIRCELL-GSM",
228 "272 02", "Digifone",
229 "274 01", "Landssiminn GSM 900",
230 "274 02", "TAL hf",
231 "276 01", "AMC",
232 "278 01", "Vodafone Malta Limited",
233 "280 01", "CYTAGSM",
234 "282 01", "Geocell Limited",
235 "282 02", "Magti GSM",
236 "283 01", "ArmGSM",
237 "284 01", "M-TEL GSM BG",
238 "286 01", "Turkcell",
239 "286 02", "TELSIM GSM",
240 "288 01", "Faroese Telecom",
241 "290 01", "Tele Greenland",
242 "293 40", "SI.MOBIL d. d.",
243 "293 41", "MOBITEL",
244 "293 70", "SI VEGA 070",
245 "294 01", "MobiMak",
246 "302 37", "Microcell Connexions Inc",
247 "302 72", "Rogers AT&T",
248 "310 01", "Cellnet",
249 "310 02", "Sprint Spectrum",
250 "310 11", "Wireless 2000 Telephone Co.",
251 "310 15", "BellSouth Mobility DCS",
252 "310 16", "T-Mobile",
253 "310 17", "Pac Bell",
254 "310 20", "T-Mobile",
255 "310 21", "T-Mobile",
256 "310 22", "T-Mobile",
257 "310 23", "T-Mobile",
258 "310 24", "T-Mobile",
259 "310 25", "T-Mobile",
260 "310 26", "T-Mobile",
261 "310 27", "T-Mobile",
262 "310 31", "T-Mobile",
263 "310 38", "AT&T Wireless",
264 "310 58", "T-Mobile",
265 "310 66", "T-Mobile",
266 "310 77", "Iowa Wireless Services LP",
267 "310 80", "T-Mobile",
268 "340 01", "AMERIS",
269 "400 01", "AZERCELL GSM",
270 "400 02", "Bakcell GSM 2000",
271 "404 07", "TATA Cellular",
272 "404 10", "AirTel",
273 "404 11", "Essar Cellphone",
274 "404 12", "Escotel",
275 "404 14", "Modicom",
276 "404 15", "Essar Cellphone",
277 "404 20", "Max Touch",
278 "404 21", "BPL - Mobile",
279 "404 27", "BPL USWEST Cellular",
280 "404 30", "Command",
281 "404 40", "SkyCell",
282 "404 41", "RPG Cellular",
283 "404 42", "AIRCEL",
284 "410 01", "Mobilink",
285 "413 02", "DIALOG GSM",
286 "415 01", "CELLIS",
287 "415 03", "LIBANCELL",
288 "416 01", "Fastlink",
289 "417 09", "MOBILE SYRIA",
290 "419 02", "MTCNet",
291 "420 01", "Al Jawwal",
292 "420 07", "E.A.E",
293 "422 02", "GTO",
294 "424 02", "UAE-ETISALAT",
295 "425 01", "Partner Communications Company Ltd",
296 "425 02", "Cellcom Israel Ltd",
297 "426 01", "BHR MOBILE PLUS",
298 "427 01", "QATARNET",
299 "432 11", "TCI",
300 "434 04", "Daewoo Unitel",
301 "434 05", "Coscom",
302 "437 01", "Bitel",
303 "454 00", "TCSL GSM",
304 "454 04", "HKGHT",
305 "454 06", "SMARTONE GSM",
306 "454 10", "New World PCS",
307 "454 12", "PEOPLES",
308 "454 16", "SUNDAY",
309 "455 01", "TELEMOVEL+ GSM900-Macau",
310 "456 01", "MobiTel",
311 "456 02", "SAMART-GSM",
312 "457 01", "Lao Shinawatra Telecom",
313 "460 00", "China Telecom GSM",
314 "460 01", "CU-GSM",
315 "466 01", "Far EasTone Telecoms 900",
316 "466 06", "TUNTEX GSM 1800",
317 "466 88", "KG Telecom",
318 "466 92", "Chunghwa GSM",
319 "466 93", "MobiTai",
320 "466 97", "TWNGSM",
321 "466 99", "TransAsia",
322 "470 01", "GrameenPhone Ltd",
323 "470 19", "Mobile 2000",
324 "502 12", "Maxis Mobile",
325 "502 13", "TM Touch",
326 "502 16", "DiGi 1800",
327 "502 17", "ADAM",
328 "502 19", "CELCOM",
329 "505 01", "MobileNet",
330 "505 02", "OPTUS",
331 "505 03", "VODAFONE",
332 "505 08", "One.Tel",
333 "510 01", "SATELINDO",
334 "510 08", "LIPPO TELECOM",
335 "510 10", "TELKOMSEL",
336 "510 11", "Excelcom",
337 "510 21", "INDOSAT",
338 "515 01", "ISLACOM",
339 "515 02", "Globe Telecom",
340 "520 01", "AIS GSM",
341 "520 10", "WCS",
342 "520 18", "Worldphone 1800",
343 "520 23", "HELLO",
344 "525 01", "SingTel Mobile",
345 "525 02", "ST-PCN",
346 "525 03", "MOBILEONE",
347 "528 11", "DSTCom",
348 "530 01", "Vodafone New Zealand Limited",
349 "542 01", "Vodafone",
350 "546 01", "Mobilis",
351 "547 20", "VINI",
352 "602 01", "MobiNil",
353 "602 02", "Tunicell",
354 "603 01", "ALGERIAN MOBILE NETWORK",
355 "604 01", "I A M",
356 "608 01", "ALIZE",
357 "611 02", "Lagui",
358 "612 03", "IVOIRIS",
359 "612 05", "Telecel",
360 "615 01", "TOGO CELL",
361 "617 01", "Cellplus Mobile Comms",
362 "618 01", "Omega",
363 "620 01", "SPACEFON",
364 "625 01", "CVMOVEL",
365 "633 01", "Seychelles Cellular Services",
366 "633 10", "AIRTEL",
367 "634 01", "MobiTel",
368 "635 10", "Rwandacell",
369 "636 01", "ETMTN",
370 "640 01", "TRITEL",
371 "641 10", "MTN-Uganda",
372 "642 02", "ANTARIS",
373 "643 01", "T.D.M GSM 900",
374 "645 01", "ZAMCELL",
375 "646 01", "Madacom",
376 "646 03", "Sacel Madagascar S.A.",
377 "647 10", "SRR",
378 "648 01", "NET*ONE",
379 "648 03", "Telecel",
380 "649 01", "MTC",
381 "650 01", "Callpoint 900",
382 "651 01", "Vodacom Lesotho (Pty) Ltd",
383 "655 01", "Vodacom",
384 "655 10", "MTN",
385 "680 38", "NPI Wireless",
386 "730 01", "Entel Telefonia Movi",
387 "730 10", "Entel PCS",
388 "734 01", "Infonet",
390 NULL
393 char *GSM_GetNetworkName(char *NetworkCode)
395 int i = 0;
396 static char retval[200];
398 EncodeUnicode(retval,"unknown",7);
399 while (GSM_Networks[i*2] != NULL) {
400 if (strcmp(GSM_Networks[i*2],NetworkCode)) {
401 EncodeUnicode(retval, GSM_Networks[i*2+1], strlen(GSM_Networks[i*2+1]));
402 break;
404 i++;
406 return retval;
409 char *GSM_GetCountryName(char *CountryCode)
411 int i = 0;
412 static char retval[200];
414 EncodeUnicode(retval,"unknown",7);
415 while (GSM_Countries[i*2] != NULL) {
416 if (strcmp(GSM_Countries[i*2],CountryCode)) {
417 EncodeUnicode(retval, GSM_Countries[i*2+1], strlen(GSM_Countries[i*2+1]));
418 break;
420 i++;
422 return retval;
425 void NOKIA_EncodeNetworkCode(unsigned char* buffer, unsigned char* output)
427 EncodeBCD(buffer, output, 6, false);
428 buffer[1] = buffer[1] | 0xf0;
431 void NOKIA_DecodeNetworkCode(unsigned char* buffer, unsigned char* output)
433 DecodeBCD(output, buffer, 3);
434 output[6] = output[5];
435 output[5] = output[4];
436 output[4] = output[3];
437 output[3] = ' ';
440 /* How should editor hadle tabs in this file? Add editor commands here.
441 * vim: noexpandtab sw=8 ts=8 sts=8: