mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-06-30 22:33:31 +08:00
net-setup: Add routing and old stack's configuration
This allows the old stack's configuration structures to be used unchanged even though this code currently does not support all of the options. It likely will never support all of the options as some should eventually come through configuration files as they would in a real FreeBSD system. Other configuration parameters are likely configurable via "hints".
This commit is contained in:
parent
4a3e48913b
commit
bd6dd6e233
@ -7,6 +7,7 @@ include $(PROJECT_ROOT)/make/leaf.cfg
|
||||
CFLAGS += -I $(INSTALL_BASE)/include
|
||||
#CFLAGS += -ffreestanding
|
||||
CFLAGS += -I include
|
||||
CFLAGS += -I rtems/include
|
||||
CFLAGS += -I lib/libc/include
|
||||
CFLAGS += -I sys
|
||||
CFLAGS += -I local
|
||||
@ -108,6 +109,8 @@ install: $(LIB)
|
||||
install -d $(INSTALL_BASE)/include
|
||||
cd include; for i in `find . -name '*.h'` ; do \
|
||||
install -c -m 644 -D "$$i" "$(INSTALL_BASE)/include/$$i" ; done
|
||||
cd rtems/include; for i in `find . -name '*.h'` ; do \
|
||||
install -c -m 644 -D "$$i" "$(INSTALL_BASE)/include/$$i" ; done
|
||||
install -c -m 644 $(LIB) $(INSTALL_BASE)
|
||||
|
||||
clean:
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/route.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
|
||||
static const struct sockaddr_in address_template = {
|
||||
sizeof(address_template),
|
||||
@ -18,6 +20,30 @@ static const struct sockaddr_in address_template = {
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
* Manipulate routing tables
|
||||
*/
|
||||
int rtems_bsdnet_rtrequest(
|
||||
int req,
|
||||
struct sockaddr *dst,
|
||||
struct sockaddr *gateway,
|
||||
struct sockaddr *netmask,
|
||||
int flags,
|
||||
struct rtentry **net_nrt
|
||||
)
|
||||
{
|
||||
int error;
|
||||
|
||||
// rtems_bsdnet_semaphore_obtain();
|
||||
error = rtrequest(req, dst, gateway, netmask, flags, net_nrt);
|
||||
// rtems_bsdnet_semaphore_release();
|
||||
if (error) {
|
||||
errno = error;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
rtems_bsdnet_initialize_sockaddr_in(struct sockaddr_in *addr)
|
||||
{
|
||||
@ -235,6 +261,7 @@ static bool rtems_bsdnet_setup_interface(
|
||||
void rtems_initialize_interfaces(void)
|
||||
{
|
||||
bool any_if_configured;
|
||||
struct rtems_bsdnet_ifconfig *ifp;
|
||||
|
||||
any_if_configured = false;
|
||||
|
||||
@ -244,7 +271,6 @@ void rtems_initialize_interfaces(void)
|
||||
"255.0.0.0"
|
||||
);
|
||||
|
||||
#if 0
|
||||
|
||||
for (ifp = rtems_bsdnet_config.ifconfig ; ifp ; ifp = ifp->next) {
|
||||
if (ifp->ip_address == NULL)
|
||||
@ -256,6 +282,30 @@ void rtems_initialize_interfaces(void)
|
||||
ifp->ip_netmask
|
||||
);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Set default route
|
||||
*/
|
||||
if (rtems_bsdnet_config.gateway && any_if_configured) {
|
||||
struct sockaddr_in address;
|
||||
struct sockaddr_in netmask;
|
||||
struct sockaddr_in gateway;
|
||||
|
||||
rtems_bsdnet_initialize_sockaddr_in(&address);
|
||||
rtems_bsdnet_initialize_sockaddr_in(&netmask);
|
||||
rtems_bsdnet_initialize_sockaddr_in(&gateway);
|
||||
|
||||
gateway.sin_addr.s_addr = inet_addr (rtems_bsdnet_config.gateway);
|
||||
|
||||
if (rtems_bsdnet_rtrequest (
|
||||
RTM_ADD,
|
||||
(struct sockaddr *)&address,
|
||||
(struct sockaddr *)&gateway,
|
||||
(struct sockaddr *)&netmask,
|
||||
(RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL) < 0) {
|
||||
printf ("Can't set default route: %s\n", strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -88,7 +88,7 @@
|
||||
/* Networking */
|
||||
#define IPSEC 1
|
||||
#define INET 1
|
||||
#define INET6 1
|
||||
// #define INET6 1
|
||||
#define TCP_SIGNATURE 1
|
||||
|
||||
/* Integer type definitions */
|
||||
|
Loading…
x
Reference in New Issue
Block a user