\doxysection{src/ss7\+\_\+asp\+\_\+peer.c File Reference}
\label{ss7__asp__peer_8c}\index{src/ss7\_asp\_peer.c@{src/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\+\_\+asp\+\_\+peer.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}ss7\+\_\+internal.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ ss7\+\_\+asp\+\_\+peer\+\_\+init} (struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer)
\item 
int \textbf{ ss7\+\_\+asp\+\_\+peer\+\_\+snprintf} (char $\ast$buf, size\+\_\+t buf\+\_\+len, struct \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer} $\ast$peer)
\item 
int \textbf{ 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{ 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{ 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{ 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{ 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{ss7__asp__peer_8c_a81c3380941dadb42610afc54465cfe4d}} 
\index{ss7\_asp\_peer.c@{ss7\_asp\_peer.c}!host\_is\_ip\_anyaddr@{host\_is\_ip\_anyaddr}}
\index{host\_is\_ip\_anyaddr@{host\_is\_ip\_anyaddr}!ss7\_asp\_peer.c@{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{ ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host2()}, and \textbf{ ss7\+\_\+asp\+\_\+peer\+\_\+match\+\_\+host()}.

\mbox{\label{ss7__asp__peer_8c_ab87b8ba42adbd3431ad712d45d7052f3}} 
\index{ss7\_asp\_peer.c@{ss7\_asp\_peer.c}!ss7\_asp\_peer\_add\_host@{ss7\_asp\_peer\_add\_host}}
\index{ss7\_asp\_peer\_add\_host@{ss7\_asp\_peer\_add\_host}!ss7\_asp\_peer.c@{ss7\_asp\_peer.c}}
\doxysubsubsection{ss7\_asp\_peer\_add\_host()}
{\footnotesize\ttfamily int 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{ ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host2()}.



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

\mbox{\label{ss7__asp__peer_8c_ab0fae7297f20a86c4473a9c3988f31c3}} 
\index{ss7\_asp\_peer.c@{ss7\_asp\_peer.c}!ss7\_asp\_peer\_add\_host2@{ss7\_asp\_peer\_add\_host2}}
\index{ss7\_asp\_peer\_add\_host2@{ss7\_asp\_peer\_add\_host2}!ss7\_asp\_peer.c@{ss7\_asp\_peer.c}}
\doxysubsubsection{ss7\_asp\_peer\_add\_host2()}
{\footnotesize\ttfamily int 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{ ss7\+\_\+asp\+\_\+peer\+\_\+add\+\_\+host()}.

\mbox{\label{ss7__asp__peer_8c_ac2e0ffdf4550d061179e02e1d0adc19c}} 
\index{ss7\_asp\_peer.c@{ss7\_asp\_peer.c}!ss7\_asp\_peer\_del\_host@{ss7\_asp\_peer\_del\_host}}
\index{ss7\_asp\_peer\_del\_host@{ss7\_asp\_peer\_del\_host}!ss7\_asp\_peer.c@{ss7\_asp\_peer.c}}
\doxysubsubsection{ss7\_asp\_peer\_del\_host()}
{\footnotesize\ttfamily int 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}, \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::idx\+\_\+primary}, and \textbf{ NULL}.



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

\mbox{\label{ss7__asp__peer_8c_a0a07753e2dbb45fb36558c64e6bac1a8}} 
\index{ss7\_asp\_peer.c@{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}!ss7\_asp\_peer.c@{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{ss7__asp__peer_8c_a073d0723890308ca9714d2fbbd5f5335}} 
\index{ss7\_asp\_peer.c@{ss7\_asp\_peer.c}!ss7\_asp\_peer\_init@{ss7\_asp\_peer\_init}}
\index{ss7\_asp\_peer\_init@{ss7\_asp\_peer\_init}!ss7\_asp\_peer.c@{ss7\_asp\_peer.c}}
\doxysubsubsection{ss7\_asp\_peer\_init()}
{\footnotesize\ttfamily void 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{ss7__asp__peer_8c_ac6cb83500d201029a2e6917efaa5104e}} 
\index{ss7\_asp\_peer.c@{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}!ss7\_asp\_peer.c@{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()}.

\mbox{\label{ss7__asp__peer_8c_a74c44996522f688100106717e91ae979}} 
\index{ss7\_asp\_peer.c@{ss7\_asp\_peer.c}!ss7\_asp\_peer\_set\_hosts@{ss7\_asp\_peer\_set\_hosts}}
\index{ss7\_asp\_peer\_set\_hosts@{ss7\_asp\_peer\_set\_hosts}!ss7\_asp\_peer.c@{ss7\_asp\_peer.c}}
\doxysubsubsection{ss7\_asp\_peer\_set\_hosts()}
{\footnotesize\ttfamily int 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{ ss7\+\_\+asp\+\_\+peer\+\_\+set\+\_\+hosts2()}.



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

\mbox{\label{ss7__asp__peer_8c_a39a8af19bbdca7c1c931e789f2e03b41}} 
\index{ss7\_asp\_peer.c@{ss7\_asp\_peer.c}!ss7\_asp\_peer\_set\_hosts2@{ss7\_asp\_peer\_set\_hosts2}}
\index{ss7\_asp\_peer\_set\_hosts2@{ss7\_asp\_peer\_set\_hosts2}!ss7\_asp\_peer.c@{ss7\_asp\_peer.c}}
\doxysubsubsection{ss7\_asp\_peer\_set\_hosts2()}
{\footnotesize\ttfamily int 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}, \textbf{ osmo\+\_\+ss7\+\_\+asp\+\_\+peer\+::idx\+\_\+primary}, and \textbf{ NULL}.



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

\mbox{\label{ss7__asp__peer_8c_a1d66512db0523f5d84806cdc8893ec08}} 
\index{ss7\_asp\_peer.c@{ss7\_asp\_peer.c}!ss7\_asp\_peer\_snprintf@{ss7\_asp\_peer\_snprintf}}
\index{ss7\_asp\_peer\_snprintf@{ss7\_asp\_peer\_snprintf}!ss7\_asp\_peer.c@{ss7\_asp\_peer.c}}
\doxysubsubsection{ss7\_asp\_peer\_snprintf()}
{\footnotesize\ttfamily int 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{ show\+\_\+one\+\_\+asp()}, \textbf{ ss7\+\_\+xua\+\_\+server\+\_\+bind()}, and \textbf{ vty\+\_\+dump\+\_\+xua\+\_\+server()}.

