Project

General

Profile

Bug #675 » netgraph-remove-xLEN.patch

nant, 06/03/2007 04:04 PM

View differences:

sys/dev/netif/ar/if_ar.c
int running; /* something is attached so we are running */
int dcd; /* do we have dcd? */
/* ---netgraph bits --- */
char nodename[NG_NODELEN + 1]; /* store our node name */
char nodename[NG_NODESIZ]; /* store our node name */
int datahooks; /* number of data hooks attached */
node_p node; /* netgraph node */
hook_p hook; /* data hook */
sys/dev/netif/mn/if_mn.c
char name[8];
u_int32_t falc_irq, falc_state, framer_state;
struct schan *ch[M32_CHAN];
char nodename[NG_NODELEN + 1];
char nodename[NG_NODESIZ];
node_p node;
u_long cnt_fec;
sys/dev/netif/sr/if_sr.c
int running; /* something is attached so we are running */
int dcd; /* do we have dcd? */
/* ---netgraph bits --- */
char nodename[NG_NODELEN + 1]; /* store our node name */
char nodename[NG_NODESIZ]; /* store our node name */
int datahooks; /* number of data hooks attached */
node_p node; /* netgraph node */
hook_p hook; /* data hook */
......
(*resp)->header.token = msg->header.token;
(*resp)->header.typecookie = NG_SR_COOKIE;
(*resp)->header.cmd = msg->header.cmd;
strncpy((*resp)->header.cmdstr, "status",
NG_CMDSTRLEN);
strlcpy((*resp)->header.cmdstr, "status",
NG_CMDSTRSIZ);
}
break;
default:
sys/netgraph/bpf/ng_bpf.h
/* Program structure for one hook */
struct ng_bpf_hookprog {
char thisHook[NG_HOOKLEN+1]; /* name of hook */
char ifMatch[NG_HOOKLEN+1]; /* match dest hook */
char ifNotMatch[NG_HOOKLEN+1]; /* !match dest hook */
char thisHook[NG_HOOKSIZ]; /* name of hook */
char ifMatch[NG_HOOKSIZ]; /* match dest hook */
char ifNotMatch[NG_HOOKSIZ]; /* !match dest hook */
int32_t bpf_prog_len; /* #isns in program */
struct bpf_insn bpf_prog[__ARRAY_ZERO]; /* bpf program */
};
......
enum {
NGM_BPF_SET_PROGRAM = 1, /* supply a struct ng_bpf_hookprog */
NGM_BPF_GET_PROGRAM, /* returns a struct ng_bpf_hookprog */
NGM_BPF_GET_STATS, /* supply name as char[NG_HOOKLEN+1] */
NGM_BPF_CLR_STATS, /* supply name as char[NG_HOOKLEN+1] */
NGM_BPF_GETCLR_STATS, /* supply name as char[NG_HOOKLEN+1] */
NGM_BPF_GET_STATS, /* supply name as char[NG_HOOKSIZ] */
NGM_BPF_CLR_STATS, /* supply name as char[NG_HOOKSIZ] */
NGM_BPF_GETCLR_STATS, /* supply name as char[NG_HOOKSIZ] */
};
#endif /* _NETGRAPH_BPF_H_ */
sys/netgraph/bridge/ng_bridge.c
static const char *
ng_bridge_nodename(node_p node)
{
static char name[NG_NODELEN+1];
static char name[NG_NODESIZ];
if (node->name != NULL)
ksnprintf(name, sizeof(name), "%s", node->name);
sys/netgraph/etf/ng_etf.h
/* This structure is returned by the NGM_ETF_GET_STATUS command */
struct ng_etffilter {
char matchhook[NG_HOOKLEN + 1]; /* hook name */
char matchhook[NG_HOOKSIZ]; /* hook name */
u_int16_t ethertype; /* this ethertype to this hook */
};
sys/netgraph/ksocket/ng_ksocket.c
LIST_ENTRY(ng_ksocket_private) siblings;
u_int32_t flags;
u_int32_t response_token;
char response_addr[NG_PATHLEN+1];
char response_addr[NG_PATHSIZ];
};
typedef struct ng_ksocket_private *priv_p;
......
struct thread *td = curthread->td_proc ? curthread : &thread0; /* XXX broken */
const priv_p priv = node->private;
struct ng_mesg *msg;
char *s1, *s2, name[NG_HOOKLEN+1];
char *s1, *s2, name[NG_HOOKSIZ];
int family, type, protocol, error;
/* Check if we're already connected */
sys/netgraph/netgraph/ng_base.c
static int
ng_load_module(const char *name)
{
char *path, filename[NG_TYPELEN + 4];
char *path, filename[NG_TYPESIZ + 3];
linker_file_t lf;
int error;
......
static int
ng_unload_module(const char *name)
{
char filename[NG_TYPELEN + 4];
char filename[NG_TYPESIZ + 3];
linker_file_t lf;
int error;
......
int i;
/* Check the name is valid */
for (i = 0; i < NG_NODELEN + 1; i++) {
for (i = 0; i < NG_NODESIZ; i++) {
if (name[i] == '\0' || name[i] == '.' || name[i] == ':')
break;
}
......
const size_t namelen = strlen(tp->name);
/* Check version and type name fields */
if (tp->version != NG_VERSION || namelen == 0 || namelen > NG_TYPELEN) {
if (tp->version != NG_VERSION || namelen == 0 || namelen >= NG_TYPESIZ) {
TRAP_ERROR;
return (EINVAL);
}
......
ng_path2node(node_p here, const char *address, node_p *destp, char **rtnp)
{
const node_p start = here;
char fullpath[NG_PATHLEN + 1];
char fullpath[NG_PATHSIZ];
char *nodename, *path, pbuf[2];
node_p node;
char *cp;
......
/* Now compute return address, i.e., the path to the sender */
if (rtnp != NULL) {
MALLOC(*rtnp, char *, NG_NODELEN + 2, M_NETGRAPH, M_NOWAIT);
MALLOC(*rtnp, char *, NG_NODESIZ + 1, M_NETGRAPH, M_NOWAIT);
if (*rtnp == NULL) {
TRAP_ERROR;
return (ENOMEM);
......
/* Fill in node info */
ni = (struct nodeinfo *) rp->data;
if (here->name != NULL)
strncpy(ni->name, here->name, NG_NODELEN);
strncpy(ni->type, here->type->name, NG_TYPELEN);
strlcpy(ni->name, here->name, NG_NODESIZ);
strlcpy(ni->type, here->type->name, NG_TYPESIZ);
ni->id = ng_node2ID(here);
ni->hooks = here->numhooks;
*resp = rp;
......
/* Fill in node info */
if (here->name)
strncpy(ni->name, here->name, NG_NODELEN);
strncpy(ni->type, here->type->name, NG_TYPELEN);
strlcpy(ni->name, here->name, NG_NODESIZ);
strlcpy(ni->type, here->type->name, NG_TYPESIZ);
ni->id = ng_node2ID(here);
/* Cycle through the linked list of hooks */
......
}
if ((hook->flags & HK_INVALID) != 0)
continue;
strncpy(link->ourhook, hook->name, NG_HOOKLEN);
strncpy(link->peerhook, hook->peer->name, NG_HOOKLEN);
strlcpy(link->ourhook, hook->name, NG_HOOKSIZ);
strlcpy(link->peerhook, hook->peer->name, NG_HOOKSIZ);
if (hook->peer->node->name != NULL)
strncpy(link->nodeinfo.name,
hook->peer->node->name, NG_NODELEN);
strncpy(link->nodeinfo.type,
hook->peer->node->type->name, NG_TYPELEN);
strlcpy(link->nodeinfo.name,
hook->peer->node->name, NG_NODESIZ);
strlcpy(link->nodeinfo.type,
hook->peer->node->type->name, NG_TYPESIZ);
link->nodeinfo.id = ng_node2ID(hook->peer->node);
link->nodeinfo.hooks = hook->peer->node->numhooks;
ni->hooks++;
......
if (!unnamed && node->name == NULL)
continue;
if (node->name != NULL)
strncpy(np->name, node->name, NG_NODELEN);
strncpy(np->type, node->type->name, NG_TYPELEN);
strlcpy(np->name, node->name, NG_NODESIZ);
strlcpy(np->type, node->type->name, NG_TYPESIZ);
np->id = ng_node2ID(node);
np->hooks = node->numhooks;
nl->numnames++;
......
__func__, "types");
break;
}
strncpy(tp->type_name, type->name, NG_TYPELEN);
strlcpy(tp->type_name, type->name, NG_TYPESIZ);
tp->numnodes = type->refs - 1; /* don't count list */
tl->numtypes++;
}
sys/netgraph/netgraph/ng_parse.c
};
const struct ng_parse_fixedstring_info ng_parse_nodebuf_info = {
NG_NODELEN + 1
NG_NODESIZ
};
const struct ng_parse_type ng_parse_nodebuf_type = {
&ng_parse_fixedstring_type,
......
};
const struct ng_parse_fixedstring_info ng_parse_hookbuf_info = {
NG_HOOKLEN + 1
NG_HOOKSIZ
};
const struct ng_parse_type ng_parse_hookbuf_type = {
&ng_parse_fixedstring_type,
......
};
const struct ng_parse_fixedstring_info ng_parse_pathbuf_info = {
NG_PATHLEN + 1
NG_PATHSIZ
};
const struct ng_parse_type ng_parse_pathbuf_type = {
&ng_parse_fixedstring_type,
......
};
const struct ng_parse_fixedstring_info ng_parse_typebuf_info = {
NG_TYPELEN + 1
NG_TYPESIZ
};
const struct ng_parse_type ng_parse_typebuf_type = {
&ng_parse_fixedstring_type,
......
};
const struct ng_parse_fixedstring_info ng_parse_cmdbuf_info = {
NG_CMDSTRLEN + 1
NG_CMDSTRSIZ
};
const struct ng_parse_type ng_parse_cmdbuf_type = {
&ng_parse_fixedstring_type,
sys/netgraph/ng_device.c
SLIST_HEAD(, ngd_connection) head;
node_p node;
char nodename[NG_NODELEN + 1];
char nodename[NG_NODESIZ];
} ngd_softc;
/* helper definition */
sys/netgraph/ng_message.h
#endif
/* ASCII string size limits */
#define NG_TYPELEN 15 /* max type name len (16 with null) */
#define NG_HOOKLEN 15 /* max hook name len (16 with null) */
#define NG_NODELEN 15 /* max node name len (16 with null) */
#define NG_PATHLEN 511 /* max path len (512 with null) */
#define NG_CMDSTRLEN 15 /* max command string (16 with null) */
#define NG_TYPESIZ 32 /* max type name len (including null) */
#define NG_HOOKSIZ 32 /* max hook name len (including null) */
#define NG_NODESIZ 32 /* max node name len (including null) */
#define NG_PATHSIZ 512 /* max path len (including null) */
#define NG_CMDSTRSIZ 32 /* max command string (including null) */
#define NG_TEXTRESPONSE 1024 /* allow this length for a text response */
/* A netgraph message */
......
u_int32_t token; /* match with reply */
u_int32_t typecookie; /* node's type cookie */
u_int32_t cmd; /* command identifier */
u_char cmdstr[NG_CMDSTRLEN+1]; /* cmd string + \0 */
u_char cmdstr[NG_CMDSTRSIZ]; /* cmd string */
} header;
char data[0]; /* placeholder for actual data */
};
......
/* Structure used for NGM_MKPEER */
struct ngm_mkpeer {
char type[NG_TYPELEN + 1]; /* peer type */
char ourhook[NG_HOOKLEN + 1]; /* hook name */
char peerhook[NG_HOOKLEN + 1]; /* peer hook name */
char type[NG_TYPESIZ]; /* peer type */
char ourhook[NG_HOOKSIZ]; /* hook name */
char peerhook[NG_HOOKSIZ]; /* peer hook name */
};
/* Keep this in sync with the above structure definition */
......
/* Structure used for NGM_CONNECT */
struct ngm_connect {
char path[NG_PATHLEN + 1]; /* peer path */
char ourhook[NG_HOOKLEN + 1]; /* hook name */
char peerhook[NG_HOOKLEN + 1]; /* peer hook name */
char path[NG_PATHSIZ]; /* peer path */
char ourhook[NG_HOOKSIZ]; /* hook name */
char peerhook[NG_HOOKSIZ]; /* peer hook name */
};
/* Keep this in sync with the above structure definition */
......
/* Structure used for NGM_NAME */
struct ngm_name {
char name[NG_NODELEN + 1]; /* node name */
char name[NG_NODESIZ]; /* node name */
};
/* Keep this in sync with the above structure definition */
......
/* Structure used for NGM_RMHOOK */
struct ngm_rmhook {
char ourhook[NG_HOOKLEN + 1]; /* hook name */
char ourhook[NG_HOOKSIZ]; /* hook name */
};
/* Keep this in sync with the above structure definition */
......
/* Structure used for NGM_NODEINFO */
struct nodeinfo {
char name[NG_NODELEN + 1]; /* node name (if any) */
char type[NG_TYPELEN + 1]; /* peer type */
char name[NG_NODESIZ]; /* node name (if any) */
char type[NG_TYPESIZ]; /* peer type */
ng_ID_t id; /* unique identifier */
u_int32_t hooks; /* number of active hooks */
};
......
/* Structure used for NGM_LISTHOOKS */
struct linkinfo {
char ourhook[NG_HOOKLEN + 1]; /* hook name */
char peerhook[NG_HOOKLEN + 1]; /* peer hook */
char ourhook[NG_HOOKSIZ]; /* hook name */
char peerhook[NG_HOOKSIZ]; /* peer hook */
struct nodeinfo nodeinfo;
};
......
/* Structure used for NGM_LISTTYPES */
struct typeinfo {
char type_name[NG_TYPELEN + 1]; /* name of type */
char type_name[NG_TYPESIZ]; /* name of type */
u_int32_t numnodes; /* number alive */
};
sys/netgraph/ng_parse.h
/*
* COMMONLY USED BOUNDED LENGTH STRING TYPES
*/
extern const struct ng_parse_type ng_parse_nodebuf_type; /* NG_NODELEN + 1 */
extern const struct ng_parse_type ng_parse_hookbuf_type; /* NG_HOOKLEN + 1 */
extern const struct ng_parse_type ng_parse_pathbuf_type; /* NG_PATHLEN + 1 */
extern const struct ng_parse_type ng_parse_typebuf_type; /* NG_TYPELEN + 1 */
extern const struct ng_parse_type ng_parse_cmdbuf_type; /* NG_CMDSTRLEN + 1 */
extern const struct ng_parse_type ng_parse_nodebuf_type; /* NG_NODESIZ */
extern const struct ng_parse_type ng_parse_hookbuf_type; /* NG_HOOKSIZ */
extern const struct ng_parse_type ng_parse_pathbuf_type; /* NG_PATHSIZ */
extern const struct ng_parse_type ng_parse_typebuf_type; /* NG_TYPESIZ */
extern const struct ng_parse_type ng_parse_cmdbuf_type; /* NG_CMDSTRSIZ */
/*
* INTEGER TYPES
sys/netgraph/ppp/ng_ppp.c
break;
case NGM_VJC_COOKIE:
{
char path[NG_PATHLEN + 1];
char path[NG_PATHSIZ];
node_p origNode;
if ((error = ng_path2node(node, raddr, &origNode, NULL)) != 0)
sys/netgraph/pppoe/ng_pppoe.c
hook_p hook;
u_int16_t Session_ID;
enum state state;
char creator[NG_NODELEN + 1]; /* who to notify */
char creator[NG_NODESIZ]; /* who to notify */
struct pppoe_full_hdr pkt_hdr; /* used when connected */
negp neg; /* used when negotiating */
/*struct sess_con *hash_next;*/ /* not yet used */
......
neg->pkt->pkt_header.ph.sid = 0x0000;
neg->timeout = 0;
strncpy(sp->creator, retaddr, NG_NODELEN);
sp->creator[NG_NODELEN] = '\0';
strlcpy(sp->creator, retaddr, NG_NODESIZ);
}
switch (msg->header.cmd) {
case NGM_PPPOE_GET_STATUS:
......
return (ENOMEM);
sts = (struct ngpppoe_sts *)msg->data;
tlen = min(NG_HOOKLEN, ntohs(tag->tag_len));
tlen = min(NG_HOOKSIZ - 1, ntohs(tag->tag_len));
strncpy(sts->hook, tag->tag_data, tlen);
sts->hook[tlen] = '\0';
error = ng_send_msg(sp->hook->node, msg, sp->creator, NULL);
......
if (msg == NULL)
return (ENOMEM);
sts = (struct ngpppoe_sts *)msg->data;
strncpy(sts->hook, sp->hook->name, NG_HOOKLEN + 1);
strlcpy(sts->hook, sp->hook->name, NG_HOOKSIZ);
error = ng_send_msg(sp->hook->node, msg, sp->creator, NULL);
return (error);
}
sys/netgraph/pppoe/ng_pppoe.h
* and begin negotiation.
*/
struct ngpppoe_init_data {
char hook[NG_HOOKLEN + 1]; /* hook to monitor on */
u_int16_t data_len; /* Length of the service name */
char hook[NG_HOOKSIZ]; /* hook to monitor on */
u_int16_t data_len; /* Length of the service name */
char data[0]; /* init data goes here */
};
......
* to whoever requested the connection. (close may use this too).
*/
struct ngpppoe_sts {
char hook[NG_HOOKLEN + 1]; /* hook associated with event session */
char hook[NG_HOOKSIZ]; /* hook associated with event session */
};
sys/netgraph/socket/ng_socket.c
meta_p mp = NULL;
int len, error;
hook_p hook = NULL;
char hookname[NG_HOOKLEN + 1];
char hookname[NG_HOOKSIZ];
if ((pcbp == NULL) || (control != NULL)) {
error = EINVAL;
......
*/
hook = LIST_FIRST(&pcbp->sockdata->node->hooks);
} else {
if (len > NG_HOOKLEN) {
if (len >= NG_HOOKSIZ) {
error = EINVAL;
goto release;
}
......
struct ngpcb *const pcbp = sockdata->datasock;
struct socket *so;
struct sockaddr_ng *addr;
char *addrbuf[NG_HOOKLEN + 1 + 4];
char *addrbuf[NG_HOOKSIZ + 4];
int addrlen;
/* If there is no data socket, black-hole it */
......
so = pcbp->ng_socket;
/* Get the return address into a sockaddr. */
addrlen = strlen(hook->name); /* <= NG_HOOKLEN */
addrlen = strlen(hook->name); /* <= NG_HOOKSIZ - 1 */
addr = (struct sockaddr_ng *) addrbuf;
addr->sg_len = addrlen + 3;
addr->sg_family = AF_NETGRAPH;
(1-1/3)