Skip to content

Commit 8c85d99

Browse files
author
viteo
committedDec 20, 2021
config to device.h
1 parent c344e6f commit 8c85d99

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed
 

‎device/device.h

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#define IP_ADDR2 7
1919
#define IP_ADDR3 1
2020

21+
/*DHCP Client addresses: IP_ADDR0.IP_ADDR1.IP_ADDR2.DHCP_ADDR_x*/
22+
#define DHCP_ADDR_1 2
23+
#define DHCP_ADDR_2 3
24+
2125
/*NETMASK*/
2226
#define NETMASK_ADDR0 255
2327
#define NETMASK_ADDR1 255

‎lib/USB_RNDIS/usb_endp.c

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ void EP3_OUT_Callback(void)
105105
{
106106
rndis_received = 0;
107107
}
108-
// DCD_EP_PrepareRx(pdev, RNDIS_DATA_OUT_EP, (uint8_t*) usb_rx_buffer, RNDIS_DATA_OUT_SZ);
109108
SetEPRxCount(CDC_DAT_EP_OUT_IDX, CDC_DATA_SIZE);
110109
SetEPRxStatus(CDC_DAT_EP_OUT_IDX, EP_RX_VALID);
111110
}

‎lib/dhcp-server/dhserver.h

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include "lwip/udp.h"
4040
#include "netif/etharp.h"
4141

42+
#define PORT_DHCP 67
43+
4244
typedef struct dhcp_entry
4345
{
4446
uint8_t mac[6];

‎lib/dns-server/dnserver.h

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#include "lwip/udp.h"
3434

35+
#define PORT_DNS 53
36+
3537
typedef uint32_t (*dns_query_proc_t)(const char *name, ip_addr_t *addr);
3638

3739
err_t dnserv_init(const ip_addr_t *bind, uint16_t port, dns_query_proc_t query_proc);

‎lib/lwip_port/netconf.c

+15-7
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,32 @@
1111
#include "lwip/init.h"
1212
#include "netif/ethernet.h"
1313

14-
struct netif rndis_netif;
14+
struct netif rndis_netif; //network interface
1515
const ip_addr_t ipaddr = IPADDR4_INIT_BYTES(IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
1616
const ip_addr_t netmask = IPADDR4_INIT_BYTES(NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
1717
const ip_addr_t gateway = IPADDR4_INIT_BYTES(GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
1818

1919
#include "dhserver.h"
2020
static dhcp_entry_t entries[] =
2121
{
22-
/* mac ip address subnet mask lease time */
23-
{ {0}, IPADDR4_INIT_BYTES(192, 168, 7, 2), IPADDR4_INIT_BYTES(255, 255, 255, 0), 24 * 60 * 60 },
24-
{ {0}, IPADDR4_INIT_BYTES(192, 168, 7, 3), IPADDR4_INIT_BYTES(255, 255, 255, 0), 24 * 60 * 60 },
25-
{ {0}, IPADDR4_INIT_BYTES(192, 168, 7, 4), IPADDR4_INIT_BYTES(255, 255, 255, 0), 24 * 60 * 60 }
22+
{
23+
{0},
24+
IPADDR4_INIT_BYTES(IP_ADDR0, IP_ADDR1, IP_ADDR2, DHCP_ADDR_1),
25+
IPADDR4_INIT_BYTES(NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3),
26+
24 * 60 * 60
27+
},
28+
{
29+
{0},
30+
IPADDR4_INIT_BYTES(IP_ADDR0, IP_ADDR1, IP_ADDR2, DHCP_ADDR_2),
31+
IPADDR4_INIT_BYTES(NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3),
32+
24 * 60 * 60
33+
},
2634
};
2735

2836
static dhcp_config_t dhcp_config =
2937
{
3038
&ipaddr, /* server address */
31-
67, /* port */
39+
PORT_DHCP, /* port */
3240
&ipaddr, /* dns server */
3341
"stm", /* dns suffix */
3442
sizeof(entries) / sizeof(entries[0]), /* entry count */
@@ -65,7 +73,7 @@ void LwIP_Init(void)
6573

6674
while (dhserv_init(&dhcp_config)) ;
6775

68-
while (dnserv_init(&ipaddr, 53, dns_query_proc)) ;
76+
while (dnserv_init(&ipaddr, PORT_DNS, dns_query_proc)) ;
6977
}
7078

7179
/**

0 commit comments

Comments
 (0)
Please sign in to comment.