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

📄 ipport.h_h

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

#define far

/* define preferred data buffer boundary, usually 2 or 4 */
#define ALIGN_TYPE   2  /* 16 bit alignment */

/* define Ethernet header size -- this is usually sizeof(struct ethhdr)
 * or the size in bytes of the Ethernet header (and must be the size
 * in bytes for NicheLite) but may be increased to force alignment of
 * the subsequent data (e.g. IP header, ARP header)
 */
#ifndef MINI_IP
#define ETHHDR_SIZE  (sizeof(struct ethhdr))
#else
#define ETHHDR_SIZE  (14)
#endif

/* convert little/big endian - these should be efficient, 
 * inline code or MACROs
 */
extern u_long lswap(u_long l); /* swap bytes in 32 bit long */
#define htonl(l) lswap(l)
#define ntohl(l) lswap(l)

/* Amazingly, some compilers really need all these u_short casts: */
#define htons(s) ((u_short)((u_short)(s) >> 8) | (u_short)((u_short)(s) << 8))
#define ntohs(s) htons(s)

/* A portable macro to check whether a ptr is within a certain range.
 * In an environment where selectors are important, this macro will
 * be altered to reflect that.
 */
 
#define IN_RANGE(p1, len1, p2) \
   (((p1) <= (p2)) && (((p1) + (len1)) > (p2)))
 
#pragma warning(disable: 4244 4310 4055 4054 4127)   /* stifle idiot warnings */

long atol(const char * txt); /* don't let compiler truncate longs */

char * npalloc(unsigned);  /* alloc & return zeroed out buffer */
void   npfree(void*);      /* not required on embedded systems */

/* define the various IP stack block and buffer allocation routines */
#define  RT_ALLOC(size)   npalloc(size)     /* route block alloc */
#define  RT_FREE(ptr)     npfree(ptr)
#define  NB_ALLOC(size)   npalloc(size)     /* netbuf structure alloc */
#define  NB_FREE(ptr)     npfree(ptr)
#define  BB_ALLOC(size)   npalloc(size)     /* Big packet buffer alloc */
#define  BB_FREE(ptr)     npfree(ptr)
#define  LB_ALLOC(size)   npalloc(size)     /* Little packet buffer alloc */
#define  LB_FREE(ptr)     npfree(ptr)
#define  UC_ALLOC(size)   npalloc(size)     /* UDP connection block alloc */
#define  UC_FREE(ptr)     npfree(ptr)
#define  TK_ALLOC(size)   npalloc(size)     /* task control block */
#define  TK_FREE(ptr)     npfree(ptr)
#define  STK_ALLOC(size)  npalloc(size)     /* task stack */
#define  STK_FREE(ptr)    npfree(ptr)

#ifdef DYNAMIC_IFACES
#define  NET_ALLOC(size)  npalloc(size)     /* struct net */
#define  NET_FREE(ptr)    npfree(ptr)
#define  IFM_ALLOC(size)  npalloc(size)     /* struct IfMib */
#define  IFM_FREE(ptr)    npfree(ptr)
#endif   /* DYNAMIC_IFACES */

#ifdef IP_PMTU
#define  PMTU_ALLOC(size) npalloc(size)     /* path MTU cache */
#define  PMTU_FREE(ptr)   npfree(ptr)
#endif   /* IP_PMTU */

/* NetPort stack generic error codes: generally full success is 0,
 * definite errors are negative numbers, and indeterminate conditions
 * are positive numbers. These may be changed if they conflict with
 * defines in the target system. They apply to the NetPort IP stack,
 * the IPX logic, and the portable SNMP Agent. If you have to change
 * these values, be sure to recompile ALL NetPort sources.
 */

#define SUCCESS          0 /* whatever the call was, it worked */

/* programming errors */
#define ENP_PARAM      -10 /* bad parameter */
#define ENP_LOGIC      -11 /* sequence of events that shouldn't happen */

/* system errors */
#define ENP_NOMEM      -20 /* malloc or calloc failed */
#define ENP_NOBUFFER   -21 /* ran out of free packets */
#define ENP_RESOURCE   -22 /* ran out of other queue-able resource */
#define SEND_DROPPED ENP_RESOURCE /* full queue or similar lack of resource */
#define ENP_BAD_STATE  -23 /* TCP layer error */
#define ENP_TIMEOUT    -24 /* TCP layer error */

#define ENP_NOFILE     -25 /* expected file was missing */
#define ENP_FILEIO     -26 /* file IO error */

/* net errors */
#define ENP_SENDERR    -30 /* send to net failed at low layer */
#define ENP_NOARPREP   -31 /* no ARP for a given host */
#define ENP_BAD_HEADER -32 /* bad header at upper layer (for upcalls) */
#define ENP_NO_ROUTE   -33 /* can't find a reasonable next IP hop */
#define ENP_NO_IFACE   -34 /* can't find a reasonable interface */
#define ENP_HARDWARE   -35 /* detected hardware failure */

/* conditions that are not really fatal OR success: */
#define ENP_SEND_PENDING 1 /* packet queued pending an ARP reply */
#define ENP_NOT_MINE     2 /* packet was not of interest (upcall reply) */

/* ARP holding packet while awaiting a response from fhost */
#define ARP_WAITING   ENP_SEND_PENDING

#define dtrap(); _asm { int 3 } /* Intel processor debugger embedded break point */

#define _NPPP            4 /* override ppp_port.h setting */

#define NO_CC_PACKING    1 /* CPU/Compiler combo can't pack structs */

/* ...thus the structs we'd normally define packed are normal */
#define START_PACKED_STRUCT(sname) struct sname {
#define END_PACKED_STRUCT(sname)  };

/* stack supports two methods of protecting its queues and data
 * structs from destructive re-entries by ISRs, multiple tasks, etc. One
 * is to lock a "resource ID" which makes code wait when trying to
 * access shared resource, the other is a CRITICAL SECTION frame. You
 * should use one or the other, not both. See manual for details.
 */


#ifdef INICHE_TASKS
/* 
 * Use the resource locking routines, and map LOCK/UNLOCK_NET_RESOURCE 
 * to them with macros.  Similar to the above case, we use macros to 
 * provide null definitions for ENTER/EXIT_CRITICAL_SECTION.
 */
extern void LOCK_NET_RESOURCE(int res);
extern void UNLOCK_NET_RESOURCE(int res);

/* 
 * also define macros for these so that tk_thrdx.h doesn't try to use its
 * own prototypes 
 */
#define LOCK_NET_RESOURCE(x)    LOCK_NET_RESOURCE(x)
#define UNLOCK_NET_RESOURCE(x)  UNLOCK_NET_RESOURCE(x)

#define ENTER_CRIT_SECTION(p); 
#define EXIT_CRIT_SECTION(p);
#else /* SUPERLOOP */
/* if we're using CRIT_SECTION, undefine RESOURCE_LOCK macros */
#define LOCK_NET_RESOURCE(res)
#define UNLOCK_NET_RESOURCE(res)

extern void ENTER_CRIT_SECTION(void *p);
extern void EXIT_CRIT_SECTION(void *p);
#endif /* INICHE_TASKS */

/* #define PID port resource IDs as indexes into net-resources[] array */
#define NET_RESID   0    /* stack code resource lock */
#define RXQ_RESID   1    /* received packet queue resource lock */
#define FREEQ_RESID 2    /* free packet queue resource lock */

#ifdef VFS_FILES
#define vfs_lock()
#define vfs_unlock()
#endif

#define OSPORT_H	"../win32/osport.h"

#ifdef INICHE_TASKS    /* InterNiche multitasking system */
#include "task.h"      /* NicheTask definitions */


/* RETURN_XXX from task routines: */
void  w32_tk_return(int error);

/* the "return(parm)" is only in this to suppress Compiler warnings */
#define TK_RETURN_OK()     { w32_tk_return(0); return(parm); }  
#define TK_RETURN_ERROR()  w32_tk_return(-1)

#include "tk_ntask.h"	/* Nichetask TK_MACRO definitions */

#define tcp_wakeup(ev)  tk_ev_wake(ev)

#define BLOCKING_APPS 1  /* use select() in FTP, WebPort, Telnet */

#else
/* define SUPERLOOP specific things here */

/* Port routine/macro to wake packet demuxer task after receives have
 * been placed in rcvdq by drivers. Define to NULL for Superloop DOS demo
 */
#define  SignalPktDemux();      

extern void tk_yield(void); /* superloop routine */

#define pre_task_setup()   NULL
#define post_task_setup()  NULL

#endif /* INICHE_TASKS */

/* NetPort printf */
#ifndef _IN_TTYIO_
void dprintf(char * format, ...);
#endif

/* net stats printf with redirectable device: */
extern int ns_printf (void * pio, char * format, ...);

/* Send startup errors to the right place */
#define initmsg dprintf

#define COMMSIZE   64   /* max bytes in community string */

#define INETNET     0   /* index into nets[] for internet iface */
#define LOCALNET    1   /* index into nets[] for local net iface */


void dputchar(int chr);	/* Windows port putchar substitute */

#ifdef putchar
#undef putchar
#endif

#define putchar(_c) dputchar(_c)

#ifdef NATIVE_PRINTF
#define dprintf printf
#else
/* map printfs into device IO system */
#define printf dprintf
#endif


#define PC_HARDWARE   1  /* target hardware is PC-like */

int prep_ppp(int);               /* in ..\ppp\sys_np.c */
int prep_ifaces(int firstIface); /* set up interfaces */

/* definitions for the BSD TCP code */
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN    4321
#define BYTE_ORDER    LITTLE_ENDIAN

/* some maximum packet buffer numbers */
#define MAXBIGPKTS    60
#define MAXLILPKTS    60
#define MAXPACKETS    (MAXLILPKTS+MAXBIGPKTS)

#define MAX_NVSTRING   128       /* MAX length of an nvparms string */

/* macros to get rid of "unused argument" warnings. With compilers that
 * can suppress these warnings, define this to nothing.
 */

#define USE_ARG(x) {x = x;}
#define USE_VOID(x) { x = x;}

/* for Microsoft/Intel, define structure pack pragmas away */
#define START_INPACK(name)
#define END_INPACK(name)

#ifdef MINI_IP
/* pull in some NicheLite definitions */
#include "minip.h"

#endif /* MINI_IP */

#endif /* _IPPORT_H_ */

/* end of file ipport.h */


⌨️ 快捷键说明

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