Bug 1174998 - Part 3: Read data call's MTU from network/apn settings. r=echen
authorJessica Jong <jjong@mozilla.com>
Wed, 23 Sep 2015 15:35:32 +0800
changeset 264050 6367ac9f290ca228475bde5540747d50283dc4f4
parent 264049 e3de9e349f1da6c70dff1fc33b09dfff42820784
child 264051 ba660084227d686484c85430af11f2bdfa1a67d3
push id65512
push userkwierso@gmail.com
push dateWed, 23 Sep 2015 20:23:51 +0000
treeherdermozilla-inbound@b00078e693a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen
bugs1174998
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1174998 - Part 3: Read data call's MTU from network/apn settings. r=echen
dom/system/gonk/DataCallInterfaceService.js
dom/system/gonk/DataCallManager.js
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/nsIDataCallInterfaceService.idl
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/DataCallInterfaceService.js
+++ b/dom/system/gonk/DataCallInterfaceService.js
@@ -67,17 +67,18 @@ DataCall.prototype = {
   suggestedRetryTime: -1,
   cid: -1,
   active: -1,
   pdpType: -1,
   ifname: null,
   addreses: null,
   dnses: null,
   gateways: null,
-  pcscf: null
+  pcscf: null,
+  mtu: -1
 };
 
 function DataCallInterfaceService() {
   this._dataCallInterfaces = [];
 
   let numClients = gRil.numRadioInterfaces;
   for (let i = 0; i < numClients; i++) {
     this._dataCallInterfaces.push(new DataCallInterface(i));
--- a/dom/system/gonk/DataCallManager.js
+++ b/dom/system/gonk/DataCallManager.js
@@ -956,17 +956,18 @@ function DataCall(aClientId, aApnSetting
     roaming_protocol: aApnSetting.roaming_protocol
   };
   this.linkInfo = {
     cid: null,
     ifname: null,
     addresses: [],
     dnses: [],
     gateways: [],
-    pcscf: []
+    pcscf: [],
+    mtu: null
   };
   this.state = NETWORK_STATE_UNKNOWN;
   this.requestedNetworkIfaces = [];
 }
 DataCall.prototype = {
   /**
    * Standard values for the APN connection retry process
    * Retry funcion: time(secs) = A * numer_of_retries^2 + B
@@ -1022,16 +1023,20 @@ DataCall.prototype = {
       }
       for (let i = 0; i < lhs.length; i++) {
         if (lhs[i] != rhs[i]) {
           return "changed";
         }
       }
     }
 
+    if (aCurrentDataCall.mtu != aUpdatedDataCall.mtu) {
+      return "changed";
+    }
+
     return "identical";
   },
 
   _getGeckoDataCallState:function (aDataCall) {
     if (aDataCall.active == Ci.nsIDataCallInterface.DATACALL_STATE_ACTIVE_UP ||
         aDataCall.active == Ci.nsIDataCallInterface.DATACALL_STATE_ACTIVE_DOWN) {
       return NETWORK_STATE_CONNECTED;
     }
@@ -1088,16 +1093,17 @@ DataCall.prototype = {
       return;
     }
 
     this.linkInfo.ifname = aDataCall.ifname;
     this.linkInfo.addresses = aDataCall.addresses ? aDataCall.addresses.split(" ") : [];
     this.linkInfo.gateways = aDataCall.gateways ? aDataCall.gateways.split(" ") : [];
     this.linkInfo.dnses = aDataCall.dnses ? aDataCall.dnses.split(" ") : [];
     this.linkInfo.pcscf = aDataCall.pcscf ? aDataCall.pcscf.split(" ") : [];
+    this.linkInfo.mtu = aDataCall.mtu > 0 ? aDataCall.mtu : 0;
     this.state = this._getGeckoDataCallState(aDataCall);
 
     // Notify DataCallHandler about data call connected.
     this.dataCallHandler.notifyDataCallChanged(this);
 
     for (let i = 0; i < this.requestedNetworkIfaces.length; i++) {
       this.requestedNetworkIfaces[i].notifyRILNetworkInterface();
     }
@@ -1141,17 +1147,18 @@ DataCall.prototype = {
       return;
     }
 
     let newLinkInfo = {
       ifname: aUpdatedDataCall.ifname,
       addresses: aUpdatedDataCall.addresses ? aUpdatedDataCall.addresses.split(" ") : [],
       dnses: aUpdatedDataCall.dnses ? aUpdatedDataCall.dnses.split(" ") : [],
       gateways: aUpdatedDataCall.gateways ? aUpdatedDataCall.gateways.split(" ") : [],
-      pcscf: aUpdatedDataCall.pcscf ? aUpdatedDataCall.pcscf.split(" ") : []
+      pcscf: aUpdatedDataCall.pcscf ? aUpdatedDataCall.pcscf.split(" ") : [],
+      mtu: aUpdatedDataCall.mtu > 0 ? aUpdatedDataCall.mtu : 0
     };
 
     switch (dataCallState) {
       case NETWORK_STATE_CONNECTED:
         if (this.state == NETWORK_STATE_CONNECTED) {
           let result =
             this._compareDataCallLink(newLinkInfo, this.linkInfo);
 
@@ -1168,16 +1175,17 @@ DataCall.prototype = {
           if (DEBUG) {
             this.debug("Data link minor change, just update and notify.");
           }
 
           this.linkInfo.addresses = newLinkInfo.addresses.slice();
           this.linkInfo.gateways = newLinkInfo.gateways.slice();
           this.linkInfo.dnses = newLinkInfo.dnses.slice();
           this.linkInfo.pcscf = newLinkInfo.pcscf.slice();
+          this.linkInfo.mtu = newLinkInfo.mtu;
         }
         break;
       case NETWORK_STATE_DISCONNECTED:
       case NETWORK_STATE_UNKNOWN:
         if (this.state == NETWORK_STATE_CONNECTED) {
           // Notify first on unexpected data call disconnection.
           this.state = dataCallState;
           for (let i = 0; i < this.requestedNetworkIfaces.length; i++) {
@@ -1267,16 +1275,17 @@ DataCall.prototype = {
 
   resetLinkInfo: function() {
     this.linkInfo.cid = null;
     this.linkInfo.ifname = null;
     this.linkInfo.addresses = [];
     this.linkInfo.dnses = [];
     this.linkInfo.gateways = [];
     this.linkInfo.pcscf = [];
+    this.linkInfo.mtu = null;
   },
 
   reset: function() {
     this.resetLinkInfo();
 
     this.state = NETWORK_STATE_UNKNOWN;
   },
 
@@ -1661,16 +1670,21 @@ RILNetworkInterface.prototype = {
   get httpProxyHost() {
     return this.apnSetting.proxy || "";
   },
 
   get httpProxyPort() {
     return this.apnSetting.port || "";
   },
 
+  get mtu() {
+    // Value provided by network has higher priority than apn settings.
+    return this.dataCall.linkInfo.mtu || this.apnSetting.mtu || -1;
+  },
+
   // Helpers
 
   debug: function(aMsg) {
     dump("-*- RILNetworkInterface[" + this.dataCallHandler.clientId + ":" +
          this.info.type + "]: " + aMsg + "\n");
   },
 
   get connected() {
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -388,17 +388,18 @@ DataCall.prototype = {
   suggestedRetryTime: -1,
   cid: -1,
   active: -1,
   pdpType: -1,
   ifname: null,
   addreses: null,
   dnses: null,
   gateways: null,
-  pcscf: null
+  pcscf: null,
+  mtu: -1
 };
 
 function RadioInterfaceLayer() {
   let workerMessenger = new WorkerMessenger();
   workerMessenger.init();
   this.setWorkerDebugFlag = workerMessenger.setDebugFlag.bind(workerMessenger);
 
   let numIfaces = this.numRadioInterfaces;
--- a/dom/system/gonk/nsIDataCallInterfaceService.idl
+++ b/dom/system/gonk/nsIDataCallInterfaceService.idl
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-[scriptable, uuid(88f18811-8f19-4902-a9b8-2a6430c71c94)]
+[scriptable, uuid(6b66446a-7000-438f-8e1b-b56b4cbf4fa9)]
 interface nsIDataCall : nsISupports
 {
   /**
    * Data call fail cause. One of the nsIDataCallInterface.DATACALL_FAIL_*
    * values.
    */
   readonly attribute long failCause;
 
@@ -56,16 +56,21 @@ interface nsIDataCall : nsISupports
    */
   readonly attribute DOMString gateways;
 
   /**
    * A space-delimited list of Proxy Call State Control Function addresses for
    * IMS client.
    */
   readonly attribute DOMString pcscf;
+
+  /**
+   * MTU received from network, -1 if not set or invalid.
+   */
+  readonly attribute long mtu;
 };
 
 [scriptable, uuid(e119c54b-9354-4ad6-a1ee-18608bde9320)]
 interface nsIDataCallInterfaceListener : nsISupports
 {
   /**
    * Notify data call interface listeners about unsolicited data call state
    * changes.
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -4531,16 +4531,21 @@ RilObject.prototype.readDataCall = funct
   options.addresses = Buf.readString();
   options.dnses = Buf.readString();
   options.gateways = Buf.readString();
 
   if (version >= 10) {
     options.pcscf = Buf.readString();
   }
 
+  if (version >= 11) {
+    let mtu = Buf.readInt32();
+    options.mtu = (mtu > 0) ? mtu : -1 ;
+  }
+
   return options;
 };
 
 RilObject.prototype[REQUEST_DATA_CALL_LIST] = function REQUEST_DATA_CALL_LIST(length, options) {
   if (options.errorMsg) {
     if (options.rilMessageType) {
       this.sendChromeMessage(options);
     }