git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
AcessNative - Changes to allow _compiling_ on windows.
[tpg/acess2.git]
/
Usermode
/
Libraries
/
libnet.so_src
/
main.c
diff --git
a/Usermode/Libraries/libnet.so_src/main.c
b/Usermode/Libraries/libnet.so_src/main.c
index
938d114
..
2adaf1b
100644
(file)
--- a/
Usermode/Libraries/libnet.so_src/main.c
+++ b/
Usermode/Libraries/libnet.so_src/main.c
@@
-11,6
+11,7
@@
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
+
// === CODE ===
int SoMain(void)
{
// === CODE ===
int SoMain(void)
{
@@
-43,17
+44,18
@@
char *Net_GetInterface(int AddressType, void *Address)
// Query the route manager for the route number
{
char buf[sizeof(int)+size];
// Query the route manager for the route number
{
char buf[sizeof(int)+size];
+ uint32_t *type = (void*)buf;
// Open
fd = open("/Devices/ip/routes", 0);
if( !fd ) {
// Open
fd = open("/Devices/ip/routes", 0);
if( !fd ) {
- fprintf(stderr, "ERROR:
It seems that '/Devices/ip/routes' does not exist, are you running Acess2?
\n");
+ fprintf(stderr, "ERROR:
Unable to open '/Devices/ip/routes'
\n");
return NULL;
}
// Make structure and ask
return NULL;
}
// Make structure and ask
- *
(int*)buf
= AddressType;
- memcpy(
&buf[sizeof(int)]
, Address, size);
+ *
type
= AddressType;
+ memcpy(
type+1
, Address, size);
routeNum = ioctl(fd, ioctl(fd, 3, "locate_route"), buf);
// Close
routeNum = ioctl(fd, ioctl(fd, 3, "locate_route"), buf);
// Close
@@
-62,15
+64,18
@@
char *Net_GetInterface(int AddressType, void *Address)
// Check answer validity
if( routeNum > 0 ) {
// Check answer validity
if( routeNum > 0 ) {
- int len = sprintf(NULL, "/Devices/ip/routes/%i", routeNum);
+ int len = sprintf(NULL, "/Devices/ip/routes/
#
%i", routeNum);
char buf[len+1];
char *ret;
char buf[len+1];
char *ret;
- sprintf(buf, "/Devices/ip/routes/%i", routeNum);
+ sprintf(buf, "/Devices/ip/routes/
#
%i", routeNum);
// Open route
fd = open(buf, 0);
// Open route
fd = open(buf, 0);
- if( !fd ) return NULL; // Shouldn't happen :/
+ if( fd == -1 ) {
+ fprintf(stderr, "Net_GetInterface - ERROR: Unable to open %s\n", buf);
+ return NULL; // Shouldn't happen :/
+ }
// Allocate space for name
ret = malloc( ioctl(fd, ioctl(fd, 3, "get_interface"), NULL) + 1 );
// Allocate space for name
ret = malloc( ioctl(fd, ioctl(fd, 3, "get_interface"), NULL) + 1 );
UCC
git Repository :: git.ucc.asn.au