dhcp.c File Reference

#include "nip_init.h"
#include "dispatcher.h"
#include "inet.h"
#include "os_core.h"
#include "nip_error.h"
#include "net/net_if.h"
#include "net/udp.h"
#include "app/dhcp.h"
#include "app/ports.h"

Include dependency graph for dhcp.c:

Go to the source code of this file.

Defines

#define DHCPMSGSIZE   sizeof( struct nip_dhcp_packet )
#define NIP_DHCP_CONF(if_id)   nip_dhcp_conf
#define CONF_ATTR(attr)   nip_dhcp_conf.attr

Functions

void nip_dhcp_start (nip_net_if_id_t net_if)
 enable dhcp for given network interface
void nip_dhcp_disable (nip_net_if_id_t net_if)
 disable dhcp for given network interface
void nip_dhcp_disp_sock_init (void)
 Dispatcher function to initialize DHCP UDP socket.
struct nip_dhcp_optionnip_dhcp_find_option (uint8_t opttype, struct nip_dhcp_packet *msg, nip_mem_size_t msg_size)
void nip_dhcp_disp_check (void)
 Dispatcher function to be called to check dhcp status.

Variables

struct nip_dhcp_config nip_dhcp_conf
 dhcp configuration variables for each interface
nip_udp_sock_id_t nip_dhcp_sock = NIP_UDP_NO_SOCKET


Define Documentation

#define CONF_ATTR ( attr   )     nip_dhcp_conf.attr

Referenced by nip_dhcp_disp_check().

#define DHCPMSGSIZE   sizeof( struct nip_dhcp_packet )

Definition at line 44 of file dhcp.c.

Referenced by nip_dhcp_disp_check().

#define NIP_DHCP_CONF ( if_id   )     nip_dhcp_conf

Definition at line 53 of file dhcp.c.

Referenced by nip_dhcp_disable(), nip_dhcp_disp_check(), and nip_dhcp_start().


Function Documentation

void nip_dhcp_disable ( nip_net_if_id_t  net_if  ) 

disable dhcp for given network interface

Definition at line 67 of file dhcp.c.

References NIP_DHCP_CONF, and NIP_DHCP_STAT_DISABLED.

void nip_dhcp_disp_check ( void   ) 

Dispatcher function to be called to check dhcp status.

Todo:
use some unique number (part of mac address?)

Definition at line 135 of file dhcp.c.

References nip_if_ip_conf::addr, nip_dhcp_packet::chaddr, nip_dhcp_packet::ciaddr, CONF_ATTR, DHCP_OPTION_DNS, DHCP_OPTION_END, DHCP_OPTION_LEASETIME, DHCP_OPTION_MSGTYPE, DHCP_OPTION_MSGTYPE_ACK, DHCP_OPTION_MSGTYPE_DISCOVER, DHCP_OPTION_MSGTYPE_NAK, DHCP_OPTION_MSGTYPE_OFFER, DHCP_OPTION_MSGTYPE_REQUEST, DHCP_OPTION_REBINDING_TIME, DHCP_OPTION_RENEWAL_TIME, DHCP_OPTION_ROUTER, DHCP_OPTION_SUBNETMASK, DHCPMSGSIZE, nip_dhcp_packet::flags, nip_dhcp_packet::hlen, nip_dhcp_packet::htype, nip_phy_if_t::hw_addr, nip_phy_if_t::hw_addr_size, nip_net_if::ip_conf, nip_dhcp_option::ipaddr, nip_dhcp_packet::magic_cookie, nip_dhcp_option::msgtype, NIP_CURR_CMD, NIP_CURR_IF, NIP_DHCP_CONF, nip_dhcp_disp_sock_init(), nip_dhcp_find_option(), NIP_DHCP_INIT_BACKOFF, NIP_DHCP_MAGIC_COOKIE, NIP_DHCP_MAX_BACKOFF, NIP_DHCP_OP_REPLY, NIP_DHCP_OP_REQUEST, nip_dhcp_sock, NIP_DHCP_STAT_BOUND, NIP_DHCP_STAT_INIT, NIP_DHCP_STAT_REBINDING, NIP_DHCP_STAT_RENEWING, NIP_DHCP_STAT_REQUESTING, NIP_DHCP_STAT_SELECTING, NIP_E_OK, nip_ip_addr_autoconf(), nip_ip_addr_set(), nip_ip_subnet_set(), nip_memcpy(), nip_memset, nip_net_if_list, nip_tickcount, nip_udp_cancel_recv(), nip_udp_cancel_send(), nip_udp_close(), nip_udp_data_ptr(), nip_udp_forward(), nip_udp_init_send(), NIP_UDP_NO_SOCKET, NIP_UDP_PORT_DHCPSERVER, nip_udp_ptr_release(), nip_udp_recvfrom(), NIP_UDP_RX_BUF, nip_udp_transmit(), NIP_UDP_TX_BUF, nip_udp_write(), ntohl, NULL, nip_dhcp_packet::op, nip_dhcp_packet::options, nip_net_if::phy_conf, nip_if_ip_conf::std_gateway, nip_dhcp_option::time, nip_phy_if_t::type, nip_dhcp_option::valsize, nip_dhcp_option::value, nip_dhcp_packet::xid, and nip_dhcp_packet::yiaddr.

Here is the call graph for this function:

void nip_dhcp_disp_sock_init ( void   ) 

Dispatcher function to initialize DHCP UDP socket.

On successfull socket setup the function will set the next-pointer to nip_dhcp_disp_check(). The socket setup may fail if the nip stack is out of space for UDP sockets. In that case nip_dhcp_disp_check() will not be called.

Definition at line 78 of file dhcp.c.

References nip_udp_sock_addr::ip, nip_dhcp_sock, NIP_UDP_PORT_DHCPCLIENT, NIP_UDP_SOCK_FLG_LISTENING, NIP_UDP_SOCK_FLG_NON_BLOCK, nip_udp_socket(), and nip_udp_sock_addr::port.

Referenced by nip_dhcp_disp_check().

Here is the call graph for this function:

Here is the caller graph for this function:

struct nip_dhcp_option* nip_dhcp_find_option ( uint8_t  opttype,
struct nip_dhcp_packet msg,
nip_mem_size_t  msg_size 
) [read]

Returns:
pointer to option in DHCP message or NULL if option was not found.

Definition at line 102 of file dhcp.c.

References DHCP_OPTION_END, DHCP_OPTION_PADDING, NULL, and nip_dhcp_packet::options.

Referenced by nip_dhcp_disp_check().

Here is the caller graph for this function:

void nip_dhcp_start ( nip_net_if_id_t  net_if  ) 

enable dhcp for given network interface

Definition at line 59 of file dhcp.c.

References NIP_DHCP_CONF, NIP_DHCP_STAT_INIT, NIP_DISP_IF_DHCP, and nip_disp_notify_if().

Here is the call graph for this function:


Variable Documentation

dhcp configuration variables for each interface

Definition at line 52 of file dhcp.c.

nip_udp_sock_id_t nip_dhcp_sock = NIP_UDP_NO_SOCKET

Definition at line 55 of file dhcp.c.

Referenced by nip_dhcp_disp_check(), and nip_dhcp_disp_sock_init().


Generated on Thu Jul 10 01:09:54 2008 for NIP by  doxygen 1.5.5