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
Usermode/libc - Fix and unit test strtoull/* behavior (edge cases)
[tpg/acess2.git]
/
Usermode
/
Applications
/
ip_src
/
routes.c
diff --git
a/Usermode/Applications/ip_src/routes.c
b/Usermode/Applications/ip_src/routes.c
index
f074bff
..
a5f682c
100644
(file)
--- a/
Usermode/Applications/ip_src/routes.c
+++ b/
Usermode/Applications/ip_src/routes.c
@@
-12,7
+12,7
@@
// === PROTOTYPES ===
int Routes_main(int argc, char *argv[]);
void DumpRoutes(void);
// === PROTOTYPES ===
int Routes_main(int argc, char *argv[]);
void DumpRoutes(void);
-void DumpRoute(const char *Name);
+void DumpRoute(
int PFD,
const char *Name);
void AddRoute(const char *Interface, int AddressType, void *Dest, int MaskBits, int Metric, void *NextHop);
// === CODE ===
void AddRoute(const char *Interface, int AddressType, void *Dest, int MaskBits, int Metric, void *NextHop);
// === CODE ===
@@
-50,15
+50,15
@@
int Routes_main(int argc, char *argv[])
}
// Destination IP
}
// Destination IP
- addrType = ParseIPAddress(argv[
3
], dest, &subnetBits);
+ addrType = ParseIPAddress(argv[
2
], dest, &subnetBits);
if( subnetBits == -1 ) {
subnetBits = Net_GetAddressSize(addrType)*8;
}
// Interface Name / Next Hop
if( subnetBits == -1 ) {
subnetBits = Net_GetAddressSize(addrType)*8;
}
// Interface Name / Next Hop
- if( (nextHopType = ParseIPAddress(argv[
4
], nextHop, &nextHopBits)) == 0 )
+ if( (nextHopType = ParseIPAddress(argv[
3
], nextHop, &nextHopBits)) == 0 )
{
// Interface name
{
// Interface name
- ifaceName = argv[
4
];
+ ifaceName = argv[
3
];
}
else
{
}
else
{
@@
-78,8
+78,8
@@
int Routes_main(int argc, char *argv[])
// Metric
if( argc - 3 >= 3 )
{
// Metric
if( argc - 3 >= 3 )
{
- metric = atoi(argv[
5
]);
- if( metric == 0 && argv[
5
][0] != '0' ) {
+ metric = atoi(argv[
4
]);
+ if( metric == 0 && argv[
4
][0] != '0' ) {
fprintf(stderr, "ERROR: Metric should be a number\n");
return -1;
}
fprintf(stderr, "ERROR: Metric should be a number\n");
return -1;
}
@@
-114,33
+114,30
@@
void DumpRoutes(void)
int dp;
char filename[FILENAME_MAX+1];
int dp;
char filename[FILENAME_MAX+1];
- dp =
o
pen(IPSTACK_ROOT"/routes", OPENFLAG_READ);
+ dp =
_SysO
pen(IPSTACK_ROOT"/routes", OPENFLAG_READ);
printf("Type\tNetwork \tGateway \tMetric\tIFace\n");
printf("Type\tNetwork \tGateway \tMetric\tIFace\n");
- while( SysReadDir(dp, filename) )
+ while(
_
SysReadDir(dp, filename) )
{
if(filename[0] == '.') continue;
{
if(filename[0] == '.') continue;
- DumpRoute(filename);
+ DumpRoute(
dp,
filename);
}
}
-
c
lose(dp);
+
_SysC
lose(dp);
}
/**
* \brief Dump a route
*/
}
/**
* \brief Dump a route
*/
-void DumpRoute(const char *Name)
+void DumpRoute(
int PFD,
const char *Name)
{
int fd;
int type;
{
int fd;
int type;
- char path[sizeof(IPSTACK_ROOT)+8+FILENAME_MAX+1] = IPSTACK_ROOT"/routes/";
- strcat(path, Name);
-
- fd = open(path, OPENFLAG_READ);
+ fd = _SysOpenChild(PFD, Name, OPENFLAG_READ);
if(fd == -1) {
if(fd == -1) {
- printf("%s:\tUnable to open
('%s')\n", Name, path
);
+ printf("%s:\tUnable to open
\n", Name
);
return ;
}
return ;
}
@@
-161,7
+158,7
@@
void DumpRoute(const char *Name)
subnet = atoi(Name+ofs);
ofs ++;
metric = atoi(Name+ofs);
subnet = atoi(Name+ofs);
ofs ++;
metric = atoi(Name+ofs);
-
ioctl(fd, ioc
tl(fd, 3, "get_nexthop"), gw); // Get Gateway/NextHop
+
_SysIOCtl(fd, _SysIOC
tl(fd, 3, "get_nexthop"), gw); // Get Gateway/NextHop
// Get the address type
switch(type)
// Get the address type
switch(type)
@@
-185,17
+182,17
@@
void DumpRoute(const char *Name)
// Interface
{
// Interface
{
- int call_num =
ioc
tl(fd, 3, "get_interface");
- int len =
ioc
tl(fd, call_num, NULL);
+ int call_num =
_SysIOC
tl(fd, 3, "get_interface");
+ int len =
_SysIOC
tl(fd, call_num, NULL);
char *buf = malloc(len+1);
char *buf = malloc(len+1);
-
ioc
tl(fd, call_num, buf);
+
_SysIOC
tl(fd, call_num, buf);
printf("'%s'\t", buf);
free(buf);
}
printf("\n");
printf("'%s'\t", buf);
free(buf);
}
printf("\n");
-
c
lose(fd);
+
_SysC
lose(fd);
}
void AddRoute(const char *Interface, int AddressType, void *Dest, int MaskBits, int Metric, void *NextHop)
}
void AddRoute(const char *Interface, int AddressType, void *Dest, int MaskBits, int Metric, void *NextHop)
@@
-227,20
+224,20
@@
void AddRoute(const char *Interface, int AddressType, void *Dest, int MaskBits,
// Open interface
strcpy(ifacePath, IPSTACK_ROOT"/");
strcat(ifacePath, Interface);
// Open interface
strcpy(ifacePath, IPSTACK_ROOT"/");
strcat(ifacePath, Interface);
- fd =
o
pen(ifacePath, 0);
+ fd =
_SysO
pen(ifacePath, 0);
if( fd == -1 ) {
fprintf(stderr, "Error: Interface '%s' does not exist\n", Interface);
return ;
}
// Get and check type
if( fd == -1 ) {
fprintf(stderr, "Error: Interface '%s' does not exist\n", Interface);
return ;
}
// Get and check type
- num =
ioctl(fd, ioc
tl(fd, 3, "getset_type"), NULL);
+ num =
_SysIOCtl(fd, _SysIOC
tl(fd, 3, "getset_type"), NULL);
if( num != AddressType ) {
fprintf(stderr, "Error: Passed type does not match interface type (%i != %i)\n",
AddressType, num);
return ;
}
if( num != AddressType ) {
fprintf(stderr, "Error: Passed type does not match interface type (%i != %i)\n",
AddressType, num);
return ;
}
-
c
lose(fd);
+
_SysC
lose(fd);
}
// Create route
}
// Create route
@@
-256,23
+253,23
@@
void AddRoute(const char *Interface, int AddressType, void *Dest, int MaskBits,
sprintf(path+ofs, ":%i:%i", MaskBits, Metric);
}
sprintf(path+ofs, ":%i:%i", MaskBits, Metric);
}
- fd =
o
pen(path, 0);
+ fd =
_SysO
pen(path, 0);
if( fd != -1 ) {
if( fd != -1 ) {
-
c
lose(fd);
+
_SysC
lose(fd);
fprintf(stderr, "Unable to create route '%s', already exists\n", path);
return ;
}
fprintf(stderr, "Unable to create route '%s', already exists\n", path);
return ;
}
- fd =
o
pen(path, OPENFLAG_CREATE, 0);
+ fd =
_SysO
pen(path, OPENFLAG_CREATE, 0);
if( fd == -1 ) {
fprintf(stderr, "Unable to create '%s'\n", path);
return ;
}
if( NextHop )
if( fd == -1 ) {
fprintf(stderr, "Unable to create '%s'\n", path);
return ;
}
if( NextHop )
-
ioctl(fd, ioc
tl(fd, 3, "set_nexthop"), NextHop);
-
ioctl(fd, ioc
tl(fd, 3, "set_interface"), (void*)Interface);
+
_SysIOCtl(fd, _SysIOC
tl(fd, 3, "set_nexthop"), NextHop);
+
_SysIOCtl(fd, _SysIOC
tl(fd, 3, "set_interface"), (void*)Interface);
-
c
lose(fd);
+
_SysC
lose(fd);
// Check if the interface name was allocated by us
if( ifaceToFree )
// Check if the interface name was allocated by us
if( ifaceToFree )
UCC
git Repository :: git.ucc.asn.au