# lan.conf
# A configuration file for lanserv or ipmi_sim to configure the various
# communication parameters for the device.

# This is a name used to identify this instance, and used to create
# the default name of the emulator startup command file and eventually
# the storage facility for permanent storage.
name "ipmisim1"

#
# Work on the BMC first
set_working_mc 0x20

  # Define a LAN channel on channel 1
  startlan 1
    # Define an IP address and port to listen on.  You can define more
    # than one address/port to listen on multiple addresses.  The ::
    # listens on all addresses.
    addr localhost 9001
    #addr 192.168.27.126 9000
    #addr 192.168.27.200 9000

    # Maximum privilege limit on the channel.
    priv_limit admin

    # Allowed IPMI 1.5 authorization types
    allowed_auths_callback none md2 md5 straight
    allowed_auths_user none md2 md5 straight
    allowed_auths_operator none md2 md5 straight
    allowed_auths_admin none md2 md5 straight

    # guid for IPMI 2.0 authorization  You can also use a string
    guid a123456789abcdefa123456789abcdef
    #guid "I_AM_A_REAL_BMC!"

    # You can specify a BMC key for IPMI 2.0 authorization.  See the
    # spec for details.
    #bmc_key "abcdefghijklmnopqrst"

    # A program to get and set the LAN configuration of the interface.
    #lan_config_program "/usr/local/bin/ipmi_sim_lancontrol eth0"
    lan_config_program "./ipmi_sim_lancontrol eth1"
  endlan

  #chassis_control "./ipmi_sim_chassiscontrol 0x20"

  # Define a serial VM inteface for channel 15 (the system interface) on
  # port 9002, just available to the local system (localhost).
  serial 15 localhost 9002 codec VM

  # startcmd is what to execute to start a VM associated with the
  # codec above (localhost 9002).  It also starts a console serial port
  # on port 9003 that is also used as the monitor interface.
  startcmd "qemu-system-x86_64 --enable-kvm -drive file=/opt/qemu/cge-complete-image-x86-generic-64-1.ext2,format=raw -nographic -kernel /opt/qemu/bzImage-1 -append 'root=/dev/sdb console=ttyS0,115200' -net nic,model=e1000,macaddr=52:54:00:12:34:59 -net user,hostfwd=tcp::5556-10.0.2.15:22 -chardev socket,id=ipmi0,host=localhost,port=9002,reconnect=10 -device ipmi-bmc-extern,id=bmc0,chardev=ipmi0 -device isa-ipmi-bt,bmc=bmc0 -serial mon:telnet::9003,server,telnet,nowait"

  sol "telnet:localhost:9003" 115200

  # Start startcmd at startup?  Default is false.
  startnow false

  # The amount of time to wait for the startcmd to do a power off
  # on a powerdown request.  The simulator will send a request to the
  # target, wait this amount of time, and then do a SIGTERM kill on the
  # process.  If this is zero, a SIGTERM will not be done (nor will a SIGKILL).
  # Note that if the simulator does not have a connection to the VM, the
  # graceful shutdown is skipped and a SIGTERM is done immediately.
  # Default time is 60 seconds.
  #poweroff_wait 30
  
  # The amount of time to wait for SIGTERM to kill the process.  If the process
  # does not terminate in this period of time, send a SIGKILL kill.  If this
  # is zero, don't send the SIGKILL.  Default time is 20 seconds.
  #kill_wait 5

  # Now add some users.  User 0 is invalid, user 1 is the special "anonymous"
  # user and cannot take a username.  Note that the users here are only
  # used if the persistent user config doesn't exist.
  #    # valid name      passw  priv-lim max-sess allowed-auths (ignored)
  user 1 true  ""        "test" user     10       none md2 md5 straight
  user 2 true  "ipmiusr" "test" admin    10       none md2 md5 straight

#  sol "/dev/ttyUSB0" 38400 history=4000 historyfru=10

#
# Switch to a new MC
#
set_working_mc 0x30

  # Add a SOL config, a device and a default baud rate.
  # "history" sets a history buffer size.  This means that DCD and CTS will
  # always be enabled to the device, and we will constantly collect
  # history for the device.  It will be available as SOL instance 2
  # on the device.  If the optional backupfile option is specified,
  # the history data is stored in the given file if the BMC shuts down
  # (or is killed by a catchable signal) and restored from that file if it
  # starts up.
  # If historyfru=N is specified, then FRU device N on the MC will be
  # able to fetch the contents of the history buffer, too, up to
  # 65535 bytes (the max size of FRU data).
  # Specifying nortscts disabled rtscts on the port.  It will still change
  # the RTS output line, but it won't listen to CTS.
  # Normally the data is left in the history buffer when read.  If
  # you want the history data to be cleared from the buffer on read
  # add readclear.
  #sol "/dev/ttyUSB0" 19200 nortscts readclear
#  sol "/dev/ttyUSB0" 38400 history=4000,backupfile=/var/ipmi_sim/solhist1 historyfru=10

  # Define a serial VM inteface for channel 15 (the system interface) on
  # port 9003 for the MC at 0x30
  serial 15 localhost 9012 codec VM

  startcmd "qemu-system-x86_64 --enable-kvm -drive file=/opt/qemu/cge-complete-image-x86-generic-64-2.ext2,format=raw -nographic -kernel /opt/qemu/bzImage-2 -append 'root=/dev/sdb console=ttyS0,115200' -net nic,model=e1000,macaddr=52:54:00:12:34:59 -net user,hostfwd=tcp::5557-10.0.2.15:22 -chardev socket,id=ipmi0,host=localhost,port=9012,reconnect=10 -device ipmi-bmc-extern,id=bmc0,chardev=ipmi0 -device isa-ipmi-kcs,bmc=bmc0,irq=5 -serial mon:tcp::9013,server,telnet,nowait"

  sol "telnet:localhost:9013" 115200

# Start startcmd at startup?  Default is false.
  startnow false

# Allow a console connection to perform emulation commands.
#console localhost 9000

# Dynamically load a module to extend the simulator.  After the module is
# loaded, if the function "ipmi_sim_module_init" is defined in the module,
# it will be called with the following parameters:
#  int ipmi_sim_module_init(sys_data_t *sys, char *initstr);
# where initstr is the init string passed on the module load line.
# It should return 0 on success or an errno no failure.
#loadlib "/opt/lib/ipmi_sim_extend.so" "Initialization String"

# "ipmb" should be added to the config file of a device
# that needs to handle an IPMB request and generate a response
# back to the requester.
# In the case of an IPMB bridge request for example, the
# BMC is considered the requester and the responder device
# should have a config file defining the IPMB channel number.
# For example:
# ipmb <channel number> <linux ipmb driver name> <device file>
# ipmb 2 ipmb_dev_int /dev/ipmb-2
#
# At the moment, this OpenIPMI ipmb interface works with the
# linux driver ipmb_dev_int.c.
