Skip to contentSkip to conversation

about option_t

DISCUSSION [email protected] 3 participants 4 messages May 5, 2008 PPP protocol drivers and compressors

lore
Share & tools
lore
#0 lore raw
typedef struct {
	char	*name;		/* name of the option */
	enum opt_type type;
	void	*addr;
	char	*description;
	unsigned int flags;
	void	*addr2;
	int	upper_limit;
	int	lower_limit;
	const char *source;
	short int priority;
	short int winner;
} option_t;

Which piece of code call the void *addr. some plugins uses this pointer to call functions when the plugin loads. BTW, what is the exactly meaning of each value of enum opt_type struct? Thanks a lot!

2008-05-05

#1 lore raw
Quoted 3 lines · On Mon, May 05, 2008 at 03:34:29PM +0800, [email protected] wrote:

Which piece of code call the void *addr. some plugins uses this pointer to call functions when the plugin loads. BTW, what is the exactly meaning of each value of enum opt_type struct? Thanks a lot!

Not an interesting question, sorry. Refer to the PPP source. It is truly fascinating and well coded. Explore references to the option_t typedef. Take particular note of ->addr and where o_bool appears in the source. It is amazing. Truly, amazing. Use a capable editor and cross referencing tool. I use emacs with etags, but you might find something else more appropriate.

Signature · 1 line
James Cameron
#2 lore raw
In reply to [email protected]
Quoted 1 line · [email protected] writes:

Which piece of code call the void *addr.

'addr' is a type-dependent value. It's not necessarily called as a function -- that only happens if the type is o_special, o_special_noarg, or o_wild.

Quoted 1 line

some plugins uses this pointer to call functions when the plugin loads. BTW, what is the exactly meaning of each value of enum opt_type struct? Thanks a lot!

The values should be relatively self-explanatory, if you read the code in options.c or examine any of the code that uses the options.

o_special_noarg - option is processed by a function call and consumes no other arguments.

o_special - option processed by function call and consumes one more argument.

o_bool - option address is a 'bool' to be set to the lower 8 bits of 'flags'. If 'addr2' is set, use the OPT_A2{COPY,CLR,CLRB,OR) to determine what is done to that value.

o_int - parse an integer, offset by low 8 bits of 'flags', and store in 'addr'.

o_wild - special self-identifying option (no keyword; parsed by appearance). Used only for IPv4 addresses, device name, and tty speed.

Signature · 1 line
James Carlson         42.703N 71.076W         <[email protected]>
#3 lore raw
In reply to [email protected]

thanks for you help!

2008-05-05

·¢¼şÈË£º James Carlson
·¢ËÍʱ¼ä£º 2008-05-05 19:41:21
ÊÕ¼şÈË£º [email protected]
³­ËÍ£º linux-ppp
Ö÷Ì⣺ Re: about option_t

Quoted 1 line · [email protected] writes:

Which piece of code call the void *addr.

'addr' is a type-dependent value. It's not necessarily called as a function -- that only happens if the type is o_special, o_special_noarg, or o_wild.

Quoted 1 line

some plugins uses this pointer to call functions when the plugin loads. BTW, what is the exactly meaning of each value of enum opt_type struct? Thanks a lot!

The values should be relatively self-explanatory, if you read the code in options.c or examine any of the code that uses the options.
o_special_noarg - option is processed by a function call and consumes no other arguments.
o_special - option processed by function call and consumes one more argument.
o_bool - option address is a 'bool' to be set to the lower 8 bits of 'flags'. If 'addr2' is set, use the OPT_A2{COPY,CLR,CLRB,OR) to determine what is done to that value.
o_int - parse an integer, offset by low 8 bits of 'flags', and store in 'addr'.
o_wild - special self-identifying option (no keyword; parsed by appearance). Used only for IPv4 addresses, device name, and tty speed.

Signature · 4 lines
__________ NOD32 3072 (20080503) Information __________
This message was checked by NOD32 antivirus system.
http://www.nod32cn.com
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±şšiş)í…æèw*jg¬±¨¶‰š�Šİ¢jÿ¾«şG«�éÿ¢¸¢·¦j:+v‰¨ŠwèjØm¶Ÿÿşø¯ù®w¥şŠàşf£¢·hš�â�úÿ†Ù¥