home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / detk45he.zip / rsvprapi.h < prev    next >
C/C++ Source or Header  |  1999-05-11  |  17KB  |  468 lines

  1. /* Licensed Materials - Property of IBM                           */
  2. /* IBM TCP/IP for OS/2                                            */
  3. /* (c) Copyright IBM Corp. 1996, 1997.  All rights reserved.      */
  4. /*                                                                */
  5. /* US Government Users Restricted Rights - Use, duplication or    */
  6. /* disclosure restricted by GSA ADP Schedule Contract with IBM    */
  7. /* Corp.                                                          */
  8. /*                                                                */
  9. /* DISCLAIMER OF WARRANTIES.  The following [enclosed] code is    */
  10. /* sample code created by IBM Corporation.  This sample code is   */
  11. /* not part of any standard or IBM product and is provided to you */
  12. /* solely for the purpose of assisting you in the development of  */
  13. /* your applications.  The code is provided "AS IS", without      */
  14. /* warranty of any kind.  IBM shall not be liable for any damages */
  15. /* arising out of your use of the sample code, even if they have  */
  16. /* been advised of the possibility of such damages.               */
  17.  
  18. #ifndef H_RSVP_RAPI
  19. #define H_RSVP_RAPI
  20.  
  21. #ifdef TCPV40HDRS
  22. #error error: rsvprapi.h is for TCP/IP toolkit 5.0 or later releases only
  23. #else
  24. /* on IBM compilers, automatically pull in the TCP/IP library */
  25. #if defined(__IBMC__) && !defined(TCP_NODEFLIB) && !defined(KERNEL)
  26. #pragma library("librsvp.lib")
  27. #endif
  28.  
  29. #include <sys\cdefs.h>
  30. #include <types.h>
  31.  
  32. #include <sys/socket.h> /* for sockaddr */
  33. #include <netinet/in.h>  /* for sockaddr_in */
  34.  
  35. #pragma pack(1)
  36.  
  37. typedef float   float32_t;
  38. typedef u_int32_t rbool_t;
  39.  
  40. /*****************************************************************************/
  41.  
  42. /*
  43.  *   Filterspec Formats
  44.  */
  45.  
  46. typedef enum {
  47.         RAPI_FILTER_NONE      = 0,    /* Empty filter */
  48.         RAPI_FILTERFORM_1     = 1,    /* Complex: sockaddr + (mask, value) */
  49.         RAPI_FILTERFORM_BASE  = 2,    /* Simple v4: Only sockaddr */
  50.         RAPI_FILTERFORM_BASE6 = 3     /* Simple v6: Only sockaddr */
  51. } rapi_filterform_t;
  52.  
  53. #define RAPI_MAXFILTER_T1       48
  54.  
  55. typedef struct {
  56.         struct sockaddr sender;    /* or use another defined struct */
  57.         u_int32_t       len;
  58.         u_char          v[RAPI_MAXFILTER_T1];
  59.         u_char          m[RAPI_MAXFILTER_T1];
  60. } rapi_filter_t1_t;
  61.  
  62. typedef struct {
  63.         struct sockaddr_in sender;
  64. } rapi_filter_base_t;
  65.  
  66. #ifdef INET6
  67. typedef struct {
  68.         struct sockaddr_in6 sender;
  69. } rapi_filter_base6_t;
  70. #endif
  71.  
  72. /*
  73.  *      RAPI Filterspec
  74.  */
  75. typedef struct {
  76.         /* len and form are a rapi_hdr_t object header */
  77.         u_int32_t               len;    /* length of filter, in bytes */
  78.         rapi_filterform_t       form;   /* filter type */
  79.         union {
  80.             rapi_filter_t1_t    t1;
  81.             rapi_filter_base_t  base;
  82. #ifdef INET6
  83.             rapi_filter_base6_t base6;
  84. #endif
  85.         }           filter;             /* variable length */
  86. } rapi_filter_t;
  87.  
  88.  
  89. /*****************************************************************************/
  90.  
  91. /*
  92.  *      Int-serv Flowspec/Tspec
  93.  */
  94.  
  95. #define TB_RATE_MAX             40e12      /* Bytes/sec */
  96. #define TB_RATE_MIN             1          /* Bytes/sec */
  97. #define TB_DEPTH_MAX            250e9      /* Bytes */
  98. #define TB_DEPTH_MIN            1          /* Bytes */
  99. #define TB_PEAK_MAX             0x7f800000 /* +ve infinity */
  100.  
  101. typedef struct {
  102.         float32_t  IS_Tspec_r;   /* Token bucket rate (IP packet bytes/sec) */
  103.         float32_t  IS_Tspec_b;   /* Token bucket depth (bytes) */
  104.         float32_t  IS_Tspec_p;   /* Peak data rate (IP packet bytes/sec) */
  105.         u_int32_t  IS_Tspec_m;   /* Min Policed Unit (bytes) */
  106.         u_int32_t  IS_Tspec_M;   /* Max packet size (bytes) */
  107. }   IS_Tspec_t;
  108.  
  109.  
  110. typedef struct {
  111.         float32_t  Guar_Rspec_R; /* Guaranteed Rate (IP packet bytes/sec) */
  112.         u_int32_t  Guar_Rspec_S; /* Slack term (microseconds) */
  113. }   Guar_Rspec_t;
  114.  
  115.  
  116. typedef struct {
  117.         IS_Tspec_t      CL_Tspec;
  118. }   CL_flowspec_t;
  119.  
  120. typedef struct {
  121.         IS_Tspec_t      Guar_Tspec;
  122.         Guar_Rspec_t    Guar_Rspec;
  123. }   Guar_flowspec_t;
  124.  
  125.  
  126. /*
  127.  *      RAPI flowspec/Tspec formats
  128.  */
  129.  
  130. typedef enum {
  131.         RAPI_FORMAT_NONE       = 0,     /* empty flowspec/tspec        */
  132.         RAPI_FORMAT_IS_CL      = 1,     /* Int-serv Controlled Load    */
  133.         RAPI_FORMAT_IS_GUAR    = 2,     /* Int-serv Guaranteed         */
  134.         RAPI_FORMAT_IS_GEN     = 3      /* Int-serv generic            */
  135. } rapi_format_t;
  136.  
  137. /*
  138.  *      RAPI Flowspec
  139.  */
  140.  
  141. typedef struct {
  142.         /* len and form are a rapi_hdr_t object header */
  143.         u_int32_t       len;
  144.         rapi_format_t   form;
  145.         union {
  146.                 CL_flowspec_t    IS_CL;     /* Int-serv Controlled Load   */
  147.                 Guar_flowspec_t  IS_Guar;   /* Int-serv Guaranteed format */
  148.         }               specbody_u;
  149. }   rapi_flowspec_t;
  150.  
  151. #define cl_tspec_r     specbody_u.IS_CL.CL_Tspec.IS_Tspec_r
  152. #define cl_tspec_b     specbody_u.IS_CL.CL_Tspec.IS_Tspec_b
  153. #define cl_tspec_p     specbody_u.IS_CL.CL_Tspec.IS_Tspec_p
  154. #define cl_tspec_m     specbody_u.IS_CL.CL_Tspec.IS_Tspec_m
  155. #define cl_tspec_M     specbody_u.IS_CL.CL_Tspec.IS_Tspec_M
  156.  
  157. #define guar_tspec_r   specbody_u.IS_Guar.Guar_Tspec.IS_Tspec_r
  158. #define guar_tspec_b   specbody_u.IS_Guar.Guar_Tspec.IS_Tspec_b
  159. #define guar_tspec_p   specbody_u.IS_Guar.Guar_Tspec.IS_Tspec_p
  160. #define guar_tspec_m   specbody_u.IS_Guar.Guar_Tspec.IS_Tspec_m
  161. #define guar_tspec_M   specbody_u.IS_Guar.Guar_Tspec.IS_Tspec_M
  162. #define guar_rspec_R   specbody_u.IS_Guar.Guar_Rspec.Guar_Rspec_R
  163. #define guar_rspec_S   specbody_u.IS_Guar.Guar_Rspec.Guar_Rspec_S
  164.  
  165. /*
  166.  *      RAPI Tspec
  167.  */
  168.  
  169. typedef struct {
  170.         /* len and form are a rapi_hdr_t object header */
  171.         u_int32_t       len;
  172.         rapi_format_t   form;
  173.         union {
  174.                 IS_Tspec_t       IS_Tspec;        /* Int-serv (generic) */
  175.         }               specbody_u;
  176. }   rapi_tspec_t;
  177.  
  178. #define tspec_r   specbody_u.IS_Tspec.IS_Tspec_r
  179. #define tspec_b   specbody_u.IS_Tspec.IS_Tspec_b
  180. #define tspec_p   specbody_u.IS_Tspec.IS_Tspec_p
  181. #define tspec_m   specbody_u.IS_Tspec.IS_Tspec_m
  182. #define tspec_M   specbody_u.IS_Tspec.IS_Tspec_M
  183.  
  184.  
  185. /*****************************************************************************/
  186.  
  187. /*
  188.  *   Adspec Formats
  189.  */
  190.  
  191. typedef struct {
  192.         rbool_t         servBreak;        /* break in service */
  193.         u_int16_t       ISHops;           /* num Int-serv aware hops */
  194.         float32_t       pathBW;           /* min path band width (bytes/sec) */
  195.         u_int32_t       pathLatency;      /* min path latency (microseconds) */
  196.         u_int16_t       composedMTU;      /* composed path MTU */
  197. } Gen_adspec_t;
  198.  
  199. typedef struct {
  200.         rbool_t         servBreak;        /* break in service */
  201.         u_int16_t       ISHops;           /* num Int-serv aware hops */
  202.         float32_t       pathBW;           /* min path band width (bytes/sec) */
  203.         u_int32_t       pathLatency;      /* min path latency (microseconds) */
  204.         u_int16_t       composedMTU;      /* composed path MTU */
  205.         u_int32_t       Ctot;             /* total rate dep. err (bytes) */
  206.         u_int32_t       Dtot;             /* total rate indep. err (microseconds) */
  207.         u_int32_t       Csum;             /* reshaped rate dep. err (bytes) */
  208.         u_int32_t       Dsum;             /* reshaped rate indep. err (microseconds) */
  209. } Guar_adspec_t;
  210.  
  211. typedef struct {
  212.         rbool_t         servBreak;        /* break in service */
  213.         u_int16_t       ISHops;           /* num Int-serv aware hops */
  214.         float32_t       pathBW;           /* min path band width (bytes/sec) */
  215.         u_int32_t       pathLatency;      /* min path latency (microseconds) */
  216.         u_int16_t       composedMTU;      /* composed path MTU */
  217. } CL_adspec_t;
  218.  
  219. typedef struct {
  220.         Gen_adspec_t    Gen_Adspec;
  221.         rbool_t         CL_present;
  222.         CL_adspec_t     CL_Adspec;
  223.         rbool_t         Guar_present;
  224.         Guar_adspec_t   Guar_Adspec;
  225. } IS_adspec_t;
  226.  
  227.  
  228. /*
  229.  *      RAPI Adspec formats
  230.  */
  231.  
  232. typedef enum {
  233.         RAPI_ADSPEC_NONE     = 0,     /* empty adspec */
  234.         RAPI_ADSPEC_IS       = 1      /* Int-serv */
  235. } rapi_adspec_form_t;
  236.  
  237. /*
  238.  *      RAPI Adspec
  239.  */
  240.  
  241. typedef struct {
  242.         /* len and form are a rapi_hdr_t object header */
  243.         u_int32_t            len;
  244.         rapi_adspec_form_t   form;
  245.         union {
  246.                 IS_adspec_t       IS_Adspec;       /* Int-serv */
  247.         }               specbody_u;
  248. }   rapi_adspec_t;
  249.  
  250. /*****************************************************************************/
  251.  
  252. /*
  253.  *    Policy Formats
  254.  */
  255.  
  256. typedef struct {
  257.     char        name[1];
  258.  
  259. } rapi_policy_name_string_t;
  260.  
  261. typedef enum {
  262.     RAPI_POLICY_TYPE_NAMESTRING   =  1
  263. } rapi_policy_form_t;
  264.  
  265. typedef enum {
  266.     RAPI_POLICYF_INTEGRITY        =  0x00000001,
  267.     RAPI_POLICYF_GLOBAL           =  0x00000002,
  268.     RAPI_POLICYF_RESP             =  0x00000004
  269. } rapi_policy_flags_t;
  270.  
  271.  
  272. /*
  273.  *    RAPI Policy
  274.  */
  275.  
  276. typedef struct {
  277.     /* len and form are a rapi_hdr_t object header */
  278.     u_int32_t               len;            /* actual length in bytes */
  279.     rapi_policy_form_t      form;           /* policy data format */
  280.     rapi_policy_flags_t     flags;
  281.     union {
  282.         rapi_policy_name_string_t    namestring;
  283.  
  284.     } pol_u;
  285.  
  286. } rapi_policy_t;
  287.  
  288.  
  289. /*****************************************************************************/
  290.  
  291. /*
  292.  *    RAPI Object Header
  293.  */
  294.  
  295. typedef struct {
  296.     u_int32_t                len;        /* actual length in bytes     */
  297.     int                      form;       /* object format              */
  298. #define RAPI_EMPTY_OTYPE     0           /* Format = 0 => empty object */
  299.  
  300. } rapi_hdr_t;
  301.  
  302.  
  303. /*****************************************************************************/
  304.  
  305. /*
  306.  *      Reservation style ids
  307.  */
  308. typedef enum {
  309.         RAPI_RSTYLE_WILDCARD = 1,       /* STYLE_ID_WF */
  310.         RAPI_RSTYLE_FIXED = 2,          /* STYLE_ID_FF */
  311.         RAPI_RSTYLE_SE = 3              /* STYLE_ID_SE */
  312. } rapi_styleid_t;
  313.  
  314. /*
  315.  *      Reservation style extension
  316.  *
  317.  *      This structure is currently undefined; in the future, it will allow
  318.  *      passing style-specific parameters for possible new styles.
  319.  */
  320. typedef void rapi_stylex_t;
  321.  
  322. /*
  323.  *      Registration flags
  324.  */
  325. #define RAPI_REQ_CONFIRM        0x20    /* Request confirmation */
  326.  
  327. /*****************************************************************************/
  328.  
  329. /*
  330.  *   RAPI client handle
  331.  */
  332.  
  333. typedef unsigned int rapi_sid_t;
  334. #define NULL_SID        0       /* Error return from rapi_session */
  335.  
  336.  
  337. /*****************************************************************************/
  338.  
  339. /*
  340.  *   RAPI User callback function
  341.  */
  342.  
  343. typedef enum {
  344.         RAPI_PATH_EVENT   = 1,
  345.         RAPI_RESV_EVENT   = 2,
  346.         RAPI_PATH_ERROR   = 3,
  347.         RAPI_RESV_ERROR   = 4,
  348.         RAPI_RESV_CONFIRM = 5,
  349. } rapi_eventinfo_t;
  350.  
  351.  
  352. typedef int ((* _System rapi_event_rtn_t)  __TCPPROTO((
  353.         rapi_sid_t,              /* Which sid generated event      */
  354.         rapi_eventinfo_t,        /* Event type                     */
  355.         rapi_styleid_t,          /* Style ID                       */
  356.         int,                     /* Error code                     */
  357.         int,                     /* Error value                    */
  358.         struct sockaddr *,       /* Error node address             */
  359.         u_char,                  /* Error flags                    */
  360.         int,                     /* Number of filter specs/sender  */
  361.                                  /*      templates in array        */
  362.         rapi_filter_t *,         /* Filter spec/sender templ array */
  363.         int,                     /* Number of flowspecs/Tspecs     */
  364.         rapi_flowspec_t *,       /* Flowspec/Tspec array           */
  365.         int,                     /* Number of adspecs              */
  366.         rapi_adspec_t *,         /* Adspec array                   */
  367.         void *                   /* Client supplied arg            */
  368. )));
  369. /* values for error flags above */
  370. #define RAPI_ERRF_InPlace  0x01  /*   Left resv in place        */
  371. #define RAPI_ERRF_NotGuilty 0x02 /*   This rcvr not guilty      */
  372.  
  373.  
  374. /*****************************************************************************/
  375.  
  376. /*
  377.  *      RAPI External Functions
  378.  */
  379. rapi_sid_t _System rapi_session __TCPPROTO((
  380.         struct sockaddr *,      /* Session: (Dst addr, port), net order */
  381.         int,                    /* Protocol id                          */
  382.         int,                    /* Flags - not defined                  */
  383.         rapi_event_rtn_t,       /* Address of callback rtn - optional   */
  384.         void *,                 /* App argument to callback - optional  */
  385.         int *                   /* error return code                    */
  386. ));
  387.  
  388. int _System rapi_sender __TCPPROTO((
  389.         rapi_sid_t,             /* Session ID                              */
  390.         int,                    /* Flags - for traffic control             */
  391.         struct sockaddr *,      /* Local host: (Src addr, port), net order */
  392.         rapi_filter_t *,        /* Sender template - not supported         */
  393.         rapi_tspec_t *,         /* Sender Tspec                            */
  394.         rapi_adspec_t *,        /* Sender Adspec                           */
  395.         rapi_policy_t *,        /* Sender policy data - not supported      */
  396.         int                     /* TTL of multicast data                   */
  397. ));
  398. /* values for flag for traffic control above */
  399. #define TC_QOS_POLICE     0x1   /* turn policing on                        */
  400. #define TC_QOS_NOPOLICE   0x2   /* turn policing off                       */
  401. #define TC_QOS_SHAPE      0x4   /* turn shaping on                         */
  402. #define TC_QOS_NOSHAPE    0x8   /* turn shaping off                        */
  403.  
  404. int _System rapi_reserve __TCPPROTO((
  405.         rapi_sid_t,             /* Session ID                      */
  406.         int,                    /* Flags - not defined             */
  407.         struct sockaddr *,      /* Recv host addr - optional       */
  408.         rapi_styleid_t,         /* Style ID                        */
  409.         rapi_stylex_t *,        /* Style extension - not supported */
  410.         rapi_policy_t *,        /* Receiver policy - not supported */
  411.         int,                    /* # of filter specs               */
  412.         rapi_filter_t *,        /* array of filter specs           */
  413.         int,                    /* # of flowspecs                  */
  414.         rapi_flowspec_t *       /* array of flowspecs              */
  415. ));
  416.  
  417. int _System rapi_release __TCPPROTO((rapi_sid_t     /* Session ID */));
  418.  
  419. int _System rapi_getfd __TCPPROTO((rapi_sid_t       /* Session ID */));
  420.  
  421. int _System rapi_dispatch __TCPPROTO((void));
  422.  
  423. int _System rapi_version __TCPPROTO((void));
  424.  
  425. /*
  426.     Formatting routines
  427.  */
  428. void _System rapi_fmt_flowspec __TCPPROTO((rapi_flowspec_t *, char *, int));
  429. void _System rapi_fmt_tspec __TCPPROTO((rapi_tspec_t *, char *, int));
  430. void _System rapi_fmt_adspec __TCPPROTO((rapi_adspec_t *, char *, int));
  431. void _System rapi_fmt_filtspec __TCPPROTO((rapi_filter_t *, char *, int));
  432.  
  433.  
  434. /*****************************************************************************/
  435.  
  436. /*
  437.  *      RAPI Error Codes
  438.  */
  439. #define RAPI_ERR_OK             0       /* No error                       */
  440. #define RAPI_ERR_INVAL          1       /* Invalid parameter              */
  441. #define RAPI_ERR_MAXSESS        2       /* Too many sessions              */
  442. #define RAPI_ERR_BADSID         3       /* Sid out of legal range.        */
  443. #define RAPI_ERR_N_FFS          4       /* Wrong n_filter/n_flow for style*/
  444. #define RAPI_ERR_BADSTYLE       5       /* Illegal reservation style      */
  445. #define RAPI_ERR_SYSCALL        6       /* system call error              */
  446. #define RAPI_ERR_OVERFLOW       7       /* Parm list overflow             */
  447. #define RAPI_ERR_MEMFULL        8       /* Not enough memory              */
  448. #define RAPI_ERR_NORSVP         9       /* Daemon doesn't respond/exist   */
  449. #define RAPI_ERR_OBJTYPE        10      /* Object type error              */
  450. #define RAPI_ERR_OBJLEN         11      /* Object length error            */
  451. #define RAPI_ERR_NOTSPEC        12      /* No sender tspec in rapi_sendr  */
  452. #define RAPI_ERR_INTSERV        13      /* Intserv format error           */
  453. /*                              14       * UNUSED                         */
  454.  
  455. /*  
  456.  * The following occur only asynchronously
  457.  */
  458. #define RAPI_ERR_BADSEND        14      /* Send interface does not exist  */
  459. #define RAPI_ERR_BADRECV        15      /* Recv interface does not exist  */
  460.  
  461. #define RAPI_ERR_UNSUPPORTED    254
  462. #define RAPI_ERR_UNKNOWN        255
  463.  
  464. #pragma pack()
  465.  
  466. #endif /* TCPV40HDRS */
  467. #endif /* H_RSVP_RAPI */
  468.