further implemented bootp protocol
This commit is contained in:
@@ -8,12 +8,28 @@
|
||||
#ifndef _BOOTP_H_
|
||||
#define _BOOTP_H_
|
||||
|
||||
/********************************************************************/
|
||||
#define BOOTP_SERVER_PORT 67
|
||||
#define BOOTP_CLIENT_PORT 68
|
||||
|
||||
/* protocol header information */
|
||||
#define BOOTP_HDR_OFFSET (ETH_HDR_LEN + IP_HDR_SIZE + UDP_HDR_SIZE)
|
||||
|
||||
/* timeout in seconds */
|
||||
#define BOOTP_TIMEOUT 2
|
||||
|
||||
/* BOOTP connection status */
|
||||
|
||||
struct bootp_connection
|
||||
{
|
||||
bool open; /* connection established flag */
|
||||
NIF *nif; /* pointer to network interface */
|
||||
IP_ADDR server_ip; /* server IP address */
|
||||
};
|
||||
|
||||
/*
|
||||
* This data definition is defined for Ethernet only!
|
||||
*/
|
||||
typedef struct
|
||||
struct bootp_packet
|
||||
{
|
||||
uint8_t type; /* bootp operation type */
|
||||
uint8_t htype; /* hardware type */
|
||||
@@ -29,9 +45,9 @@ typedef struct
|
||||
uint8_t sname[64]; /* server name */
|
||||
uint8_t file[128]; /* name of bootfile */
|
||||
uint8_t vend[64]; /* vendor specific (see below) */
|
||||
} bootp_frame_hdr;
|
||||
};
|
||||
|
||||
#define BOOTP_HDR_LEN sizeof(bootp_frame_hdr)
|
||||
#define BOOTP_PACKET_LEN (BOOTP_HDR_OFFSET + sizeof(struct bootp_packet))
|
||||
|
||||
/* possible values for type field */
|
||||
#define BOOTP_TYPE_BOOTREQUEST 1
|
||||
@@ -46,11 +62,6 @@ typedef struct
|
||||
/* values for flags - only broadcast flag in use */
|
||||
#define BOOTP_FLAGS_BROADCAST 1
|
||||
|
||||
#define BOOTP_TIMEOUT (1) /* Timeout in seconds */
|
||||
|
||||
/* Protocol Header information */
|
||||
#define BOOTP_HDR_OFFSET ETH_HDR_LEN
|
||||
|
||||
extern void bootp_request(NIF *, uint8_t *);
|
||||
extern void bootp_handler(NIF *, NBUF *);
|
||||
//extern void bootp_init(BOOTP_INFO *);
|
||||
|
||||
154
include/nbuf.h
154
include/nbuf.h
@@ -1,85 +1,69 @@
|
||||
/*
|
||||
* File: nbuf.h
|
||||
* Purpose: Definitions for network buffer management
|
||||
*
|
||||
* Notes: These routines implement a network buffer scheme
|
||||
*/
|
||||
|
||||
#ifndef _NBUF_H_
|
||||
#define _NBUF_H_
|
||||
|
||||
/********************************************************************/
|
||||
/*
|
||||
* Include the Queue structure definitions
|
||||
*/
|
||||
#include "queue.h"
|
||||
|
||||
/*
|
||||
* Number of network buffers to use
|
||||
*/
|
||||
#define NBUF_MAX 30
|
||||
|
||||
/*
|
||||
* Size of each buffer in bytes
|
||||
*/
|
||||
#ifndef NBUF_SZ
|
||||
#define NBUF_SZ 1520
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines to identify all the buffer queues
|
||||
* - FREE must always be defined as 0
|
||||
*/
|
||||
#define NBUF_FREE 0 /* available buffers */
|
||||
#define NBUF_TX_RING 1 /* buffers in the Tx BD ring */
|
||||
#define NBUF_RX_RING 2 /* buffers in the Rx BD ring */
|
||||
#define NBUF_SCRATCH 3 /* misc */
|
||||
#define NBUF_MAXQ 4 /* total number of queueus */
|
||||
|
||||
/*
|
||||
* Buffer Descriptor Format
|
||||
*
|
||||
* Fields:
|
||||
* next Pointer to next node in the queue
|
||||
* data Pointer to the data buffer
|
||||
* offset Index into buffer
|
||||
* length Remaining bytes in buffer from (data + offset)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
QNODE node;
|
||||
uint8_t *data;
|
||||
uint16_t offset;
|
||||
uint16_t length;
|
||||
} NBUF;
|
||||
|
||||
/*
|
||||
* Functions to manipulate the network buffers.
|
||||
*/
|
||||
int
|
||||
nbuf_init(void);
|
||||
|
||||
void
|
||||
nbuf_flush(void);
|
||||
|
||||
NBUF *
|
||||
nbuf_alloc (void);
|
||||
|
||||
void
|
||||
nbuf_free(NBUF *);
|
||||
|
||||
NBUF *
|
||||
nbuf_remove(int);
|
||||
|
||||
void
|
||||
nbuf_add(int, NBUF *);
|
||||
|
||||
void
|
||||
nbuf_reset(void);
|
||||
|
||||
void
|
||||
nbuf_debug_dump(void);
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
#endif /* _NBUF_H_ */
|
||||
/*
|
||||
* File: nbuf.h
|
||||
* Purpose: Definitions for network buffer management
|
||||
*
|
||||
* Notes: These routines implement a network buffer scheme
|
||||
*/
|
||||
|
||||
#ifndef _NBUF_H_
|
||||
#define _NBUF_H_
|
||||
|
||||
/********************************************************************/
|
||||
/*
|
||||
* Include the Queue structure definitions
|
||||
*/
|
||||
#include "queue.h"
|
||||
|
||||
/*
|
||||
* Number of network buffers to use
|
||||
*/
|
||||
#define NBUF_MAX 30
|
||||
|
||||
/*
|
||||
* Size of each buffer in bytes
|
||||
*/
|
||||
#ifndef NBUF_SZ
|
||||
#define NBUF_SZ 1520
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines to identify all the buffer queues
|
||||
* - FREE must always be defined as 0
|
||||
*/
|
||||
#define NBUF_FREE 0 /* available buffers */
|
||||
#define NBUF_TX_RING 1 /* buffers in the Tx BD ring */
|
||||
#define NBUF_RX_RING 2 /* buffers in the Rx BD ring */
|
||||
#define NBUF_SCRATCH 3 /* misc */
|
||||
#define NBUF_MAXQ 4 /* total number of queueus */
|
||||
|
||||
/*
|
||||
* Buffer Descriptor Format
|
||||
*
|
||||
* Fields:
|
||||
* next Pointer to next node in the queue
|
||||
* data Pointer to the data buffer
|
||||
* offset Index into buffer
|
||||
* length Remaining bytes in buffer from (data + offset)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
QNODE node;
|
||||
uint8_t *data;
|
||||
uint16_t offset;
|
||||
uint16_t length;
|
||||
} NBUF;
|
||||
|
||||
/*
|
||||
* Functions to manipulate the network buffers.
|
||||
*/
|
||||
extern int nbuf_init(void);
|
||||
extern void nbuf_flush(void);
|
||||
extern NBUF *nbuf_alloc (void);
|
||||
extern void nbuf_free(NBUF *);
|
||||
extern NBUF *nbuf_remove(int);
|
||||
extern void nbuf_add(int, NBUF *);
|
||||
extern void nbuf_reset(void);
|
||||
extern void nbuf_debug_dump(void);
|
||||
|
||||
|
||||
#endif /* _NBUF_H_ */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* File: net.h
|
||||
* Purpose: Network definitions and prototypes for dBUG.
|
||||
* Purpose: Network definitions and prototypes for BaS.
|
||||
*
|
||||
* Notes:
|
||||
*/
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
int net_init(void);
|
||||
extern int net_init(void);
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/*
|
||||
* File: net_timer.h
|
||||
* Purpose: Provide a timer use by the dBUG network as a timeout
|
||||
* Purpose: Provide a timer use by the BaS network as a timeout
|
||||
* indicator
|
||||
*
|
||||
* Notes:
|
||||
*/
|
||||
|
||||
#ifndef _TIMER_H_
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#ifndef _TFTP_H_
|
||||
#define _TFTP_H_
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
#define TFTP_RRQ (1)
|
||||
#define TFTP_WRQ (2)
|
||||
#define TFTP_DATA (3)
|
||||
|
||||
Reference in New Issue
Block a user