home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / radius_2.zip / radius.h < prev    next >
C/C++ Source or Header  |  1996-06-04  |  6KB  |  231 lines

  1. /*
  2.  *
  3.  *    RADIUS
  4.  *    Remote Authentication Dial In User Service
  5.  *
  6.  *
  7.  *    Livingston Enterprises, Inc.
  8.  *    6920 Koll Center Parkway
  9.  *    Pleasanton, CA   94566
  10.  *
  11.  *    Copyright 1992 Livingston Enterprises, Inc.
  12.  *
  13.  *    Permission to use, copy, modify, and distribute this software for any
  14.  *    purpose and without fee is hereby granted, provided that this
  15.  *    copyright and permission notice appear on all copies and supporting
  16.  *    documentation, the name of Livingston Enterprises, Inc. not be used
  17.  *    in advertising or publicity pertaining to distribution of the
  18.  *    program without specific prior permission, and notice be given
  19.  *    in supporting documentation that copying and distribution is by
  20.  *    permission of Livingston Enterprises, Inc.   
  21.  *
  22.  *    Livingston Enterprises, Inc. makes no representations about
  23.  *    the suitability of this software for any purpose.  It is
  24.  *    provided "as is" without express or implied warranty.
  25.  *
  26.  */
  27.  
  28. /*
  29.  *    @(#)radius.h    1.9 11/14/94 
  30.  */
  31.  
  32. #include "conf.h"
  33.  
  34. /* #define DBM 1 */
  35. #define NOSHADOW 1
  36. #define AUTH_VECTOR_LEN        16
  37. #define AUTH_PASS_LEN        16
  38. #define AUTH_STRING_LEN        128    /* maximum of 254 */
  39.  
  40. typedef struct pw_auth_hdr {
  41.     u_char        code;
  42.     u_char        id;
  43.     u_short        length;
  44.     u_char        vector[AUTH_VECTOR_LEN];
  45.     u_char        data[2];
  46. } AUTH_HDR;
  47.  
  48. #define AUTH_HDR_LEN            20
  49. #define CHAP_VALUE_LENGTH        16
  50.  
  51. #define PW_AUTH_UDP_PORT        1645
  52. #define PW_ACCT_UDP_PORT        1646
  53.  
  54. #define PW_TYPE_STRING            0
  55. #define PW_TYPE_INTEGER            1
  56. #define PW_TYPE_IPADDR            2
  57. #define PW_TYPE_DATE            3
  58.  
  59.  
  60. #define    PW_AUTHENTICATION_REQUEST    1
  61. #define    PW_AUTHENTICATION_ACK        2
  62. #define    PW_AUTHENTICATION_REJECT    3
  63. #define    PW_ACCOUNTING_REQUEST        4
  64. #define    PW_ACCOUNTING_RESPONSE        5
  65. #define    PW_ACCOUNTING_STATUS        6
  66. #define PW_PASSWORD_REQUEST        7
  67. #define PW_PASSWORD_ACK            8
  68. #define PW_PASSWORD_REJECT        9
  69. #define    PW_ACCOUNTING_MESSAGE        10
  70. #define PW_ACCESS_CHALLENGE        11
  71.  
  72. #define    PW_USER_NAME            1
  73. #define    PW_PASSWORD            2
  74. #define    PW_CHAP_PASSWORD        3
  75. #define    PW_CLIENT_ID            4
  76. #define    PW_CLIENT_PORT_ID        5
  77. #define    PW_USER_SERVICE_TYPE        6
  78. #define    PW_FRAMED_PROTOCOL        7
  79. #define    PW_FRAMED_ADDRESS        8
  80. #define    PW_FRAMED_NETMASK        9
  81. #define    PW_FRAMED_ROUTING        10
  82. #define    PW_FRAMED_FILTER_ID        11
  83. #define    PW_FRAMED_MTU            12
  84. #define    PW_FRAMED_COMPRESSION        13
  85. #define    PW_LOGIN_HOST            14
  86. #define    PW_LOGIN_SERVICE        15
  87. #define    PW_LOGIN_TCP_PORT        16
  88. #define PW_OLD_PASSWORD            17
  89. #define PW_PORT_MESSAGE            18
  90. #define PW_DIALBACK_NO            19
  91. #define PW_DIALBACK_NAME        20
  92. #define PW_EXPIRATION            21
  93. #define PW_FRAMED_ROUTE            22
  94. #define PW_FRAMED_IPXNET        23
  95. #define PW_STATE            24
  96.  
  97. #define PW_ACCT_STATUS_TYPE        40
  98. #define PW_ACCT_DELAY_TIME        41
  99. #define PW_ACCT_INPUT_OCTETS        42
  100. #define PW_ACCT_OUTPUT_OCTETS        43
  101. #define PW_ACCT_SESSION_ID        44
  102. #define PW_ACCT_AUTHENTIC        45
  103. #define PW_ACCT_SESSION_TIME        46
  104.  
  105. /*
  106.  *    INTEGER TRANSLATIONS
  107.  */
  108.  
  109. /*    USER TYPES    */
  110.  
  111. #define    PW_LOGIN_USER            1
  112. #define    PW_FRAMED_USER            2
  113. #define    PW_DIALBACK_LOGIN_USER        3
  114. #define    PW_DIALBACK_FRAMED_USER        4
  115.  
  116. /*    FRAMED PROTOCOLS    */
  117.  
  118. #define    PW_PPP                1
  119. #define    PW_SLIP                2
  120.  
  121. /*    FRAMED ROUTING VALUES    */
  122.  
  123. #define    PW_NONE                0
  124. #define    PW_BROADCAST            1
  125. #define    PW_LISTEN            2
  126. #define    PW_BROADCAST_LISTEN        3
  127.  
  128. /*    FRAMED COMPRESSION TYPES    */
  129.  
  130. #define    PW_VAN_JACOBSEN_TCP_IP        1
  131.  
  132. /*    LOGIN SERVICES    */
  133.  
  134. #define    PW_TELNET            0
  135. #define    PW_RLOGIN            1
  136. #define    PW_TCP_CLEAR            2
  137. #define    PW_PORTMASTER            3
  138.  
  139. /*    AUTHENTICATION LEVEL    */
  140.  
  141. #define PW_AUTH_NONE            0
  142. #define PW_AUTH_RADIUS            1
  143. #define PW_AUTH_LOCAL            2
  144.  
  145. /*    STATUS TYPES    */
  146.  
  147. #define PW_STATUS_START            1
  148. #define PW_STATUS_STOP            2
  149. #define PW_STATUS_ALIVE            3
  150.  
  151. /* Default Database File Names */
  152. #ifndef OS2
  153. #define RADIUS_DIR            "/etc/raddb"
  154. #define RADACCT_DIR            "/usr/adm/radacct"
  155. #else
  156. #define RADIUS_DIR            "/raddb"
  157. #define RADACCT_DIR        "/radacct"
  158. #endif
  159. #define RADIUS_DICTIONARY    "dictionary"
  160. #define RADIUS_CLIENTS        "clients"
  161. #define RADIUS_USERS        "users"
  162. #define RADIUS_HOLD            "holdusers"
  163. #define RADIUS_LOG            "logfile"
  164.  
  165. /* Server data structures */
  166.  
  167. typedef struct dict_attr {
  168.     char        name[32];
  169.     int            value;
  170.     int            type;
  171.     struct dict_attr    *next;
  172. } DICT_ATTR;
  173.  
  174. typedef struct dict_value {
  175.     char            attrname[32];
  176.     char            name[32];
  177.     int            value;
  178.     struct dict_value    *next;
  179. } DICT_VALUE;
  180.  
  181. typedef struct value_pair {
  182.     char            name[32];
  183.     int            attribute;
  184.     int            type;
  185.     UINT4            lvalue;
  186.     char            strvalue[AUTH_STRING_LEN];
  187.     struct value_pair    *next;
  188. } VALUE_PAIR;
  189.  
  190. typedef struct auth_req {
  191.     UINT4            ipaddr;
  192.     u_short            udp_port;
  193.     u_char            id;
  194.     u_char            code;
  195.     u_char            vector[16];
  196.     u_char            secret[16];
  197.     VALUE_PAIR        *request;
  198.     int            child_pid;    /* Process ID of child */
  199.     UINT4            timestamp;
  200.     struct auth_req        *next;        /* Next active request */
  201. } AUTH_REQ;
  202.  
  203. #define DEBUG    if(debug_flag)printf
  204.  
  205. #define SECONDS_PER_DAY        86400
  206. #define MAX_REQUEST_TIME    30
  207. #define CLEANUP_DELAY        5
  208. #define MAX_REQUESTS        100
  209.  
  210. #include "util.h"
  211.  
  212. /* in radiusd.c */
  213. int log_err(char    *msg);
  214. void debug_pair(FILE *fd,VALUE_PAIR *pair);
  215. int        calc_digest(u_char        *digest,AUTH_REQ    *authreq);
  216. /* in attrprint.c */
  217. void fprint_attr_val(FILE        *fd,VALUE_PAIR    *pair);
  218. /* in acct.c */
  219. void send_acct_reply(AUTH_REQ *authreq,VALUE_PAIR    *reply,char    *msg,int activefd);
  220. void rad_accounting(AUTH_REQ    *authreq,int        activefd);
  221. /* in md5.c */
  222. void md5_calc(unsigned char *output,unsigned char *input,unsigned int inlen);
  223. /* in version.c */
  224. void version(void);
  225. /* in dict.c */
  226. int dict_init();
  227. /* in users.c  */
  228. int user_find(char    *name,VALUE_PAIR    **check_pairs,VALUE_PAIR    **reply_pairs);
  229. int user_update(char        *name,VALUE_PAIR    *user_check,VALUE_PAIR    *user_reply);
  230.  
  231.