Harald Welte | 8acc356 | 2013-03-21 15:05:20 +0100 | [diff] [blame] | 1 | |
| 2 | == mgw_nat == |
| 3 | |
| 4 | == files == |
| 5 | |
| 6 | === mgw_nat_app.erl === |
| 7 | |
| 8 | This file contains the OTP application wrapper for running mgw_nat as an |
| 9 | OTP application. It exports the start/2 and stop/1 functions which are |
| 10 | required for application:{start,stop}(mgw_nat) to work. |
| 11 | |
| 12 | There is also mgw_nat_app:reload_config/0, which will re-read the config |
| 13 | file given to the erl machine as '-config' shell argument. |
| 14 | |
| 15 | === mgw_nat_sup.erl === |
| 16 | |
| 17 | This is the supervisor code, it starts: |
| 18 | * one mgw_nat_adm process |
| 19 | * one mgw_nat_usr for each signalling link in the config file |
| 20 | |
| 21 | === mgw_nat_adm.erl === |
| 22 | |
| 23 | This is a permanent server running under the supervisor, taking care of |
| 24 | realoading configuration or dumping some information as well as casting |
| 25 | messages to all of the mgw_nat_usr children. |
| 26 | |
| 27 | === mgw_nat_usr.erl === |
| 28 | |
| 29 | This is a gen_server OTP behavior which wraps the sctp_helper. Among |
| 30 | the arguments passed to the sctp_helper are the 'rewrite_act_mod', whcih |
| 31 | is the name of the Erlang module actually doing the rewriting. |
| 32 | |
| 33 | === sctp_helper.erl === |
| 34 | |
| 35 | Erlang module for wrapping both a listen-type and a connect-type SCTP |
| 36 | connection, taking care of re-connects, etc. Each actual user payload |
| 37 | message is handled via handle_rx_data/5, which will in turn call the |
| 38 | rewrite_actor/5 function of the 'rewrite_act_mod' |
| 39 | |
| 40 | === mgw_nat_act_vfuk_onw === |
| 41 | |
| 42 | This is a rewrite actor module for patching the advertised CAMEL Phase |
| 43 | during Location update of inbound roaming subsribers. |
| 44 | |
| 45 | the rewrite_actor/5 is first called with sctp as the first element, at |
| 46 | which time mgw_nat:mangle_rx_data/4 is being called. mangle_rx_data |
| 47 | will parse all higher level protocols (m2ua/mtp3/sccp/tcap/map), |
| 48 | and each time one protocol layer has been decoded, it will again call |
| 49 | the rewrite_actor/5 function with the first argument set to the protocol |
| 50 | in question. |
| 51 | |
| 52 | m2ua/mtp3/sccp is handled without modification by the default clause of |
| 53 | rewrite_actor/5. |
| 54 | |
| 55 | Once the map level is reached, the mangle_map_camel_phase/3 function is |
| 56 | called. If the direction is STP->MSC, then the message is in the |
| 57 | direction we are not interested in. |
| 58 | |
| 59 | In the MSC->STP direction, we decode the called_party_addr, do a global |
| 60 | title match on it. If there is a match against the int_camel_ph_tbl, |
| 61 | then the hierarchical record data structure is walked by |
| 62 | osmo_util:tuple_walk/3 which will call caleph_twalk_cb/3. If there is a |
| 63 | match on UpdateLocationArg, the supportedCamelPhases is rewritten |
| 64 | accordingly. |
| 65 | |
| 66 | === mgw_nat_act_bow_onw.erl === |
| 67 | |
| 68 | This is a much more complex rewrite actor doing a lot of different |
| 69 | rewrites whihc are not described here in detail. |
| 70 | |
| 71 | === imsi_list.erl === |
| 72 | |
| 73 | maintains a list of 1:1 IMSI mappings, internally represented by tw |
| 74 | gb_tree's. |
| 75 | * read_list/1 populates the gb_trees from an Erlang list |
| 76 | * read_file/1 populates the gb_trees from a CSV file |
| 77 | * match_imsi/3 matches an IMSI either in forward or reverse direction |
| 78 | |
| 79 | === mangle_tt_sri_sm.erl === |
| 80 | |
| 81 | Contains utility code for rewriting the translation type of the global |
| 82 | title present in SRI-for-SM messages. |
| 83 | |
| 84 | === sccp_masq.erl === |
| 85 | |
| 86 | This code implements SCCP masquerading: |
| 87 | |
| 88 | The mgw_nat gateway has a pool of dynamically-allocated SCCP global |
| 89 | titles. Whenever needed (decided by other code), the original GT is |
| 90 | replaced with one dynamically allocated from the pool. If ther ever is |
| 91 | a SCCP mesage directed at one of the dynamic addresses in response, the |
| 92 | inverse translation back to the original address is performed. |