OpenCores
URL https://opencores.org/ocsvn/1g_ethernet_dpi/1g_ethernet_dpi/trunk

Subversion Repositories 1g_ethernet_dpi

[/] [1g_ethernet_dpi/] [trunk/] [sw/] [dev/] [test_main/] [src/] [net/] [ip.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 kuzmi4
#ifndef _IP_H_
2
#define _IP_H_
3
 
4
#ifdef __cplusplus
5
extern "C"
6
{
7
#endif// __cplusplus
8
 
9
#include "eth.h"
10
#include "net.h"
11
 
12
#define     ETH_IP     ntohs(0x0800) // IP type, net endian
13
 
14
// tbd
15
struct _ip_hdr {
16
   u8      ip_ver_ihl;    // 4 bit version, 4 bit hdr len in 32bit words 
17
   u8      ip_tos;        // Type of Service,  RFC 2474 -> {DSCP[5:0], ECN[1:0]} 
18
   u16     ip_len;        // Total packet length including header 
19
   u16     ip_id;         // ID for fragmentation 
20
   u16     ip_flgs_foff;  // mask in flags as needed 
21
   u8      ip_time;       // Time to live (secs) 
22
   u8      ip_prot;       // protocol 
23
   u16     ip_chksum;     // Header checksum 
24
   u32     ip_src;        // Source Addr 
25
   u32     ip_dest;       // Destination Addr 
26
} _packed_struct;
27
typedef struct _ip_hdr ip_hdr_t;
28
 
29
// Some macros for finding IP offsets in incoming packets
30
#define  ip_head(p)         (ip_hdr_t *)(p + ETH_HDR_SZ)
31
#define  ip_hlen(pip)       (((pip)->ip_ver_ihl  &  0x0f) << 2)
32
#define  ip_data(pip)       ((char *)(pip) +  ip_hlen(pip))
33
 
34
// fragmentation flag bits, for masking into 16bit flags/offset word
35
#define  IP_FLG_DF   0x4000   // Don't   Fragment (DF) bit 
36
#define  IP_FLG_MF   0x2000   // More Fragments (MF) bit 
37
#define  IP_FLG_MASK 0xe000   // for masking out all flags from word
38
 
39
// IPv4 def:
40
#define  IP_VER   4     // IPv4 -> 4 / RFC#791
41
#define  IP_LEN   5     // RFC#791 -> 5
42
 
43
// Ext:
44
void eth_ip_init(net_if_t *ip_net_if);
45
void eth_ip(char *iv_data);
46
 
47
#ifdef __cplusplus
48
}
49
#endif// __cplusplus
50
 
51
#endif   // _IP_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.