/daten/src/linux-2.4.27-rsbac-v1.2.3/rsbac/help/net_getname.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
#include <rsbac/types.h>
00012
#include <rsbac/getname.h>
00013
#include <rsbac/net_getname.h>
00014
#include <rsbac/helpers.h>
00015
#include <rsbac/error.h>
00016
00017
#ifdef __KERNEL__
00018
#include <linux/string.h>
00019
#include <linux/module.h>
00020
#else
00021
#include <linux/socket.h>
00022
#include <string.h>
00023
#endif
00024
00025 static char net_temp_syscall_list[
NTS_none+1][19] = {
00026
"new_template",
00027
"copy_template",
00028
"delete_template",
00029
"check_id",
00030
"get_address",
00031
"get_address_family",
00032
"get_valid_len",
00033
"get_type",
00034
"get_protocol",
00035
"get_netdev",
00036
"get_min_port",
00037
"get_max_port",
00038
"get_name",
00039
"set_address",
00040
"set_address_family",
00041
"set_valid_len",
00042
"set_type",
00043
"set_protocol",
00044
"set_netdev",
00045
"set_min_port",
00046
"set_max_port",
00047
"set_name",
00048
"none" };
00049
00050 static char net_family_list[
AF_MAX+1][19] = {
00051
"ANY",
00052
"UNIX",
00053
"INET",
00054
"AX25",
00055
"IPX",
00056
"APPLETALK",
00057
"NETROM",
00058
"BRIDGE",
00059
"ATMPVC",
00060
"X25",
00061
"INET6",
00062
"ROSE",
00063
"DECnet",
00064
"NETBEUI",
00065
"SECURITY",
00066
"KEY",
00067
"NETLINK",
00068
"PACKET",
00069
"ASH",
00070
"ECONET",
00071
"ATMSVC",
00072
"(undefined)",
00073
"SNA",
00074
"IRDA",
00075
"PPPOX",
00076
"WANPIPE",
00077
"(undefined)",
00078
"(undefined)",
00079
"(undefined)",
00080
"(undefined)",
00081
"(undefined)",
00082
"BLUETOOTH",
00083
"MAX" };
00084
00085 struct proto_desc_t
00086 {
00087 char name[19];
00088 int nr;
00089 };
00090 #define NR_PROTO 18
00091
00092 static struct proto_desc_t net_protocol_list[
NR_PROTO] = {
00093 {
"ANY", 0},
00094 {
"ICMP", 1},
00095 {
"IGMP", 2},
00096 {
"IPIP", 4},
00097 {
"TCP", 6},
00098 {
"EGP", 8},
00099 {
"PUP", 12},
00100 {
"UDP", 17},
00101 {
"IDP", 22},
00102 {
"RSVP", 46},
00103 {
"GRE", 47},
00104 {
"IPV6", 41},
00105 {
"PIM", 103},
00106 {
"ESP", 50},
00107 {
"AH", 51},
00108 {
"COMP", 108},
00109 {
"RAW", 255},
00110 {
"MAX",
RSBAC_NET_PROTO_MAX} };
00111
00112 static char rsbac_net_type_list[
RSBAC_NET_TYPE_MAX+1][19] = {
00113
"ANY",
00114
"STREAM",
00115
"DGRAM",
00116
"RAW",
00117
"RDM",
00118
"SEQPACKET",
00119
"(undefined)",
00120
"(undefined)",
00121
"(undefined)",
00122
"(undefined)",
00123
"PACKET",
00124
00125
00126
00127
00128
"MAX" };
00129
00130
00131
00132 char *
rsbac_get_net_temp_syscall_name(
char * name,
00133
enum rsbac_net_temp_syscall_t value)
00134 {
00135
if(!name)
00136
return(
NULL);
00137
if(value >
NTS_none)
00138 strcpy(name,
"ERROR!");
00139
else
00140 strcpy(name,
net_temp_syscall_list[value]);
00141
return(name);
00142 };
00143
00144
#ifndef __KERNEL__
00145 enum rsbac_net_temp_syscall_t rsbac_get_net_temp_syscall_nr(
const char * name)
00146 {
00147
enum rsbac_net_temp_syscall_t i;
00148
00149
if(!name)
00150
return(
NTS_none);
00151
for (i = 0; i <
NTS_none; i++)
00152 {
00153
if (!strcmp(name,
net_temp_syscall_list[i]))
00154 {
00155
return(i);
00156 }
00157 }
00158
return(
NTS_none);
00159 };
00160
#endif
00161
00162
#ifdef __KERNEL__
00163
#if defined(CONFIG_RSBAC_REG) || defined(CONFIG_RSBAC_REG_MAINT)
00164
EXPORT_SYMBOL(rsbac_get_net_family_name);
00165
#endif
00166
#endif
00167 char *
rsbac_get_net_family_name(
char * name,
00168 u_int value)
00169 {
00170
if(!name)
00171
return(
NULL);
00172
if(value >
AF_MAX)
00173 strcpy(name,
"ERROR!");
00174
else
00175 strcpy(name,
net_family_list[value]);
00176
return(name);
00177 };
00178
00179
#ifndef __KERNEL__
00180 int rsbac_get_net_family_nr(
const char * name)
00181 {
00182
int i;
00183
00184
if(!name)
00185
return(
AF_MAX);
00186
for (i = 0; i <
AF_MAX; i++)
00187 {
00188
if (!strcmp(name,
net_family_list[i]))
00189 {
00190
return(i);
00191 }
00192 }
00193
return(
AF_MAX);
00194 };
00195
#endif
00196
00197
#ifdef __KERNEL__
00198
#if defined(CONFIG_RSBAC_REG) || defined(CONFIG_RSBAC_REG_MAINT)
00199
EXPORT_SYMBOL(rsbac_get_net_protocol_name);
00200
#endif
00201
#endif
00202 char *
rsbac_get_net_protocol_name(
char * name,
00203 u_int value)
00204 {
00205
int i;
00206
00207
if(!name)
00208
return(
NULL);
00209
if(value >=
RSBAC_NET_PROTO_MAX)
00210 strcpy(name,
"ERROR!");
00211
else
00212 {
00213
for (i = 0; i <
NR_PROTO; i++)
00214 {
00215
if (
net_protocol_list[i].
nr == value)
00216 {
00217 strcpy(name,
net_protocol_list[i].name);
00218
return name;
00219 }
00220 }
00221 sprintf(name,
"%u", value);
00222 }
00223
return(name);
00224 };
00225
00226
#ifndef __KERNEL__
00227 int rsbac_get_net_protocol_nr(
const char * name)
00228 {
00229
int i;
00230
00231
if(!name)
00232
return(
RSBAC_NET_PROTO_MAX);
00233
for (i = 0; i <
NR_PROTO; i++)
00234 {
00235
if (!strcmp(name,
net_protocol_list[i].name))
00236 {
00237
return(
net_protocol_list[i].
nr);
00238 }
00239 }
00240
return(
RSBAC_NET_PROTO_MAX);
00241 };
00242
#endif
00243
00244
#ifdef __KERNEL__
00245
#if defined(CONFIG_RSBAC_REG) || defined(CONFIG_RSBAC_REG_MAINT)
00246
EXPORT_SYMBOL(rsbac_get_net_type_name);
00247
#endif
00248
#endif
00249 char *
rsbac_get_net_type_name(
char * name,
00250 u_int value)
00251 {
00252
if(!name)
00253
return(
NULL);
00254
if(value >
RSBAC_NET_TYPE_MAX)
00255 strcpy(name,
"ERROR!");
00256
else
00257 strcpy(name,
rsbac_net_type_list[value]);
00258
return(name);
00259 };
00260
00261
#ifndef __KERNEL__
00262 int rsbac_get_net_type_nr(
const char * name)
00263 {
00264
int i;
00265
00266
if(!name)
00267
return(
RSBAC_NET_TYPE_MAX);
00268
for (i = 0; i <
RSBAC_NET_TYPE_MAX; i++)
00269 {
00270
if (!strcmp(name,
rsbac_net_type_list[i]))
00271 {
00272
return(i);
00273 }
00274 }
00275
return(
RSBAC_NET_TYPE_MAX);
00276 };
00277
#endif
00278
00279
#ifdef __KERNEL__
00280
int rsbac_net_str_to_inet(
char * str, __u32 * addr)
00281 {
00282
char * end;
00283 __u32 s0,s1,s2,s3;
00284
00285
if(!str || !addr)
00286
return -
RSBAC_EINVALIDPOINTER;
00287 s0 = simple_strtoul(str, &end, 10);
00288
if(!*end || (s0 > 255))
00289
return -
RSBAC_EINVALIDVALUE;
00290 end++;
00291 s1 = simple_strtoul(end, &end, 10);
00292
if(!*end || (s1 > 255))
00293
return -
RSBAC_EINVALIDVALUE;
00294 end++;
00295 s2 = simple_strtoul(end, &end, 10);
00296
if(!*end || (s2 > 255))
00297
return -
RSBAC_EINVALIDVALUE;
00298 end++;
00299 s3 = simple_strtoul(end, &end, 10);
00300
if(*end || (s3 > 255))
00301
return -
RSBAC_EINVALIDVALUE;
00302 *addr = s0 | (s1 << 8) | (s2 << 16) | (s3 << 24);
00303
return 0;
00304 }
00305
#endif
Generated on Tue Aug 31 10:05:26 2004 for RSBAC by
1.3.8