Add a bunch of APNs

Fork of C027_Support by Xinlei Cao

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MDMAPN.h Source File

MDMAPN.h

00001 #pragma once 
00002 
00003 /* ----------------------------------------------------------------
00004    APN stands for Access Point Name, a setting on your modem or phone
00005    that identifies an external network your phone can access for data 
00006    (e.g. 3G or 4G Internet service on your phone). 
00007    
00008    The APN settings can be forced when calling the join function.
00009    Below is a list of known APNs that us used if no apn config 
00010    is forced. This list could be extended by other settings.
00011    
00012    For further reading:
00013    wiki apn: http://en.wikipedia.org/wiki/Access_Point_Name
00014    wiki mcc/mnc: http://en.wikipedia.org/wiki/Mobile_country_code
00015    google: https://www.google.de/search?q=APN+list   
00016 ---------------------------------------------------------------- */
00017 
00018 //! helper to generate the APN string
00019 #define _APN(apn,username,password) apn "\0" username "\0" password "\0"
00020 
00021 //! helper to extract a field from the config string 
00022 #define _APN_GET(cfg) \
00023     *cfg ? cfg : ""; \
00024     cfg  += strlen(cfg) + 1
00025                     
00026 //! APN lookup struct
00027 typedef struct { 
00028     const char* mccmnc; //!< mobile country code (MCC) and mobile network code MNC  
00029     const char* cfg;    //!< APN configuartion string, use _APN macro to generate
00030 } APN_t;
00031 
00032 //! default APN settings used by many networks
00033 static const char* apndef = _APN(,,)
00034                             _APN("internet",,);
00035 
00036 /*! this is a list of special APNs for different network operators 
00037     There is no need to enter the default apn internet in the table; 
00038     apndef will be used if no entry matches.
00039     
00040     The APN without username/password have to be listed first.
00041 */
00042 static const APN_t apnlut[] = {
00043 // MCC Country
00044 //  { /* Operator */ "MCC-MNC[,MNC]" _APN(APN,USERNAME,PASSWORD) },
00045 // MCC must be 3 digits
00046 // MNC must be either 2 or 3 digits
00047 // MCC must be separated by '-' from MNC, multiple MNC can be separated by ','
00048 
00049 // 427 Qatar - QA
00050     { /* ooredoo */ "427-01",     _APN("data",,)
00051                                   _APN("internet.m2m.ooredoo.qa",,) },
00052 
00053 // 232 Austria - AUT
00054     { /* T-Mobile */ "232-03",    _APN("m2m.business",,) },
00055 
00056 // 460 China - CN
00057     { /* CN Mobile */"460-00",    _APN("cmnet",,)
00058                                   _APN("cmwap",,) },
00059     { /* Unicom */   "460-01",    _APN("3gnet",,)
00060                                   _APN("uninet","uninet","uninet") },
00061                                 
00062 // 262 Germany - DE
00063 //    { /* T-Mobile */ "262-01",  _APN("internet.t-mobile","t-mobile","tm") },
00064     { /* T-Mobile */ "262-02,06", _APN("m2m.business",,) },
00065     { /* T-Mobile */ "262-01",    _APN("internet.m2mportal.de", "m2m", "sim")
00066                                   _APN("internet.telekom",,) },
00067 // 222 Italy - IT
00068     { /* TIM */      "222-01",    _APN("ibox.tim.it",,) },
00069     { /* Vodafone */ "222-10",    _APN("web.omnitel.it",,) },
00070     { /* Wind */     "222-88",    _APN("internet.wind.biz",,) },
00071 
00072 // 440 Japan - JP
00073     { /* Softbank */ "440-04,06,20,40,41,42,43,44,45,46,47,48,90,91,92,93,94,95"
00074                          ",96,97,98"
00075                                   _APN("open.softbank.ne.jp","opensoftbank","ebMNuX1FIHg9d3DA")
00076                                   _APN("smile.world","dna1trop","so2t3k3m2a") },
00077     { /* NTTDoCoMo */"440-09,10,11,12,13,14,15,16,17,18,19,21,22,23,24,25,26,27,"
00078                          "28,29,30,31,32,33,34,35,36,37,38,39,58,59,60,61,62,63,"
00079                          "64,65,66,67,68,69,87,99",
00080                                   _APN("bmobilewap",,) /*BMobile*/
00081                                   _APN("mpr2.bizho.net","Mopera U",) /* DoCoMo */
00082                                   _APN("3g-uno.ntt.com",,) /* DoCoMo */
00083                                   _APN("3gd-ocn.ntt.com",,) /* DoCoMo */
00084                                   _APN("nttcom.fr",,) /* DoCoMo */
00085                                   _APN("bmobile.ne.jp","bmobile@wifi2","bmobile") /*BMobile*/ },
00086 
00087 // 204 Netherlands - NL
00088     { /* Vodafone */ "204-04",    _APN("public4.m2minternet.com",,) 
00089                                   _APN("test.teleena.com",,) },
00090     { /* Teleena */  "204-07",    _APN("test.teleena.com",,) },
00091 
00092 // 293 Slovenia - SI
00093     { /* Si.mobil */ "293-40",    _APN("internet.simobil.si",,) },
00094     { /* Tusmobil */ "293-70",    _APN("internet.tusmobil.si",,) },
00095 
00096 // 240 Sweden SE
00097     { /* Telia */    "240-01",    _APN("online.telia.se",,) },
00098     { /* Telenor */  "240-06,08", _APN("services.telenor.se",,) },
00099     { /* Tele2 */    "240-07",    _APN("m2m.tele2.com",,)
00100                                   _APN("mobileinternet.tele2.se",,) },
00101 
00102 // 228 Switzerland - CH
00103     { /* Swisscom */ "228-01",    _APN("swisscom-test.m2m.ch",,)
00104                                   _APN("gprs.swisscom.ch",,) },
00105     { /* Orange */   "228-03",    _APN("internet",,) /* contract */
00106                                   _APN("click",,)    /* pre-pay */ },
00107                                   
00108 // 270 Luxembourg
00109     { /* Post */     "270-01",    _APN("postm2m.lu",,)},
00110 
00111 // 234 United Kingdom - GB
00112     { /* O2 */       "234-02,10,11",
00113                                   _APN("mobile.o2.co.uk","faster","web") /* contract */
00114                                   _APN("mobile.o2.co.uk","bypass","web") /* pre-pay */
00115                                   _APN("payandgo.o2.co.uk","payandgo","payandgo") },
00116     { /* Vodafone */ "234-15",    _APN("internet","web","web")          /* contract */
00117                                   _APN("pp.vodafone.co.uk","wap","wap")  /* pre-pay */ },
00118     { /* Three */    "234-20",    _APN("three.co.uk",,) },
00119     { /* EE */       "234-33,30", _APN("EEm2m",,)
00120                                   _APN("m2mdata",,) },
00121 
00122 // 310 United States of America - US
00123     { /* Kore Telematics */ "505-02",   _APN("od1.korem2m.com",,) },
00124     { /* T-Mobile */ "310-026,260,490",
00125                                   _APN("epc.tmobile.com",,)
00126                                   _APN("fast.tmobile.com",,) /* LTE */ },
00127     { /* AT&T */     "310-030,150,170,260,410,560,680",
00128                                   _APN("phone",,)
00129                                   _APN("wap.cingular","WAP@CINGULARGPRS.COM","CINGULAR1")
00130                                   _APN("isp.cingular","ISP@CINGULARGPRS.COM","CINGULAR1") },
00131                                   
00132 // 602 UAE
00133     { /* Etisalat */ "602-602",   _APN("internet.etisalat",,)},
00134 
00135 // 732 Colombia
00136     { /* Comcel */   "732-101",   _APN("internet.comcel.com.co",,)
00137                                   _APN("internet.movistar.com.co",,) },
00138 
00139 // 405 India
00140     { /* Reliance */ "405-21",    _APN("unlimitiot",,)
00141                                   _APN("IoTtest",,) },
00142 
00143 // 901 International - INT
00144     { /* Transatel */ "901-37",   _APN("netgprs.com","tsl","tsl") },
00145 };
00146 
00147 inline const char* apnconfig(const char* imsi)
00148 {
00149     const char* config = NULL;
00150     if (imsi && *imsi) {
00151         // many carriers use internet without username and password, os use this as default
00152         // now try to lookup the setting for our table
00153         for (int i = 0; i < sizeof(apnlut)/sizeof(*apnlut) && !config; i ++) {
00154             const char* p = apnlut[i].mccmnc;
00155             // check the MCC
00156             if ((0 == memcmp(imsi, p, 3))) {
00157                 p += 3;
00158                 // check all the MNC, MNC length can be 2 or 3 digits
00159                 while (((p[0] == '-') || (p[0] == ',')) && 
00160                         (p[1] >= '0') && (p[1] <= '9') && 
00161                         (p[2] >= '0') && (p[2] <= '9') && !config) {
00162                     int l = ((p[3] >= '0') && (p[3] <= '9')) ? 3 : 2;
00163                     if (0 == memcmp(imsi+3,p+1,l))
00164                         config = apnlut[i].cfg;
00165                     p += 1 + l;
00166                 } 
00167             }
00168         }
00169     }
00170     // use default if not found
00171     if (!config)
00172         config = apndef;
00173     return config;
00174 }