\doxysection{src/osmo\+\_\+ss7\+\_\+asp\+\_\+peer.c File Reference}
\label{osmo__ss7__asp__peer_8c}\index{src/osmo\_ss7\_asp\_peer.c@{src/osmo\_ss7\_asp\_peer.c}}
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$inttypes.\+h$>$}\newline
{\ttfamily \#include $<$netdb.\+h$>$}\newline
{\ttfamily \#include $<$netinet/in.\+h$>$}\newline
{\ttfamily \#include $<$netinet/sctp.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/logging.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/socket.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/sockaddr\+\_\+str.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/sigtran/osmo\+\_\+ss7.\+h$>$}\newline
{\ttfamily \#include \char`\"{}ss7\+\_\+internal.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+init} (struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer)
\item 
int \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+snprintf} (char $\ast$buf, size\+\_\+t buf\+\_\+len, struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer)
\item 
int \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+set\+\_\+hosts2} (struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer, void $\ast$talloc\+\_\+ctx, const char $\ast$const $\ast$hosts, size\+\_\+t host\+\_\+cnt, int idx\+\_\+primary)
\begin{DoxyCompactList}\small\item\em Set (copy) addresses for a given ASP peer. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+set\+\_\+hosts} (struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer, void $\ast$talloc\+\_\+ctx, const char $\ast$const $\ast$hosts, size\+\_\+t host\+\_\+cnt)
\begin{DoxyCompactList}\small\item\em Set (copy) addresses for a given ASP peer. \end{DoxyCompactList}\item 
static bool \textbf{ host\+\_\+is\+\_\+ip\+\_\+anyaddr} (const char $\ast$host, bool is\+\_\+v6)
\item 
int \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host2} (struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer, void $\ast$talloc\+\_\+ctx, const char $\ast$host, bool is\+\_\+primary\+\_\+addr)
\begin{DoxyCompactList}\small\item\em Append (copy) address to a given ASP peer. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+del\+\_\+host} (struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer, const char $\ast$host)
\begin{DoxyCompactList}\small\item\em Remove address from a given ASP peer. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host} (struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer, void $\ast$talloc\+\_\+ctx, const char $\ast$host)
\begin{DoxyCompactList}\small\item\em Append (copy) address to a given ASP peer. \end{DoxyCompactList}\item 
bool \textbf{ ss7\+\_\+asp\+\_\+peer\+\_\+match\+\_\+host} (const struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer, const char $\ast$host, bool host\+\_\+is\+\_\+v6)
\item 
int \textbf{ ss7\+\_\+asp\+\_\+peer\+\_\+find\+\_\+host} (const struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer, const char $\ast$host)
\begin{DoxyCompactList}\small\item\em Find the exact IP address match and return its index in the array. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function Documentation}
\mbox{\label{osmo__ss7__asp__peer_8c_a81c3380941dadb42610afc54465cfe4d}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!host\_is\_ip\_anyaddr@{host\_is\_ip\_anyaddr}}
\index{host\_is\_ip\_anyaddr@{host\_is\_ip\_anyaddr}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{host\_is\_ip\_anyaddr()}
{\footnotesize\ttfamily static bool host\+\_\+is\+\_\+ip\+\_\+anyaddr (\begin{DoxyParamCaption}\item[{const char $\ast$}]{host,  }\item[{bool}]{is\+\_\+v6 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Referenced by \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host2()}, and \textbf{ ss7\+\_\+asp\+\_\+peer\+\_\+match\+\_\+host()}.

\mbox{\label{osmo__ss7__asp__peer_8c_a6c91baa9261a1bcc0a6f2fae5e84b972}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!osmo\_ss7\_asp\_peer\_add\_host@{osmo\_ss7\_asp\_peer\_add\_host}}
\index{osmo\_ss7\_asp\_peer\_add\_host@{osmo\_ss7\_asp\_peer\_add\_host}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{osmo\_ss7\_asp\_peer\_add\_host()}
{\footnotesize\ttfamily int osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$}]{peer,  }\item[{void $\ast$}]{talloc\+\_\+ctx,  }\item[{const char $\ast$}]{host }\end{DoxyParamCaption})}



Append (copy) address to a given ASP peer. 

Previous addresses are kept. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em peer} & Application Server Process peer the address is appended to. \\
\hline
\mbox{\texttt{ in}}  & {\em talloc\+\_\+ctx} & talloc context used to allocate new address. \\
\hline
\mbox{\texttt{ in}}  & {\em host} & string containing an IP address. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative otherwise 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host2()}.



Referenced by \textbf{ osmo\+\_\+sccp\+\_\+simple\+\_\+server\+\_\+add\+\_\+clnt()}, \textbf{ osmo\+\_\+ss7\+\_\+xua\+\_\+server\+\_\+add\+\_\+local\+\_\+host()}, and \textbf{ ss7\+\_\+asp\+\_\+set\+\_\+default\+\_\+peer\+\_\+hosts()}.

\mbox{\label{osmo__ss7__asp__peer_8c_a1ef86819b8f03d91f909da6e4db7287a}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!osmo\_ss7\_asp\_peer\_add\_host2@{osmo\_ss7\_asp\_peer\_add\_host2}}
\index{osmo\_ss7\_asp\_peer\_add\_host2@{osmo\_ss7\_asp\_peer\_add\_host2}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{osmo\_ss7\_asp\_peer\_add\_host2()}
{\footnotesize\ttfamily int osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host2 (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$}]{peer,  }\item[{void $\ast$}]{talloc\+\_\+ctx,  }\item[{const char $\ast$}]{host,  }\item[{bool}]{is\+\_\+primary\+\_\+addr }\end{DoxyParamCaption})}



Append (copy) address to a given ASP peer. 

Previous addresses are kept. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em peer} & Application Server Process peer the address is appended to. \\
\hline
\mbox{\texttt{ in}}  & {\em talloc\+\_\+ctx} & talloc context used to allocate new address. \\
\hline
\mbox{\texttt{ in}}  & {\em host} & string containing an IP address. \\
\hline
\mbox{\texttt{ in}}  & {\em is\+\_\+primary\+\_\+addr} & whether this IP address is to be added as SCTP Primary Address \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative otherwise 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host}, \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host\+\_\+cnt}, \textbf{ host\+\_\+is\+\_\+ip\+\_\+anyaddr()}, and \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::idx\+\_\+primary}.



Referenced by \textbf{ DEFUN\+\_\+\+ATTR()}, and \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host()}.

\mbox{\label{osmo__ss7__asp__peer_8c_a4bd800113cd229e0dd5ebfd32fb6c1cb}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!osmo\_ss7\_asp\_peer\_del\_host@{osmo\_ss7\_asp\_peer\_del\_host}}
\index{osmo\_ss7\_asp\_peer\_del\_host@{osmo\_ss7\_asp\_peer\_del\_host}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{osmo\_ss7\_asp\_peer\_del\_host()}
{\footnotesize\ttfamily int osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+del\+\_\+host (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$}]{peer,  }\item[{const char $\ast$}]{host }\end{DoxyParamCaption})}



Remove address from a given ASP peer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em peer} & Application Server Process peer the address is removed from. \\
\hline
\mbox{\texttt{ in}}  & {\em host} & string containing an IP address. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative otherwise 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host}, \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host\+\_\+cnt}, and \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::idx\+\_\+primary}.



Referenced by \textbf{ DEFUN\+\_\+\+ATTR()}, and \textbf{ osmo\+\_\+ss7\+\_\+xua\+\_\+server\+\_\+del\+\_\+local\+\_\+host()}.

\mbox{\label{osmo__ss7__asp__peer_8c_aed428cfcb66cb8b106de45150506ef3e}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!osmo\_ss7\_asp\_peer\_init@{osmo\_ss7\_asp\_peer\_init}}
\index{osmo\_ss7\_asp\_peer\_init@{osmo\_ss7\_asp\_peer\_init}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{osmo\_ss7\_asp\_peer\_init()}
{\footnotesize\ttfamily void osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+init (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$}]{peer }\end{DoxyParamCaption})}



References \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::idx\+\_\+primary}.



Referenced by \textbf{ ss7\+\_\+asp\+\_\+alloc()}.

\mbox{\label{osmo__ss7__asp__peer_8c_aff39a38183c940601c2a937603a3c741}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!osmo\_ss7\_asp\_peer\_set\_hosts@{osmo\_ss7\_asp\_peer\_set\_hosts}}
\index{osmo\_ss7\_asp\_peer\_set\_hosts@{osmo\_ss7\_asp\_peer\_set\_hosts}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{osmo\_ss7\_asp\_peer\_set\_hosts()}
{\footnotesize\ttfamily int osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+set\+\_\+hosts (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$}]{peer,  }\item[{void $\ast$}]{talloc\+\_\+ctx,  }\item[{const char $\ast$const $\ast$}]{hosts,  }\item[{size\+\_\+t}]{host\+\_\+cnt }\end{DoxyParamCaption})}



Set (copy) addresses for a given ASP peer. 

Previous addresses are freed. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em peer} & Application Server Process peer whose addresses are to be set. \\
\hline
\mbox{\texttt{ in}}  & {\em talloc\+\_\+ctx} & talloc context used to allocate new addresses. \\
\hline
\mbox{\texttt{ in}}  & {\em hosts} & Array of strings containing IP addresses. \\
\hline
\mbox{\texttt{ in}}  & {\em host\+\_\+cnt} & Number of strings in hosts \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative otherwise 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+set\+\_\+hosts2()}.



Referenced by \textbf{ osmo\+\_\+sccp\+\_\+simple\+\_\+client\+\_\+on\+\_\+ss7\+\_\+id()}, \textbf{ osmo\+\_\+sccp\+\_\+simple\+\_\+server\+\_\+add\+\_\+clnt()}, \textbf{ osmo\+\_\+ss7\+\_\+xua\+\_\+server\+\_\+set\+\_\+local\+\_\+hosts()}, and \textbf{ xua\+\_\+accept\+\_\+cb()}.

\mbox{\label{osmo__ss7__asp__peer_8c_aace928f5efcaeedc6675dba51294aa64}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!osmo\_ss7\_asp\_peer\_set\_hosts2@{osmo\_ss7\_asp\_peer\_set\_hosts2}}
\index{osmo\_ss7\_asp\_peer\_set\_hosts2@{osmo\_ss7\_asp\_peer\_set\_hosts2}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{osmo\_ss7\_asp\_peer\_set\_hosts2()}
{\footnotesize\ttfamily int osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+set\+\_\+hosts2 (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$}]{peer,  }\item[{void $\ast$}]{talloc\+\_\+ctx,  }\item[{const char $\ast$const $\ast$}]{hosts,  }\item[{size\+\_\+t}]{host\+\_\+cnt,  }\item[{int}]{idx\+\_\+primary }\end{DoxyParamCaption})}



Set (copy) addresses for a given ASP peer. 

Previous addresses are freed. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em peer} & Application Server Process peer whose addresses are to be set. \\
\hline
\mbox{\texttt{ in}}  & {\em talloc\+\_\+ctx} & talloc context used to allocate new addresses. \\
\hline
\mbox{\texttt{ in}}  & {\em hosts} & Array of strings containing IP addresses. \\
\hline
\mbox{\texttt{ in}}  & {\em host\+\_\+cnt} & Number of strings in hosts \\
\hline
\mbox{\texttt{ in}}  & {\em idx\+\_\+primary} & Index in \char`\"{}hosts\char`\"{} array marking the SCTP Primary Address, -\/1 if no explicit Primary Address set \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative otherwise 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host}, \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host\+\_\+cnt}, and \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::idx\+\_\+primary}.



Referenced by \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+set\+\_\+hosts()}.

\mbox{\label{osmo__ss7__asp__peer_8c_a5f7cd03bf480ca74d5ad2c9a6a0d8f46}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!osmo\_ss7\_asp\_peer\_snprintf@{osmo\_ss7\_asp\_peer\_snprintf}}
\index{osmo\_ss7\_asp\_peer\_snprintf@{osmo\_ss7\_asp\_peer\_snprintf}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{osmo\_ss7\_asp\_peer\_snprintf()}
{\footnotesize\ttfamily int osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+\_\+snprintf (\begin{DoxyParamCaption}\item[{char $\ast$}]{buf,  }\item[{size\+\_\+t}]{buf\+\_\+len,  }\item[{struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$}]{peer }\end{DoxyParamCaption})}



References \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host}, \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host\+\_\+cnt}, \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::idx\+\_\+primary}, \textbf{ len}, and \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::port}.



Referenced by \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+restart()}, \textbf{ osmo\+\_\+ss7\+\_\+xua\+\_\+server\+\_\+bind()}, \textbf{ show\+\_\+one\+\_\+asp()}, and \textbf{ vty\+\_\+dump\+\_\+xua\+\_\+server()}.

\mbox{\label{osmo__ss7__asp__peer_8c_a0a07753e2dbb45fb36558c64e6bac1a8}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!ss7\_asp\_peer\_find\_host@{ss7\_asp\_peer\_find\_host}}
\index{ss7\_asp\_peer\_find\_host@{ss7\_asp\_peer\_find\_host}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{ss7\_asp\_peer\_find\_host()}
{\footnotesize\ttfamily int ss7\+\_\+asp\+\_\+peer\+\_\+find\+\_\+host (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$}]{peer,  }\item[{const char $\ast$}]{host }\end{DoxyParamCaption})}



Find the exact IP address match and return its index in the array. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em peer} & Application Server Process peer where the address is looked up. \\
\hline
\mbox{\texttt{ in}}  & {\em host} & string containing an IP address. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
$>$=0 on success containing the index of the host; negative otherwise 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host}, and \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host\+\_\+cnt}.



Referenced by \textbf{ DEFUN\+\_\+\+ATTR()}.

\mbox{\label{osmo__ss7__asp__peer_8c_ac6cb83500d201029a2e6917efaa5104e}} 
\index{osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}!ss7\_asp\_peer\_match\_host@{ss7\_asp\_peer\_match\_host}}
\index{ss7\_asp\_peer\_match\_host@{ss7\_asp\_peer\_match\_host}!osmo\_ss7\_asp\_peer.c@{osmo\_ss7\_asp\_peer.c}}
\doxysubsubsection{ss7\_asp\_peer\_match\_host()}
{\footnotesize\ttfamily bool ss7\+\_\+asp\+\_\+peer\+\_\+match\+\_\+host (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$}]{peer,  }\item[{const char $\ast$}]{host,  }\item[{bool}]{host\+\_\+is\+\_\+v6 }\end{DoxyParamCaption})}



References \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host}, \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::host\+\_\+cnt}, and \textbf{ host\+\_\+is\+\_\+ip\+\_\+anyaddr()}.



Referenced by \textbf{ ss7\+\_\+asp\+\_\+find\+\_\+by\+\_\+socket\+\_\+addr()}.

