# The Network Kit: BIpHandler

Derived from: none

Declared in: be/addons/net_server/IpDevice.h

Library: libnetdev.so

## Overview

As discussed in the BIpDevice section, the Network Server doesn't directly receive packets from IP devices. Instead, those devices monitor the appropriate interface for IP packets and forward them to the Network Server for dispatching to the appropriate protocol handler. This is done using the BIpHandler class.

When you write a IP device add-on, you create a class, derived from the BIpDevice class, that represents your add-on to the Network Server. The Network Server tells your IP device add-on to begin monitoring the network for IP packets by calling the BIpDevice's `Run()` function. The `Run()` function should create a thread that watches for packets on the interface.

The BIpHandler class represents the interface between the Network Server and your IP device add-on; when your `Run()` function is called, you receive a pointer to a BIpHandler object whose member functions you can call to interact with the Network Server.

When the packet monitoring thread receives an IP packet, it needs to forward the packet to the Network Server. This is done by calling the `PacketReceived()` function in the BIpHandler object passed to the `Run()` function.

You can also determine your IP address, using the `Address()` function, and change your IP address by calling `SetAddress()`. The interface's netmask can be obtained by calling the `NetMask()` function.

## Member Functions

### Address(), SetAddress()

          virtual uint32 Address(void) = 0

          virtual void SetAddress(uint32 address) = 0

          virtual uint32 NetMask(void) = 0

`Address()` returns the IP address of the interface from which your IP device is receiving packets.

`SetAddress()` lets you set the IP address you want to listen to. This allows your IP device to work with dynamic IP addresses.

`NetMask()` returns the netmask of the interface your IP device is connected to.

### PacketReceived()

          virtual void PacketReceived(BNetPacket *packet, BIpDevice *ipDevice) = 0

When your IP device handler receives a packet, it should use this function to forward the packet to the Network Server for dispatching. The packet parameter is a pointer to the packet itself, which must be of a class derived from BNetPacket (such as BStandardPacket or a custom packet class), and ipDevice must be a reference to your BIpDevice-derived object.

The Be Book, in lovely HTML, for BeOS Release 3.

Copyright © 1998 Be, Inc. All rights reserved.

Last modified March 26, 1998.