session.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * session.c - PPP session control.
  3. *
  4. * Copyright (c) 2007 Diego Rivera. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * 2. The name(s) of the authors of this software must not be used to
  14. * endorse or promote products derived from this software without
  15. * prior written permission.
  16. *
  17. * 3. Redistributions of any form whatsoever must retain the following
  18. * acknowledgment:
  19. * "This product includes software developed by Paul Mackerras
  20. * <paulus@samba.org>".
  21. *
  22. * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
  23. * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  24. * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
  25. * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  26. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  27. * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  28. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  29. */
  30. #ifndef __SESSION_H
  31. #define __SESSION_H
  32. #define SESS_AUTH 1 /* Check User Authentication */
  33. #define SESS_ACCT 2 /* Check Account Validity */
  34. /* Convenience parameter to do the whole enchilada */
  35. #define SESS_ALL (SESS_AUTH | SESS_ACCT)
  36. /*
  37. * int session_start(...)
  38. *
  39. * Start a session, performing any necessary validations.
  40. *
  41. * Parameters:
  42. * const int flags :
  43. * Any combination of the SESS_XXX flags, to indicate what the function
  44. * should do as part of its checks
  45. *
  46. * const char* user :
  47. * The username to validate. May safely be null.
  48. *
  49. * const char* passwd :
  50. * The password to validate the user with. May safely be null.
  51. *
  52. * const char* tty :
  53. * The TTY the user is connected on. May safely be null.
  54. *
  55. * char** msg :
  56. * A char* to return an error or success message. This message will be returned
  57. * regardless of the result. May safely be null.
  58. *
  59. * Return Value:
  60. * Zero value for failure, non-zero value for successful session verification.
  61. */
  62. int
  63. session_start(const int flags, const char* user, const char* passwd, const char* tty, char** msg);
  64. /* Added these macros for convenience... */
  65. #define session_auth(user, pass, tty, msg) \
  66. session_start(SESS_AUTH, user, pass, tty, msg)
  67. #define session_check(user, pass, tty, msg) \
  68. session_start(SESS_ACCT, user, pass, tty, msg)
  69. #define session_full(user, pass, tty, msg) \
  70. session_start(SESS_ALL, user, pass, tty, msg)
  71. /*
  72. * void session_end(...)
  73. *
  74. * End a previously-started session.
  75. *
  76. * Parameters:
  77. * const char* tty :
  78. * The TTY the user is connected on. May safely be null.
  79. */
  80. void
  81. session_end(const char* tty);
  82. #endif