DhcpServer library for mbed-os.

Fork of DhcpServer by Daiki Kato

mbedボードをDHCPサーバとして使用するためのライブラリです。mbedボードとPCを直結する際などに使用してください。
このクラスは5つのIPアドレスを割り当てられることができます。
IPアドレスの上位3バイトはサーバーアドレスと同じで、下の1バイトは、10-14が割り当てられます。
例えば、サーバーアドレスが"192.168.0.1"の場合、IPアドレスは"192.168.0.10"~"192.168.0.14"が割り当てられます。

EthernetInterfaceでconnectを実行した後に、DhcpServerを使用してください。

    EthernetInterface eth;
    eth.init("192.168.0.1", "255.255.255.0", "192.168.0.1");
    eth.connect();
    DhcpServer dhcp_server(&eth, "HostName");


Library in Beta!

This library is in Beta.
このライブラリはβ版です。

DhcpServer.h

Committer:
dkato
Date:
2018-06-21
Revision:
4:ac6385f9f2db
Parent:
3:bdea854c0ec8

File content as of revision 4:ac6385f9f2db:

/**************************************************************************//**
* @file          DhcpServer.h
* @brief         DhcpServer API
******************************************************************************/
#ifndef DHCP_SERVER_H_
#define DHCP_SERVER_H_

/** This class is intended for use the mbed board as a DHCP server.
 *  This class can be allocated five IP addresses.
 *  Top 3byte of IP address is the same as the server address, the lower 1byte is 10-14 is allocated.
 *  For example, if the server address is "192.168.0.1", IP address will be allocated "192.168.0.10" ~ "192.168.0.14".
 */
class DhcpServer {
public:
    /** Constructor: Initializes DhcpServer.
     *
     * @param net Common interface that is shared between network devices
     * @param name a pointer to a string containing the server name. (e.g."ServerName")
     */
    DhcpServer(NetworkInterface *net, const char * name);

    /** Destructor
     *
     */
    virtual ~DhcpServer();

private:
    #define CONNECT_NUM    (5)

    UDPSocket dhcp_server;
    Thread dhcpThread;
    char * receivebuff;
    char * sendbuff;
    char chaddr_tbl[CONNECT_NUM][6];

    void dhcp_process(void);
};
#endif /* DHCP_SERVER_H_ */