Deleted Added
full compact
5c5
< .\" $FreeBSD: head/lib/libc/rpc/PSD.doc/xdr.nts.ms 106143 2002-10-29 14:56:09Z ru $
---
> .\" $FreeBSD: head/lib/libc/rpc/PSD.doc/xdr.nts.ms 108533 2003-01-01 18:49:04Z schweikh $
26c26
< machinex-independent fashion.
---
> machinex-independent fashion.
30,31c30,31
< XDR is the backbone of Sun's Remote Procedure Call package, in the
< sense that data for remote procedure calls is transmitted using the
---
> XDR is the backbone of Sun's Remote Procedure Call package, in the
> sense that data for remote procedure calls is transmitted using the
37,38c37,38
< routines, see the
< .I xdr(3N)
---
> routines, see the
> .I xdr(3N)
42c42
< This chapter contains a short tutorial overview of the XDR library
---
> This chapter contains a short tutorial overview of the XDR library
45c45
< to work across different languages, operating systems, and machine
---
> to work across different languages, operating systems, and machine
52c52
< sections.
---
> sections.
60c60
< .I rpcgen
---
> .I rpcgen
129c129
< .I writer
---
> .I writer
131c131
< .I reader
---
> .I reader
144c144
< With the advent of local area networks and 4.2BSD came the concept
---
> With the advent of local area networks and 4.2BSD came the concept
148c148
< .I writer
---
> .I writer
161c161
< .I writer
---
> .I writer
163c163
< .I reader
---
> .I reader
173c173
< .I read()
---
> .I read()
175c175
< .I write()
---
> .I write()
260c260
< XDR's approach to standardizing data representations is
---
> XDR's approach to standardizing data representations is
281,284c281,284
< of the ISO model, are canonical protocols. The advantage of any canonical
< approach is simplicity; in the case of XDR, a single set of conversion
< routines is written once and is never touched again. The canonical approach
< has a disadvantage, but it is unimportant in real-world data transfer
---
> of the ISO model, are canonical protocols. The advantage of any canonical
> approach is simplicity; in the case of XDR, a single set of conversion
> routines is written once and is never touched again. The canonical approach
> has a disadvantage, but it is unimportant in real-world data transfer
286c286
< according to the XDR standard. The sending machine converts the integers
---
> according to the XDR standard. The sending machine converts the integers
293,295c293,295
< insignificant, especially in networking applications. Most of the time
< required to prepare a data structure for transfer is not spent in conversion
< but in traversing the elements of the data structure. To transmit a tree,
---
> insignificant, especially in networking applications. Most of the time
> required to prepare a data structure for transfer is not spent in conversion
> but in traversing the elements of the data structure. To transmit a tree,
298c298
< deallocated as well. Similarly, to receive a tree, storage must be
---
> deallocated as well. Similarly, to receive a tree, storage must be
300c300
< properly aligned, and pointers must be constructed to link the leaves
---
> properly aligned, and pointers must be constructed to link the leaves
302c302
< structures whether or not conversion is required. In networking
---
> structures whether or not conversion is required. In networking
304c304
< down through the sender's protocol layers, across the network and up through
---
> down through the sender's protocol layers, across the network and up through
311,312c311,312
< allows you to write and read arbitrary C constructs in a consistent,
< specified, well-documented manner. Thus, it can make sense to use the
---
> allows you to write and read arbitrary C constructs in a consistent,
> specified, well-documented manner. Thus, it can make sense to use the
336c336
< .I xdrstdio_create()
---
> .I xdrstdio_create()
339c339
< .I FILE
---
> .I FILE
344c344
< .I writer
---
> .I writer
348c348
< .I reader
---
> .I reader
356c356
< .I xdr_long()
---
> .I xdr_long()
358c358
< primitive is characteristic of most XDR library
---
> primitive is characteristic of most XDR library
361c361
< .I FALSE
---
> .I FALSE
363c363
< .I TRUE
---
> .I TRUE
377c377
< .I xxx
---
> .I xxx
382c382
< .I xxx
---
> .I xxx
388c388
< .I xdrs
---
> .I xdrs
403c403
< are passed among machines.
---
> are passed among machines.
405c405
< direction of the XDR operation.
---
> direction of the XDR operation.
439c439
< .I xdrs
---
> .I xdrs
444c444
< .I FALSE
---
> .I FALSE
450c450
< .I TRUE
---
> .I TRUE
452c452
< .I FALSE
---
> .I FALSE
463c463
< .I xdr_gnumbers()
---
> .I xdr_gnumbers()
543c543
< .I TRUE
---
> .I TRUE
545c545
< .I FALSE
---
> .I FALSE
564c564
< .I xdrs
---
> .I xdrs
570c570
< .I TRUE
---
> .I TRUE
572c572
< .I FALSE
---
> .I FALSE
584c584
< .I enum
---
> .I enum
589,591c589,591
< .I TRUE
< (1) or
< .I FALSE
---
> .I TRUE
> (1) or
> .I FALSE
613c613
< are addresses of the associated type that provides data to, or
---
> are addresses of the associated type that provides data to, or
677c677
< .I xdrs
---
> .I xdrs
680c680
< .I sp
---
> .I sp
684c684
< .I maxlength
---
> .I maxlength
690c690
< .I FALSE
---
> .I FALSE
694c694
< .I TRUE
---
> .I TRUE
698c698
< .I maxlength
---
> .I maxlength
700c700
< .I xdr_string()
---
> .I xdr_string()
702c702
< .I malloc()
---
> .I malloc()
706c706
< .I xdr_string()
---
> .I xdr_string()
710c710
< .I XDR_ENCODE
---
> .I XDR_ENCODE
712c712
< .I sp
---
> .I sp
723c723
< .I sp
---
> .I sp
727c727
< .I *sp
---
> .I *sp
730c730
< .I *sp
---
> .I *sp
739c739
< .I XDR_FREE
---
> .I XDR_FREE
745c745
< .I *sp
---
> .I *sp
749c749
< .I xdr_string()
---
> .I xdr_string()
751c751
< .I maxlength
---
> .I maxlength
758c758
< Byte arrays differ from strings in the following three ways:
---
> Byte arrays differ from strings in the following three ways:
765c765
< .I xdr_bytes()
---
> .I xdr_bytes()
782c782
< .I lp
---
> .I lp
784c784
< .I *lp
---
> .I *lp
793c793
< .I xdr_bytes()
---
> .I xdr_bytes()
801c801
< .I xdr_bytes()
---
> .I xdr_bytes()
819c819
< .I ap
---
> .I ap
822c822
< .I *ap
---
> .I *ap
824c824
< .I NULL
---
> .I NULL
827c827
< .I *ap
---
> .I *ap
830c830
< .I *lp
---
> .I *lp
832,833c832,833
< .I *lp
< is set to the array length when the array is deserialized.
---
> .I *lp
> is set to the array length when the array is deserialized.
835c835
< .I maxlength
---
> .I maxlength
843c843
< .I xdr_element()
---
> .I xdr_element()
849c849
< Before defining more constructed data types, it is appropriate to
---
> Before defining more constructed data types, it is appropriate to
854c854
< A user on a networked machine can be identified by
---
> A user on a networked machine can be identified by
858c858
< .I gethostname
---
> .I gethostname
860,861c860,861
< .I geteuid
< man page; and (c) the group numbers to which the user belongs:
---
> .I geteuid
> man page; and (c) the group numbers to which the user belongs:
863,864c863,864
< .I getgroups
< man page. A structure with this information and its associated
---
> .I getgroups
> man page. A structure with this information and its associated
885c885
< xdr_array(xdrs, &nup->nu_gids, &nup->nu_glen,
---
> xdr_array(xdrs, &nup->nu_gids, &nup->nu_glen,
976c976
< .I xdr_wrap_string()
---
> .I xdr_wrap_string()
978c978
< .I xdr_string()
---
> .I xdr_string()
980c980
< .I xdr_array()
---
> .I xdr_array()
982c982
< .I xdr_wrap_string()
---
> .I xdr_wrap_string()
998c998
< .I xdr_opaque()
---
> .I xdr_opaque()
1009c1009
< .I p
---
> .I p
1045c1045
< if (!xdr_vector(xdrs, nup->nu_gids, NGRPS, sizeof(int),
---
> if (!xdr_vector(xdrs, nup->nu_gids, NGRPS, sizeof(int),
1074c1074
< First the routine translates the discriminant of the union located at
---
> First the routine translates the discriminant of the union located at
1079c1079
< .I *unp
---
> .I *unp
1085c1085
< structures.
---
> structures.
1096c1096
< .I NULL
---
> .I NULL
1108c1108
< .I gnumbers
---
> .I gnumbers
1150,1151c1150,1151
< .I xdr_gnumbers()
< was presented above in
---
> .I xdr_gnumbers()
> was presented above in
1154c1154
< .I xdr_wrap_string()
---
> .I xdr_wrap_string()
1156,1157c1156,1157
< The default
< .I arm
---
> The default
> .I arm
1159c1159
< .I xdr_union()
---
> .I xdr_union()
1161c1161
< .I NULL
---
> .I NULL
1164c1164
< .I u_tag_arms
---
> .I u_tag_arms
1178c1178
< .I xdr_union()
---
> .I xdr_union()
1187c1187
< .I xdr_reference()
---
> .I xdr_reference()
1201c1201
< .I pp
---
> .I pp
1207c1207
< .I sizeof()
---
> .I sizeof()
1212c1212
< .I *pp
---
> .I *pp
1217c1217
< .I xdr_struct()
---
> .I xdr_struct()
1222c1222
< .I xdr_reference()
---
> .I xdr_reference()
1226c1226
< .I xdr_reference()
---
> .I xdr_reference()
1228c1228
< .I xdr_array()
---
> .I xdr_array()
1234c1234
< .I gnumbers
---
> .I gnumbers
1260c1260
< .I "Pointer Semantics and XDR"
---
> .I "Pointer Semantics and XDR"
1262c1262
< In many applications, C programmers attach double meaning to
---
> In many applications, C programmers attach double meaning to
1264c1264
< .I NULL
---
> .I NULL
1271c1271
< .I NULL
---
> .I NULL
1283c1283
< .I xdr_reference()
---
> .I xdr_reference()
1288c1288
< .I NULL
---
> .I NULL
1290c1290
< .I xdr_reference()
---
> .I xdr_reference()
1294,1297c1294,1297
< .I xdr_pointer()
< correctly handles
< .I NULL
< pointers. For more information about its use, see
---
> .I xdr_pointer()
> correctly handles
> .I NULL
> pointers. For more information about its use, see
1306,1307c1306,1307
< it can correctly deal with
< .I NULL
---
> it can correctly deal with
> .I NULL
1313c1313
< .I xdr_reference()
---
> .I xdr_reference()
1315c1315
< .I xdr_void()
---
> .I xdr_void()
1318c1318
< .I NULL
---
> .I NULL
1340c1340
< .I xdr_getpos()
---
> .I xdr_getpos()
1345c1345
< .I xdr_getpos()
---
> .I xdr_getpos()
1351c1351
< .I xdr_setpos()
---
> .I xdr_setpos()
1357c1357
< .I xdr_setpos()
---
> .I xdr_setpos()
1364c1364
< .I xdr_destroy()
---
> .I xdr_destroy()
1406c1406
< .I xdrstdio_create()
---
> .I xdrstdio_create()
1421c1421
< .I xdrstdio_create()
---
> .I xdrstdio_create()
1448c1448
< .I xdrmem_create()
---
> .I xdrmem_create()
1465c1465
< .I sendto()
---
> .I sendto()
1486c1486
< .I xdrrec_create()
---
> .I xdrrec_create()
1505c1505
< .I readproc()
---
> .I readproc()
1507c1507
< .I writeproc()
---
> .I writeproc()
1511c1511
< .I read()
---
> .I read()
1524c1524
< .I xxx
---
> .I xxx
1526c1526
< .I readproc()
---
> .I readproc()
1566c1566
< .I xdrrec_endofrecord()
---
> .I xdrrec_endofrecord()
1574c1574
< .I writeproc
---
> .I writeproc
1576c1576
< .I writeproc
---
> .I writeproc
1580c1580
< .I xdrrec_skiprecord()
---
> .I xdrrec_skiprecord()
1588c1588
< .I xdrrec_eof()
---
> .I xdrrec_eof()
1661c1661
< .I NULL
---
> .I NULL
1664c1664
< .I x_inline()
---
> .I x_inline()
1667c1667
< Users are encouraged not to use this feature.)
---
> Users are encouraged not to use this feature.)
1676c1676
< .I TRUE
---
> .I TRUE
1678c1678
< .I FALSE
---
> .I FALSE
1710c1710
< .I FALSE
---
> .I FALSE
1730,1731c1730,1731
< using both the XDR C library routines and the XDR data description
< language.
---
> using both the XDR C library routines and the XDR data description
> language.
1734c1734
< describes this
---
> describes this
1742c1742
< topic earlier in this chapter
---
> topic earlier in this chapter
1744c1744
< routines for a individual's gross assets and liabilities.
---
> routines for an individual's gross assets and liabilities.
1765c1765
< Now assume that we wish to implement a linked list of such information.
---
> Now assume that we wish to implement a linked list of such information.
1780,1785c1780,1785
< structure. Similarly the
< .I gn_next
< field is used to indicate whether or not the object has terminated.
< Unfortunately, if the object continues, the
< .I gn_next
< field is also the address of where it continues. The link addresses
---
> structure. Similarly the
> .I gn_next
> field is used to indicate whether or not the object has terminated.
> Unfortunately, if the object continues, the
> .I gn_next
> field is also the address of where it continues. The link addresses
1788,1789c1788,1789
< The XDR data description of this linked list is described by the
< recursive declaration of
---
> The XDR data description of this linked list is described by the
> recursive declaration of
1806c1806
< following it. If the boolean is
---
> following it. If the boolean is
1808c1808
< then it is the last data field of the structure. If it is
---
> then it is the last data field of the structure. If it is
1810c1810
< then it is followed by a gnumbers structure and (recursively) by a
---
> then it is followed by a gnumbers structure and (recursively) by a
1812,1815c1812,1815
< Note that the C declaration has no boolean explicitly declared in it
< (though the
< .I gn_next
< field implicitly carries the information), while the XDR data
---
> Note that the C declaration has no boolean explicitly declared in it
> (though the
> .I gn_next
> field implicitly carries the information), while the XDR data
1818,1821c1818,1821
< Hints for writing the XDR routines for a
< .I gnumbers_list
< follow easily from the XDR description above. Note how the primitive
< .I xdr_pointer()
---
> Hints for writing the XDR routines for a
> .I gnumbers_list
> follow easily from the XDR description above. Note how the primitive
> .I xdr_pointer()
1840,1841c1840,1841
< return(xdr_pointer(xdrs, gnp,
< sizeof(struct gnumbers_node),
---
> return(xdr_pointer(xdrs, gnp,
> sizeof(struct gnumbers_node),
1873c1873
< if (!xdr_reference(xdrs, gnp,
---
> if (!xdr_reference(xdrs, gnp,
1878c1878
< gnp = (xdrs->x_op == XDR_FREE) ?
---
> gnp = (xdrs->x_op == XDR_FREE) ?
1888,1890c1888,1890
< this statement is unnecessary in the
< .I XDR_DECODE
< case, since the value of more_data is not known until we
---
> this statement is unnecessary in the
> .I XDR_DECODE
> case, since the value of more_data is not known until we
1893,1907c1893,1907
< The next statement XDR's the more_data field of the XDR union.
< Then if there is truly no more data, we set this last pointer to
< .I NULL
< to indicate the end of the list, and return
< .I TRUE
< because we are done. Note that setting the pointer to
< .I NULL
< is only important in the
< .I XDR_DECODE
< case, since it is already
< .I NULL
< in the
< .I XDR_ENCODE
< and
< XDR_FREE
---
> The next statement XDR's the more_data field of the XDR union.
> Then if there is truly no more data, we set this last pointer to
> .I NULL
> to indicate the end of the list, and return
> .I TRUE
> because we are done. Note that setting the pointer to
> .I NULL
> is only important in the
> .I XDR_DECODE
> case, since it is already
> .I NULL
> in the
> .I XDR_ENCODE
> and
> XDR_FREE
1910c1910
< Next, if the direction is
---
> Next, if the direction is
1912,1916c1912,1916
< the value of
< .I nextp
< is set to indicate the location of the next pointer in the list.
< We do this now because we need to dereference gnp to find the
< location of the next item in the list, and after the next
---
> the value of
> .I nextp
> is set to indicate the location of the next pointer in the list.
> We do this now because we need to dereference gnp to find the
> location of the next item in the list, and after the next
1918c1918
< .I gnp
---
> .I gnp
1920,1923c1920,1923
< directions though, because in the
< .I XDR_DECODE
< direction the value of
< .I gnp
---
> directions though, because in the
> .I XDR_DECODE
> direction the value of
> .I gnp
1926c1926
< Next, we XDR the data in the node using the primitive
---
> Next, we XDR the data in the node using the primitive
1928,1930c1928,1930
< .I xdr_reference()
< is like
< .I xdr_pointer()
---
> .I xdr_reference()
> is like
> .I xdr_pointer()
1932,1937c1932,1937
< send over the boolean indicating whether there is more data.
< We use it instead of
< .I xdr_pointer()
< because we have already XDR'd this information ourselves. Notice
< that the xdr routine passed is not the same type as an element
< in the list. The routine passed is
---
> send over the boolean indicating whether there is more data.
> We use it instead of
> .I xdr_pointer()
> because we have already XDR'd this information ourselves. Notice
> that the xdr routine passed is not the same type as an element
> in the list. The routine passed is
1939,1940c1939,1940
< for XDR'ing gnumbers, but each element in the list is actually of
< type
---
> for XDR'ing gnumbers, but each element in the list is actually of
> type
1942,1950c1942,1950
< We don't pass
< .I xdr_gnumbers_node()
< because it is recursive, and instead use
< .I xdr_gnumbers()
< which XDR's all of the non-recursive part. Note that this trick
< will work only if the
< .I gn_numbers
< field is the first item in each element, so that their addresses
< are identical when passed to
---
> We don't pass
> .I xdr_gnumbers_node()
> because it is recursive, and instead use
> .I xdr_gnumbers()
> which XDR's all of the non-recursive part. Note that this trick
> will work only if the
> .I gn_numbers
> field is the first item in each element, so that their addresses
> are identical when passed to
1953,1955c1953,1955
< Finally, we update
< .I gnp
< to point to the next item in the list. If the direction is
---
> Finally, we update
> .I gnp
> to point to the next item in the list. If the direction is
1957,1960c1957,1960
< we set it to the previously saved value, otherwise we can
< dereference
< .I gnp
< to get the proper value. Though harder to understand than the
---
> we set it to the previously saved value, otherwise we can
> dereference
> .I gnp
> to get the proper value. Though harder to understand than the
1963,1964c1963,1964
< a lot of procedure call overhead has been removed. Most lists
< are small though (in the hundreds of items or less) and the
---
> a lot of procedure call overhead has been removed. Most lists
> are small though (in the hundreds of items or less) and the