\doxysection{src/core/mnl.c File Reference}
\label{mnl_8c}\index{src/core/mnl.c@{src/core/mnl.c}}


This code integrates libmnl (minimal netlink library) into the osmocom select loop abstraction.  


{\ttfamily \#include \char`\"{}config.\+h\char`\"{}}\newline
{\ttfamily \#include $<$osmocom/core/select.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/logging.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/mnl.\+h$>$}\newline
{\ttfamily \#include $<$libmnl/libmnl.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static int \textbf{ osmo\+\_\+mnl\+\_\+fd\+\_\+cb} (struct \textbf{ osmo\+\_\+fd} $\ast$ofd, unsigned int what)
\item 
struct \textbf{ osmo\+\_\+mnl} $\ast$ \textbf{ osmo\+\_\+mnl\+\_\+init} (void $\ast$ctx, int bus, unsigned int groups, mnl\+\_\+cb\+\_\+t mnl\+\_\+cb, void $\ast$priv)
\begin{DoxyCompactList}\small\item\em create an osmocom-\/wrapped limnl netlink socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+mnl\+\_\+destroy} (struct \textbf{ osmo\+\_\+mnl} $\ast$omnl)
\begin{DoxyCompactList}\small\item\em destroy an existing osmocom-\/wrapped mnl netlink socket\+: Unregister + close + free. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
This code integrates libmnl (minimal netlink library) into the osmocom select loop abstraction. 

It allows other osmocom libraries or application code to create netlink sockets and subscribe to netlink events via libmnl. The completion handler / callbacks are dispatched via libosmocore select loop handling. 

\doxysubsection{Function Documentation}
\mbox{\label{mnl_8c_aa9759151d4d3fe75178a4e7786acef6d}} 
\index{mnl.c@{mnl.c}!osmo\_mnl\_destroy@{osmo\_mnl\_destroy}}
\index{osmo\_mnl\_destroy@{osmo\_mnl\_destroy}!mnl.c@{mnl.c}}
\doxysubsubsection{osmo\_mnl\_destroy()}
{\footnotesize\ttfamily void osmo\+\_\+mnl\+\_\+destroy (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+mnl} $\ast$}]{omnl }\end{DoxyParamCaption})}



destroy an existing osmocom-\/wrapped mnl netlink socket\+: Unregister + close + free. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em omnl} & \doxyref{osmo\+\_\+mnl}{p.}{structosmo__mnl} socket previously returned by \doxyref{osmo\+\_\+mnl\+\_\+init()}{p.}{mnl_8c_afa1cb4b93b6a178b9f1152f7b1beec8e} \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+mnl\+::mnls}, \textbf{ osmo\+\_\+mnl\+::ofd}, and \textbf{ osmo\+\_\+fd\+\_\+unregister()}.



Referenced by \textbf{ netdev\+\_\+netns\+\_\+ctx\+\_\+free()}.

\mbox{\label{mnl_8c_a7f7abd51687d4faee8f71b6f5c5b5d7e}} 
\index{mnl.c@{mnl.c}!osmo\_mnl\_fd\_cb@{osmo\_mnl\_fd\_cb}}
\index{osmo\_mnl\_fd\_cb@{osmo\_mnl\_fd\_cb}!mnl.c@{mnl.c}}
\doxysubsubsection{osmo\_mnl\_fd\_cb()}
{\footnotesize\ttfamily static int osmo\+\_\+mnl\+\_\+fd\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{ofd,  }\item[{unsigned int}]{what }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+fd\+::data}, \textbf{ DLGLOBAL}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ osmo\+\_\+mnl\+::mnl\+\_\+cb}, \textbf{ osmo\+\_\+mnl\+::mnls}, \textbf{ osmo\+\_\+mnl\+::ofd}, and \textbf{ OSMO\+\_\+\+FD\+\_\+\+READ}.



Referenced by \textbf{ osmo\+\_\+mnl\+\_\+init()}.

\mbox{\label{mnl_8c_afa1cb4b93b6a178b9f1152f7b1beec8e}} 
\index{mnl.c@{mnl.c}!osmo\_mnl\_init@{osmo\_mnl\_init}}
\index{osmo\_mnl\_init@{osmo\_mnl\_init}!mnl.c@{mnl.c}}
\doxysubsubsection{osmo\_mnl\_init()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+mnl} $\ast$ osmo\+\_\+mnl\+\_\+init (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{int}]{bus,  }\item[{unsigned int}]{groups,  }\item[{mnl\+\_\+cb\+\_\+t}]{mnl\+\_\+cb,  }\item[{void $\ast$}]{priv }\end{DoxyParamCaption})}



create an osmocom-\/wrapped limnl netlink socket. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context from which to allocate \\
\hline
\mbox{\texttt{ in}}  & {\em bus} & netlink socket bus ID (see NETLINK\+\_\+$\ast$ constants) \\
\hline
\mbox{\texttt{ in}}  & {\em groups} & groups of messages to bind/subscribe to \\
\hline
\mbox{\texttt{ in}}  & {\em mnl\+\_\+cb} & callback function called for each incoming message \\
\hline
\mbox{\texttt{ in}}  & {\em priv} & opaque private user data \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
newly-\/allocated \doxyref{osmo\+\_\+mnl}{p.}{structosmo__mnl} or NULL in case of error. 
\end{DoxyReturn}


References \textbf{ DLGLOBAL}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ osmo\+\_\+mnl\+::mnl\+\_\+cb}, \textbf{ osmo\+\_\+mnl\+::mnls}, \textbf{ osmo\+\_\+mnl\+::ofd}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+READ}, \textbf{ osmo\+\_\+fd\+\_\+register()}, \textbf{ osmo\+\_\+fd\+\_\+setup()}, \textbf{ osmo\+\_\+mnl\+\_\+fd\+\_\+cb()}, and \textbf{ osmo\+\_\+mnl\+::priv}.



Referenced by \textbf{ netdev\+\_\+netns\+\_\+ctx\+\_\+init()}.

