2 .\" Copyright 1989 AT&T Copyright (c) 2006, Sun Microsystems, Inc.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH COPYB 9F "Jan 16, 2006"
8 copyb \- copy a message block
12 #include <sys/stream.h>
16 \fBmblk_t *\fR\fBcopyb\fR(\fBmblk_t *\fR\fIbp\fR);
22 Architecture independent level 1 (DDI/DKI).
30 Pointer to the message block from which data is copied.
36 The \fBcopyb()\fR function allocates a new message block, and copies into it
37 the data from the block that \fIbp\fR denotes. The new block will be at least
38 as large as the block being copied. \fBcopyb()\fR uses the \fBb_rptr\fR and
39 \fBb_wptr\fR members of \fIbp\fR to determine how many bytes to copy.
43 If successful, \fBcopyb()\fR returns a pointer to the newly allocated message
44 block containing the copied data. Otherwise, it returns a \fINULL\fR pointer.
48 The \fBcopyb()\fR function can be called from user, interrupt, or kernel
52 \fBExample 1 \fRUsing copyb
55 For each message in the list, test to see if the downstream queue is full with
56 the \fBcanputnext\fR(9F) function (line 21). If it is not full, use \fBcopyb\fR
57 to copy a header message block, and \fBdupmsg\fR(9F) to duplicate the data to
58 be retransmitted. If either operation fails, reschedule a timeout at the next
63 Update the new header block with the correct destination address (line 34),
64 link the message to it (line 35), and send it downstream (line 36). At the end
65 of the list, reschedule this routine.
74 5 struct retrans *r_next;
77 8 struct protoheader {
86 15 retransmit(struct retrans *ret)
89 18 struct protoheader *php;
92 21 if (!canputnext(ret->r_outq)) { /* no room */
96 25 bp = copyb(header); /* copy header msg. block */
99 28 mp = dupmsg(ret->r_mp); /* duplicate data */
100 29 if (mp == NULL) { /* if unsuccessful */
101 30 freeb(bp); /* free the block */
104 33 php = (struct protoheader *)bp->b_rptr;
105 34 php->h_address = ret->r_address; /* new header */
106 35 bp->bp_cont = mp; /* link the message */
107 36 putnext(ret->r_outq, bp); /* send downstream */
108 37 ret = ret->r_next;
111 40 (void) timeout(retransmit, (caddr_t)ret, RETRANS_TIME);
119 \fBallocb\fR(9F), \fBcanputnext\fR(9F), \fBdupmsg\fR(9F)
122 \fIWriting Device Drivers\fR
125 \fISTREAMS Programming Guide\fR