\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 }osmo\_ss7\_as \{}
\DoxyCodeLine{88         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{89         \textcolor{keyword}{struct }osmo\_ss7\_instance *inst;}
\DoxyCodeLine{90 }
\DoxyCodeLine{92         \textcolor{keyword}{struct }osmo\_fsm\_inst *fi;}
\DoxyCodeLine{93 }
\DoxyCodeLine{95         \textcolor{keywordtype}{bool} rkm\_dyn\_allocated;}
\DoxyCodeLine{96 }
\DoxyCodeLine{98         \textcolor{keywordtype}{bool} simple\_client\_allocated;}
\DoxyCodeLine{99 }
\DoxyCodeLine{101         \textcolor{keyword}{struct }rate\_ctr\_group *ctrg;}
\DoxyCodeLine{102 }
\DoxyCodeLine{103         \textcolor{comment}{/* ASP loadshare: */}}
\DoxyCodeLine{104         \textcolor{keyword}{struct }osmo\_ss7\_as\_esls\_entry aesls\_table[NUM\_AS\_EXT\_SLS];}
\DoxyCodeLine{105 }
\DoxyCodeLine{106 \textcolor{preprocessor}{\#ifdef WITH\_TCAP\_LOADSHARING}}
\DoxyCodeLine{107         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{108                 \textcolor{comment}{/* optimisation: true if tid\_ranges contains PCs (not only wildcards) */}}
\DoxyCodeLine{109                 \textcolor{keywordtype}{bool} contains\_pc;}
\DoxyCodeLine{110                 \textcolor{comment}{/* optimisation: true if tid\_ranges contains SSNs (not only wildcards (0))  */}}
\DoxyCodeLine{111                 \textcolor{keywordtype}{bool} contains\_ssn;}
\DoxyCodeLine{112                 DECLARE\_HASHTABLE(tid\_ranges, 10);}
\DoxyCodeLine{113                 \textcolor{comment}{/* gargabe collector timer */}}
\DoxyCodeLine{114                 \textcolor{keyword}{struct }osmo\_timer\_list gc\_timer;}
\DoxyCodeLine{115                 \textcolor{comment}{/* TODO: the hash tables size might not be optimal */}}
\DoxyCodeLine{116                 DECLARE\_HASHTABLE(trans\_track\_own, 10);}
\DoxyCodeLine{117                 DECLARE\_HASHTABLE(trans\_track\_peer, 10);}
\DoxyCodeLine{118         \} tcap;}
\DoxyCodeLine{119 \textcolor{preprocessor}{\#endif }\textcolor{comment}{/* WITH\_TCAP\_LOADSHARING */}\textcolor{preprocessor}{}}
\DoxyCodeLine{120 }
\DoxyCodeLine{121         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{122                 \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{123                 \textcolor{keywordtype}{char} *description;}
\DoxyCodeLine{124                 \textcolor{keyword}{enum} osmo\_ss7\_asp\_protocol proto;}
\DoxyCodeLine{125                 \textcolor{keyword}{struct }osmo\_ss7\_routing\_key routing\_key;}
\DoxyCodeLine{126                 \textcolor{keyword}{enum} osmo\_ss7\_as\_traffic\_mode mode;}
\DoxyCodeLine{127                 \textcolor{comment}{/* traffic mode was configured by VTY / config file */}}
\DoxyCodeLine{128                 \textcolor{keywordtype}{bool} mode\_set\_by\_vty;}
\DoxyCodeLine{129                 \textcolor{comment}{/* traffic mode was configured by RKM (routing key management) or first ASPAC */}}
\DoxyCodeLine{130                 \textcolor{keywordtype}{bool} mode\_set\_by\_peer;}
\DoxyCodeLine{131                 uint32\_t recovery\_timeout\_msec;}
\DoxyCodeLine{132                 uint8\_t qos\_class;}
\DoxyCodeLine{133                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{134                         \textcolor{keywordtype}{bool} opc\_enabled;}
\DoxyCodeLine{135                         \textcolor{keywordtype}{bool} dpc\_enabled;}
\DoxyCodeLine{136                         uint32\_t opc;}
\DoxyCodeLine{137                         uint32\_t dpc;}
\DoxyCodeLine{138                         \textcolor{keyword}{enum} osmo\_ss7\_as\_patch\_sccp\_mode sccp\_mode;}
\DoxyCodeLine{139                 \} pc\_override;}
\DoxyCodeLine{140 }
\DoxyCodeLine{141                 \textcolor{keyword}{struct }osmo\_ss7\_asp *asps[16];}
\DoxyCodeLine{142                 \textcolor{comment}{/* used for load-\/sharing traffic mode (round robin implementation) */}}
\DoxyCodeLine{143                 uint8\_t last\_asp\_idx\_assigned;}
\DoxyCodeLine{144                 uint8\_t last\_asp\_idx\_sent;}
\DoxyCodeLine{145 }
\DoxyCodeLine{146                 \textcolor{keyword}{struct }\{}
\DoxyCodeLine{147                         \textcolor{comment}{/* How many bits from ITU SLS field (starting from least-\/significant-\/bit)}}
\DoxyCodeLine{148 \textcolor{comment}{                        * to skip for routing decisions.}}
\DoxyCodeLine{149 \textcolor{comment}{                        * range 0-\/3, defaults to 0, which means take all 4 bits. */}}
\DoxyCodeLine{150                         uint8\_t sls\_shift;}
\DoxyCodeLine{151                         \textcolor{comment}{/* Whether to generate a extended-\/SLS with OPC information, see opc\_shift below. */}}
\DoxyCodeLine{152                         \textcolor{keywordtype}{bool} opc\_sls;}
\DoxyCodeLine{153                         \textcolor{comment}{/* How many bits from ITU OPC field (starting from least-\/significant-\/bit)}}
\DoxyCodeLine{154 \textcolor{comment}{                        * to skip for routing decisions (always takes 12 bits).}}
\DoxyCodeLine{155 \textcolor{comment}{                        * range 0-\/2, defaults to 0, which means take least significant 12 bits. */}}
\DoxyCodeLine{156                         uint8\_t opc\_shift;}
\DoxyCodeLine{157 \textcolor{preprocessor}{\#ifdef WITH\_TCAP\_LOADSHARING}}
\DoxyCodeLine{158                         \textcolor{comment}{/* Should we do load-\/sharing based on tcap ids? */}}
\DoxyCodeLine{159                         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{160                                 \textcolor{keywordtype}{bool} enabled;}
\DoxyCodeLine{161                                 \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} timeout\_s;}
\DoxyCodeLine{162                         \} tcap;}
\DoxyCodeLine{163 \textcolor{preprocessor}{\#endif }\textcolor{comment}{/* WITH\_TCAP\_LOADSHARING */}\textcolor{preprocessor}{}}
\DoxyCodeLine{164                 \} loadshare;}
\DoxyCodeLine{165         \} cfg;}
\DoxyCodeLine{166 \};}
\DoxyCodeLine{167 \textcolor{keyword}{struct }osmo\_ss7\_as *ss7\_as\_alloc(\textcolor{keyword}{struct} osmo\_ss7\_instance *inst, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name,}
\DoxyCodeLine{168                                  \textcolor{keyword}{enum} osmo\_ss7\_asp\_protocol proto);}
\DoxyCodeLine{169 \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{170 }
\DoxyCodeLine{171 \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} osmo\_ss7\_as\_count\_asp(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_as *as);}
\DoxyCodeLine{172 \textcolor{keywordtype}{int} ss7\_as\_add\_asp(\textcolor{keyword}{struct} osmo\_ss7\_as *as, \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{173 \textcolor{keywordtype}{int} ss7\_as\_del\_asp(\textcolor{keyword}{struct} osmo\_ss7\_as *as, \textcolor{keyword}{struct} osmo\_ss7\_asp *asp);}
\DoxyCodeLine{174 \textcolor{keywordtype}{int} ss7\_as\_get\_local\_role(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_ss7\_as *as);}
\DoxyCodeLine{175 \textcolor{keywordtype}{void} ss7\_as\_loadshare\_binding\_table\_reset(\textcolor{keyword}{struct} osmo\_ss7\_as *as);}
\DoxyCodeLine{176 }
\DoxyCodeLine{177 \textcolor{preprocessor}{\#define LOGPAS(as, subsys, level, fmt, args ...) \(\backslash\)}}
\DoxyCodeLine{178 \textcolor{preprocessor}{        \_LOGSS7((as)-\/>inst, subsys, level, "{}AS(\%s) "{}} fmt, (as)-\/>cfg.name, \#\# args)}

\end{DoxyCode}
