ipprobe-mt.h

Go to the documentation of this file.
00001 /*
00002  * $Id: ipprobe-mt.h 366303 2010-03-05 13:14:01Z taoliu $
00003  *
00004  * This code is provided as is by Juniper Networks SDK Developer Support.
00005  * It is provided with no warranties or guarantees, and Juniper Networks
00006  * will not provide support or maintenance of this code in any fashion.
00007  * The code is provided only to help a developer better understand how
00008  * the SDK can be used.
00009  *
00010  * Copyright (c) 2009, Juniper Networks, Inc.
00011  * All rights reserved.
00012  */
00013 
00022 #ifndef __IPPROBE_MT_H__
00023 #define __IPPROBE_MT_H__
00024 
00025 #define IP_HEADER_LEN             20    
00027 #define PROBE_NAME_LEN            64    
00028 #define PROBE_MNGR_PORT_DEFAULT   6068  
00029 #define RSPD_MNGR_PORT_DEFAULT    6069  
00030 #define CONN_RETRY_DEFAULT        32    
00032 #define PROBE_MGMT_MSG_REG        1     
00033 #define PROBE_MGMT_MSG_ADD_DST    2     
00035 #define RSPD_MGMT_MSG_REQ         1     
00036 #define RSPD_MGMT_MSG_ACK         2     
00038 #define PROBE_PKT_REQ             1     
00039 #define PROBE_PKT_REPLY           2     
00040 #define PROBE_PKT_REQ_LAST        3     
00042 #define PROBE_PKT_SIZE_MIN        64    
00043 #define PROBE_PKT_SIZE_MAX        1024  
00044 #define PROBE_PKT_COUNT_MAX       200   
00046 #define PROBE_PKT_TTL_DEFAULT     128   
00049 #define PROBE_TRACE(_msg_type, _fmt, ...) \
00050     junos_trace((_msg_type), _fmt, ##__VA_ARGS__)
00051 
00053 #define PROBE_LOG(_level, _fmt, ...)   \
00054         ERRMSG(IPPROBE-MT, (_level), _fmt, ##__VA_ARGS__)
00055 
00057 typedef struct probe_params_s {
00058     LIST_ENTRY(probe_params_s)  entry;                
00059     char                        name[PROBE_NAME_LEN]; 
00060     uint8_t                     proto;                
00061     uint8_t                     tos;                  
00062     uint16_t                    src_port;             
00063     uint16_t                    dst_port;             
00064     uint16_t                    pkt_size;             
00065     uint16_t                    pkt_count;            
00066     uint16_t                    pkt_interval;         
00067 } probe_params_t;
00068 
00070 typedef struct {
00071     u_short               id;              
00072     u_short               type;            
00073     u_short               seq;             
00074     struct timeval        tx_time;         
00075     struct timeval        target_rx_time;  
00076     struct timeval        target_tx_time;  
00077     struct timeval        rx_time;         
00078     char                  pad[0];          
00079 } probe_pkt_data_t;
00080 
00082 typedef struct {
00083     struct ip             header;          
00084     union {
00085         struct icmphdr    icmp;            
00086         struct udphdr     udp;             
00087     };
00088     probe_pkt_data_t      data;            
00089 } probe_pkt_t;
00090 
00092 typedef struct probe_s {
00093     LIST_ENTRY(probe_s)   entry;           
00094     pthread_t             tid;             
00095     evContext             ev_ctx;          
00097     pconn_client_t        *client_hdl;     
00099     pconn_session_t       *ssn;            
00101     probe_params_t        params;          
00102     int                   rspd_socket;     
00103     evFileID              rspd_read_fid;   
00105     in_addr_t             dst_first;       
00106     patroot               dst_pat;         
00108     int                   dst_count;       
00109     int                   tx_socket;       
00111     evTimerID             tx_tid;          
00113     int                   tx_count;        
00114     uint8_t               *tx_buf;         
00115     int                   rx_socket;       
00117     evFileID              rx_fid;          
00118 } probe_t;
00119 
00121 typedef struct {
00122     float             delay_sd;        
00123     float             delay_ds;        
00124     float             rrt;             
00125     float             jitter_sd;       
00126     float             jitter_ds;       
00127     float             jitter_rr;       
00128 } pkt_stats_t;
00129 
00131 typedef struct {
00132     float             delay_sd_average;   
00133     float             delay_ds_average;   
00134     float             delay_rr_average;   
00135     float             delay_sd_max;       
00136     float             delay_ds_max;       
00137     float             delay_rr_max;       
00138     float             jitter_sd_average;  
00139     float             jitter_ds_average;  
00140     float             jitter_rr_average;  
00141     float             jitter_sd_max;      
00142     float             jitter_ds_max;      
00143     float             jitter_rr_max;      
00144 } probe_result_t;
00145 
00147 typedef struct probe_rx_buf_s {
00148     LIST_ENTRY(probe_rx_buf_s)  entry;       
00149     uint8_t                     pkt[0];      
00150 } probe_rx_buf_t;
00151 
00153 typedef enum {
00154     PROBE_DST_STATE_INIT,                  
00155     PROBE_DST_STATE_RUN,                   
00156     PROBE_DST_STATE_DONE                   
00157 } probe_dst_state_t;
00158 
00160 typedef struct {
00161     patnode               node;            
00162     in_addr_t             dst_addr;        
00163     in_addr_t             local_addr;      
00164     probe_dst_state_t     state;           
00165     probe_result_t        result;          
00166     int                   rx_count;        
00167     LIST_HEAD(, probe_rx_buf_s)  rx_buf_list;  
00168     probe_rx_buf_t        *rx_buf_last;    
00169 } probe_dst_t;
00170 
00172 typedef struct {
00173     uint16_t              type;            
00174     uint16_t              timeout;         
00175     uint16_t              port;            
00176     uint8_t               proto;           
00177 } rspd_mgmt_pkt_t;
00178 
00180 typedef struct {
00181     evContext             ev_ctx;          
00182     pconn_server_t        *hdl;            
00183     uint16_t              port;            
00184 } probe_mngr_t;
00185 
00187 typedef struct {
00188     evContext             ev_ctx;          
00189     int                   socket;          
00190     evFileID              read_fid;        
00191     uint16_t              port;            
00192     rspd_mgmt_pkt_t       rx_pkt;          
00193 } rspd_mngr_t;
00194 
00196 typedef struct rspd_s {
00197     LIST_ENTRY(rspd_s)    entry;           
00198     evContext             ev_ctx;          
00199     int                   socket;          
00200     evFileID              read_fid;        
00201     uint8_t               proto;           
00202     uint16_t              port;            
00203     int                   usage;           
00204     int                   timeout;         
00205     uint8_t               rx_buf[PROBE_PKT_SIZE_MAX];  
00206 } rspd_t;
00207 
00208 int probe_mngr_init(evContext lev_ctx);
00209 int probe_mngr_open(uint16_t port);
00210 int probe_mngr_probe_start(char *name, in_addr_t dst_addr);
00211 int probe_mngr_probe_stop(char *name);
00212 int probe_mngr_probe_clear(char *name);
00213 patroot *probe_mngr_probe_result_get(char *name);
00214 void probe_mngr_close(void);
00215 
00216 int rspd_mngr_init(evContext lev_ctx);
00217 int rspd_mngr_open(uint16_t port);
00218 void rspd_mngr_close(void);
00219 
00220 int config_read(int check);
00221 probe_params_t *probe_params_get(char *name);
00222 
00223 void *probe_thrd_entry(probe_t *probe);
00224 
00225 #endif
00226 

2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:27:00 2010 for SDK Your Net Corporation IP Probe MT: ipprobe-mt 1.0 by Doxygen 1.5.1