Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DhcpSession"/> class.
        /// </summary>
        /// <param name="dhcpService">The DHCP service.</param>
        /// <param name="physicalAddress">The physical address.</param>
        /// <param name="sessionTimeOut">The session time out.</param>
        /// <exception cref="ArgumentNullException">dhcpService</exception>
        /// <autogeneratedoc />
        public DhcpSession(IDhcpService dhcpService, PhysicalAddress physicalAddress, TimeSpan sessionTimeOut)
        {
            _dhcpService       = dhcpService ?? throw new ArgumentNullException(nameof(dhcpService));
            PhysicalAddress    = physicalAddress;
            _dhcpSessionResult = new DhcpSessionResult(physicalAddress);

            Logger = _dhcpService.LoggerFactory.CreatePureLogger <DhcpSession>();

            CreatedTimestamp = UpdatedTimestamp = DateTimeOffset.Now;
            SessionTimeOut   = sessionTimeOut;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DhcpMessageEventArgs" /> class.
        /// </summary>
        /// <param name="dhcpService">Controlling DhcpService interface</param>
        /// <param name="channel">Socket channel request is received on.</param>
        /// <param name="data">Raw data received from socket.</param>
        /// <exception cref="ArgumentNullException">
        /// channel
        /// or
        /// data
        /// or
        /// DhcpService
        /// </exception>
        public DhcpMessageEventArgs(IDhcpService dhcpService, SocketChannel channel, SocketBuffer data)
        {
            Channel       = channel ?? throw new ArgumentNullException(nameof(channel));
            ChannelBuffer = data ?? throw new ArgumentNullException(nameof(data));
            DhcpService   = dhcpService ?? throw new ArgumentNullException(nameof(DhcpService));

            var logger = dhcpService.Logger;

            try
            {
                // Parse the dhcp message
                RequestMessage = new DhcpMessage(data.Buffer, dhcpService.LoggerFactory, logger);


                logger?.LogTrace(
                    "DHCP PACKET with message id {SessionId} successfully parsed from client endpoint {RemoteEndPoint}",
                    RequestMessage.SessionId.ToHexString("0x"), Channel.RemoteEndpoint);
            }
            catch (Exception ex)
            {
                logger?.LogError(ex, "Error parsing DHCP message");
            }
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DhcpSession"/> class.
 /// </summary>
 /// <param name="dhcpService">The DHCP service.</param>
 /// <param name="physicalAddress">The physical address.</param>
 /// <autogeneratedoc />
 public DhcpSession(IDhcpService dhcpService, PhysicalAddress physicalAddress) :
     this(dhcpService, physicalAddress, DefaultSessionTimeOut)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DhcpDiscoveredDeviceEvent"/> class.
 /// </summary>
 /// <param name="dhcpService">The DHCP service.</param>
 /// <param name="dhcpDiscoveredDevice">The DHCP discovered device.</param>
 /// <exception cref="ArgumentNullException">
 /// dhcpService
 /// or
 /// dhcpDiscoveredDevice
 /// </exception>
 /// <autogeneratedoc />
 public DhcpDiscoveredDeviceEvent(IDhcpService dhcpService, IDhcpDiscoveredDevice dhcpDiscoveredDevice)
 {
     DhcpService          = dhcpService ?? throw new ArgumentNullException(nameof(dhcpService));
     DhcpDiscoveredDevice =
         dhcpDiscoveredDevice ?? throw new ArgumentNullException(nameof(dhcpDiscoveredDevice));
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NetworkMapService"/> class.
 /// </summary>
 /// <param name="networkMap">The network map.</param>
 /// <param name="dhcpService">The DHCP service.</param>
 /// <param name="applicationLifetime">The application lifetime.</param>
 /// <exception cref="ArgumentNullException">
 /// networkMap
 /// or
 /// dhcpService
 /// </exception>
 /// <autogeneratedoc />
 public NetworkMapService(INetworkMap networkMap, IDhcpService dhcpService, IApplicationLifetime applicationLifetime = null) :
     base(networkMap?.CommonServices, applicationLifetime, ServiceHost.NetworkMap)
 {
     NetworkMap  = networkMap ?? throw new ArgumentNullException(nameof(networkMap));
     DhcpService = dhcpService ?? throw new ArgumentNullException(nameof(dhcpService));
 }