libosmogb 1.11.1
Osmocom Gb library
Loading...
Searching...
No Matches
gprs_ns2_frgre.c File Reference

NS-over-FR-over-GRE implementation. More...

#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <arpa/inet.h>
#include <osmocom/core/byteswap.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/select.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/talloc.h>
#include <osmocom/gprs/gprs_ns2.h>
#include "gprs_ns2_internal.h"

Data Structures

struct  gre_hdr
struct  priv_bind
struct  priv_vc

Macros

#define GRE_PTYPE_FR   0x6559
#define GRE_PTYPE_IPv4   0x0800
#define GRE_PTYPE_IPv6   0x86dd
#define GRE_PTYPE_KAR   0x0000 /* keepalive response */
#define IPPROTO_GRE   47

Functions

struct gre_hdr __attribute__ ((packed))
static void free_bind (struct gprs_ns2_vc_bind *bind)
 clean up all private driver state.
static int frgre_sendmsg (struct gprs_ns2_vc_bind *bind, struct msgb *msg, struct osmo_sockaddr *dest)
static void free_vc (struct gprs_ns2_vc *nsvc)
static struct priv_vcfrgre_alloc_vc (struct gprs_ns2_vc_bind *bind, struct gprs_ns2_vc *nsvc, struct osmo_sockaddr *remote, uint16_t dlci)
static int handle_rx_gre_ipv6 (struct osmo_fd *bfd, struct msgb *msg, struct ip6_hdr *ip6hdr, struct gre_hdr *greh)
static int handle_rx_gre_ipv4 (struct osmo_fd *bfd, struct msgb *msg, struct iphdr *iph, struct gre_hdr *greh)
static struct msgbread_nsfrgre_msg (struct osmo_fd *bfd, int *error, struct osmo_sockaddr *saddr, uint16_t *dlci, const struct gprs_ns2_vc_bind *bind)
static int ns2_find_vc_by_dlci (struct gprs_ns2_vc_bind *bind, uint16_t dlci, struct gprs_ns2_vc **result)
static int handle_nsfrgre_read (struct osmo_fd *bfd)
static int handle_nsfrgre_write (struct osmo_fd *bfd)
static int frgre_vc_sendmsg (struct gprs_ns2_vc *nsvc, struct msgb *msg)
static int frgre_fd_cb (struct osmo_fd *bfd, unsigned int what)
int gprs_ns2_is_frgre_bind (struct gprs_ns2_vc_bind *bind)
 determine if given bind is for FR-GRE encapsulation.
int gprs_ns2_frgre_bind (struct gprs_ns2_inst *nsi, const char *name, const struct osmo_sockaddr *local, int dscp, struct gprs_ns2_vc_bind **result)
 Create a new bind for NS over FR-GRE.

Variables

uint16_t flags
uint16_t ptype
struct gprs_ns2_vc_driver vc_driver_frgre
struct priv_bind __attribute__

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) as well as its successor 3GPP TS 48.016

Macro Definition Documentation

◆ GRE_PTYPE_FR

#define GRE_PTYPE_FR   0x6559

◆ GRE_PTYPE_IPv4

#define GRE_PTYPE_IPv4   0x0800

◆ GRE_PTYPE_IPv6

#define GRE_PTYPE_IPv6   0x86dd

◆ GRE_PTYPE_KAR

#define GRE_PTYPE_KAR   0x0000 /* keepalive response */

◆ IPPROTO_GRE

#define IPPROTO_GRE   47

Function Documentation

◆ free_bind()

void free_bind ( struct gprs_ns2_vc_bind * bind)
static

clean up all private driver state.

Should be only called by gprs_ns2_free_bind()

References priv_bind::fd, gprs_ns2_vc_bind::nsvc, and gprs_ns2_vc_bind::priv.

◆ free_vc()

void free_vc ( struct gprs_ns2_vc * nsvc)
static

References gprs_ns2_vc::priv.

◆ frgre_alloc_vc()

struct priv_vc * frgre_alloc_vc ( struct gprs_ns2_vc_bind * bind,
struct gprs_ns2_vc * nsvc,
struct osmo_sockaddr * remote,
uint16_t dlci )
static

◆ frgre_fd_cb()

int frgre_fd_cb ( struct osmo_fd * bfd,
unsigned int what )
static

◆ frgre_sendmsg()

int frgre_sendmsg ( struct gprs_ns2_vc_bind * bind,
struct msgb * msg,
struct osmo_sockaddr * dest )
inlinestatic

◆ frgre_vc_sendmsg()

◆ gprs_ns2_frgre_bind()

int gprs_ns2_frgre_bind ( struct gprs_ns2_inst * nsi,
const char * name,
const struct osmo_sockaddr * local,
int dscp,
struct gprs_ns2_vc_bind ** result )

Create a new bind for NS over FR-GRE.

Parameters
[in]nsiNS instance in which to create the bind
[in]locallocal address on which to bind
[in]dscpDSCP/TOS bits to use for transmitted data on this bind
[out]resultpointer to the created bind or if a bind with the name exists return the bind.
Returns
0 on success; negative on error. -EALREADY returned in case a bind with the name exists

References priv_bind::addr, osmo_fd::cb, osmo_fd::data, gprs_ns2_vc_bind::driver, priv_bind::dscp, priv_bind::fd, FRAME_RELAY_SDU, free_vc(), gprs_ns2_vc_bind::free_vc, frgre_fd_cb(), frgre_vc_sendmsg(), gprs_ns2_bind_by_name(), gprs_ns2_free_bind(), GPRS_NS2_LL_FR_GRE, IPPROTO_GRE, gprs_ns2_vc_bind::ll, gprs_ns2_vc_bind::mtu, ns2_bind_alloc(), gprs_ns2_vc_bind::nsi, gprs_ns2_vc_bind::nsvc, gprs_ns2_vc_bind::priv, osmo_sockaddr::sa, gprs_ns2_vc_bind::send_vc, gprs_ns2_vc_bind::transfer_capability, osmo_sockaddr::u, and vc_driver_frgre.

◆ gprs_ns2_is_frgre_bind()

int gprs_ns2_is_frgre_bind ( struct gprs_ns2_vc_bind * bind)

determine if given bind is for FR-GRE encapsulation.

References gprs_ns2_vc_bind::driver, and vc_driver_frgre.

◆ handle_nsfrgre_read()

◆ handle_nsfrgre_write()

int handle_nsfrgre_write ( struct osmo_fd * bfd)
static

Referenced by frgre_fd_cb().

◆ handle_rx_gre_ipv4()

int handle_rx_gre_ipv4 ( struct osmo_fd * bfd,
struct msgb * msg,
struct iphdr * iph,
struct gre_hdr * greh )
static

◆ handle_rx_gre_ipv6()

int handle_rx_gre_ipv6 ( struct osmo_fd * bfd,
struct msgb * msg,
struct ip6_hdr * ip6hdr,
struct gre_hdr * greh )
static

◆ ns2_find_vc_by_dlci()

int ns2_find_vc_by_dlci ( struct gprs_ns2_vc_bind * bind,
uint16_t dlci,
struct gprs_ns2_vc ** result )
static

◆ read_nsfrgre_msg()

struct msgb * read_nsfrgre_msg ( struct osmo_fd * bfd,
int * error,
struct osmo_sockaddr * saddr,
uint16_t * dlci,
const struct gprs_ns2_vc_bind * bind )
static

Variable Documentation

◆ __attribute__

struct priv_bind __attribute__

◆ flags

uint16_t flags

◆ ptype

uint16_t ptype

◆ vc_driver_frgre

struct gprs_ns2_vc_driver vc_driver_frgre
Initial value:
= {
.name = "GB frame relay over GRE",
.free_bind = free_bind,
}
static void free_bind(struct gprs_ns2_vc_bind *bind)
clean up all private driver state.
Definition gprs_ns2_fr.c:154

Referenced by gprs_ns2_frgre_bind(), and gprs_ns2_is_frgre_bind().