Files
mips/src/common/network/dhcp.h
T
jens d668370db8 - fixed msg_type
git-svn-id: http://moon:8086/svn/mips@221 a8ebac50-d88d-4704-bea3-6648445a41b3
2021-11-25 08:19:05 +00:00

79 lines
2.1 KiB
C

// -------------------------------------------------------------------------
// ipv4.h
//
// 21.12.2003, J. Ahrensfeld
//
// -------------------------------------------------------------------------
#ifndef DHCP_H
#define DHCP_H
#include <libsys/libsys.h>
#include "ethernet.h"
// -------------------------------------------------------------------------
typedef uint8_t dhcp_sname_t[64];
typedef uint8_t dhcp_file_t[128];
typedef uint8_t dhcp_option_t[312];
typedef struct _sDHCP
{
uint8_t op, htype, hlen, hops;
uint32_t xid;
uint16_t secs, flags;
uint8_t ciaddr[4];
uint8_t yiaddr[4];
uint8_t siaddr[4];
uint8_t giaddr[4];
uint8_t chaddr[16];
dhcp_sname_t sname;
dhcp_file_t file;
dhcp_option_t options;
} __attribute__ ((__packed__)) DHCP;
#define DHCP_MAGIC_COOKIE 0x63825363
#define DHCP_BOOTREQUEST 1 // request.
#define DHCP_BOOTREPLY 2 // reply.
typedef struct _sdhcp_opt_hdr_t
{
uint8_t code;
uint8_t size;
} __attribute__ ((__packed__)) dhcp_opt_hdr_t;
typedef struct _soption_list_t
{
size_t capacity;
size_t size;
uint8_t *buffer;
uint8_t *pData;
} option_list_t;
#define DHCP_FLAGS_BROADCAST 0x8000
#define DHCP_OPT_HOSTNAME 12
#define DHCP_OPT_REQIP 50
#define DHCP_OPT_MSGTYPE 53
#define DHCP_OPT_SERVERID 54
#define DHCP_OPT_CLIENTID 61
#define DHCP_OPT_END 255
#define DHCP_MSG_DHCPDISCOVER 1
#define DHCP_MSG_DHCPOFFER 2
#define DHCP_MSG_DHCPREQUEST 3
#define DHCP_MSG_DHCPDECLINE 4
#define DHCP_MSG_DHCPACK 5
#define DHCP_MSG_DHCPNAK 6
#define DHCP_MSG_DHCPRELEASE 7
// -------------------------------------------------------------------------
void DHCP_request_send(packet_t *pPacket, uint8_t dhcp_msg_type, uint8_t *mac_addr_src, uint8_t *inet_addr_src, uint8_t *inet_addr_dst, DHCP *pLast);
void option_list_init(option_list_t *pObj, void *pBuffer, size_t size);
void option_list_append(option_list_t *pObj, uint8_t option_type, void const *pData, size_t size);
size_t data_entry_create(void *pDst, uint8_t type, void const *pData, size_t size);
// -------------------------------------------------------------------------
#endif // DHCP_H