📄 udp.h
字号:
/*
* FILENAME: udp.h
*
* Copyright 2000 By InterNiche Technologies Inc. All rights reserved
*
* UDP protocol definitions
*
* MODULE: INET
*
*
* PORTABLE: yes
*/
/* Additional Copyrights: */
/* Portions Copyright 1990, 1993 by NetPort Software. */
/* Copyright 1986 by Carnegie Mellon */
/* Copyright 1983 by the Massachusetts Institute of Technology */
#ifndef _UDP_H_
#define _UDP_H_ 1
/* UDP Header structure */
struct udp
{
unshort ud_srcp; /* source port */
unshort ud_dstp; /* dest port */
unshort ud_len; /* length of UDP packet */
unshort ud_cksum; /* UDP checksum */
};
/* The UDP Connection structure */
struct udp_conn
{
struct udp_conn * u_next;
unshort u_lport; /* local port (host byte order) */
unshort u_fport; /* foreign port (host byte order) */
ip_addr u_lhost; /* local host IP address (network byte order) */
ip_addr u_fhost; /* foreign host IP address (network byte order) */
int (*u_rcv)(PACKET, void*); /* incoming packet handler */
void * u_data; /* user 'per-connection' token */
int (*u_durcv)(); /* incoming dest. unreach. handler */
};
/* UDP stats (MIB information), see RFC 1156 */
struct UdpMib
{
u_long udpInDatagrams; /* total delivered Datagrams */
u_long udpNoPorts; /* undelivered datagrams: unused port */
u_long udpInErrors; /* undelivered datagrams: other reasons */
u_long udpOutDatagrams; /* successfully sent datagrams */
};
extern struct UdpMib udp_mib;
typedef struct UdpMib * UDPMIB;
typedef struct udp_conn * UDPCONN;
struct ph /* pseudo header for checksumming */
{
ip_addr ph_src; /* source address */
ip_addr ph_dest; /* dest address */
char ph_zero; /* zero (reserved) */
char ph_prot; /* protocol */
unshort ph_len; /* udp length */
};
#define UDP_PROT 17 /* UDP Internet protocol number */
#define UDPLEN sizeof(struct udp)
#define udp_head(pip) ((struct udp *)ip_data((pip)))
#define udp_data(pup) ((char *)(pup) + sizeof(struct udp))
extern UDPCONN firstudp;
/* Some reserved UDP ports */
#define RIP_PORT 520
#define DNS_PORT 53
#define SNMP_PORT 161
/* function prototypes -JB- */
int udpdemux(PACKET);
int udp_send(unshort /*fport*/, unshort /*lport*/, PACKET);
void udpswap(struct udp *);
unshort udp_socket(void);
PACKET udp_alloc(int, int);
int udp_maxalloc(void);
void udp_free(PACKET);
UDPCONN udp_open(ip_addr, unshort /*fport*/, unshort /*lport*/,
int(*)(PACKET, void * /*data*/) , void * /*data*/);
void udp_close(UDPCONN);
int udp_stats(void * pio);
/* some hardwired protocol callbacks: */
int snmp_upc(PACKET, unshort /*lport*/); /* SNMPv1 receive upcall */
int v3_udp_recv(PACKET, unshort /*lport*/); /* SNMPv3 receive upcall */
int dns_upcall(PACKET pkt, unshort); /* DNS */
int rip_udp_recv(PACKET p, unshort); /* RIP */
#endif /* _UDP_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -