I stuck this code into an existing driver to do the test, so a cut-n-paste might
be somewhat misleading, but it’s basically "mount -Tio-net -o myInt
".
I’d think you’d want to return an error code if ANY of the options was entered
illegally; what would be the point of setting flags indicating that a value was
required (or not allowed) if you didn’t want to know about an error?
Also, on the subject of documenting this functions, it would be nice to hae a list
of the options that it “automatically” parses. It is not at all obvious, for
instance, that you can enter “duplex=false” as well as “duplex=0.”
Murf
Chris McKillop wrote:
Well, it probably should have a flag to say if an error for a given value
is critical and, in turn, will return an error from the parse routine.
Can I see the io-net command line you are using that gives the error?
An exact cut-n-paste would be best.
chris
John A. Murphy <> murf@perftech.com> > wrote:
Here are the relevant code fragments. I create one private option, “myInt”,
just to test the flags.
Murf
typedef struct
{
nic_options_t nic; /* generic nic driver options /
int myInt; / unique options */
} our_options_t;
our_options_t ourOptions;
static drvr_subopt_tbl_t ourOptionsTable [] = {
{“myInt”,
offsetof(our_options_t, myInt),
DRVR_OPT_FLAG_VAL_SINT32 | DRVR_OPT_FLAG_VAL_REQ,
NULL},
};
int detect (void *dll_hdl, io_net_self_t *ion, char *options)
{
drvr_subopt_tbl_chain_t link;
link.next = NULL;
link.table = ourOptionsTable;
link.table_size = sizeof(ourOptionsTable) / sizeof(drvr_subopt_tbl_t);
cc = nic_parse_subopts(&ourOptions, “SiS”, options, &link);
if (cc) slogf(_SLOGC_NETWORK, _SLOG_INFO, “nic_parse_subopts returned %d”,
cc);
return ENODEV;
}
Chris McKillop wrote:
Please post a the structure as you have it setup.
chris
John A. Murphy <> murf@perftech.com> > wrote:
Is there any documentation available on nic_parse_subopts and/or
drvr_parse_subopts? In particular, is there any information on error
conditions?
If I set the DRVR_OPT_FLAG_VAL_REQ flag, and then supply (on the command
line) that option without a value, I see a “Malformed argument” message
posted to slogger, but nic_parse_subopts still returns zero! Is there
any way for the driver to find out about the bad command line?
Murf
\
Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/
\
Chris McKillop <> cdm@qnx.com> > “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/