FreeBSD kernel IPv4 code
alias_nbt.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <netinet/libalias/alias_local.h>
#include <netinet/libalias/alias_mod.h>
Include dependency graph for alias_nbt.c:

Go to the source code of this file.

Data Structures

struct  NBTArguments
 
struct  NbtDataHeader
 
struct  NbtNSHeader
 
struct  NBTNsQuestion
 
struct  NBTNsResource
 
struct  NBTNsRNB
 
struct  NBTNsResourceA
 
struct  NBTNsResourceNULL
 
struct  NBTNsResourceNBSTAT
 

Macros

#define NETBIOS_NS_PORT_NUMBER   137
 
#define NETBIOS_DGM_PORT_NUMBER   138
 
#define OpQuery   0
 
#define OpUnknown   4
 
#define OpRegist   5
 
#define OpRelease   6
 
#define OpWACK   7
 
#define OpRefresh   8
 
#define FMT_ERR   0x1
 
#define SRV_ERR   0x2
 
#define IMP_ERR   0x4
 
#define RFS_ERR   0x5
 
#define ACT_ERR   0x6
 
#define CFT_ERR   0x7
 
#define DGM_DIRECT_UNIQ   0x10
 
#define DGM_DIRECT_GROUP   0x11
 
#define DGM_BROADCAST   0x12
 
#define DGM_ERROR   0x13
 
#define DGM_QUERY   0x14
 
#define DGM_POSITIVE_RES   0x15
 
#define DGM_NEGATIVE_RES   0x16
 
#define QS_TYPE_NB   0x0020
 
#define QS_TYPE_NBSTAT   0x0021
 
#define QS_CLAS_IN   0x0001
 
#define RR_TYPE_A   0x0001
 
#define RR_TYPE_NS   0x0002
 
#define RR_TYPE_NULL   0x000a
 
#define RR_TYPE_NB   0x0020
 
#define RR_TYPE_NBSTAT   0x0021
 
#define RR_CLAS_IN   0x0001
 
#define SizeOfNsResource   8
 
#define SizeOfNsRNB   6
 
#define SizeOfResourceA   6
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int AliasHandleUdpNbt (struct libalias *, struct ip *, struct alias_link *, struct in_addr *, u_short)
 
static int AliasHandleUdpNbtNS (struct libalias *, struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *)
 
static int fingerprint1 (struct libalias *la, struct alias_data *ah)
 
static int protohandler1 (struct libalias *la, struct ip *pip, struct alias_data *ah)
 
static int fingerprint2 (struct libalias *la, struct alias_data *ah)
 
static int protohandler2in (struct libalias *la, struct ip *pip, struct alias_data *ah)
 
static int protohandler2out (struct libalias *la, struct ip *pip, struct alias_data *ah)
 
static int mod_handler (module_t mod, int type, void *data)
 
 DECLARE_MODULE (alias_nbt, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND)
 
 MODULE_VERSION (alias_nbt, 1)
 
 MODULE_DEPEND (alias_nbt, libalias, 1, 1, 1)
 
static u_char * AliasHandleName (u_char *p, char *pmax)
 
static u_char * AliasHandleQuestion (u_short count, NBTNsQuestion *q, char *pmax, NBTArguments *nbtarg)
 
static u_char * AliasHandleResourceNB (NBTNsResource *q, char *pmax, NBTArguments *nbtarg)
 
static u_char * AliasHandleResourceA (NBTNsResource *q, char *pmax, NBTArguments *nbtarg)
 
static u_char * AliasHandleResourceNULL (NBTNsResource *q, char *pmax, NBTArguments *nbtarg)
 
static u_char * AliasHandleResourceNS (NBTNsResource *q, char *pmax, NBTArguments *nbtarg)
 
static u_char * AliasHandleResourceNBSTAT (NBTNsResource *q, char *pmax, NBTArguments *nbtarg)
 
static u_char * AliasHandleResource (u_short count, NBTNsResource *q, char *pmax, NBTArguments *nbtarg)
 

Variables

struct proto_handler handlers []
 
static moduledata_t alias_mod
 

Macro Definition Documentation

◆ ACT_ERR

#define ACT_ERR   0x6

Definition at line 222 of file alias_nbt.c.

◆ CFT_ERR

#define CFT_ERR   0x7

Definition at line 223 of file alias_nbt.c.

◆ DGM_BROADCAST

#define DGM_BROADCAST   0x12

Definition at line 320 of file alias_nbt.c.

◆ DGM_DIRECT_GROUP

#define DGM_DIRECT_GROUP   0x11

Definition at line 319 of file alias_nbt.c.

◆ DGM_DIRECT_UNIQ

#define DGM_DIRECT_UNIQ   0x10

Definition at line 318 of file alias_nbt.c.

◆ DGM_ERROR

#define DGM_ERROR   0x13

Definition at line 321 of file alias_nbt.c.

◆ DGM_NEGATIVE_RES

#define DGM_NEGATIVE_RES   0x16

Definition at line 324 of file alias_nbt.c.

◆ DGM_POSITIVE_RES

#define DGM_POSITIVE_RES   0x15

Definition at line 323 of file alias_nbt.c.

◆ DGM_QUERY

#define DGM_QUERY   0x14

Definition at line 322 of file alias_nbt.c.

◆ FMT_ERR

#define FMT_ERR   0x1

Definition at line 218 of file alias_nbt.c.

◆ IMP_ERR

#define IMP_ERR   0x4

Definition at line 220 of file alias_nbt.c.

◆ NETBIOS_DGM_PORT_NUMBER

#define NETBIOS_DGM_PORT_NUMBER   138

Definition at line 72 of file alias_nbt.c.

◆ NETBIOS_NS_PORT_NUMBER

#define NETBIOS_NS_PORT_NUMBER   137

Definition at line 71 of file alias_nbt.c.

◆ OpQuery

#define OpQuery   0

Definition at line 203 of file alias_nbt.c.

◆ OpRefresh

#define OpRefresh   8

Definition at line 208 of file alias_nbt.c.

◆ OpRegist

#define OpRegist   5

Definition at line 205 of file alias_nbt.c.

◆ OpRelease

#define OpRelease   6

Definition at line 206 of file alias_nbt.c.

◆ OpUnknown

#define OpUnknown   4

Definition at line 204 of file alias_nbt.c.

◆ OpWACK

#define OpWACK   7

Definition at line 207 of file alias_nbt.c.

◆ QS_CLAS_IN

#define QS_CLAS_IN   0x0001

Definition at line 407 of file alias_nbt.c.

◆ QS_TYPE_NB

#define QS_TYPE_NB   0x0020

Definition at line 405 of file alias_nbt.c.

◆ QS_TYPE_NBSTAT

#define QS_TYPE_NBSTAT   0x0021

Definition at line 406 of file alias_nbt.c.

◆ RFS_ERR

#define RFS_ERR   0x5

Definition at line 221 of file alias_nbt.c.

◆ RR_CLAS_IN

#define RR_CLAS_IN   0x0001

Definition at line 455 of file alias_nbt.c.

◆ RR_TYPE_A

#define RR_TYPE_A   0x0001

Definition at line 450 of file alias_nbt.c.

◆ RR_TYPE_NB

#define RR_TYPE_NB   0x0020

Definition at line 453 of file alias_nbt.c.

◆ RR_TYPE_NBSTAT

#define RR_TYPE_NBSTAT   0x0021

Definition at line 454 of file alias_nbt.c.

◆ RR_TYPE_NS

#define RR_TYPE_NS   0x0002

Definition at line 451 of file alias_nbt.c.

◆ RR_TYPE_NULL

#define RR_TYPE_NULL   0x000a

Definition at line 452 of file alias_nbt.c.

◆ SizeOfNsResource

#define SizeOfNsResource   8

Definition at line 456 of file alias_nbt.c.

◆ SizeOfNsRNB

#define SizeOfNsRNB   6

Definition at line 464 of file alias_nbt.c.

◆ SizeOfResourceA

#define SizeOfResourceA   6

Definition at line 538 of file alias_nbt.c.

◆ SRV_ERR

#define SRV_ERR   0x2

Definition at line 219 of file alias_nbt.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ AliasHandleName()

static u_char * AliasHandleName ( u_char *  p,
char *  pmax 
)
static

Definition at line 251 of file alias_nbt.c.

Referenced by AliasHandleQuestion(), AliasHandleResource(), AliasHandleResourceNS(), and AliasHandleUdpNbt().

Here is the caller graph for this function:

◆ AliasHandleQuestion()

static u_char * AliasHandleQuestion ( u_short  count,
NBTNsQuestion q,
char *  pmax,
NBTArguments nbtarg 
)
static

Definition at line 414 of file alias_nbt.c.

References AliasHandleName(), count, QS_TYPE_NB, QS_TYPE_NBSTAT, and NBTNsQuestion::type.

Referenced by AliasHandleUdpNbtNS().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AliasHandleResource()

static u_char * AliasHandleResource ( u_short  count,
NBTNsResource q,
char *  pmax,
NBTArguments nbtarg 
)
static

Definition at line 699 of file alias_nbt.c.

References AliasHandleName(), AliasHandleResourceA(), AliasHandleResourceNB(), AliasHandleResourceNBSTAT(), AliasHandleResourceNS(), AliasHandleResourceNULL(), count, RR_TYPE_A, RR_TYPE_NB, RR_TYPE_NBSTAT, RR_TYPE_NS, RR_TYPE_NULL, and NBTNsResource::type.

Referenced by AliasHandleUdpNbtNS().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AliasHandleResourceA()

static u_char * AliasHandleResourceA ( NBTNsResource q,
char *  pmax,
NBTArguments nbtarg 
)
static

Definition at line 544 of file alias_nbt.c.

References NBTNsResourceA::addr, ADJUST_CHECKSUM, INET_NTOA_BUF, inet_ntoa_r(), NBTArguments::newaddr, NBTArguments::oldaddr, NBTNsResource::rdlen, SizeOfResourceA, and NBTArguments::uh_sum.

Referenced by AliasHandleResource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AliasHandleResourceNB()

static u_char * AliasHandleResourceNB ( NBTNsResource q,
char *  pmax,
NBTArguments nbtarg 
)
static

Definition at line 471 of file alias_nbt.c.

References NBTNsRNB::addr, ADJUST_CHECKSUM, INET_NTOA_BUF, inet_ntoa_r(), NBTArguments::newaddr, NBTArguments::oldaddr, NBTNsResource::rdlen, SizeOfNsResource, SizeOfNsRNB, and NBTArguments::uh_sum.

Referenced by AliasHandleResource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AliasHandleResourceNBSTAT()

static u_char * AliasHandleResourceNBSTAT ( NBTNsResource q,
char *  pmax,
NBTArguments nbtarg 
)
static

Definition at line 673 of file alias_nbt.c.

References NBTNsResource::rdlen.

Referenced by AliasHandleResource().

Here is the caller graph for this function:

◆ AliasHandleResourceNS()

static u_char * AliasHandleResourceNS ( NBTNsResource q,
char *  pmax,
NBTArguments nbtarg 
)
static

Definition at line 640 of file alias_nbt.c.

References AliasHandleName(), and NBTNsResource::rdlen.

Referenced by AliasHandleResource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AliasHandleResourceNULL()

static u_char * AliasHandleResourceNULL ( NBTNsResource q,
char *  pmax,
NBTArguments nbtarg 
)
static

Definition at line 605 of file alias_nbt.c.

References NBTNsResource::rdlen.

Referenced by AliasHandleResource().

Here is the caller graph for this function:

◆ AliasHandleUdpNbt()

static int AliasHandleUdpNbt ( struct libalias la,
struct ip pip,
struct alias_link lnk,
struct in_addr alias_address,
u_short  alias_port 
)
static

◆ AliasHandleUdpNbtNS()

static int AliasHandleUdpNbtNS ( struct libalias la,
struct ip pip,
struct alias_link lnk,
struct in_addr alias_address,
u_short *  alias_port,
struct in_addr original_address,
u_short *  original_port 
)
static

◆ DECLARE_MODULE()

DECLARE_MODULE ( alias_nbt  ,
alias_mod  ,
SI_SUB_DRIVERS  ,
SI_ORDER_SECOND   
)

◆ fingerprint1()

static int fingerprint1 ( struct libalias la,
struct alias_data ah 
)
static

◆ fingerprint2()

static int fingerprint2 ( struct libalias la,
struct alias_data ah 
)
static

◆ mod_handler()

static int mod_handler ( module_t  mod,
int  type,
void *  data 
)
static

Definition at line 153 of file alias_nbt.c.

References handlers, LibAliasAttachHandlers(), and LibAliasDetachHandlers().

Here is the call graph for this function:

◆ MODULE_DEPEND()

MODULE_DEPEND ( alias_nbt  ,
libalias  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( alias_nbt  ,
 
)

◆ protohandler1()

static int protohandler1 ( struct libalias la,
struct ip pip,
struct alias_data ah 
)
static

Definition at line 94 of file alias_nbt.c.

References alias_data::aaddr, AliasHandleUdpNbt(), alias_data::aport, and alias_data::lnk.

Here is the call graph for this function:

◆ protohandler2in()

static int protohandler2in ( struct libalias la,
struct ip pip,
struct alias_data ah 
)
static

Definition at line 112 of file alias_nbt.c.

References alias_data::aaddr, AliasHandleUdpNbtNS(), alias_data::aport, alias_data::dport, alias_data::lnk, and alias_data::oaddr.

Here is the call graph for this function:

◆ protohandler2out()

static int protohandler2out ( struct libalias la,
struct ip pip,
struct alias_data ah 
)
static

Definition at line 120 of file alias_nbt.c.

References alias_data::aaddr, AliasHandleUdpNbtNS(), alias_data::aport, alias_data::lnk, and alias_data::sport.

Here is the call graph for this function:

Variable Documentation

◆ alias_mod

moduledata_t alias_mod
static
Initial value:
= {
"alias_nbt", mod_handler, NULL
}
static int mod_handler(module_t mod, int type, void *data)
Definition: alias_nbt.c:153

Definition at line 175 of file alias_nbt.c.

◆ handlers

struct proto_handler handlers[]
Initial value:
= {
{
.pri = 130,
.dir = IN|OUT,
.proto = UDP,
.fingerprint = &fingerprint1,
.protohandler = &protohandler1
},
{
.pri = 140,
.dir = IN,
.proto = UDP,
.fingerprint = &fingerprint2,
.protohandler = &protohandler2in
},
{
.pri = 140,
.dir = OUT,
.proto = UDP,
.fingerprint = &fingerprint2,
.protohandler = &protohandler2out
},
{ EOH }
}
#define UDP
Definition: alias_mod.h:59
#define EOH
Definition: alias_mod.h:92
#define IN
Definition: alias_mod.h:52
#define OUT
Definition: alias_mod.h:53
static int fingerprint2(struct libalias *la, struct alias_data *ah)
Definition: alias_nbt.c:100
static int protohandler2in(struct libalias *la, struct ip *pip, struct alias_data *ah)
Definition: alias_nbt.c:112
static int protohandler1(struct libalias *la, struct ip *pip, struct alias_data *ah)
Definition: alias_nbt.c:94
static int fingerprint1(struct libalias *la, struct alias_data *ah)
Definition: alias_nbt.c:82
static int protohandler2out(struct libalias *la, struct ip *pip, struct alias_data *ah)
Definition: alias_nbt.c:120

Definition at line 127 of file alias_nbt.c.

Referenced by mod_handler().