lwip-1.4.1 (partial)
dhcp-server/dhserver.h@1:119c4f7144c8, 2018-07-24 (annotated)
- Committer:
- ua1arn
- Date:
- Tue Jul 24 17:36:01 2018 +0000
- Revision:
- 1:119c4f7144c8
lwip 1.4.1 with necessary servers
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ua1arn | 1:119c4f7144c8 | 1 | /* |
ua1arn | 1:119c4f7144c8 | 2 | * The MIT License (MIT) |
ua1arn | 1:119c4f7144c8 | 3 | * |
ua1arn | 1:119c4f7144c8 | 4 | * Copyright (c) 2015 by Sergey Fetisov <fsenok@gmail.com> |
ua1arn | 1:119c4f7144c8 | 5 | * |
ua1arn | 1:119c4f7144c8 | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
ua1arn | 1:119c4f7144c8 | 7 | * of this software and associated documentation files (the "Software"), to deal |
ua1arn | 1:119c4f7144c8 | 8 | * in the Software without restriction, including without limitation the rights |
ua1arn | 1:119c4f7144c8 | 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
ua1arn | 1:119c4f7144c8 | 10 | * copies of the Software, and to permit persons to whom the Software is |
ua1arn | 1:119c4f7144c8 | 11 | * furnished to do so, subject to the following conditions: |
ua1arn | 1:119c4f7144c8 | 12 | * |
ua1arn | 1:119c4f7144c8 | 13 | * The above copyright notice and this permission notice shall be included in all |
ua1arn | 1:119c4f7144c8 | 14 | * copies or substantial portions of the Software. |
ua1arn | 1:119c4f7144c8 | 15 | * |
ua1arn | 1:119c4f7144c8 | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
ua1arn | 1:119c4f7144c8 | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
ua1arn | 1:119c4f7144c8 | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
ua1arn | 1:119c4f7144c8 | 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
ua1arn | 1:119c4f7144c8 | 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ua1arn | 1:119c4f7144c8 | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
ua1arn | 1:119c4f7144c8 | 22 | * SOFTWARE. |
ua1arn | 1:119c4f7144c8 | 23 | */ |
ua1arn | 1:119c4f7144c8 | 24 | |
ua1arn | 1:119c4f7144c8 | 25 | /* |
ua1arn | 1:119c4f7144c8 | 26 | * version: 1.0 demo (7.02.2015) |
ua1arn | 1:119c4f7144c8 | 27 | * brief: tiny dhcp ipv4 server using lwip (pcb) |
ua1arn | 1:119c4f7144c8 | 28 | * ref: https://lists.gnu.org/archive/html/lwip-users/2012-12/msg00016.html |
ua1arn | 1:119c4f7144c8 | 29 | */ |
ua1arn | 1:119c4f7144c8 | 30 | |
ua1arn | 1:119c4f7144c8 | 31 | #ifndef DHSERVER_H |
ua1arn | 1:119c4f7144c8 | 32 | #define DHSERVER_H |
ua1arn | 1:119c4f7144c8 | 33 | |
ua1arn | 1:119c4f7144c8 | 34 | #include <stdint.h> |
ua1arn | 1:119c4f7144c8 | 35 | #include <stdbool.h> |
ua1arn | 1:119c4f7144c8 | 36 | #include <stdio.h> |
ua1arn | 1:119c4f7144c8 | 37 | #include <string.h> |
ua1arn | 1:119c4f7144c8 | 38 | #include "lwip/err.h" |
ua1arn | 1:119c4f7144c8 | 39 | #include "lwip/udp.h" |
ua1arn | 1:119c4f7144c8 | 40 | #include "netif/etharp.h" |
ua1arn | 1:119c4f7144c8 | 41 | |
ua1arn | 1:119c4f7144c8 | 42 | typedef struct dhcp_entry |
ua1arn | 1:119c4f7144c8 | 43 | { |
ua1arn | 1:119c4f7144c8 | 44 | uint8_t mac[6]; |
ua1arn | 1:119c4f7144c8 | 45 | uint8_t addr[4]; |
ua1arn | 1:119c4f7144c8 | 46 | uint8_t subnet[4]; |
ua1arn | 1:119c4f7144c8 | 47 | uint32_t lease; |
ua1arn | 1:119c4f7144c8 | 48 | } dhcp_entry_t; |
ua1arn | 1:119c4f7144c8 | 49 | |
ua1arn | 1:119c4f7144c8 | 50 | typedef struct dhcp_config |
ua1arn | 1:119c4f7144c8 | 51 | { |
ua1arn | 1:119c4f7144c8 | 52 | uint8_t addr[4]; |
ua1arn | 1:119c4f7144c8 | 53 | uint16_t port; |
ua1arn | 1:119c4f7144c8 | 54 | uint8_t dns[4]; |
ua1arn | 1:119c4f7144c8 | 55 | const char *domain; |
ua1arn | 1:119c4f7144c8 | 56 | int num_entry; |
ua1arn | 1:119c4f7144c8 | 57 | dhcp_entry_t *entries; |
ua1arn | 1:119c4f7144c8 | 58 | } dhcp_config_t; |
ua1arn | 1:119c4f7144c8 | 59 | |
ua1arn | 1:119c4f7144c8 | 60 | err_t dhserv_init(dhcp_config_t *config); |
ua1arn | 1:119c4f7144c8 | 61 | void dhserv_free(void); |
ua1arn | 1:119c4f7144c8 | 62 | |
ua1arn | 1:119c4f7144c8 | 63 | #endif /* DHSERVER_H */ |