⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ip.h

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 H
📖 第 1 页 / 共 2 页
字号:
char *   ip_startup(void);

#ifndef MINI_IP
int      ip_demux(PACKET);    /* demux incoming IP to upper layers */
int      ip_init(void);
ip_addr  ip_mymach(ip_addr);
int      ip_more(void);
NET      iproute(ip_addr, ip_addr*);
RTMIB    add_route(ip_addr dest, ip_addr mask, ip_addr nexthop, int iface, int type);
int      del_route(ip_addr dest, ip_addr mask, int iface);
RTMIB    rt_lookup(ip_addr host);
#endif   /* MINI_IP */

#ifdef IP_FRAGMENTS
int   ip_reassm(PACKET newp);    /* process received IP fragments */
void  ip_frag_check(void);       /* check for fragment timeouts */
#endif   /* IP_FRAGMENTS */

#ifdef IP_RAW

/* struct ipraw_ep - IP's endpoint for raw IP access
 */
struct ipraw_ep {
   struct ipraw_ep * ipr_next;
   ip_addr ipr_laddr;               /* local host IP address binding */
   ip_addr ipr_faddr;               /* remote host IP address binding 
                                     * (connection) */
   int (*ipr_rcv)(PACKET, void*);   /* incoming packet handler */
   void * ipr_data;                 /* user 'per-connection' token */
   u_char ipr_prot;                 /* IP protocol ID binding */
};

/* ipraw_eps - pointer to list of raw IP endpoints 
 */
extern struct ipraw_ep * ipraw_eps;

/* prototypes for raw IP API functions
 */
struct ipraw_ep * ip_raw_open(u_char prot, ip_addr laddr, ip_addr faddr,
                              int (*handler)(PACKET, void *), void * data);
void ip_raw_close(struct ipraw_ep * ep);
int ip_raw_write(PACKET p);
PACKET ip_raw_alloc(int datalen, int hdrincl);
void ip_raw_free(PACKET p);
int ip_raw_maxalloc(int hdrincl);

#endif /* IP_RAW */

#ifdef IP_MULTICAST
/*
 * Internet multicast address structure.  There is one of these for each
 * IP multicast group to which this host belongs on a given network
 * interface.  They are kept in a linked list, rooted in the interface's 
 * NET structure.
 */
struct in_multi
{
     unsigned long  inm_addr;    /* IP multicast address */
     NET   inm_netp;             /* back pointer to NET structure  */
     unsigned inm_refcount;      /* no. membership claims by sockets */
     unsigned inm_timer;         /* IGMP membership report timer */
     struct in_multi * inm_next; /* ptr   to next  multicast   address */
};

/*
 * Structure stored in mbuf in inpcb.ip_options
 * and passed to ip_output when ip options are in use.
 * The actual length of the options (including ipopt_dst)
 * is in m_len.
 */
#define  MAX_IPOPTLEN   40
#define  IP_MAX_MEMBERSHIPS   20
#define  IN_MULTICAST(i)   (((long)(i) &  0xf0000000) == 0xe0000000)

#define  IM_ALLOC(size)    npalloc(size)
#define  IM_FREE(ptr)      npfree(ptr)
#define  INM_ALLOC(size)   npalloc(size)
#define  INM_FREE(ptr)     npfree(ptr)

/*
 * Defaults and limits for multicast options
 */
#define  IP_DEFAULT_MULTICAST_TTL   1  /* limit m'casts to 1 hop  */
#define  IP_DEFAULT_MULTICAST_LOOP  1  /* hear sends if a member  */
#define  IP_MAX_MEMBERSHIPS         20 /* max memberships */

/*
 * Structure attached to inpcb.ip_moptions and
 * passed to ip_output when IP multicast options are in use.
 */
struct ip_moptions
{
     struct net  *  imo_multicast_netp;/*   netp  for   outgoing multicasts */
     u_char   imo_multicast_ttl;   /* TTL for outgoing multicasts */
     u_char   imo_multicast_loop;  /* 1 => hear sends if a member */
     u_short  imo_num_memberships;/*  no.   memberships this  socket */
     struct in_multi * imo_membership[IP_MAX_MEMBERSHIPS];
};

/*
 * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
 */
struct ip_mreq
{
     ip_addr  imr_multiaddr;/*  IP multicast   address  of group */
     ip_addr  imr_interface;/*  local IP address  of interface */
};

/*
 * Structure used by macros below to remember position when stepping through
 * all of the in_multi records.
 */
struct in_multistep
{
     NET   netp;
     struct in_multi * i_inm;
};


extern   struct in_multi* in_next_multi(struct in_multistep step, 
             struct in_multi * inm,  int   idx);
extern   struct in_multi* in_first_multi(struct in_multistep step, 
            struct in_multi * inm,  int   idx);
/*
 * Macro to step through all of the in_multi records, one at a time.
 * The current position is remembered in "step", which the caller must
 * provide.  IN_FIRST_MULTI(), below, must be called to initialize "step"
 * and get the first record.  Both macros return a NULL "inm" when there
 * are no remaining records.
 */
#define IN_NEXT_MULTI(step, inm, idx) \
 /* struct in_multistep  step; */ \
 /* struct in_multi *inm; */ \
{ \
 if (((inm) = (step).i_inm) != NULL) \
  (step).i_inm = (inm)->inm_next; \
 else \
  while (((step).netp != NULL) && idx <= (int)ifNumber) { \
   (inm) = mcnet[if_netnumber((step).netp)]; \
   (step).netp = nets[(u_short)(idx)++]; \
   if ((inm) != NULL) { \
    (step).i_inm = (inm)->inm_next; \
    break; \
   } \
  } \
}

#define IN_FIRST_MULTI(step, inm, idx) \
 /* struct in_multistep step; */ \
 /* struct in_multi *inm; */ \
{ \
 (step).netp = nets[(idx)++]; \
 (step).i_inm = NULL; \
 IN_NEXT_MULTI((step), (inm), (idx)); \
}

void IN_LOOKUP_MULTI(ip_addr, NET, struct in_multi**);


/* base of linked lists for
 * multicast addresses indexed by
 * net index
 */

extern struct in_multi * mcnet[MAXNETS];

#endif   /* IP_MULTICAST */


/*
 * Socket options for use with [gs]etsockopt at the IP level.
 * First word of comment is data type; bool is stored in int.
 */
#define  IP_OPTIONS        1  /* buf/ip_opts; set/get IP options */
#define  IP_HDRINCL        2  /* int; header is included with data */
#define  IP_TOS            3  /* int; IP type of service and preced. */
#define  IP_TTL_OPT        4  /* int; IP time to live */
#define  IP_RECVOPTS       5  /* bool; receive all IP opts w/dgram */
#define  IP_RECVRETOPTS    6  /* bool; receive IP opts for response */
#define  IP_RECVDSTADDR    7  /* bool; receive IP dst addr w/dgram */
#define  IP_RETOPTS        8  /* ip_opts; set/get IP options */
#define  IP_MULTICAST_IF   9  /* u_char; set/get IP multicast i/f  */
#define  IP_MULTICAST_TTL  10 /* u_char; set/get IP multicast ttl */
#define  IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */
#define  IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
#define  IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */

//int   ip2mac(PACKET, ip_addr ipaddr);     /* put IP packet on MAC layer */

#ifdef NPDEBUG
void  ip_dump(PACKET);  /* this needs printf, DEBUG = on */
#endif

int   ip_stats(void * pio);         /* print IP layer stats */

PACKET ip_copypkt(PACKET p);        /* copy packet into new buffer */

/* IP/TCP checksummer; usually in assembly language somewhere... -JB- */
unsigned short cksum(void*, unsigned);


/* Host endian values for IP address class & subnet manipulation */
#define  AMASK    htonl(0x80000000)
#define  AADDR    htonl(0x00000000)
#define  BMASK    htonl(0xC0000000)
#define  BADDR    htonl(0x80000000)
#define  CMASK    htonl(0xE0000000)
#define  CADDR    htonl(0xC0000000)
#define  IPLBA    htonl(0x7F000000) /* IP LoopBack net Address */


/* ethernet & token ring protocol values in local endian: */
#define     ARPTP    ntohs(0x0806)     /* ARP type */
#define     IPTP     ntohs(0x0800)     /* IP type */

#define     TCPTP    0x06     /* TCP type on IP (8 bit, no swap) */


/* structure for converting ip_addr to 4 unsigned char values: */
struct l2b  {
   union {
      unsigned long  iplong;
      unsigned char  ipchar[4];
   }ip;
};

#endif   /* _IPHFILE_H_ */



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -