mirror of
https://github.com/drasko/open-ameba.git
synced 2024-11-21 21:44:19 +00:00
add netif, dhcp, netbios, mDSN names
This commit is contained in:
parent
255332ad03
commit
30329bd439
18 changed files with 2352 additions and 2319 deletions
|
@ -16,7 +16,7 @@
|
|||
#include <wifi/wifi_conf.h>
|
||||
#include <wifi/wifi_util.h>
|
||||
|
||||
rtw_mode_t wifi_mode = RTW_MODE_STA;
|
||||
extern rtw_mode_t wifi_mode; // = RTW_MODE_STA;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -481,6 +481,12 @@ struct pbuf *udp_packet_buffer, struct ip_addr *sender_addr, uint16_t sender_por
|
|||
pbuf_free(udp_packet_buffer);
|
||||
}
|
||||
|
||||
void dhcps_set_addr_pool(int addr_pool_set, struct ip_addr * addr_pool_start, struct ip_addr *addr_pool_end)
|
||||
{
|
||||
dhcps_ip4addr_pool_start = ip4_addr4(addr_pool_start);
|
||||
dhcps_ip4addr_pool_end = ip4_addr4(addr_pool_end);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize dhcp server.
|
||||
* @param None.
|
||||
|
|
|
@ -89,6 +89,13 @@
|
|||
|
||||
static void arp_timer(void *arg);
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
char lwip_host_name[NET_IF_NUM][LWIP_NETIF_HOSTNAME_SIZE] = {
|
||||
DEF_HOSTNAME"0",
|
||||
DEF_HOSTNAME"1",
|
||||
DEF_HOSTNAME"2"
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* In this function, the hardware should be initialized.
|
||||
|
@ -132,8 +139,6 @@ static void low_level_init(struct netif *netif)
|
|||
|
||||
static err_t low_level_output(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
|
||||
|
||||
/* Refer to eCos lwip eth_drv_send() */
|
||||
struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
|
||||
int sg_len = 0;
|
||||
|
@ -294,9 +299,9 @@ err_t ethernetif_init(struct netif *netif)
|
|||
#if LWIP_NETIF_HOSTNAME
|
||||
/* Initialize interface hostname */
|
||||
if(netif->name[1] == '0')
|
||||
netif->hostname = "lwip0";
|
||||
netif->hostname = lwip_host_name[0];
|
||||
else if(netif->name[1] == '1')
|
||||
netif->hostname = "lwip1";
|
||||
netif->hostname = lwip_host_name[1];
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
netif->output = etharp_output;
|
||||
|
@ -312,13 +317,14 @@ err_t ethernetif_init(struct netif *netif)
|
|||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_ETHERNET
|
||||
err_t ethernetif_mii_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
netif->hostname = "lwip2";
|
||||
netif->hostname = lwip_host_name[2];
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
netif->output = etharp_output;
|
||||
|
@ -335,6 +341,7 @@ err_t ethernetif_mii_init(struct netif *netif)
|
|||
return ERR_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void arp_timer(void *arg)
|
||||
{
|
||||
etharp_tmr();
|
||||
|
|
|
@ -2,9 +2,17 @@
|
|||
#define __ETHERNETIF_H__
|
||||
|
||||
|
||||
#include "autoconf.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
#ifndef LWIP_NETIF_HOSTNAME_SIZE
|
||||
#define LWIP_NETIF_HOSTNAME_SIZE 16
|
||||
#endif
|
||||
extern char lwip_host_name[NET_IF_NUM][LWIP_NETIF_HOSTNAME_SIZE];
|
||||
#endif
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Ethernet Buffer
|
||||
//----- ------------------------------------------------------------------
|
||||
|
|
|
@ -25,12 +25,12 @@ uint32_t mDNSPlatformInetAddr(char *cp)
|
|||
|
||||
// Mandatory function to get hostname
|
||||
// called when mDNS initialization
|
||||
char *mDNSPlatformHostname(void)
|
||||
_WEAK char *mDNSPlatformHostname(void)
|
||||
{
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
return xnetif[0].hostname;
|
||||
#else
|
||||
return "ameba";
|
||||
return DEF_HOSTNAME;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "rtl8195a/rtl_common.h"
|
||||
#include "rtl8195a.h"
|
||||
|
||||
#include "lwip/opt.h"
|
||||
//#include "lwip/opt.h"
|
||||
#include "netbios/netbios.h"
|
||||
|
||||
#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */
|
||||
|
@ -52,9 +52,9 @@
|
|||
#define NETBIOS_CODE_ATTR
|
||||
#define NETBIOS_DATA_ATTR
|
||||
|
||||
//extern struct netif xnetif[NET_IF_NUM];
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
|
||||
#define NBS_DEF_NAME "rtl871x"
|
||||
#define NBS_DEF_NAME DEF_HOSTNAME
|
||||
|
||||
/** This is an example implementation of a NetBIOS name server.
|
||||
* It responds to name queries for a configurable name.
|
||||
|
@ -163,6 +163,10 @@ PACK_STRUCT_END
|
|||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
|
||||
//#define toupper(CH) \
|
||||
// (((CH) >= 'a' && (CH) <= 'z') ? ((CH) - 'a' + 'A') : (CH))
|
||||
|
||||
|
||||
/** NetBIOS decoding name */
|
||||
static int8_t NETBIOS_CODE_ATTR NBNS_decode(char *dst, char *src)
|
||||
{
|
||||
|
@ -346,41 +350,30 @@ bool NETBIOS_CODE_ATTR netbios_off(void) {
|
|||
|
||||
void NETBIOS_CODE_ATTR netbios_init(void) {
|
||||
struct udp_pcb *pcb;
|
||||
char buf[] = "a"NBS_DEF_NAME;
|
||||
#if NET_IF_NUM > 0
|
||||
if (netbios_name[0][0] == 0) {
|
||||
buf[0] = 'a'; // SoftAP
|
||||
netbios_set_name(0, buf);
|
||||
}
|
||||
#endif
|
||||
#if NET_IF_NUM > 1
|
||||
if (netbios_name[1][0] == 0) {
|
||||
buf[0] = 's'; // Station
|
||||
netbios_set_name(1, buf);
|
||||
}
|
||||
#endif
|
||||
#if NET_IF_NUM > 2
|
||||
if (netbios_name[2][0] == 0) {
|
||||
buf[0] = 'e'; // Ethernet
|
||||
netbios_set_name(2, buf);
|
||||
}
|
||||
#endif
|
||||
#if NET_IF_NUM > 3
|
||||
#error "NBNS: Add NETBIOS Name!"
|
||||
#endif
|
||||
char buf[NETBIOS_NAME_LEN];
|
||||
if (netbios_pcb() != NULL)
|
||||
return;
|
||||
|
||||
#if DEBUGSOO > 1
|
||||
#if NET_IF_NUM > 2
|
||||
// os_printf("NetBIOS init, name AP: '%s', ST: '%s', Eth: '%s'\n", netbios_name[0], netbios_name[1], netbios_name[2]);
|
||||
os_printf("NetBIOS init, interface 0: '%s', 1: '%s', 2: '%s'\n", netbios_name[0], netbios_name[1], netbios_name[2]);
|
||||
#elif NET_IF_NUM > 1
|
||||
// os_printf("NetBIOS init, name AP: '%s', ST: '%s'\n", netbios_name[0], netbios_name[1]);
|
||||
os_printf("NetBIOS init, interface 0: '%s', 1: '%s'\n", netbios_name[0], netbios_name[1]);
|
||||
#else
|
||||
os_printf("NetBIOS init\n");
|
||||
for(int i = 0; i < NET_IF_NUM; i++) {
|
||||
if (netbios_name[i][0] == 0) {
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
if(xnetif[i].hostname != 0) {
|
||||
netbios_set_name(i, xnetif[i].hostname);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
sprintf(buf, NBS_DEF_NAME "%d", i);
|
||||
netbios_set_name(i, buf);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#if DEBUGSOO > 1
|
||||
os_printf("NetBIOS init, interface ");
|
||||
for(int i = 0; i < NET_IF_NUM; i++) {
|
||||
os_printf("%d: '%s' ", i, netbios_name[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
pcb = udp_new();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef __NETBIOS_H__
|
||||
#define __NETBIOS_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/** default port number for "NetBIOS Name service */
|
||||
#define NETBIOS_PORT 137
|
||||
|
||||
|
@ -15,7 +17,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#if LWIP_NETIF_HOSTNAME
|
||||
extern char netbios_name[NET_IF_NUM][NETBIOS_NAME_LEN + 1]; // default netifs/interfacenum: 0 - SoftAP, 1 - Station, 2 - Ethernet
|
||||
//#endif
|
||||
|
||||
// struct udp_pcb * netbios_pcb(void);
|
||||
void netbios_init(void);
|
||||
|
|
|
@ -292,14 +292,15 @@ int sscanf(const char *buf, const char *fmt, ...) {
|
|||
return i;
|
||||
}
|
||||
|
||||
#define TOUPPER(CH) \
|
||||
(((CH) >= 'a' && (CH) <= 'z') ? ((CH) - 'a' + 'A') : (CH))
|
||||
char toupper(char ch) {
|
||||
return ((ch >= 'a' && ch <= 'z') ? ch - 'a' + 'A' : ch);
|
||||
};
|
||||
|
||||
int _stricmp (const char *s1, const char *s2)
|
||||
{
|
||||
while (*s2 != 0 && TOUPPER (*s1) == TOUPPER (*s2))
|
||||
while (*s2 != 0 && toupper(*s1) == toupper(*s2))
|
||||
s1++, s2++;
|
||||
return (int) (TOUPPER (*s1) - TOUPPER (*s2));
|
||||
return (int) (toupper(*s1) - toupper(*s2));
|
||||
}
|
||||
|
||||
unsigned long long __aeabi_llsr(unsigned long long val, unsigned int shift)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4534
build/obj/build.nmap
4534
build/obj/build.nmap
File diff suppressed because it is too large
Load diff
13
flasher.mk
13
flasher.mk
|
@ -70,6 +70,7 @@ RAM_IMAGE?= $(BIN_DIR)/ram.bin
|
|||
|
||||
RAM1_IMAGE ?= $(BIN_DIR)/ram_1.bin
|
||||
RAM1P_IMAGE ?= $(BIN_DIR)/ram_1.p.bin
|
||||
RAM1R_IMAGE ?= $(BIN_DIR)/ram_1.r.bin
|
||||
|
||||
RAM2_IMAGE = $(BIN_DIR)/ram_2.bin
|
||||
RAM2P_IMAGE = $(BIN_DIR)/ram_2.p.bin
|
||||
|
@ -97,10 +98,10 @@ all: $(ELFFILE) $(OTA_IMAGE) $(FLASH_IMAGE) _endgenbin
|
|||
mp: $(ELFFILE) $(OTA_IMAGE) $(FLASH_IMAGE) _endgenbin
|
||||
|
||||
copybin1:
|
||||
cp $(patsubst sdk/%,$(SDK_PATH)%,$(BOOTS))/ram_1.r.bin $(BIN_DIR)/ram_1.r.bin
|
||||
# cp $(patsubst sdk/%,$(SDK_PATH)%,$(BOOTS))/ram_1.r.bin $(BIN_DIR)/ram_1.r.bin
|
||||
cp $(patsubst sdk/%,$(SDK_PATH)%,$(BOOTS))/ram_1.p.bin $(BIN_DIR)/ram_1.p.bin
|
||||
# @chmod 777 $(OBJ_DIR)/ram_1.r.bin
|
||||
@$(OBJCOPY) --rename-section .data=.loader.data,contents,alloc,load,readonly,data -I binary -O elf32-littlearm -B arm $(BIN_DIR)/ram_1.r.bin $(OBJ_DIR)/ram_1.r.o
|
||||
# @$(OBJCOPY) --rename-section .data=.loader.data,contents,alloc,load,readonly,data -I binary -O elf32-littlearm -B arm $(BIN_DIR)/ram_1.r.bin $(OBJ_DIR)/ram_1.r.o
|
||||
|
||||
genbin1: $(ELFFILE) $(RAM1P_IMAGE)
|
||||
|
||||
|
@ -172,11 +173,11 @@ $(OTA_IMAGE): $(RAM2NS_IMAGE) $(RAM3_IMAGE)
|
|||
|
||||
$(RAM1P_IMAGE): $(ELFFILE) $(NMAPFILE)
|
||||
@echo "==========================================================="
|
||||
@echo "Create image1p ($(RAM1P_IMAGE))"
|
||||
@echo "Create image1r ($(RAM1R_IMAGE))"
|
||||
# @echo "===========================================================" .bootloader
|
||||
ifdef COMPILED_BOOT
|
||||
@mkdir -p $(BIN_DIR)
|
||||
@rm -f $(RAM1_IMAGE) $(RAM1P_IMAGE)
|
||||
@rm -f $(RAM1_IMAGE) $(RAM1R_IMAGE)
|
||||
ifdef COMPILED_BOOT_BIN
|
||||
@$(eval RAM1_START_ADDR := $(shell grep _binary_build_bin_ram_1_r_bin_start $(NMAPFILE) | awk '{print $$1}'))
|
||||
@$(eval RAM1_END_ADDR := $(shell grep _binary_build_bin_ram_1_r_bin_end $(NMAPFILE) | awk '{print $$1}'))
|
||||
|
@ -192,14 +193,14 @@ ifdef COMPILED_BOOT_BIN
|
|||
else
|
||||
$(OBJCOPY) -j .rom_ram -Obinary $(ELFFILE) $(RAM_IMAGE)
|
||||
$(OBJCOPY) -j .ram.start.table -j .ram_image1.text -Obinary $(ELFFILE) $(RAM1_IMAGE)
|
||||
$(PICK) 0x$(RAM1_START_ADDR) 0x$(RAM1_END_ADDR) $(RAM1_IMAGE) $(RAM1P_IMAGE) head+reset_offset 0x0B000
|
||||
$(PICK) 0x$(RAM1_START_ADDR) 0x$(RAM1_END_ADDR) $(RAM1_IMAGE) $(RAM1R_IMAGE) head+reset_offset 0x0B000
|
||||
endif
|
||||
else
|
||||
$(error "BOOT-image size = 0")
|
||||
# $(error Flasher: COMPILE_BOOT = No)
|
||||
endif
|
||||
else
|
||||
@if [ -s $(RAM1P_IMAGE) ]; then echo "Use external $(RAM1P_IMAGE)!"; fi
|
||||
@if [ -s $(RAM1R_IMAGE) ]; then echo "Use external $(RAM1R_IMAGE)!"; fi
|
||||
endif
|
||||
|
||||
$(RAM2P_IMAGE): $(ELFFILE) $(NMAPFILE)
|
||||
|
|
|
@ -64,6 +64,17 @@
|
|||
#define IP_FRAG 1
|
||||
#define ARP_QUEUEING 0
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
|
||||
* field.
|
||||
*/
|
||||
#define LWIP_NETIF_HOSTNAME 1
|
||||
#define LWIP_NETIF_HOSTNAME_SIZE 16
|
||||
/**
|
||||
* netif0: DEF_HOSTNAME "0", netif1: DEF_HOSTNAME "1", ..
|
||||
*/
|
||||
#define DEF_HOSTNAME "rtl871x"
|
||||
|
||||
/**
|
||||
* NO_SYS==1: Provides VERY minimal functionality. Otherwise,
|
||||
* use lwIP facilities.
|
||||
|
|
|
@ -50,7 +50,7 @@ application: build_info $(SRC_O) $(DRAM_O) $(BOOT_O)
|
|||
# @echo "==========================================================="
|
||||
@mkdir -p $(BIN_DIR) $(OBJ_DIR)
|
||||
## @cp $(patsubst sdk/%,$(SDK_PATH)%,$(BOOTS))/ram_1.r.bin $(BIN_DIR)/ram_1.r.bin
|
||||
## @cp $(patsubst sdk/%,$(SDK_PATH)%,$(BOOTS))/ram_1.p.bin $(BIN_DIR)/ram_1.p.bin
|
||||
@cp $(patsubst sdk/%,$(SDK_PATH)%,$(BOOTS))/ram_1.p.bin $(BIN_DIR)/ram_1.p.bin
|
||||
# @chmod 777 $(OBJ_DIR)/ram_1.r.bin
|
||||
## $(OBJCOPY) --rename-section .data=.loader.data,contents,alloc,load,readonly,data -I binary -O elf32-littlearm -B arm $(BIN_DIR)/ram_1.r.bin $(OBJ_DIR)/ram_1.r.o
|
||||
@echo "==========================================================="
|
||||
|
|
Loading…
Reference in a new issue