-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.lisp
36 lines (31 loc) · 974 Bytes
/
session.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
;;;; -*- Mode: Lisp -*-
;;;; $Id$
(in-package :ipmi)
(defclass ipmi-session ()
((socket :type datagram-usocket
:accessor ipmi-socket
:initarg :socket)
(host :type string
:accessor ipmi-host
:initarg :host)
(port :type integer
:accessor ipmi-port
:initarg :port
:initform *asf-rmcp-port*)
(version :type number
:accessor ipmi-version
:initarg :version
:initform 1.5))
(:documentation "IPMI session"))
(defun open-session (host)
(make-instance 'ipmi-session
:socket (ipmi-connect host)
:host host))
(defun close-session (session)
(declare (type ipmi-session session))
(socket-close (ipmi-socket session)))
(defmacro with-open-session ((session &rest args) &body body)
`(let ((,session (open-session ,@args)))
(unwind-protect
(progn ,@body)
(close-session ,session))))