/[dynamips]/trunk/atm.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/atm.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Sat Oct 6 16:45:40 2007 UTC (11 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 3667 byte(s)
make working copy

1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4 *
5 * ATM definitions.
6 */
7
8 #ifndef __ATM_H__
9 #define __ATM_H__
10
11 #include <pthread.h>
12
13 #include "utils.h"
14 #include "mempool.h"
15 #include "net_io.h"
16
17 /* ATM payload size */
18 #define ATM_HDR_SIZE 5
19 #define ATM_PAYLOAD_SIZE 48
20 #define ATM_CELL_SIZE (ATM_HDR_SIZE + ATM_PAYLOAD_SIZE)
21 #define ATM_AAL5_TRAILER_SIZE 8
22 #define ATM_AAL5_TRAILER_POS (ATM_CELL_SIZE - ATM_AAL5_TRAILER_SIZE)
23
24 /* ATM header structure */
25 #define ATM_HDR_VPI_MASK 0xFFF00000
26 #define ATM_HDR_VPI_SHIFT 20
27 #define ATM_HDR_VCI_MASK 0x000FFFF0
28 #define ATM_HDR_VCI_SHIFT 4
29 #define ATM_HDR_PTI_MASK 0x0000000E
30 #define ATM_HDR_PTI_SHIFT 1
31
32 /* PTI bits */
33 #define ATM_PTI_EOP 0x00000002 /* End of packet */
34 #define ATM_PTI_CONGESTION 0x00000004 /* Congestion detected */
35 #define ATM_PTI_NETWORK 0x00000008 /* Network traffic */
36
37 /* VP-level switch table */
38 typedef struct atmsw_vp_conn atmsw_vp_conn_t;
39 struct atmsw_vp_conn {
40 atmsw_vp_conn_t *next;
41 netio_desc_t *input,*output;
42 u_int vpi_in,vpi_out;
43 m_uint64_t cell_cnt;
44 };
45
46 /* VC-level switch table */
47 typedef struct atmsw_vc_conn atmsw_vc_conn_t;
48 struct atmsw_vc_conn {
49 atmsw_vc_conn_t *next;
50 netio_desc_t *input,*output;
51 u_int vpi_in,vci_in;
52 u_int vpi_out,vci_out;
53 m_uint64_t cell_cnt;
54 };
55
56 /* Virtual ATM switch table */
57 #define ATMSW_NIO_MAX 32
58 #define ATMSW_VP_HASH_SIZE 256
59 #define ATMSW_VC_HASH_SIZE 1024
60
61 typedef struct atmsw_table atmsw_table_t;
62 struct atmsw_table {
63 char *name;
64 pthread_mutex_t lock;
65 mempool_t mp;
66 m_uint64_t cell_drop;
67 atmsw_vp_conn_t *vp_table[ATMSW_VP_HASH_SIZE];
68 atmsw_vc_conn_t *vc_table[ATMSW_VC_HASH_SIZE];
69 };
70
71 #define ATMSW_LOCK(t) pthread_mutex_lock(&(t)->lock)
72 #define ATMSW_UNLOCK(t) pthread_mutex_unlock(&(t)->lock)
73
74 /* Compute HEC field for ATM header */
75 m_uint8_t atm_compute_hec(m_uint8_t *cell_header);
76
77 /* Insert HEC field into an ATM header */
78 void atm_insert_hec(m_uint8_t *cell_header);
79
80 /* Update the CRC on the data block one byte at a time */
81 m_uint32_t atm_update_crc(m_uint32_t crc_accum,m_uint8_t *ptr,int len);
82
83 /* Initialize ATM code (for HEC checksums) */
84 void atm_init(void);
85
86 /* Acquire a reference to an ATM switch (increment reference count) */
87 atmsw_table_t *atmsw_acquire(char *name);
88
89 /* Release an ATM switch (decrement reference count) */
90 int atmsw_release(char *name);
91
92 /* Create a virtual switch table */
93 atmsw_table_t *atmsw_create_table(char *name);
94
95 /* Create a VP switch connection */
96 int atmsw_create_vpc(atmsw_table_t *t,char *nio_input,u_int vpi_in,
97 char *nio_output,u_int vpi_out);
98
99 /* Delete a VP switch connection */
100 int atmsw_delete_vpc(atmsw_table_t *t,char *nio_input,u_int vpi_in,
101 char *nio_output,u_int vpi_out);
102
103 /* Create a VC switch connection */
104 int atmsw_create_vcc(atmsw_table_t *t,
105 char *input,u_int vpi_in,u_int vci_in,
106 char *output,u_int vpi_out,u_int vci_out);
107
108 /* Delete a VC switch connection */
109 int atmsw_delete_vcc(atmsw_table_t *t,
110 char *nio_input,u_int vpi_in,u_int vci_in,
111 char *nio_output,u_int vpi_out,u_int vci_out);
112
113 /* Save the configuration of an ATM switch */
114 void atmsw_save_config(atmsw_table_t *t,FILE *fd);
115
116 /* Save configurations of all ATM switches */
117 void atmsw_save_config_all(FILE *fd);
118
119 /* Delete an ATM switch */
120 int atmsw_delete(char *name);
121
122 /* Delete all ATM switches */
123 int atmsw_delete_all(void);
124
125 /* Start a virtual ATM switch */
126 int atmsw_start(char *filename);
127
128 #endif

  ViewVC Help
Powered by ViewVC 1.1.26