Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/interface_rmcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
import pyipmi
import pyipmi.interfaces


# Test with ipmi_sim, a tool that ships with openipmi
# This should work with the default config file /etc/ipmi/ipmi.conf;
# just run ipmi_sim -p in another window to start the server
intf = pyipmi.interfaces.create_interface('rmcp',
slave_address=0x81,
host_target_address=0x20,
keep_alive_interval=0)
sess = pyipmi.Session()
sess.set_session_type_rmcp('10.0.114.116', 623)
sess.set_auth_type_user('admin', 'admin')
sess.set_session_type_rmcp('localhost', 9001)
sess.set_auth_type_user('ipmiusr', 'test')
sess.set_priv_level("ADMINISTRATOR")
target = pyipmi.Target(ipmb_address=0x20)

Expand Down
5 changes: 3 additions & 2 deletions pyipmi/interfaces/rmcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,12 @@ def close(self) -> None:
def _send_rmcp_msg(self, sdu: bytes | None, class_of_msg: int) -> None:
rmcp = RmcpMsg(class_of_msg)
pdu = rmcp.pack(sdu, self.seq_number)
self._sock.sendto(pdu, (self.host, self.port))
self._sock.send(pdu)
if self.seq_number != 255:
self.seq_number = (self.seq_number + 1) % 254

def _receive_rmcp_msg(self) -> tuple[int | None, int | None, bytes]:
(pdu, _) = self._sock.recvfrom(4096)
pdu = self._sock.recv(4096)
rmcp = RmcpMsg()
sdu = rmcp.unpack(pdu)
return (rmcp.seq_number, rmcp.class_of_msg, sdu)
Expand Down Expand Up @@ -526,6 +526,7 @@ def establish_session(self, session: Session) -> None:
self._session = None
self.host = session._rmcp_host
self.port = session._rmcp_port
self._sock.connect((self.host, self.port))

# 0 - Ping
self.ping()
Expand Down