diff options
author | brian <brian@FreeBSD.org> | 2000-11-16 23:14:53 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2000-11-16 23:14:53 +0000 |
commit | 5d83d171df44f3eeea633909f60d663b281955df (patch) | |
tree | bb54eddf2ccaaba216b60b60fc7e740eac92361a /sys/netgraph/ng_parse.h | |
parent | 282d572dc01fd60b8231fd60e70fbbc9e015d440 (diff) | |
download | FreeBSD-src-5d83d171df44f3eeea633909f60d663b281955df.zip FreeBSD-src-5d83d171df44f3eeea633909f60d663b281955df.tar.gz |
Go back to using data_len in struct ngpppoe_init_data after discussions
with Julian and Archie.
Implement a new ``sizedstring'' parse type for dealing with field pairs
consisting of a uint16_t followed by a data field of that size, and use
this to deal with the data_len and data fields.
Written by: Archie with some input by me
Agreed in principle by: julian
Diffstat (limited to 'sys/netgraph/ng_parse.h')
-rw-r--r-- | sys/netgraph/ng_parse.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sys/netgraph/ng_parse.h b/sys/netgraph/ng_parse.h index 027605d..13aa294 100644 --- a/sys/netgraph/ng_parse.h +++ b/sys/netgraph/ng_parse.h @@ -396,6 +396,17 @@ struct ng_parse_fixedstring_info { }; /* + * EXPLICITLY SIZED STRING TYPE + * + * These are strings that have a two byte length field preceding them. + * Parsed strings are NOT NUL-terminated. + * + * Default value: Empty string + * Additional info: None + */ +extern const struct ng_parse_type ng_parse_sizedstring_type; + +/* * COMMONLY USED BOUNDED LENGTH STRING TYPES */ extern const struct ng_parse_type ng_parse_nodebuf_type; /* NG_NODELEN + 1 */ @@ -506,16 +517,20 @@ extern enum ng_parse_token ng_parse_get_token(const char *s, * the string value. The string token must be enclosed in double quotes * and the normal C backslash escapes are recognized. The caller must * eventually free() the returned result. Returns NULL if token is - * not a string token, or parse or other error. + * not a string token, or parse or other error. Otherwise, *lenp contains + * the number of characters parsed, and *slenp (if not NULL) contains + * the actual number of characters in the parsed string. */ -extern char *ng_get_string_token(const char *s, int *startp, int *lenp); +extern char *ng_get_string_token(const char *s, int *startp, + int *lenp, int *slenp); /* * Convert a raw string into a doubly-quoted string including any * necessary backslash escapes. Caller must free the result. - * Returns NULL if ENOMEM. + * Returns NULL if ENOMEM. Normally "slen" should equal strlen(s) + * unless you want to encode NUL bytes. */ -extern char *ng_encode_string(const char *s); +extern char *ng_encode_string(const char *s, int slen); #endif /* _NETGRAPH_PARSE_H_ */ |