DhcpServer library for mbed-os.
Fork of DhcpServer by
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(ð, "HostName");
Library in Beta!
This library is in Beta.
このライブラリはβ版です。
DhcpServer.h@2:4a34731d231e, 2017-06-20 (annotated)
- Committer:
- dkato
- Date:
- Tue Jun 20 10:32:37 2017 +0000
- Revision:
- 2:4a34731d231e
- Parent:
- 1:14ee6da645a9
- Child:
- 3:bdea854c0ec8
Supports mbed os 5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dkato | 1:14ee6da645a9 | 1 | /**************************************************************************//** |
dkato | 1:14ee6da645a9 | 2 | * @file DhcpServer.h |
dkato | 1:14ee6da645a9 | 3 | * @brief DhcpServer API |
dkato | 1:14ee6da645a9 | 4 | ******************************************************************************/ |
dkato | 0:1c2747611cab | 5 | #ifndef DHCP_SERVER_H_ |
dkato | 0:1c2747611cab | 6 | #define DHCP_SERVER_H_ |
dkato | 0:1c2747611cab | 7 | |
dkato | 1:14ee6da645a9 | 8 | /** This class is intended for use the mbed board as a DHCP server. |
dkato | 1:14ee6da645a9 | 9 | * This class can be allocated five IP addresses. |
dkato | 1:14ee6da645a9 | 10 | * Top 3byte of IP address is the same as the server address, the lower 1byte is 10-14 is allocated. |
dkato | 1:14ee6da645a9 | 11 | * For example, if the server address is "192.168.0.1", IP address will be allocated "192.168.0.10" ~ "192.168.0.14". |
dkato | 1:14ee6da645a9 | 12 | */ |
dkato | 0:1c2747611cab | 13 | class DhcpServer { |
dkato | 0:1c2747611cab | 14 | public: |
dkato | 1:14ee6da645a9 | 15 | /** Constructor: Initializes DhcpServer. |
dkato | 1:14ee6da645a9 | 16 | * |
dkato | 2:4a34731d231e | 17 | * @param net Common interface that is shared between network devices |
dkato | 1:14ee6da645a9 | 18 | * @param name a pointer to a string containing the server name. (e.g."ServerName") |
dkato | 1:14ee6da645a9 | 19 | */ |
dkato | 2:4a34731d231e | 20 | DhcpServer(NetworkInterface *net, char * name); |
dkato | 1:14ee6da645a9 | 21 | |
dkato | 1:14ee6da645a9 | 22 | /** Destructor |
dkato | 1:14ee6da645a9 | 23 | * |
dkato | 1:14ee6da645a9 | 24 | */ |
dkato | 0:1c2747611cab | 25 | virtual ~DhcpServer(); |
dkato | 2:4a34731d231e | 26 | |
dkato | 2:4a34731d231e | 27 | private: |
dkato | 2:4a34731d231e | 28 | #define CONNECT_NUM (5) |
dkato | 2:4a34731d231e | 29 | |
dkato | 2:4a34731d231e | 30 | UDPSocket dhcp_server; |
dkato | 2:4a34731d231e | 31 | Thread dhcpThread; |
dkato | 2:4a34731d231e | 32 | char * receivebuff; |
dkato | 2:4a34731d231e | 33 | char * sendbuff; |
dkato | 2:4a34731d231e | 34 | char chaddr_tbl[CONNECT_NUM][6]; |
dkato | 2:4a34731d231e | 35 | |
dkato | 2:4a34731d231e | 36 | void dhcp_process(void); |
dkato | 0:1c2747611cab | 37 | }; |
dkato | 1:14ee6da645a9 | 38 | #endif /* DHCP_SERVER_H_ */ |