⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protocol.c

📁 DHCP服务器源码
💻 C
📖 第 1 页 / 共 3 页
字号:
			(h -> inner, id, name, value);	return ISC_R_NOTFOUND;}isc_result_t omapi_protocol_get_value (omapi_object_t *h,				       omapi_object_t *id,				       omapi_data_string_t *name,				       omapi_value_t **value){	omapi_protocol_object_t *p;	if (h -> type != omapi_type_protocol)		return ISC_R_INVALIDARG;	p = (omapi_protocol_object_t *)h;	if (omapi_ds_strcmp (name, "default-authenticator") == 0) {		if (!p -> default_auth)			return ISC_R_NOTFOUND;		return omapi_make_object_value (value, name,						p -> default_auth -> a, MDL);	}		if (h -> inner && h -> inner -> type -> get_value)		return (*(h -> inner -> type -> get_value))			(h -> inner, id, name, value);	return ISC_R_NOTFOUND;}isc_result_t omapi_protocol_destroy (omapi_object_t *h,				     const char *file, int line){	omapi_protocol_object_t *p;	if (h -> type != omapi_type_protocol)		return ISC_R_INVALIDARG;	p = (omapi_protocol_object_t *)h;	if (p -> message)		omapi_message_dereference (&p -> message, file, line);	/* This will happen if: 1) A default authenticator is supplied to	   omapi_protocol_connect(), and 2) something goes wrong before	   the authenticator can be opened. */	if (p -> default_auth && !p -> remote_auth_list)		dfree (p -> default_auth, file, line);	while (p -> remote_auth_list) {		omapi_remote_auth_t *r = p -> remote_auth_list -> next;		p -> remote_auth_list = r;		if (r) {			omapi_object_dereference (&r -> a, file, line);			dfree (r, file, line);		}	}	return ISC_R_SUCCESS;}/* Write all the published values associated with the object through the   specified connection. */isc_result_t omapi_protocol_stuff_values (omapi_object_t *c,					  omapi_object_t *id,					  omapi_object_t *p){	int i;	if (p -> type != omapi_type_protocol)		return ISC_R_INVALIDARG;	if (p -> inner && p -> inner -> type -> stuff_values)		return (*(p -> inner -> type -> stuff_values)) (c, id,								p -> inner);	return ISC_R_SUCCESS;}/* Returns a boolean indicating whether this protocol requires that   messages be authenticated or not. */isc_boolean_t omapi_protocol_authenticated (omapi_object_t *h){	if (h -> type != omapi_type_protocol)		return isc_boolean_false;	if (((omapi_protocol_object_t *)h) -> insecure)		return isc_boolean_false;	else		return isc_boolean_true;}/* Sets the address and authenticator verification callbacks.  The handle   is to a listener object, not a protocol object. */isc_result_t omapi_protocol_configure_security (omapi_object_t *h,						isc_result_t (*verify_addr)						 (omapi_object_t *,						  omapi_addr_t *),						isc_result_t (*verify_auth)						 (omapi_object_t *,						  omapi_auth_key_t *)){	omapi_protocol_listener_object_t *l;	if (h -> outer && h -> outer -> type == omapi_type_protocol_listener)		h = h -> outer;	if (h -> type != omapi_type_protocol_listener)		return ISC_R_INVALIDARG;	l = (omapi_protocol_listener_object_t *)h;	l -> verify_auth = verify_auth;	l -> insecure = 0;	return omapi_listener_configure_security (h -> outer, verify_addr);}					      /* Set up a listener for the omapi protocol.    The handle stored points to   a listener object, not a protocol object. */isc_result_t omapi_protocol_listen (omapi_object_t *h,				    unsigned port,				    int max){	isc_result_t status;	omapi_protocol_listener_object_t *obj;	obj = (omapi_protocol_listener_object_t *)0;	status = omapi_protocol_listener_allocate (&obj, MDL);	if (status != ISC_R_SUCCESS)		return status;	status = omapi_object_reference (&h -> outer,					 (omapi_object_t *)obj, MDL);	if (status != ISC_R_SUCCESS) {		omapi_protocol_listener_dereference (&obj, MDL);		return status;	}	status = omapi_object_reference (&obj -> inner, h, MDL);	if (status != ISC_R_SUCCESS) {		omapi_protocol_listener_dereference (&obj, MDL);		return status;	}	/* What a terrible default. */	obj -> insecure = 1;	status = omapi_listen ((omapi_object_t *)obj, port, max);	omapi_protocol_listener_dereference (&obj, MDL);	return status;}/* Signal handler for protocol listener - if we get a connect signal,   create a new protocol connection, otherwise pass the signal down. */isc_result_t omapi_protocol_listener_signal (omapi_object_t *o,					     const char *name, va_list ap){	isc_result_t status;	omapi_object_t *c;	omapi_protocol_object_t *obj;	omapi_protocol_listener_object_t *p;	if (!o || o -> type != omapi_type_protocol_listener)		return ISC_R_INVALIDARG;	p = (omapi_protocol_listener_object_t *)o;	/* Not a signal we recognize? */	if (strcmp (name, "connect")) {		if (p -> inner && p -> inner -> type -> signal_handler)			return (*(p -> inner -> type -> signal_handler))				(p -> inner, name, ap);		return ISC_R_NOTFOUND;	}	c = va_arg (ap, omapi_object_t *);	if (!c || c -> type != omapi_type_connection)		return ISC_R_INVALIDARG;	obj = (omapi_protocol_object_t *)0;	status = omapi_protocol_allocate (&obj, MDL);	if (status != ISC_R_SUCCESS)		return status;	obj -> verify_auth = p -> verify_auth;	obj -> insecure = p -> insecure;	status = omapi_object_reference (&obj -> outer, c, MDL);	if (status != ISC_R_SUCCESS) {	      lose:		omapi_protocol_dereference (&obj, MDL);		omapi_disconnect (c, 1);		return status;	}	status = omapi_object_reference (&c -> inner,					 (omapi_object_t *)obj, MDL);	if (status != ISC_R_SUCCESS)		goto lose;	/* Send the introductory message. */	status = omapi_protocol_send_intro ((omapi_object_t *)obj,					    OMAPI_PROTOCOL_VERSION,					    sizeof (omapi_protocol_header_t));	if (status != ISC_R_SUCCESS)		goto lose;	omapi_protocol_dereference (&obj, MDL);	return status;}isc_result_t omapi_protocol_listener_set_value (omapi_object_t *h,						omapi_object_t *id,						omapi_data_string_t *name,						omapi_typed_data_t *value){	if (h -> type != omapi_type_protocol_listener)		return ISC_R_INVALIDARG;		if (h -> inner && h -> inner -> type -> set_value)		return (*(h -> inner -> type -> set_value))			(h -> inner, id, name, value);	return ISC_R_NOTFOUND;}isc_result_t omapi_protocol_listener_get_value (omapi_object_t *h,						omapi_object_t *id,						omapi_data_string_t *name,						omapi_value_t **value){	if (h -> type != omapi_type_protocol_listener)		return ISC_R_INVALIDARG;		if (h -> inner && h -> inner -> type -> get_value)		return (*(h -> inner -> type -> get_value))			(h -> inner, id, name, value);	return ISC_R_NOTFOUND;}isc_result_t omapi_protocol_listener_destroy (omapi_object_t *h,					      const char *file, int line){	if (h -> type != omapi_type_protocol_listener)		return ISC_R_INVALIDARG;	return ISC_R_SUCCESS;}/* Write all the published values associated with the object through the   specified connection. */isc_result_t omapi_protocol_listener_stuff (omapi_object_t *c,					    omapi_object_t *id,					    omapi_object_t *p){	int i;	if (p -> type != omapi_type_protocol_listener)		return ISC_R_INVALIDARG;	if (p -> inner && p -> inner -> type -> stuff_values)		return (*(p -> inner -> type -> stuff_values)) (c, id,								p -> inner);	return ISC_R_SUCCESS;}isc_result_t omapi_protocol_send_status (omapi_object_t *po,					 omapi_object_t *id,					 isc_result_t waitstatus,					 unsigned rid, const char *msg){	isc_result_t status;	omapi_message_object_t *message = (omapi_message_object_t *)0;	omapi_object_t *mo;	if (po -> type != omapi_type_protocol)		return ISC_R_INVALIDARG;	status = omapi_message_new ((omapi_object_t **)&message, MDL);	if (status != ISC_R_SUCCESS)		return status;	mo = (omapi_object_t *)message;	status = omapi_set_int_value (mo, (omapi_object_t *)0,				      "op", OMAPI_OP_STATUS);	if (status != ISC_R_SUCCESS) {		omapi_message_dereference (&message, MDL);		return status;	}	status = omapi_set_int_value (mo, (omapi_object_t *)0,				      "rid", (int)rid);	if (status != ISC_R_SUCCESS) {		omapi_message_dereference (&message, MDL);		return status;	}	status = omapi_set_int_value (mo, (omapi_object_t *)0,				      "result", (int)waitstatus);	if (status != ISC_R_SUCCESS) {		omapi_message_dereference (&message, MDL);		return status;	}	/* If a message has been provided, send it. */	if (msg) {		status = omapi_set_string_value (mo, (omapi_object_t *)0,						 "message", msg);		if (status != ISC_R_SUCCESS) {			omapi_message_dereference (&message, MDL);			return status;		}	}	status = omapi_protocol_send_message (po, id, mo, (omapi_object_t *)0);	omapi_message_dereference (&message, MDL);	return status;}/* The OMAPI_NOTIFY_PROTOCOL flag will cause the notify-object for the   message to be set to the protocol object.  This is used when opening   the default authenticator. */isc_result_t omapi_protocol_send_open (omapi_object_t *po,				       omapi_object_t *id,				       const char *type,				       omapi_object_t *object,				       unsigned flags){	isc_result_t status;	omapi_message_object_t *message = (omapi_message_object_t *)0;	omapi_object_t *mo;	if (po -> type != omapi_type_protocol)		return ISC_R_INVALIDARG;	status = omapi_message_new ((omapi_object_t **)&message, MDL);	mo = (omapi_object_t *)message;	if (status == ISC_R_SUCCESS)		status = omapi_set_int_value (mo, (omapi_object_t *)0,					      "op", OMAPI_OP_OPEN);	if (status == ISC_R_SUCCESS)		status = omapi_set_object_value (mo, (omapi_object_t *)0,						 "object", object);	if ((flags & OMAPI_CREATE) && (status == ISC_R_SUCCESS))		status = omapi_set_boolean_value (mo, (omapi_object_t *)0,						  "create", 1);	if ((flags & OMAPI_UPDATE) && (status == ISC_R_SUCCESS))		status = omapi_set_boolean_value (mo, (omapi_object_t *)0,						  "update", 1);	if ((flags & OMAPI_EXCL) && (status == ISC_R_SUCCESS))		status = omapi_set_boolean_value (mo, (omapi_object_t *)0,						  "exclusive", 1);	if ((flags & OMAPI_NOTIFY_PROTOCOL) && (status == ISC_R_SUCCESS))		status = omapi_set_object_value (mo, (omapi_object_t *)0,						 "notify-object", po);	if (type && (status == ISC_R_SUCCESS))		status = omapi_set_string_value (mo, (omapi_object_t *)0,						 "type", type);	if (status == ISC_R_SUCCESS)		status = omapi_message_register (mo);	if (status == ISC_R_SUCCESS) {		status = omapi_protocol_send_message (po, id, mo,						      (omapi_object_t *)0);		if (status != ISC_R_SUCCESS)			omapi_message_unregister (mo);	}	if (message)		omapi_message_dereference (&message, MDL);	return status;}isc_result_t omapi_protocol_send_update (omapi_object_t *po,					 omapi_object_t *id,					 unsigned rid,					 omapi_object_t *object){	isc_result_t status;	omapi_message_object_t *message = (omapi_message_object_t *)0;	omapi_object_t *mo;	if (po -> type != omapi_type_protocol)		return ISC_R_INVALIDARG;	status = omapi_message_new ((omapi_object_t **)&message, MDL);	if (status != ISC_R_SUCCESS)		return status;	mo = (omapi_object_t *)message;	status = omapi_set_int_value (mo, (omapi_object_t *)0,				      "op", OMAPI_OP_UPDATE);	if (status != ISC_R_SUCCESS) {		omapi_message_dereference (&message, MDL);		return status;	}	if (rid) {		omapi_handle_t handle;		status = omapi_set_int_value (mo, (omapi_object_t *)0,					      "rid", (int)rid);		if (status != ISC_R_SUCCESS) {			omapi_message_dereference (&message, MDL);			return status;		}		status = omapi_object_handle (&handle, object);		if (status != ISC_R_SUCCESS) {			omapi_message_dereference (&message, MDL);			return status;		}		status = omapi_set_int_value (mo, (omapi_object_t *)0,					      "handle", (int)handle);		if (status != ISC_R_SUCCESS) {			omapi_message_dereference (&message, MDL);			return status;		}	}					status = omapi_set_object_value (mo, (omapi_object_t *)0,					 "object", object);	if (status != ISC_R_SUCCESS) {		omapi_message_dereference (&message, MDL);		return status;	}	status = omapi_protocol_send_message (po, id, mo, (omapi_object_t *)0);	omapi_message_dereference (&message, MDL);	return status;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -