\doxysection{ss7\+\_\+asp.\+h}
\label{ss7__asp_8h_source}\index{src/ss7\_asp.h@{src/ss7\_asp.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{2 }
\DoxyCodeLine{3 \textcolor{preprocessor}{\#include "{}config.h"{}}}
\DoxyCodeLine{4 }
\DoxyCodeLine{5 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{6 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <osmocom/core/fsm.h>}}
\DoxyCodeLine{8 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{9 \textcolor{preprocessor}{\#include <osmocom/core/tdef.h>}}
\DoxyCodeLine{10 \textcolor{preprocessor}{\#include <osmocom/netif/stream.h>}}
\DoxyCodeLine{11 }
\DoxyCodeLine{12 \textcolor{preprocessor}{\#include <osmocom/sigtran/osmo\_ss7.h>}}
\DoxyCodeLine{13 }
\DoxyCodeLine{14 \textcolor{preprocessor}{\#include "{}ss7\_asp\_peer.h"{}}}
\DoxyCodeLine{15 \textcolor{preprocessor}{\#include "{}ss7\_internal.h"{}}}
\DoxyCodeLine{16 }
\DoxyCodeLine{17 \textcolor{comment}{/***********************************************************************}}
\DoxyCodeLine{18 \textcolor{comment}{ * SS7 Application Server Processes}}
\DoxyCodeLine{19 \textcolor{comment}{ ***********************************************************************/}}
\DoxyCodeLine{20 }
\DoxyCodeLine{21 \textcolor{keyword}{struct }osmo\_ss7\_instance;}
\DoxyCodeLine{22 }
\DoxyCodeLine{23 \textcolor{keyword}{struct }osmo\_xua\_layer\_manager \{}
\DoxyCodeLine{24         \textcolor{comment}{/* Submit primitives M3UA -\/> LM:}}
\DoxyCodeLine{25 \textcolor{comment}{         * oph: \{sap: XUA\_SAP\_LM, prim: enum osmo\_xlm\_prim\_type\},}}
\DoxyCodeLine{26 \textcolor{comment}{         * cb\_data: (struct osmo\_ss7\_asp *)}}
\DoxyCodeLine{27 \textcolor{comment}{         */}}
\DoxyCodeLine{28         osmo\_prim\_cb prim\_cb;}
\DoxyCodeLine{29         void (*free\_func)(\textcolor{keyword}{struct }osmo\_xua\_layer\_manager *lm);}
\DoxyCodeLine{30         \textcolor{keywordtype}{void} *priv;}
\DoxyCodeLine{31 \};}
\DoxyCodeLine{32 \textcolor{keyword}{struct }osmo\_xua\_layer\_manager *xua\_layer\_manager\_default\_alloc(\textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{33 }
\DoxyCodeLine{34 \textcolor{keyword}{enum} ss7\_asp\_xua\_timer \{}
\DoxyCodeLine{35         \textcolor{comment}{/* 0 kept unused on purpose since it's handled specially by osmo\_fsm */}}
\DoxyCodeLine{36         SS7\_ASP\_XUA\_T\_ACK = 1, \textcolor{comment}{/* RFC3868 \& RFC4666 timer T(ack) */}}
\DoxyCodeLine{37         SS7\_ASP\_XUA\_T\_BEAT, \textcolor{comment}{/* RFC3868 \& RFC4666 timer T(beat) */}}
\DoxyCodeLine{38         \textcolor{comment}{/* This must remain the last item: */}}
\DoxyCodeLine{39         SS7\_ASP\_XUA\_TIMERS\_LEN}
\DoxyCodeLine{40 \};}
\DoxyCodeLine{41 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }value\_string ss7\_asp\_xua\_timer\_names[];}
\DoxyCodeLine{42 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_tdef ss7\_asp\_xua\_timer\_defaults[SS7\_ASP\_XUA\_TIMERS\_LEN];}
\DoxyCodeLine{43 \textcolor{comment}{/* According to SUA RFC3868 Section 8, M3UA RFC4666 Section 4.3.4.1 */}}
\DoxyCodeLine{44 \textcolor{preprocessor}{\#define SS7\_ASP\_XUA\_DEFAULT\_T\_ACK\_SEC   2}}
\DoxyCodeLine{45 \textcolor{comment}{/* According to SUA RFC3868 Section 8 */}}
\DoxyCodeLine{46 \textcolor{preprocessor}{\#define SS7\_ASP\_XUA\_DEFAULT\_T\_BEAT\_SEC  30}}
\DoxyCodeLine{47 }
\DoxyCodeLine{48 \textcolor{keyword}{enum} ss7\_asp\_ctr \{}
\DoxyCodeLine{49         SS7\_ASP\_CTR\_PKT\_RX\_TOTAL,}
\DoxyCodeLine{50         SS7\_ASP\_CTR\_PKT\_RX\_UNKNOWN,}
\DoxyCodeLine{51         SS7\_ASP\_CTR\_PKT\_RX\_NI\_MISMATCH,}
\DoxyCodeLine{52         SS7\_ASP\_CTR\_PKT\_TX\_TOTAL,}
\DoxyCodeLine{53 \};}
\DoxyCodeLine{54 }
\DoxyCodeLine{55 \textcolor{keyword}{struct }osmo\_ss7\_asp \{}
\DoxyCodeLine{57         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{58         \textcolor{keyword}{struct }llist\_head assoc\_as\_list; \textcolor{comment}{/* list of struct ss7\_as\_asp\_assoc */}}
\DoxyCodeLine{59         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_assoc\_as; \textcolor{comment}{/* amount of ss7\_as\_asp\_assoc/ss7\_as in as\_list */}}
\DoxyCodeLine{60 }
\DoxyCodeLine{61         \textcolor{keyword}{struct }osmo\_ss7\_instance *inst;}
\DoxyCodeLine{62 }
\DoxyCodeLine{64         \textcolor{keyword}{struct }osmo\_fsm\_inst *fi;}
\DoxyCodeLine{65 }
\DoxyCodeLine{67         \textcolor{keyword}{struct }osmo\_xua\_server *xua\_server;}
\DoxyCodeLine{68         \textcolor{keyword}{struct }llist\_head siblings;}
\DoxyCodeLine{69 }
\DoxyCodeLine{71         \textcolor{keyword}{struct }osmo\_stream\_cli *client;}
\DoxyCodeLine{72         \textcolor{keyword}{struct }osmo\_stream\_srv *server;}
\DoxyCodeLine{74         \textcolor{keywordtype}{char} *sock\_name;}
\DoxyCodeLine{75 }
\DoxyCodeLine{76         \textcolor{comment}{/* Peer's ASP Identifier, as received during ASPUP (SG/IPSP) and ASPUP ACK (IPSP),}}
\DoxyCodeLine{77 \textcolor{comment}{         * and transmitted during NOTIFY. */}}
\DoxyCodeLine{78         uint32\_t remote\_asp\_id;}
\DoxyCodeLine{79         \textcolor{keywordtype}{bool} remote\_asp\_id\_present;}
\DoxyCodeLine{80 }
\DoxyCodeLine{81         \textcolor{comment}{/* Layer Manager to which we talk */}}
\DoxyCodeLine{82         \textcolor{keyword}{struct }osmo\_xua\_layer\_manager *lm;}
\DoxyCodeLine{83 }
\DoxyCodeLine{85         \textcolor{keywordtype}{bool} dyn\_allocated;}
\DoxyCodeLine{86 }
\DoxyCodeLine{88         \textcolor{keywordtype}{bool} simple\_client\_allocated;}
\DoxyCodeLine{89 }
\DoxyCodeLine{91         \textcolor{keyword}{struct }rate\_ctr\_group *ctrg;}
\DoxyCodeLine{92 }
\DoxyCodeLine{94         \textcolor{keyword}{struct }msgb *pending\_msg;}
\DoxyCodeLine{95 }
\DoxyCodeLine{96         \textcolor{comment}{/* IPA proto ASP specific fields. */}}
\DoxyCodeLine{97         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{98                 \textcolor{comment}{/* Incoming IPA PDUs have no SLS field, hence a potentially}}
\DoxyCodeLine{99 \textcolor{comment}{                 * unique one within AS is assigned to this ASP and applied}}
\DoxyCodeLine{100 \textcolor{comment}{                 * manually when received. */}}
\DoxyCodeLine{101                 uint8\_t sls:4;}
\DoxyCodeLine{102                 \textcolor{keywordtype}{bool} sls\_assigned;}
\DoxyCodeLine{103         \} ipa;}
\DoxyCodeLine{104 }
\DoxyCodeLine{105 \textcolor{preprocessor}{\#ifdef WITH\_TCAP\_LOADSHARING}}
\DoxyCodeLine{106         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{107                 \textcolor{keywordtype}{bool} enabled;}
\DoxyCodeLine{108         \} tcap;}
\DoxyCodeLine{109 \textcolor{preprocessor}{\#endif }\textcolor{comment}{/* WITH\_TCAP\_LOADSHARING */}\textcolor{preprocessor}{}}
\DoxyCodeLine{110 }
\DoxyCodeLine{111         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{112                 \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{113                 \textcolor{keywordtype}{char} *description;}
\DoxyCodeLine{114                 \textcolor{keyword}{enum} osmo\_ss7\_asp\_protocol proto;}
\DoxyCodeLine{115                 \textcolor{keyword}{enum} osmo\_ss7\_asp\_admin\_state adm\_state;}
\DoxyCodeLine{116                 \textcolor{keywordtype}{bool} is\_server;}
\DoxyCodeLine{117                 \textcolor{keyword}{enum} osmo\_ss7\_asp\_role role;}
\DoxyCodeLine{118                 \textcolor{keywordtype}{bool} role\_set\_by\_vty;}
\DoxyCodeLine{119                 \textcolor{keywordtype}{bool} trans\_role\_set\_by\_vty;}
\DoxyCodeLine{120                 \textcolor{comment}{/* Used internally by "{}asp"{} node to figure out if "{}no shutdown"{}}}
\DoxyCodeLine{121 \textcolor{comment}{                 * was done explicitly, in order to avoid automatic asp}}
\DoxyCodeLine{122 \textcolor{comment}{                 * reconfiguring/restart at go\_parent().}}
\DoxyCodeLine{123 \textcolor{comment}{                 * Can be dropped in the future once we make sure everybody uses}}
\DoxyCodeLine{124 \textcolor{comment}{                 * "{}[no] shutdown"{} explicitly in cfg files. */}}
\DoxyCodeLine{125                 \textcolor{keywordtype}{bool} explicit\_shutdown\_state\_by\_vty\_since\_node\_enter;}
\DoxyCodeLine{126 }
\DoxyCodeLine{127                 \textcolor{comment}{/* Local ASP Identifier transmitted during ASPUP (ASP/IPSP) and ASPUP ACK (IPSP),}}
\DoxyCodeLine{128 \textcolor{comment}{                * and received during NOTIFY.}}
\DoxyCodeLine{129 \textcolor{comment}{                * "{}The optional ASP Identifier parameter contains a unique value}}
\DoxyCodeLine{130 \textcolor{comment}{                * that is locally significant among the ASPs that support an AS"{}. */}}
\DoxyCodeLine{131                 uint32\_t local\_asp\_id;}
\DoxyCodeLine{132                 \textcolor{keywordtype}{bool} local\_asp\_id\_present;}
\DoxyCodeLine{133 }
\DoxyCodeLine{134                 \textcolor{keyword}{struct }osmo\_ss7\_asp\_peer local;}
\DoxyCodeLine{135                 \textcolor{keyword}{struct }osmo\_ss7\_asp\_peer remote;}
\DoxyCodeLine{136                 uint8\_t qos\_class;}
\DoxyCodeLine{137                 uint32\_t quirks;}
\DoxyCodeLine{138 }
\DoxyCodeLine{139                 \textcolor{comment}{/* Whether to Tx xUA DAUD during ASP activation when in ASP role. */}}
\DoxyCodeLine{140                 \textcolor{keywordtype}{bool} daud\_act;}
\DoxyCodeLine{141 }
\DoxyCodeLine{142                 \textcolor{comment}{/* T\_defs used by the default\_lm: */}}
\DoxyCodeLine{143                 \textcolor{keyword}{struct }osmo\_tdef *T\_defs\_xua;}
\DoxyCodeLine{144 }
\DoxyCodeLine{145                 \textcolor{comment}{/* T\_defs used by the default\_lm: */}}
\DoxyCodeLine{146                 \textcolor{keyword}{struct }osmo\_tdef *T\_defs\_lm;}
\DoxyCodeLine{147 }
\DoxyCodeLine{148                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{149                         \textcolor{keywordtype}{bool} num\_ostreams\_present;}
\DoxyCodeLine{150                         \textcolor{keywordtype}{bool} max\_instreams\_present;}
\DoxyCodeLine{151                         \textcolor{keywordtype}{bool} max\_attempts\_present;}
\DoxyCodeLine{152                         \textcolor{keywordtype}{bool} max\_init\_timeo\_present;}
\DoxyCodeLine{153                         uint16\_t num\_ostreams\_value;}
\DoxyCodeLine{154                         uint16\_t max\_instreams\_value;}
\DoxyCodeLine{155                         uint16\_t max\_attempts\_value;}
\DoxyCodeLine{156                         uint16\_t max\_init\_timeo\_value; \textcolor{comment}{/* ms */}}
\DoxyCodeLine{157                 \} sctp\_init;}
\DoxyCodeLine{158 }
\DoxyCodeLine{159                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{160                         \textcolor{keywordtype}{bool} keepalive\_enable;}
\DoxyCodeLine{161                         \textcolor{keywordtype}{bool} keepalive\_time\_present;}
\DoxyCodeLine{162                         \textcolor{keywordtype}{bool} keepalive\_intvl\_present;}
\DoxyCodeLine{163                         \textcolor{keywordtype}{bool} keepalive\_probes\_present;}
\DoxyCodeLine{164                         \textcolor{keywordtype}{bool} user\_timeout\_present;}
\DoxyCodeLine{165                         \textcolor{keywordtype}{int} keepalive\_time\_value; \textcolor{comment}{/* seconds */}}
\DoxyCodeLine{166                         \textcolor{keywordtype}{int} keepalive\_intvl\_value; \textcolor{comment}{/* seconds */}}
\DoxyCodeLine{167                         \textcolor{keywordtype}{int} keepalive\_probes\_value;}
\DoxyCodeLine{168                         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} user\_timeout\_value; \textcolor{comment}{/* milliseconds */}}
\DoxyCodeLine{169                 \} tcp;}
\DoxyCodeLine{170 }
\DoxyCodeLine{172                 \textcolor{keywordtype}{int} trans\_proto;}
\DoxyCodeLine{173         \} cfg;}
\DoxyCodeLine{174 \};}
\DoxyCodeLine{175 }
\DoxyCodeLine{176 \textcolor{keyword}{struct }osmo\_ss7\_asp *ss7\_asp\_alloc(\textcolor{keyword}{struct} osmo\_ss7\_instance *inst, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name,}
\DoxyCodeLine{177                                    uint16\_t remote\_port, uint16\_t local\_port,}
\DoxyCodeLine{178                                    \textcolor{keywordtype}{int} trans\_proto, \textcolor{keyword}{enum} osmo\_ss7\_asp\_protocol proto);}
\DoxyCodeLine{179 \textcolor{keywordtype}{bool} ss7\_asp\_set\_default\_peer\_hosts(\textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{180 \textcolor{keywordtype}{bool} ss7\_asp\_is\_started(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{181 \textcolor{keywordtype}{int} ss7\_asp\_get\_fd(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{182 \textcolor{keywordtype}{int} ss7\_asp\_disconnect\_stream(\textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{183 }
\DoxyCodeLine{184 \textcolor{keywordtype}{int} ss7\_asp\_apply\_tcp\_pars(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{185 \textcolor{keywordtype}{int} ss7\_asp\_apply\_peer\_primary\_address(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{186 \textcolor{keywordtype}{int} ss7\_asp\_apply\_primary\_address(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{187 \textcolor{keywordtype}{int} ss7\_asp\_apply\_new\_local\_address(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} loc\_idx);}
\DoxyCodeLine{188 \textcolor{keywordtype}{int} ss7\_asp\_apply\_drop\_local\_address(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} loc\_idx);}
\DoxyCodeLine{189 }
\DoxyCodeLine{190 \textcolor{keywordtype}{void} ss7\_asp\_restart\_after\_reconfigure(\textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{191 }
\DoxyCodeLine{192 \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} ss7\_asp\_get\_all\_rctx(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp, uint32\_t *rctx, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} rctx\_size,}
\DoxyCodeLine{193                                   \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_as *excl\_as);}
\DoxyCodeLine{194 \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} ss7\_asp\_get\_all\_rctx\_be(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp, uint32\_t *rctx, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} rctx\_size,}
\DoxyCodeLine{195                                   \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_as *excl\_as);}
\DoxyCodeLine{196 \textcolor{keyword}{struct }osmo\_ss7\_as *ss7\_asp\_get\_first\_as(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{197 }
\DoxyCodeLine{198 \textcolor{keywordtype}{int} ss7\_asp\_determine\_traf\_mode(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{199 \textcolor{keywordtype}{bool} ss7\_asp\_check\_remote\_asp\_id\_unique(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *asp, uint32\_t remote\_asp\_id);}
\DoxyCodeLine{200 }
\DoxyCodeLine{201 \textcolor{preprocessor}{\#define LOGPASP(asp, subsys, level, fmt, args ...) \(\backslash\)}}
\DoxyCodeLine{202 \textcolor{preprocessor}{        \_LOGSS7((asp)-\/>inst, subsys, level, "{}ASP(\%s) "{}} fmt, (asp)-\/>cfg.name, \#\# args)}

\end{DoxyCode}
