home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / radi116c.zip / radius116c / src / radius / radius.h < prev    next >
C/C++ Source or Header  |  1997-02-27  |  7KB  |  272 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. #include "pwd.h"
  34.  
  35.  
  36.  
  37. /* OS/2 Compiler-specific definitions  */
  38. #if (defined(__IBMC__) || defined(__IBMCPP__))
  39.  
  40. #define ThreadedCode _Optlink
  41. #define ultoa _ultoa
  42.  
  43. #endif
  44.  
  45. #if     defined(__BORLANDC__)
  46.  
  47. #define ThreadedCode _Cdecl
  48. #define _beginthread(a,b,c,d) _beginthread(a,c,d)
  49.  
  50. #endif
  51.  
  52.  
  53.  
  54. /* #define DBM 1 */
  55. #define NOSHADOW 1
  56. #define AUTH_VECTOR_LEN        16
  57. #define AUTH_PASS_LEN        16
  58. #define AUTH_STRING_LEN        128    /* maximum of 254 */
  59.  
  60. typedef struct pw_auth_hdr {
  61.     u_char        code;
  62.     u_char        id;
  63.     u_short        length;
  64.     u_char        vector[AUTH_VECTOR_LEN];
  65.     u_char        data[2];
  66. } AUTH_HDR;
  67.  
  68. #define AUTH_HDR_LEN            20
  69. #define CHAP_VALUE_LENGTH        16
  70.  
  71. #define PW_AUTH_UDP_PORT        1645
  72. #define PW_ACCT_UDP_PORT        1646
  73.  
  74. #define PW_TYPE_STRING            0
  75. #define PW_TYPE_INTEGER            1
  76. #define PW_TYPE_IPADDR            2
  77. #define PW_TYPE_DATE            3
  78.  
  79.  
  80. #define    PW_AUTHENTICATION_REQUEST    1
  81. #define    PW_AUTHENTICATION_ACK        2
  82. #define    PW_AUTHENTICATION_REJECT    3
  83. #define    PW_ACCOUNTING_REQUEST        4
  84. #define    PW_ACCOUNTING_RESPONSE        5
  85. #define    PW_ACCOUNTING_STATUS        6
  86. #define PW_PASSWORD_REQUEST        7
  87. #define PW_PASSWORD_ACK            8
  88. #define PW_PASSWORD_REJECT        9
  89. #define    PW_ACCOUNTING_MESSAGE        10
  90. #define PW_ACCESS_CHALLENGE        11
  91.  
  92. #define    PW_USER_NAME            1
  93. #define    PW_PASSWORD            2
  94. #define    PW_CHAP_PASSWORD        3
  95. #define    PW_CLIENT_ID            4
  96. #define    PW_CLIENT_PORT_ID        5
  97. #define    PW_USER_SERVICE_TYPE        6
  98. #define    PW_FRAMED_PROTOCOL        7
  99. #define    PW_FRAMED_ADDRESS        8
  100. #define    PW_FRAMED_NETMASK        9
  101. #define    PW_FRAMED_ROUTING        10
  102. #define    PW_FRAMED_FILTER_ID        11
  103. #define    PW_FRAMED_MTU            12
  104. #define    PW_FRAMED_COMPRESSION        13
  105. #define    PW_LOGIN_HOST            14
  106. #define    PW_LOGIN_SERVICE        15
  107. #define    PW_LOGIN_TCP_PORT        16
  108. #define PW_OLD_PASSWORD            17
  109. #define PW_PORT_MESSAGE            18
  110. #define PW_DIALBACK_NO            19
  111. #define PW_DIALBACK_NAME        20
  112. #define PW_EXPIRATION            21
  113. #define PW_FRAMED_ROUTE            22
  114. #define PW_FRAMED_IPXNET        23
  115. #define PW_STATE            24
  116. #define PW_SESSIONS            25
  117. #define PW_SESSION_TIMEOUT            27
  118. #define PW_IDLE_TIMEOUT            28
  119.  
  120. #define PW_ACCT_STATUS_TYPE        40
  121. #define PW_ACCT_DELAY_TIME        41
  122. #define PW_ACCT_INPUT_OCTETS        42
  123. #define PW_ACCT_OUTPUT_OCTETS        43
  124. #define PW_ACCT_SESSION_ID        44
  125. #define PW_ACCT_AUTHENTIC        45
  126. #define PW_ACCT_SESSION_TIME        46
  127.  
  128. /*
  129.  *    INTEGER TRANSLATIONS
  130.  */
  131.  
  132. /*    USER TYPES    */
  133.  
  134. #define    PW_LOGIN_USER            1
  135. #define    PW_FRAMED_USER            2
  136. #define    PW_DIALBACK_LOGIN_USER        3
  137. #define    PW_DIALBACK_FRAMED_USER        4
  138.  
  139. /*    FRAMED PROTOCOLS    */
  140.  
  141. #define    PW_PPP                1
  142. #define    PW_SLIP                2
  143.  
  144. /*    FRAMED ROUTING VALUES    */
  145.  
  146. #define    PW_NONE                0
  147. #define    PW_BROADCAST            1
  148. #define    PW_LISTEN            2
  149. #define    PW_BROADCAST_LISTEN        3
  150.  
  151. /*    FRAMED COMPRESSION TYPES    */
  152.  
  153. #define    PW_VAN_JACOBSEN_TCP_IP        1
  154.  
  155. /*    LOGIN SERVICES    */
  156.  
  157. #define    PW_TELNET            0
  158. #define    PW_RLOGIN            1
  159. #define    PW_TCP_CLEAR            2
  160. #define    PW_PORTMASTER            3
  161.  
  162. /*    AUTHENTICATION LEVEL    */
  163.  
  164. #define PW_AUTH_NONE            0
  165. #define PW_AUTH_RADIUS            1
  166. #define PW_AUTH_LOCAL            2
  167.  
  168. /*    STATUS TYPES    */
  169.  
  170. #define PW_STATUS_START            1
  171. #define PW_STATUS_STOP            2
  172. #define PW_STATUS_ALIVE            3
  173.  
  174. /* Default Database File Names */
  175. #ifndef OS2
  176. #define RADIUS_DIR            "/etc/raddb"
  177. #define RADACCT_DIR            "/usr/adm/radacct"
  178. #else
  179. #define RADIUS_DIR            "\\raddb"
  180. #define RADACCT_DIR        "\\radacct"
  181. #endif
  182. #define RADIUS_DICTIONARY    "dictionary"
  183. #define RADIUS_CLIENTS        "clients"
  184. #define RADIUS_USERS        "users"
  185. #define RADIUS_HOLD            "holdusers"
  186. #define RADIUS_LOG            "logfile"
  187.  
  188. /* Server data structures */
  189.  
  190. typedef struct dict_attr {
  191.     char        name[32];
  192.     int            value;
  193.     int            type;
  194.     struct dict_attr    *next;
  195. } DICT_ATTR;
  196.  
  197. typedef struct dict_value {
  198.     char            attrname[32];
  199.     char            name[32];
  200.     int            value;
  201.     struct dict_value    *next;
  202. } DICT_VALUE;
  203.  
  204. typedef struct value_pair {
  205.     char            name[32];
  206.     int            attribute;
  207.     int            type;
  208.     UINT4            lvalue;
  209.     char            strvalue[AUTH_STRING_LEN];
  210.     struct value_pair    *next;
  211. } VALUE_PAIR;
  212.  
  213. typedef struct auth_req {
  214.     UINT4            ipaddr;
  215.     u_short            udp_port;
  216.     u_char            id;
  217.     u_char            code;
  218.     u_char            vector[16];
  219.     u_char            secret[16];
  220.     VALUE_PAIR        *request;
  221.     int            child_pid;    /* Process ID of child */
  222.     UINT4            timestamp;
  223.     struct auth_req        *next;        /* Next active request */
  224. } AUTH_REQ;
  225.  
  226. #define DEBUG    if(debug_flag)printf
  227.  
  228. #define SECONDS_PER_DAY        86400
  229. #define MAX_REQUEST_TIME    30
  230. #define CLEANUP_DELAY        5
  231. #define MAX_REQUESTS        100
  232.  
  233. #include "util.h"
  234.  
  235.  
  236. #define UserFileSemName "\\SEM32\\RADIUSD\\USERS"
  237.  
  238. /* in radiusd.c */
  239. int log_err(char    *msg);
  240. void debug_pair(FILE *fd,VALUE_PAIR *pair);
  241. int        calc_digest(u_char        *digest,AUTH_REQ    *authreq);
  242. AUTH_REQ    *radrecv(UINT4 host,
  243.                    u_short udp_port,
  244.                    u_char *buffer,
  245.                    int length);
  246. int radrespond(AUTH_REQ *authreq, int activefd);
  247.  
  248. /* in attrprint.c */
  249. void fprint_attr_val(FILE        *fd,VALUE_PAIR    *pair);
  250. /* in md5.c */
  251. void md5_calc(unsigned char *output,unsigned char *input,unsigned int inlen);
  252. /* in version.c */
  253. void version(void);
  254. /* in dict.c */
  255. int dict_init(void);
  256. DICT_ATTR    * dict_attrget(int attribute);
  257. DICT_ATTR    *dict_attrfind(char *attrname);
  258. DICT_VALUE    *dict_valfind(char *valname);
  259. DICT_VALUE    *dict_valget(int value, char *attrname);
  260.  
  261. /* in users.c  */
  262. int user_find(char    *name,VALUE_PAIR    **check_pairs,VALUE_PAIR    **reply_pairs);
  263. int user_update(char        *name,VALUE_PAIR    *user_check,VALUE_PAIR    *user_reply);
  264.  
  265.  
  266. /* in acct.c */
  267. int user_sessions(char *username);
  268. void send_acct_reply(AUTH_REQ *authreq,VALUE_PAIR    *reply,char    *msg,int activefd);
  269. void rad_accounting(AUTH_REQ    *authreq,int        activefd);
  270. void ThreadedCode AccountingThread(void * arg);
  271.  
  272.