Metaswitch/sprout — pull request #589 by AlexHockey (2014-06-04 13:01:36+00:00)
Title: [Reviewer: Mike][From: Alex]

Mike, this is a pull request to fix #532 (sprout never sends originating INTERIM or STOP messages for calls). I've fixed this as follows:

* Introduce the `charge-orig` and `charge-term` tokens to indicate if sprout should do originating and/or terminating billing for the call.
* Sprout sets these in record-route headers at the start of originating processing, and at the end of terminating processing.
* For subsequent in-dialog requests sprout sends originating and/or terminating ACRs depending on whether the tokens are present in it's route header. Note that this means that if sprout record-routes itself multiple times (e.g. between App Servers) it only sends at most 1 orig ACR and 1 term ACR. It made more sense to this than send an ACR on every hop (as this means we get 1 STOP per START, rather than N STOPs per START).
* In order to make this change I've had to refactor `stateful_proxy.cpp` a bit, mainly to distinguish earlier between access/routing proxies, and in-dialog/out-of-dialog requests.

I've ran the UTs and kicked the tires live but I need to add more UTs. At this stage I'd like you to cast you eyes over the design and code and let me know if you're generally happy with it (a full review can wait till after I've finished the UTs). Some things that might be controversial:
* The names of the new parameters. I chose these as they could be used by bono in future (which also has problems working out if it's originating or terminating). But they are different from what we discussed last week.
* The split between in-dialog/out-of-dialog. I believe this is in keeping with TS 24.229, which frequently uses "requests for a dialog or stand-alone transaction" to discriminate between different situations.