\doxysection{ss7\+\_\+as.\+h}
\label{ss7__as_8h_source}\index{src/ss7\_as.h@{src/ss7\_as.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/hashtable.h>}}
\DoxyCodeLine{9 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{10 \textcolor{preprocessor}{\#include <osmocom/core/tdef.h>}}
\DoxyCodeLine{11 \textcolor{preprocessor}{\#include <osmocom/netif/stream.h>}}
\DoxyCodeLine{12 }
\DoxyCodeLine{13 \textcolor{preprocessor}{\#include <osmocom/sigtran/osmo\_ss7.h>}}
\DoxyCodeLine{14 }
\DoxyCodeLine{15 \textcolor{preprocessor}{\#include "{}ss7\_internal.h"{}}}
\DoxyCodeLine{16 \textcolor{preprocessor}{\#include "{}xua\_msg.h"{}}}
\DoxyCodeLine{17 }
\DoxyCodeLine{18 \textcolor{comment}{/***********************************************************************}}
\DoxyCodeLine{19 \textcolor{comment}{ * SS7 Application Server}}
\DoxyCodeLine{20 \textcolor{comment}{ ***********************************************************************/}}
\DoxyCodeLine{21 }
\DoxyCodeLine{22 \textcolor{keyword}{struct }osmo\_ss7\_instance;}
\DoxyCodeLine{23 \textcolor{keyword}{struct }osmo\_ss7\_asp;}
\DoxyCodeLine{24 \textcolor{keyword}{struct }osmo\_mtp\_transfer\_param;}
\DoxyCodeLine{25 \textcolor{keyword}{struct }xua\_msg;}
\DoxyCodeLine{26 }
\DoxyCodeLine{27 \textcolor{keyword}{enum} osmo\_ss7\_as\_patch\_sccp\_mode \{}
\DoxyCodeLine{28         OSMO\_SS7\_PATCH\_NONE, \textcolor{comment}{/* no patching of SCCP */}}
\DoxyCodeLine{29         OSMO\_SS7\_PATCH\_BOTH, \textcolor{comment}{/* patch both OPC and DPC into SCCP addresses */}}
\DoxyCodeLine{30 \};}
\DoxyCodeLine{31 }
\DoxyCodeLine{32 \textcolor{keyword}{enum} ss7\_as\_ctr \{}
\DoxyCodeLine{33         SS7\_AS\_CTR\_RX\_MSU\_DISCARD,}
\DoxyCodeLine{34         SS7\_AS\_CTR\_RX\_MSU\_TOTAL,}
\DoxyCodeLine{35         SS7\_AS\_CTR\_RX\_MSU\_SLS\_0,}
\DoxyCodeLine{36         SS7\_AS\_CTR\_RX\_MSU\_SLS\_1,}
\DoxyCodeLine{37         SS7\_AS\_CTR\_RX\_MSU\_SLS\_2,}
\DoxyCodeLine{38         SS7\_AS\_CTR\_RX\_MSU\_SLS\_3,}
\DoxyCodeLine{39         SS7\_AS\_CTR\_RX\_MSU\_SLS\_4,}
\DoxyCodeLine{40         SS7\_AS\_CTR\_RX\_MSU\_SLS\_5,}
\DoxyCodeLine{41         SS7\_AS\_CTR\_RX\_MSU\_SLS\_6,}
\DoxyCodeLine{42         SS7\_AS\_CTR\_RX\_MSU\_SLS\_7,}
\DoxyCodeLine{43         SS7\_AS\_CTR\_RX\_MSU\_SLS\_8,}
\DoxyCodeLine{44         SS7\_AS\_CTR\_RX\_MSU\_SLS\_9,}
\DoxyCodeLine{45         SS7\_AS\_CTR\_RX\_MSU\_SLS\_10,}
\DoxyCodeLine{46         SS7\_AS\_CTR\_RX\_MSU\_SLS\_11,}
\DoxyCodeLine{47         SS7\_AS\_CTR\_RX\_MSU\_SLS\_12,}
\DoxyCodeLine{48         SS7\_AS\_CTR\_RX\_MSU\_SLS\_13,}
\DoxyCodeLine{49         SS7\_AS\_CTR\_RX\_MSU\_SLS\_14,}
\DoxyCodeLine{50         SS7\_AS\_CTR\_RX\_MSU\_SLS\_15,}
\DoxyCodeLine{51         SS7\_AS\_CTR\_TX\_MSU\_TOTAL,}
\DoxyCodeLine{52         SS7\_AS\_CTR\_TX\_MSU\_SLS\_0,}
\DoxyCodeLine{53         SS7\_AS\_CTR\_TX\_MSU\_SLS\_1,}
\DoxyCodeLine{54         SS7\_AS\_CTR\_TX\_MSU\_SLS\_2,}
\DoxyCodeLine{55         SS7\_AS\_CTR\_TX\_MSU\_SLS\_3,}
\DoxyCodeLine{56         SS7\_AS\_CTR\_TX\_MSU\_SLS\_4,}
\DoxyCodeLine{57         SS7\_AS\_CTR\_TX\_MSU\_SLS\_5,}
\DoxyCodeLine{58         SS7\_AS\_CTR\_TX\_MSU\_SLS\_6,}
\DoxyCodeLine{59         SS7\_AS\_CTR\_TX\_MSU\_SLS\_7,}
\DoxyCodeLine{60         SS7\_AS\_CTR\_TX\_MSU\_SLS\_8,}
\DoxyCodeLine{61         SS7\_AS\_CTR\_TX\_MSU\_SLS\_9,}
\DoxyCodeLine{62         SS7\_AS\_CTR\_TX\_MSU\_SLS\_10,}
\DoxyCodeLine{63         SS7\_AS\_CTR\_TX\_MSU\_SLS\_11,}
\DoxyCodeLine{64         SS7\_AS\_CTR\_TX\_MSU\_SLS\_12,}
\DoxyCodeLine{65         SS7\_AS\_CTR\_TX\_MSU\_SLS\_13,}
\DoxyCodeLine{66         SS7\_AS\_CTR\_TX\_MSU\_SLS\_14,}
\DoxyCodeLine{67         SS7\_AS\_CTR\_TX\_MSU\_SLS\_15,}
\DoxyCodeLine{68 \textcolor{preprocessor}{\#ifdef WITH\_TCAP\_LOADSHARING}}
\DoxyCodeLine{69         SS7\_AS\_CTR\_RX\_TCAP\_DECODED,}
\DoxyCodeLine{70         SS7\_AS\_CTR\_RX\_TCAP\_FAILED,}
\DoxyCodeLine{71         SS7\_AS\_CTR\_TCAP\_ASP\_SELECTED,}
\DoxyCodeLine{72         SS7\_AS\_CTR\_TCAP\_ASP\_FALLBACK,}
\DoxyCodeLine{73         SS7\_AS\_CTR\_TCAP\_ASP\_FAILED,}
\DoxyCodeLine{74 \textcolor{preprocessor}{\#endif }\textcolor{comment}{/* WITH\_TCAP\_LOADSHARING */}\textcolor{preprocessor}{}}
\DoxyCodeLine{75 \};}
\DoxyCodeLine{76 }
\DoxyCodeLine{77 \textcolor{preprocessor}{\#define NUM\_AS\_EXT\_SLS 128}}
\DoxyCodeLine{78 \textcolor{keyword}{typedef} uint8\_t as\_ext\_sls\_t; \textcolor{comment}{/* range: 0-\/127, 7 bit */}}
\DoxyCodeLine{79 \textcolor{keyword}{struct }osmo\_ss7\_as\_esls\_entry \{}
\DoxyCodeLine{80         \textcolor{comment}{/* ITU Q.704 4.2.1: "{}normal signallink link"{} */}}
\DoxyCodeLine{81         \textcolor{keyword}{struct }osmo\_ss7\_asp *normal\_asp;}
\DoxyCodeLine{82         \textcolor{comment}{/* ITU Q.704 4.2.1: "{}alternative signallink link"{} */}}
\DoxyCodeLine{83         \textcolor{keyword}{struct }osmo\_ss7\_asp *alt\_asp;}
\DoxyCodeLine{84 \};}
\DoxyCodeLine{85 }
\DoxyCodeLine{86 \textcolor{keyword}{struct }ss7\_as\_asp\_assoc \{}
\DoxyCodeLine{87         \textcolor{comment}{/* Entry in (struct osmo\_ss7\_as*)-\/>assoc\_asp\_list */}}
\DoxyCodeLine{88         \textcolor{keyword}{struct }llist\_head as\_entry;}
\DoxyCodeLine{89         \textcolor{comment}{/* Entry in (struct osmo\_ss7\_asp*)-\/>assoc\_as\_list */}}
\DoxyCodeLine{90         \textcolor{keyword}{struct }llist\_head asp\_entry;}
\DoxyCodeLine{91         \textcolor{keyword}{struct }osmo\_ss7\_as *as; \textcolor{comment}{/* backpointer */}}
\DoxyCodeLine{92         \textcolor{keyword}{struct }osmo\_ss7\_asp *asp; \textcolor{comment}{/* backpointer */}}
\DoxyCodeLine{93 \};}
\DoxyCodeLine{94 }
\DoxyCodeLine{95 \textcolor{keyword}{struct }osmo\_ss7\_as \{}
\DoxyCodeLine{97         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{98         \textcolor{keyword}{struct }osmo\_ss7\_instance *inst;}
\DoxyCodeLine{99 }
\DoxyCodeLine{101         \textcolor{keyword}{struct }osmo\_fsm\_inst *fi;}
\DoxyCodeLine{102 }
\DoxyCodeLine{104         \textcolor{keywordtype}{bool} rkm\_dyn\_allocated;}
\DoxyCodeLine{105 }
\DoxyCodeLine{107         \textcolor{keywordtype}{bool} simple\_client\_allocated;}
\DoxyCodeLine{108 }
\DoxyCodeLine{110         \textcolor{keyword}{struct }rate\_ctr\_group *ctrg;}
\DoxyCodeLine{111 }
\DoxyCodeLine{112         \textcolor{comment}{/* ASP loadshare: */}}
\DoxyCodeLine{113         \textcolor{keyword}{struct }osmo\_ss7\_as\_esls\_entry aesls\_table[NUM\_AS\_EXT\_SLS];}
\DoxyCodeLine{114 }
\DoxyCodeLine{115 \textcolor{preprocessor}{\#ifdef WITH\_TCAP\_LOADSHARING}}
\DoxyCodeLine{116         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{117                 \textcolor{comment}{/* optimisation: true if tid\_ranges contains PCs (not only wildcards) */}}
\DoxyCodeLine{118                 \textcolor{keywordtype}{bool} contains\_pc;}
\DoxyCodeLine{119                 \textcolor{comment}{/* optimisation: true if tid\_ranges contains SSNs (not only wildcards (0))  */}}
\DoxyCodeLine{120                 \textcolor{keywordtype}{bool} contains\_ssn;}
\DoxyCodeLine{121                 DECLARE\_HASHTABLE(tid\_ranges, 10);}
\DoxyCodeLine{122                 \textcolor{comment}{/* gargabe collector timer */}}
\DoxyCodeLine{123                 \textcolor{keyword}{struct }osmo\_timer\_list gc\_timer;}
\DoxyCodeLine{124                 \textcolor{comment}{/* TODO: the hash tables size might not be optimal */}}
\DoxyCodeLine{125                 DECLARE\_HASHTABLE(trans\_track\_own, 10);}
\DoxyCodeLine{126                 DECLARE\_HASHTABLE(trans\_track\_peer, 10);}
\DoxyCodeLine{127         \} tcap;}
\DoxyCodeLine{128 \textcolor{preprocessor}{\#endif }\textcolor{comment}{/* WITH\_TCAP\_LOADSHARING */}\textcolor{preprocessor}{}}
\DoxyCodeLine{129 }
\DoxyCodeLine{130         \textcolor{comment}{/* used for load-\/sharing traffic mode (round robin implementation) */}}
\DoxyCodeLine{131         \textcolor{keyword}{struct }ss7\_as\_asp\_assoc *last\_asp\_idx\_assigned;}
\DoxyCodeLine{132         \textcolor{keyword}{struct }ss7\_as\_asp\_assoc *last\_asp\_idx\_sent;}
\DoxyCodeLine{133 }
\DoxyCodeLine{134         \textcolor{keyword}{struct }llist\_head assoc\_asp\_list; \textcolor{comment}{/* list of struct ss7\_as\_asp\_assoc */}}
\DoxyCodeLine{135         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_assoc\_asps; \textcolor{comment}{/* amount of ss7\_as\_asp\_assoc/ss7\_asp in assoc\_asp\_list */}}
\DoxyCodeLine{136 }
\DoxyCodeLine{137         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{138                 \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{139                 \textcolor{keywordtype}{char} *description;}
\DoxyCodeLine{140                 \textcolor{keyword}{enum} osmo\_ss7\_asp\_protocol proto;}
\DoxyCodeLine{141                 \textcolor{keyword}{struct }osmo\_ss7\_routing\_key routing\_key;}
\DoxyCodeLine{142                 \textcolor{keyword}{enum} osmo\_ss7\_as\_traffic\_mode mode;}
\DoxyCodeLine{143                 \textcolor{comment}{/* traffic mode was configured by VTY / config file */}}
\DoxyCodeLine{144                 \textcolor{keywordtype}{bool} mode\_set\_by\_vty;}
\DoxyCodeLine{145                 \textcolor{comment}{/* traffic mode was configured by RKM (routing key management) or first ASPAC */}}
\DoxyCodeLine{146                 \textcolor{keywordtype}{bool} mode\_set\_by\_peer;}
\DoxyCodeLine{147                 uint32\_t recovery\_timeout\_msec;}
\DoxyCodeLine{148                 uint8\_t qos\_class;}
\DoxyCodeLine{149                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{150                         \textcolor{keywordtype}{bool} opc\_enabled;}
\DoxyCodeLine{151                         \textcolor{keywordtype}{bool} dpc\_enabled;}
\DoxyCodeLine{152                         uint32\_t opc;}
\DoxyCodeLine{153                         uint32\_t dpc;}
\DoxyCodeLine{154                         \textcolor{keyword}{enum} osmo\_ss7\_as\_patch\_sccp\_mode sccp\_mode;}
\DoxyCodeLine{155                 \} pc\_override;}
\DoxyCodeLine{156 }
\DoxyCodeLine{157                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{158                         \textcolor{comment}{/* How many bits from ITU SLS field (starting from least-\/significant-\/bit)}}
\DoxyCodeLine{159 \textcolor{comment}{                        * to skip for routing decisions.}}
\DoxyCodeLine{160 \textcolor{comment}{                        * range 0-\/3, defaults to 0, which means take all 4 bits. */}}
\DoxyCodeLine{161                         uint8\_t sls\_shift;}
\DoxyCodeLine{162                         \textcolor{comment}{/* Whether to generate a extended-\/SLS with OPC information, see opc\_shift below. */}}
\DoxyCodeLine{163                         \textcolor{keywordtype}{bool} opc\_sls;}
\DoxyCodeLine{164                         \textcolor{comment}{/* How many bits from ITU OPC field (starting from least-\/significant-\/bit)}}
\DoxyCodeLine{165 \textcolor{comment}{                        * to skip for routing decisions (always takes 12 bits).}}
\DoxyCodeLine{166 \textcolor{comment}{                        * range 0-\/2, defaults to 0, which means take least significant 12 bits. */}}
\DoxyCodeLine{167                         uint8\_t opc\_shift;}
\DoxyCodeLine{168 \textcolor{preprocessor}{\#ifdef WITH\_TCAP\_LOADSHARING}}
\DoxyCodeLine{169                         \textcolor{comment}{/* Should we do load-\/sharing based on tcap ids? */}}
\DoxyCodeLine{170                         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{171                                 \textcolor{keywordtype}{bool} enabled;}
\DoxyCodeLine{172                                 \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} timeout\_s;}
\DoxyCodeLine{173                                 \textcolor{keyword}{struct }ss7\_as\_asp\_assoc *last\_asp\_idx\_sent;}
\DoxyCodeLine{174                         \} tcap;}
\DoxyCodeLine{175 \textcolor{preprocessor}{\#endif }\textcolor{comment}{/* WITH\_TCAP\_LOADSHARING */}\textcolor{preprocessor}{}}
\DoxyCodeLine{176                 \} loadshare;}
\DoxyCodeLine{177         \} cfg;}
\DoxyCodeLine{178 \};}
\DoxyCodeLine{179 \textcolor{keyword}{struct }osmo\_ss7\_as *ss7\_as\_alloc(\textcolor{keyword}{struct} osmo\_ss7\_instance *inst, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name,}
\DoxyCodeLine{180                                  \textcolor{keyword}{enum} osmo\_ss7\_asp\_protocol proto);}
\DoxyCodeLine{181 \textcolor{keyword}{struct }osmo\_ss7\_asp *ss7\_as\_select\_asp(\textcolor{keyword}{struct} osmo\_ss7\_as *as, \textcolor{keyword}{const} \textcolor{keyword}{struct} xua\_msg *xua);}
\DoxyCodeLine{182 }
\DoxyCodeLine{183 \textcolor{keywordtype}{int} ss7\_as\_add\_asp(\textcolor{keyword}{struct} osmo\_ss7\_as *as, \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{184 \textcolor{keywordtype}{int} ss7\_as\_del\_asp(\textcolor{keyword}{struct} osmo\_ss7\_as *as, \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{185 \textcolor{keywordtype}{int} ss7\_as\_get\_local\_role(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_as *as);}
\DoxyCodeLine{186 \textcolor{keyword}{struct }osmo\_ss7\_asp *ss7\_as\_find\_asp\_by\_remote\_asp\_id(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_as *as, uint32\_t asp\_id,}
\DoxyCodeLine{187                                                       \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_asp *excl\_asp);}
\DoxyCodeLine{188 \textcolor{keywordtype}{void} ss7\_as\_loadshare\_binding\_table\_reset(\textcolor{keyword}{struct} osmo\_ss7\_as *as);}
\DoxyCodeLine{189 }
\DoxyCodeLine{190 \textcolor{keywordtype}{void} ss7\_as\_del\_asp\_update\_llist\_round\_robin(\textcolor{keyword}{struct} osmo\_ss7\_as *as, \textcolor{keyword}{struct} osmo\_ss7\_asp *asp, \textcolor{keyword}{struct} ss7\_as\_asp\_assoc **state);}
\DoxyCodeLine{191 \textcolor{preprocessor}{\#define ss7\_as\_asp\_assoc\_llist\_round\_robin(as, state) \(\backslash\)}}
\DoxyCodeLine{192 \textcolor{preprocessor}{        ss7\_llist\_round\_robin(\&(as)-\/>assoc\_asp\_list, (void **)state, struct ss7\_as\_asp\_assoc, as\_entry)}}
\DoxyCodeLine{193 }
\DoxyCodeLine{194 \textcolor{preprocessor}{\#define LOGPAS(as, subsys, level, fmt, args ...) \(\backslash\)}}
\DoxyCodeLine{195 \textcolor{preprocessor}{        \_LOGSS7((as)-\/>inst, subsys, level, "{}AS(\%s) "{}} fmt, (as)-\/>cfg.name, \#\# args)}

\end{DoxyCode}
