\doxysection{src/gb/gprs\+\_\+ns\+\_\+frgre.c File Reference}
\label{gprs__ns__frgre_8c}\index{src/gb/gprs\_ns\_frgre.c@{src/gb/gprs\_ns\_frgre.c}}


NS-\/over-\/\+FR-\/over-\/\+GRE implementation.  


{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$sys/socket.\+h$>$}\newline
{\ttfamily \#include $<$netinet/in.\+h$>$}\newline
{\ttfamily \#include $<$netinet/ip.\+h$>$}\newline
{\ttfamily \#include $<$arpa/inet.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/select.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/byteswap.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/msgb.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/socket.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/gprs/gprs\+\_\+ns.\+h$>$}\newline
{\ttfamily \#include \char`\"{}common\+\_\+vty.\+h\char`\"{}}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ gre\+\_\+hdr}
\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ GRE\+\_\+\+PTYPE\+\_\+\+FR}~0x6559
\item 
\#define \textbf{ GRE\+\_\+\+PTYPE\+\_\+\+IPv4}~0x0800
\item 
\#define \textbf{ GRE\+\_\+\+PTYPE\+\_\+\+KAR}~0x0000 /$\ast$ keepalive response $\ast$/
\item 
\#define \textbf{ IPPROTO\+\_\+\+GRE}~47
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ gre\+\_\+hdr} \textbf{ \+\_\+\+\_\+attribute\+\_\+\+\_\+} ((packed))
\item 
static int \textbf{ handle\+\_\+rx\+\_\+gre\+\_\+ipv4} (struct \textbf{ osmo\+\_\+fd} $\ast$bfd, struct \textbf{ msgb} $\ast$\textbf{ msg}, struct iphdr $\ast$iph, struct \textbf{ gre\+\_\+hdr} $\ast$greh)
\item 
static struct \textbf{ msgb} $\ast$ \textbf{ read\+\_\+nsfrgre\+\_\+msg} (struct \textbf{ osmo\+\_\+fd} $\ast$bfd, int $\ast$error, struct sockaddr\+\_\+in $\ast$saddr)
\item 
int \textbf{ gprs\+\_\+ns\+\_\+rcvmsg} (struct \textbf{ gprs\+\_\+ns\+\_\+inst} $\ast$nsi, struct \textbf{ msgb} $\ast$\textbf{ msg}, struct sockaddr\+\_\+in $\ast$saddr, enum \textbf{ gprs\+\_\+ns\+\_\+ll} ll)
\begin{DoxyCompactList}\small\item\em Receive incoming NS message from underlying transport layer. \end{DoxyCompactList}\item 
static int \textbf{ handle\+\_\+nsfrgre\+\_\+read} (struct \textbf{ osmo\+\_\+fd} $\ast$bfd)
\item 
static int \textbf{ handle\+\_\+nsfrgre\+\_\+write} (struct \textbf{ osmo\+\_\+fd} $\ast$bfd)
\item 
int \textbf{ gprs\+\_\+ns\+\_\+frgre\+\_\+sendmsg} (struct \textbf{ gprs\+\_\+nsvc} $\ast$nsvc, struct \textbf{ msgb} $\ast$\textbf{ msg})
\item 
static int \textbf{ nsfrgre\+\_\+fd\+\_\+cb} (struct \textbf{ osmo\+\_\+fd} $\ast$bfd, unsigned int what)
\item 
int \textbf{ gprs\+\_\+ns\+\_\+frgre\+\_\+listen} (struct \textbf{ gprs\+\_\+ns\+\_\+inst} $\ast$nsi)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
uint16\+\_\+t \textbf{ flags}
\item 
uint16\+\_\+t \textbf{ ptype}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
NS-\/over-\/\+FR-\/over-\/\+GRE implementation. 

GPRS Networks Service (NS) messages on the Gb interface, 3GPP TS 08.\+16 version 8.\+0.\+1 Release 1999 / ETSI TS 101 299 V8.\+0.\+1 (2002-\/05). 

\doxysubsection{Macro Definition Documentation}
\mbox{\label{gprs__ns__frgre_8c_a8f21d6a9aa6a76a99064adede0069eaa}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!GRE\_PTYPE\_FR@{GRE\_PTYPE\_FR}}
\index{GRE\_PTYPE\_FR@{GRE\_PTYPE\_FR}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{GRE\_PTYPE\_FR}
{\footnotesize\ttfamily \#define GRE\+\_\+\+PTYPE\+\_\+\+FR~0x6559}

\mbox{\label{gprs__ns__frgre_8c_a62ecd933e8d4e55dcb50528774e5628c}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!GRE\_PTYPE\_IPv4@{GRE\_PTYPE\_IPv4}}
\index{GRE\_PTYPE\_IPv4@{GRE\_PTYPE\_IPv4}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{GRE\_PTYPE\_IPv4}
{\footnotesize\ttfamily \#define GRE\+\_\+\+PTYPE\+\_\+\+IPv4~0x0800}

\mbox{\label{gprs__ns__frgre_8c_ae81d806ca5ef853fc65003d6c1cd88df}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!GRE\_PTYPE\_KAR@{GRE\_PTYPE\_KAR}}
\index{GRE\_PTYPE\_KAR@{GRE\_PTYPE\_KAR}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{GRE\_PTYPE\_KAR}
{\footnotesize\ttfamily \#define GRE\+\_\+\+PTYPE\+\_\+\+KAR~0x0000 /$\ast$ keepalive response $\ast$/}

\mbox{\label{gprs__ns__frgre_8c_a62b96b4d881982b3a6d911ddc0294f09}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!IPPROTO\_GRE@{IPPROTO\_GRE}}
\index{IPPROTO\_GRE@{IPPROTO\_GRE}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{IPPROTO\_GRE}
{\footnotesize\ttfamily \#define IPPROTO\+\_\+\+GRE~47}



\doxysubsection{Function Documentation}
\mbox{\label{gprs__ns__frgre_8c_a5a54120379f9a7be3948b65e7c5abb02}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!gprs\_ns\_frgre\_listen@{gprs\_ns\_frgre\_listen}}
\index{gprs\_ns\_frgre\_listen@{gprs\_ns\_frgre\_listen}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{gprs\_ns\_frgre\_listen()}
{\footnotesize\ttfamily int gprs\+\_\+ns\+\_\+frgre\+\_\+listen (\begin{DoxyParamCaption}\item[{struct \textbf{ gprs\+\_\+ns\+\_\+inst} $\ast$}]{nsi }\end{DoxyParamCaption})}



References \textbf{ osmo\+\_\+fd\+::cb}, \textbf{ osmo\+\_\+fd\+::data}, \textbf{ DNS}, \textbf{ gprs\+\_\+ns\+\_\+inst\+::enabled}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ gprs\+\_\+ns\+\_\+inst\+::fd}, \textbf{ gprs\+\_\+ns\+\_\+inst\+::frgre}, \textbf{ IPPROTO\+\_\+\+GRE}, \textbf{ gprs\+\_\+ns\+\_\+inst\+::local\+\_\+ip}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ nsfrgre\+\_\+fd\+\_\+cb()}, \textbf{ osmo\+\_\+htonl}, \textbf{ OSMO\+\_\+\+SOCK\+\_\+\+F\+\_\+\+BIND}, and \textbf{ osmo\+\_\+sock\+\_\+init\+\_\+ofd()}.

\mbox{\label{gprs__ns__frgre_8c_ac426de2326b02388b097f3059e352295}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!gprs\_ns\_frgre\_sendmsg@{gprs\_ns\_frgre\_sendmsg}}
\index{gprs\_ns\_frgre\_sendmsg@{gprs\_ns\_frgre\_sendmsg}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{gprs\_ns\_frgre\_sendmsg()}
{\footnotesize\ttfamily int gprs\+\_\+ns\+\_\+frgre\+\_\+sendmsg (\begin{DoxyParamCaption}\item[{struct \textbf{ gprs\+\_\+nsvc} $\ast$}]{nsvc,  }\item[{struct \textbf{ msgb} $\ast$}]{msg }\end{DoxyParamCaption})}



References \textbf{ gprs\+\_\+nsvc\+::bts\+\_\+addr}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ gprs\+\_\+ns\+\_\+inst\+::fd}, \textbf{ gre\+\_\+hdr\+::flags}, \textbf{ gprs\+\_\+ns\+\_\+inst\+::frgre}, \textbf{ gprs\+\_\+nsvc\+::frgre}, \textbf{ GRE\+\_\+\+PTYPE\+\_\+\+FR}, \textbf{ IPPROTO\+\_\+\+GRE}, \textbf{ msg}, \textbf{ msgb\+\_\+free()}, \textbf{ msgb\+\_\+push()}, \textbf{ gprs\+\_\+nsvc\+::nsi}, \textbf{ osmo\+\_\+htons}, \textbf{ osmo\+\_\+ntohs}, and \textbf{ gre\+\_\+hdr\+::ptype}.



Referenced by \textbf{ gprs\+\_\+ns\+\_\+tx()}.

\mbox{\label{gprs__ns__frgre_8c_a51b56c06de7c56f60a3d573c92ddbfa8}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!handle\_nsfrgre\_read@{handle\_nsfrgre\_read}}
\index{handle\_nsfrgre\_read@{handle\_nsfrgre\_read}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{handle\_nsfrgre\_read()}
{\footnotesize\ttfamily static int handle\+\_\+nsfrgre\+\_\+read (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{bfd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+fd\+::data}, \textbf{ DNS}, \textbf{ GPRS\+\_\+\+NS\+\_\+\+LL\+\_\+\+FR\+\_\+\+GRE}, \textbf{ gprs\+\_\+ns\+\_\+rcvmsg()}, \textbf{ LOGL\+\_\+\+INFO}, \textbf{ LOGP}, \textbf{ msg}, \textbf{ msgb\+\_\+free()}, \textbf{ osmo\+\_\+ntohs}, and \textbf{ read\+\_\+nsfrgre\+\_\+msg()}.



Referenced by \textbf{ nsfrgre\+\_\+fd\+\_\+cb()}.

\mbox{\label{gprs__ns__frgre_8c_a1cae912a76240e07b4077c30c2d4759b}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!handle\_nsfrgre\_write@{handle\_nsfrgre\_write}}
\index{handle\_nsfrgre\_write@{handle\_nsfrgre\_write}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{handle\_nsfrgre\_write()}
{\footnotesize\ttfamily static int handle\+\_\+nsfrgre\+\_\+write (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{bfd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Referenced by \textbf{ nsfrgre\+\_\+fd\+\_\+cb()}.

\mbox{\label{gprs__ns__frgre_8c_a51aaeff1f93914c4650e7ab3d633ac64}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!handle\_rx\_gre\_ipv4@{handle\_rx\_gre\_ipv4}}
\index{handle\_rx\_gre\_ipv4@{handle\_rx\_gre\_ipv4}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{handle\_rx\_gre\_ipv4()}
{\footnotesize\ttfamily static int handle\+\_\+rx\+\_\+gre\+\_\+ipv4 (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{bfd,  }\item[{struct \textbf{ msgb} $\ast$}]{msg,  }\item[{struct iphdr $\ast$}]{iph,  }\item[{struct \textbf{ gre\+\_\+hdr} $\ast$}]{greh }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+fd\+::data}, \textbf{ DNS}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ gprs\+\_\+ns\+\_\+inst\+::fd}, \textbf{ gprs\+\_\+ns\+\_\+inst\+::frgre}, \textbf{ GRE\+\_\+\+PTYPE\+\_\+\+KAR}, \textbf{ IPPROTO\+\_\+\+GRE}, \textbf{ LOGL\+\_\+\+DEBUG}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ msg}, \textbf{ osmo\+\_\+htons}, and \textbf{ gre\+\_\+hdr\+::ptype}.



Referenced by \textbf{ read\+\_\+nsfrgre\+\_\+msg()}.

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



References \textbf{ handle\+\_\+nsfrgre\+\_\+read()}, \textbf{ handle\+\_\+nsfrgre\+\_\+write()}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+READ}, and \textbf{ OSMO\+\_\+\+FD\+\_\+\+WRITE}.



Referenced by \textbf{ gprs\+\_\+ns\+\_\+frgre\+\_\+listen()}.

\mbox{\label{gprs__ns__frgre_8c_a165001967d670890c4ba0a37fd0f1658}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!read\_nsfrgre\_msg@{read\_nsfrgre\_msg}}
\index{read\_nsfrgre\_msg@{read\_nsfrgre\_msg}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{read\_nsfrgre\_msg()}
{\footnotesize\ttfamily static struct \textbf{ msgb} $\ast$ read\+\_\+nsfrgre\+\_\+msg (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{bfd,  }\item[{int $\ast$}]{error,  }\item[{struct sockaddr\+\_\+in $\ast$}]{saddr }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ DNS}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ gre\+\_\+hdr\+::flags}, \textbf{ GRE\+\_\+\+PTYPE\+\_\+\+FR}, \textbf{ GRE\+\_\+\+PTYPE\+\_\+\+IPv4}, \textbf{ handle\+\_\+rx\+\_\+gre\+\_\+ipv4()}, \textbf{ if()}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGL\+\_\+\+NOTICE}, \textbf{ LOGP}, \textbf{ msg}, \textbf{ msgb\+\_\+alloc()}, \textbf{ msgb\+\_\+free()}, \textbf{ msgb\+\_\+put()}, \textbf{ NS\+\_\+\+ALLOC\+\_\+\+SIZE}, \textbf{ osmo\+\_\+htons}, \textbf{ osmo\+\_\+ntohs}, and \textbf{ gre\+\_\+hdr\+::ptype}.



Referenced by \textbf{ handle\+\_\+nsfrgre\+\_\+read()}.



\doxysubsection{Variable Documentation}
\mbox{\label{gprs__ns__frgre_8c_a1e87af3c18a2fd36c61faf89949bdc3f}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!flags@{flags}}
\index{flags@{flags}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{flags}
{\footnotesize\ttfamily uint16\+\_\+t flags}

\mbox{\label{gprs__ns__frgre_8c_ab4891e9b77eb26f33d21cfde982564cb}} 
\index{gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}!ptype@{ptype}}
\index{ptype@{ptype}!gprs\_ns\_frgre.c@{gprs\_ns\_frgre.c}}
\doxysubsubsection{ptype}
{\footnotesize\ttfamily uint16\+\_\+t ptype}

