From: Paul B. S. <pa...@us...> - 2001-09-03 18:41:10
|
Update of /cvsroot/linux-atm/linux-atm/src/include In directory usw-pr-cvs1:/tmp/cvs-serv10656/include Added Files: Tag: V2_4_0 atmsap.h atm.h atmd.h Makefile.am stdint.h Log Message: --- NEW FILE: atmsap.h --- /* atmsap.h - ATM Service Access Point addressing definitions */ /* Written 1996-1998 by Werner Almesberger, EPFL LRC/ICA */ #ifndef _ATMSAP_H #define _ATMSAP_H #include <stdint.h> #include <linux/atmsap.h> /* * Selected ISO/IEC TR 9577 Network Layer Protocol Identifiers (NLPID) */ #define NLPID_IEEE802_1_SNAP 0x80 /* IEEE 802.1 SNAP */ /* * Selected Organizationally Unique Identifiers (OUIs) */ #define ATM_FORUM_OUI "\x00\xA0\x3E" /* ATM Forum */ #define EPFL_OUI "\x00\x60\xD7" /* EPF Lausanne, CH */ /* * Selected vendor-specific application identifiers (for B-HLI). Such an * identifier consists of three bytes containing the OUI, followed by four * bytes assigned by the organization owning the OUI. */ #define ANS_HLT_VS_ID ATM_FORUM_OUI "\x00\x00\x00\x01" /* ATM Name System, af-saa-0069.000 */ #define VOD_HLT_VS_ID ATM_FORUM_OUI "\x00\x00\x00\x02" /* VoD, af-saa-0049.001 */ #define AREQUIPA_HLT_VS_ID EPFL_OUI "\x01\x00\x00\x01" /* Arequipa */ #define TTCP_HLT_VS_ID EPFL_OUI "\x01\x00\x00\x03" /* ttcp_atm */ /* Mapping of "well-known" TCP, UDP, etc. port numbers to ATM BHLIs. btd-saa-api-bhli-01.02 */ void atm_tcpip_port_mapping(char *vs_id,uint8_t protocol,uint16_t port); #endif --- NEW FILE: atm.h --- /* atm.h - Functions useful for ATM applications */ /* Written 1995-2000 by Werner Almesberger, EPFL-LRC/ICA */ #ifndef _ATM_H #define _ATM_H #include <stdint.h> #include <sys/socket.h> #include <linux/atm.h> /* * For versions of glibc < 2.1 */ #ifndef AF_ATMPVC #define AF_ATMPVC 8 #endif #ifndef AF_ATMSVC #define AF_ATMSVC 20 #endif #ifndef PF_ATMPVC #define PF_ATMPVC AF_ATMPVC #endif #ifndef PF_ATMSVC #define PF_ATMSVC AF_ATMSVC #endif #ifndef SOL_ATM #define SOL_ATM 264 #endif #ifndef SOL_AAL #define SOL_AAL 265 #endif #define HOSTS_ATM "/etc/hosts.atm" /* text2atm flags */ #define T2A_PVC 1 /* address is PVC */ #define T2A_SVC 2 /* address is SVC */ #define T2A_UNSPEC 4 /* allow unspecified parts in PVC address */ #define T2A_WILDCARD 8 /* allow wildcards in PVC or SVC address */ #define T2A_NNI 16 /* allow NNI VPI range (PVC) */ #define T2A_NAME 32 /* allow name resolution */ #define T2A_REMOTE 64 /* OBSOLETE */ #define T2A_LOCAL 128 /* don't use ANS */ /* atm2text flags */ #define A2T_PRETTY 1 /* add syntactic sugar */ #define A2T_NAME 2 /* attempt name lookup */ #define A2T_REMOTE 4 /* OBSOLETE */ #define A2T_LOCAL 8 /* don't use ANS */ /* atm_equal flags */ #define AXE_WILDCARD 1 /* allow wildcard match */ #define AXE_PRVOPT 2 /* private part of SVC address is optional */ /* text2qos flags */ #define T2Q_DEFAULTS 1 /* structure contains default values */ /* text2sap flags */ #define T2S_NAME 1 /* attempt name lookup */ #define T2S_LOCAL 2 /* we may support NIS or such in the future */ /* sap2text flags */ #define S2T_NAME 1 /* attempt name lookup */ #define S2T_LOCAL 2 /* we may support NIS or such in the future */ /* sap_equal flags */ #define SXE_COMPATIBLE 1 /* check for compatibility instead of identity*/ #define SXE_NEGOTIATION 2 /* allow negotiation; requires SXE_COMPATIBLE; assumes "a" defines the available capabilities */ #define SXE_RESULT 4 /* return selected SAP */ #define MAX_ATM_ADDR_LEN (2*ATM_ESA_LEN+ATM_E164_LEN+5) /* 4 dots, 1 plus */ #define MAX_ATM_NAME_LEN 256 /* wild guess */ #define MAX_ATM_QOS_LEN 116 /* 5+4+2*(3+3*(7+9)+2)+1 */ #define MAX_ATM_SAP_LEN 255 /* BHLI(27)+1+3*BLLI(L2=33,L3=41,+1)+2 */ int text2atm(const char *text,struct sockaddr *addr,int length,int flags); int atm2text(char *buffer,int length,const struct sockaddr *addr,int flags); int atm_equal(const struct sockaddr *a,const struct sockaddr *b,int len, int flags); int sdu2cell(int s,int sizes,const int *sdu_size,int *num_sdu); int text2qos(const char *text,struct atm_qos *qos,int flags); int qos2text(char *buffer,int length,const struct atm_qos *qos,int flags); int qos_equal(const struct atm_qos *a,const struct atm_qos *b); int text2sap(const char *text,struct atm_sap *sap,int flags); int sap2text(char *buffer,int length,const struct atm_sap *sap,int flags); int sap_equal(const struct atm_sap *a,const struct atm_sap *b,int flags,...); int __t2q_get_rate(const char **text,int up); int __atmlib_fetch(const char **pos,...); /* internal use only */ #endif --- NEW FILE: atmd.h --- /* atmd.h - Functions useful for demons (and some other ATM tools) */ /* Written 1995-2000 by Werner Almesberger, EPFL-LRC/ICA */ #ifndef _ATMD_H #define _ATMD_H /*--------------------------- Common definitions ----------------------------*/ #include <stdint.h> #include <stdio.h> #include <sys/types.h> #include <sys/time.h> /* doubly linked list primitives */ #define Q_INSERT_HEAD(r,i) ({ (i)->next = r; (i)->prev = NULL; \ if (r) (r)->prev = i; r = i; }) #define Q_INSERT_AFTER(r,i,a) ({ if (a) { (i)->next = (a)->next; \ (i)->prev = a; if ((a)->next) (a)->next->prev = i; (a)->next = i; } \ else { (i)->next = r; (i)->prev = NULL; if (r) (r)->prev = i; r = i; } }) #define Q_INSERT_BEFORE(r,i,b) ({ if (b) { (i)->next = b; \ (i)->prev = (b)->prev; if ((b)->prev) (b)->prev->next = i; else r = i; \ (b)->prev = i; } else { (i)->next = r; (i)->prev = NULL; \ if (r) (r)->prev = i; r = i; } }) #define Q_REMOVE(r,i) ({ if ((i)->next) (i)->next->prev = (i)->prev; \ if ((i)->prev) (i)->prev->next = (i)->next; else r = (i)->next; }) extern struct timeval now; extern int debug; #define alloc_t(t) ((t *) alloc(sizeof(t))) void *alloc(size_t size); uint32_t read_netl(void *p); /*--------------------------- Diagnostic messages ---------------------------*/ #include <stdarg.h> #define DIAG_DEBUG 3 #define DIAG_INFO 2 #define DIAG_WARN 1 #define DIAG_ERROR 0 #define DIAG_FATAL -1 void set_application(const char *name); void set_logfile(const char *name); FILE *get_logfile(void); void set_verbosity(const char *component,int level); int get_verbosity(const char *component); void vdiag(const char *component,int severity,const char *fmt,va_list ap); void diag(const char *component,int severity,const char *fmt,...); void diag_dump(const char *component,int severity,const char *title, const unsigned char *data,int len); /*------------------------------ Timer support ------------------------------*/ #include <sys/time.h> typedef struct _timer { struct timeval expiration; void (*callback)(void *user); void *user; struct _timer *prev,*next; } TIMER; TIMER *start_timer(long usec,void (*callback)(void *user),void *user); void stop_timer(TIMER *timer); void (*timer_handler(TIMER *timer))(void *user); struct timeval *next_timer(void); void pop_timer(TIMER *timer); void expire_timers(void); /*--------------------------- Unix domain sockets ---------------------------*/ #include <sys/socket.h> #include <sys/un.h> typedef struct { int s; /* socket */ struct sockaddr_un addr; /* reply address */ int size; /* address size */ } UN_CTX; int un_create(const char *path,mode_t mode); /* * Creates a Unix domain DGRAM socket, binds it to the specified path, and * returns the socket descriptor. Returns a negative value on error. */ int un_attach(const char *path); /* * Creates a Unix domain DGRAM socket and connects it to the specified path. * The local side is bound to an ephemeral address. Returns the socket * descriptor on success, a negative value otherwise. */ int un_recv_connect(int s,void *buf,int size); /* * Performs a recv(s,buf,size,0) and connects the socket to the sender's * address. Returns a negative value on error. */ int un_reply(int s,void *buf,int size, int (*handler)(void *buf,int len,void *user),void *user); /* * Receives a message from the socket into the buffer provided by the caller, * invokes handler for processing and optionally sends back a reply. If the * handler returns a negative value or zero, no reply is sent. If the handler * returns a positive value, this is interpreted as the length of the reply to * send. The data is taken from the buffer. If any system call fails, un_reply * returns a negative value. Otherwise, it returns whatever was returned by the * handler function. */ int un_recv(UN_CTX *ctx,int s,void *buf,int size); /* * Receive a message into the specified buffer and store the information needed * to send a reply in ctx. Sets errno and returns a negative value on error. */ int un_send(const UN_CTX *ctx,void *buf,int len); /* * Send a reply to the sender identified by ctx. Sets errno and returns a * negative value on error. */ /* ------------------------- IP address operations ------------------------- */ #include <netinet/in.h> #define T2I_NAME 1 /* do a name lookup */ #define T2I_ERROR 2 /* print error messages */ uint32_t text2ip(const char *text,const char *component,int flags); /* * Converts a text string to an IP address. If resolution fails, text2ip * returns INADDR_NONE. If T2I_ERROR is set, errors messages are printed. If * component is non-NULL, they are logged using diag(). Otherwise, they are * printed on standard error. Note that T2I_NAME uses gethostbyname() which * may attempt resolution via DNS or NIS. */ /* ------------------------ Kernel pointer handles ------------------------- */ #include <atm.h> #define KPRT_PRINT_BUFS 4 /* up to that many buffers are concurrently available */ int kptr_eq(const atm_kptr_t *a,const atm_kptr_t *b); /* * Returns 1 if A and B are equal, 0 otherwise. Note that unused areas of the * handles must be initialized to a system-wide constant pattern, e.g. 0. */ const char *kptr_print(const atm_kptr_t *p); /* * Returns a pointer to a static buffer containing an ASCII representation of * a kernel pointer handle. After KPRT_PRINT_BUFS calls to kptr_print, old * buffers are reused. */ #endif --- NEW FILE: Makefile.am --- include_HEADERS = atm.h atmd.h atmsap.h noinst_HEADERS = stdint.h --- NEW FILE: stdint.h --- /* stdint.h - provides uintXX_t until glibc does */ #ifndef _STDINT_H #include <features.h> #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 #include "/usr/include/stdint.h" #elif __GLIBC__ >= 2 /* Works for i386 and Alpha */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #else #ifndef _LINUX_TYPES_H #include <linux/types.h> #endif #endif #ifndef _STDINT_H #define _STDINT_H #endif #endif |