Our netstack works now! I used Vision and Net+ and it did not crash!!!
But I would not consider it stable. Not tested on R5 net_server, only BONE (replaced BONE stack)! Not compatible to BONE applications (you must use net_server apps or OBOS apps)! Removed debug output from compat.c. Fixed DNS bug (well, it's very hacky). NOTE FOR BONE USERS: Uncomment the definition of BONE_VERSION in select.c! git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7185 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
/* These routines are included in libnet simply because R5 expects them
|
/* These routines are included in libnet simply because R5 expects them
|
||||||
* to be there. They should mostly be no-ops...
|
* to be there. They should mostly be no-ops...
|
||||||
|
* Some of them are hacks! We must fix this!!!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -75,15 +76,17 @@ _EXPORT int _netconfig_find(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* XXX: HACK HACK HACK! FIXME! */
|
||||||
/* This is a terrible hack :(
|
/* This is a terrible hack :(
|
||||||
* We should really get these settings values by parsing $HOME/config/settings/network file, which
|
* TODO: We should really get these settings values by parsing
|
||||||
* will make both R5 and BONE compatible
|
* $HOME/config/settings/network file, which will make both R5 and BONE compatible.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_EXPORT char * find_net_setting(net_settings * ncw, const char * heading, const char * name, char * value, unsigned nbytes)
|
_EXPORT char * find_net_setting(net_settings * ncw, const char * heading,
|
||||||
|
const char * name, char * value, unsigned nbytes)
|
||||||
{
|
{
|
||||||
|
// printf("find_net_setting\n");
|
||||||
printf("find_net_setting\n");
|
|
||||||
|
|
||||||
if (strcmp(heading, "GLOBAL") != 0)
|
if (strcmp(heading, "GLOBAL") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -101,7 +104,8 @@ _EXPORT char * find_net_setting(net_settings * ncw, const char * heading, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_EXPORT status_t set_net_setting(net_settings * ncw, const char * heading, const char * name, const char * value)
|
_EXPORT status_t set_net_setting(net_settings * ncw, const char * heading,
|
||||||
|
const char * name, const char * value)
|
||||||
{
|
{
|
||||||
printf("set_net_setting\n");
|
printf("set_net_setting\n");
|
||||||
return B_UNSUPPORTED;
|
return B_UNSUPPORTED;
|
||||||
@@ -110,7 +114,7 @@ _EXPORT status_t set_net_setting(net_settings * ncw, const char * heading, const
|
|||||||
|
|
||||||
_EXPORT int gethostname(char * name, size_t length)
|
_EXPORT int gethostname(char * name, size_t length)
|
||||||
{
|
{
|
||||||
printf("gethostname\n");
|
// printf("gethostname\n");
|
||||||
if (find_net_setting(NULL, "GLOBAL", "HOSTNAME", name, length) == NULL)
|
if (find_net_setting(NULL, "GLOBAL", "HOSTNAME", name, length) == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
@@ -120,7 +124,7 @@ _EXPORT int gethostname(char * name, size_t length)
|
|||||||
|
|
||||||
_EXPORT int getusername(char * name, size_t length)
|
_EXPORT int getusername(char * name, size_t length)
|
||||||
{
|
{
|
||||||
printf("getusername\n");
|
// printf("getusername\n");
|
||||||
if (find_net_setting(NULL, "GLOBAL", "USERNAME", name, length) == NULL)
|
if (find_net_setting(NULL, "GLOBAL", "USERNAME", name, length) == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
@@ -130,7 +134,7 @@ _EXPORT int getusername(char * name, size_t length)
|
|||||||
|
|
||||||
_EXPORT int getpassword(char * pwd, size_t length)
|
_EXPORT int getpassword(char * pwd, size_t length)
|
||||||
{
|
{
|
||||||
printf("getpassword\n");
|
// printf("getpassword\n");
|
||||||
if (find_net_setting(NULL, "GLOBAL", "PASSWORD", pwd, length) == NULL)
|
if (find_net_setting(NULL, "GLOBAL", "PASSWORD", pwd, length) == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
#include "net_stack_driver.h"
|
#include "net_stack_driver.h"
|
||||||
|
|
||||||
|
// uncomment this line if you have BONE
|
||||||
|
// #define BONE_VERSION 1
|
||||||
|
|
||||||
#ifndef BONE_VERSION
|
#ifndef BONE_VERSION
|
||||||
|
|
||||||
static int fd_set_count(fd_set * bits, int nbits)
|
static int fd_set_count(fd_set * bits, int nbits)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ _EXPORT int socket(int family, int type, int protocol)
|
|||||||
/* also convert AF_INET */
|
/* also convert AF_INET */
|
||||||
if (family == 1)
|
if (family == 1)
|
||||||
family = AF_INET;
|
family = AF_INET;
|
||||||
};
|
}
|
||||||
|
|
||||||
args.u.socket.family = family;
|
args.u.socket.family = family;
|
||||||
args.u.socket.type = type;
|
args.u.socket.type = type;
|
||||||
@@ -126,7 +126,16 @@ _EXPORT int connect(int sock, const struct sockaddr *addr, int addrlen)
|
|||||||
struct sockaddr temp;
|
struct sockaddr temp;
|
||||||
struct stack_driver_args args;
|
struct stack_driver_args args;
|
||||||
|
|
||||||
if (g_beos_r5_compatibility) {
|
// XXX: HACK! FIXME!
|
||||||
|
// Our DNS resolver uses the new stack codes, but old apps set R5 compatibility.
|
||||||
|
// So, resolving an address AFTER the app opens a socket fails because
|
||||||
|
// connect() thinks we are in compatibility mode and thus translates the
|
||||||
|
// new style address family into the old style (and sockaddr format).
|
||||||
|
// So, we check if the address family is our AF_INET (might indicate that we
|
||||||
|
// are using the new stack mixed with the old one.
|
||||||
|
// We can to solve this problem by making R5 compatibility socket-specific.
|
||||||
|
// This would need a new ioctl() for retrieving the socket mode.
|
||||||
|
if (g_beos_r5_compatibility && addr->sa_family != AF_INET) {
|
||||||
convert_from_beos_r5_sockaddr(&temp, addr);
|
convert_from_beos_r5_sockaddr(&temp, addr);
|
||||||
addr = &temp;
|
addr = &temp;
|
||||||
addrlen = sizeof(struct sockaddr_in);
|
addrlen = sizeof(struct sockaddr_in);
|
||||||
@@ -235,7 +244,8 @@ _EXPORT ssize_t sendto(int sock, const void *buffer, size_t buflen, int flags,
|
|||||||
struct msghdr mh;
|
struct msghdr mh;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
|
|
||||||
if (g_beos_r5_compatibility) {
|
// XXX: DNS HACK!
|
||||||
|
if (g_beos_r5_compatibility && addr->sa_family != AF_INET) {
|
||||||
convert_from_beos_r5_sockaddr(&temp, addr);
|
convert_from_beos_r5_sockaddr(&temp, addr);
|
||||||
addr = &temp;
|
addr = &temp;
|
||||||
addrlen = sizeof(struct sockaddr_in);
|
addrlen = sizeof(struct sockaddr_in);
|
||||||
|
|||||||
Reference in New Issue
Block a user