divergence.html

来自「SLP协议在linux下的实现。此版本为1.2.1版。官方网站为www.open」· HTML 代码 · 共 181 行

HTML
181
字号
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head>   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">   <meta name="GENERATOR" content="Mozilla/4.77C-CCK-MCD Caldera Systems OpenLinux [en] (X11; U; Linux 2.4.2 i686) [Netscape]">   <title>OpenSLP Programmers Guide - Divergence from RFC 2614</title></head><body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000"><h2>Divergence from RFC 2614</h2><hr WIDTH="100%"><h3>SLP Service URLs are required</h3>SLP Service URL syntax is required for all functions that accept url strings.&nbsp;The following is a list of affected functions:<ul><li><tt>SLPReg()</tt></li><li><tt>SLPDeReg()</tt></li><li><tt>SLPDelAttrs()</tt></li><li><tt>SLPFindAttrs()</tt></li><li><tt>SLPParseSrvURL()</tt></li><li><tt>SLPSrvURLCallback()</tt></li></ul>The decision to require SLP Service URL syntax was made based on in partthe following scenario:<blockquote>Suppose that two calls were made to SLPReg() with&nbsp; <tt>srvurl</tt>sand <tt>srvtype</tt>s of "192.168.100.2","http" and "192.168.100.2","ftp".&nbsp;Now the developer wants to deregister one service with out deregisteringthe other.&nbsp; How can it be done?&nbsp; The SLPDeReg() call does nothave a service type parameter so it would be impossible for the underlyingimplementation to distinguish between the two registrations.&nbsp; In attemptto standardize, OpenSLP expects valid Service URLS.</blockquote>OpenSLP requires strict Service URL syntax because a Service URL can betreated as a unique "database key" that identifies a registered service.&nbsp;&nbsp;Not requiring Service URL syntax allows for several ambiguities like theone mentioned above.<br>&nbsp;<h3>Scopelist may be the empty string ("")</h3>In the calls where a scope list is accepted as a parameters, RFC 2614 saysthat this parameter may not be the empty string or&nbsp; NULL.&nbsp;&nbsp;OpenSLP allows scope list to be NULL or the empty string.&nbsp; If theempty string is passed in as a scopelist, then OpenSLP will use the scopelistthe system administrator has configured for the machine.&nbsp; This saves99% of all developers the time of calling SLPFindScopes() and parsing theresult.<p>Scoping is almost entirely an administrative task that is only requiredfor scalebility of the SLP wire protocol.&nbsp; Having to deal with andunderstand scopes will be a burdon to the large majority of programmers.&nbsp;Unless they are writing some sort of SLP browser, they will be very contentto use the scope that the machine is configured to use.<br>&nbsp;<h3>The SLPSetProperty() is ignored</h3>The SLPSetProperty() and SLPGetProperty() calls are impossible implementin a way that would be both scalable and thread safe.&nbsp; The SLPGetProperty()call could never be made thread safe unless return value was a pointerto a buffer dynamically allocated the library and freed by the caller.The SLPSetProperty() call would still access with the data store in sucha way that mutexes would be required to ensure that SLPSetProperty() andSLPGetProperty() were never used the same buffers at the same time.&nbsp;Even if a thread safe data store were devised, the SLPGetProperty() callwould be used so frequently during internal operations of the library thatperformance might be adversely affected due to mutex bottlenecking or theamount of processing required to resolve the attribute name to a value.<br>&nbsp;<h3>NULL and empty string are acceptable parameters</h3>According to RFC 2614, NULL is not exceptable value for any parameter.&nbsp;Instead programmers are instructed to passed the empty string "".&nbsp;OpenSLP allows programmers to use either NULL or the empty string.&nbsp;&nbsp;It is very easy to deal with both NULL or empty string in the implementation,and allows developers to write more familiar and slightly more efficientcode.&nbsp; There should not be any reason why the compiler should be requiredto pass a pointer to a static constant empty string when NULL will do justa well.&nbsp;&nbsp; This is why the vast majority of C APIs use NULL toindicate an ignored parameter or default value -- not the empty string("").<br>&nbsp;<h3>Incremental registrations an de-registrations</h3>The only reason I can think of ever wanting to expose the functionalityof incremental registration and deregistration is to represent dynamicdata via SLP attributes.&nbsp; I can think of a long list of reasons whythis is a very very bad idea.&nbsp; With out doubt, it is best to instructSLP developers to minimize when ever possible, the number of calls thatultimately generate SrvReg and SrvDereg messages.&nbsp; If dynamic datais to be represented, it is best do do it via a specialized protocol optimizedfor the given service.&nbsp; OpenSLP does not support incremental registrationsand de-registrations via SLPReg() and SLPDelAttrs() because we have foundthat when developers really learn what happens "under the SLP covers" theyare very careful *not* to call then very often.<p>In addition to poor usage of network resources, incremental registrationsand de-registrations require additional code that decreases the efficiencyof and increases the size, and complexity of API and agent implementations.<p>The work around for this behavior involves the following:<ul><li>Design application usage of SLP such that SLP is not used to store greatquantities of data</li><li>Design application usage of SLP such that SLP is not used to store dynamicdata</li><li>If the need does arise to add or remove an attribute from an existing registrationsimply re-register the service with new attributes as "fresh" registration.</li></ul><h3>Addition of a very simple attribute parsing function</h3>The following function is secretly included with OpenSLP and has provento be very useful.<p><tt>/*=========================================================================*/</tt><br><tt>SLPError SLPParseAttrs(const char* pcAttrList,</tt><br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const char *pcAttrId,</tt><br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char** ppcAttrVal);</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/* Used to get individual attribute values from an attribute stringthat&nbsp;&nbsp; */</tt><br><tt>/* is passed to the SLPAttrCallback&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/* pcAttrList (IN) A character buffer containing a comma separated,null&nbsp;&nbsp; */</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;terminated list of attribute id/value assignments, in&nbsp;&nbsp; */</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SLP wire format; i.e.&nbsp; "(attr-id=attr-value-list)"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/* pcAttrId (IN)&nbsp;&nbsp; The string indicating which attributevalue to return.&nbsp; */</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MUST not be null.&nbsp; MUST not be the empty string ("").&nbsp;&nbsp;*/</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/* ppcAttrVal (OUT) A pointer to a pointer to the buffer to receive&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;attribute value.&nbsp; The memory should be freed by a call&nbsp; */</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to SLPFree() when no longer needed.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/* Returns: Returns SLP_PARSE_ERROR if an attribute of the specifiedid&nbsp;&nbsp;&nbsp; */</tt><br><tt>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; was notfound otherwise SLP_OK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</tt><br><tt>/*=========================================================================*/</tt><br>&nbsp;<h3>Some .conf properties are ignored</h3>See the <a href="../UsersGuide/SlpConf.html">OpenSLP Users Guide</a> formore details<br>&nbsp;</body></html>

⌨️ 快捷键说明

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