| OpenSS7 SS7 for the Common Man | © Copyright 1997-2007 OpenSS7 Corporation All Rights Reserved. Last modified: Sat, 01 Nov 2008 10:41:52 GMT | ||||||||||||||||
| |||||||||||||||||
| Manpage of M_COPYOUTDescription: Manual PageKeywords: ss7 ss7/ip ss7 over ip ss7 mtp ss7 sccp ss7 tcap sigtran mtp sccp tcap openss7 acb56 linux telephony pstn linux telephony linux nebs linux compactpciM_COPYOUTSection: Linux Fast-STREAMS DDI/DKI (9)Updated: 2008-10-31 Index Return to Main Contents NAMEM_COPYOUT - STREAMS copyout messageFORMATThe M_COPYOUT message block is a datab(9) structure and associated data buffer that contains unstructured data. An M_COPYOUT message is a high priority message that consists of one M_COPYOUT message block followed by one or more M_DATA(9) message blocks. INTERFACEDESCRIPTIONThe M_COPYOUT is a high priority message generated by a driver or module and sent upstream to request that the Stream head perform a copyout(9) on behalf of the driver or module. It is valid only after receiving an M_IOCTL(9) message and before an M_IOCACK(9) or M_IOCNAK(9), for a given ioctl operation identifier, ioc_id . M_COPYOUT is a high priority message that is not subject to flow control within a Stream. The format of the message is one M_COPYOUT message block followed by one or more M_DATA(9) blocks. The M_COPYOUT message block contains a copyreq(9) structure, defined in <sys/stream.h>:
struct copyreq {
int cq_cmd; /* ioctl command (from ioc_cmd) */
cred_t *cq_cr; /* full credentials */
uint cq_id; /* ioctl id (from ioc_id) */
caddr_t cq_addr; /* address top copy data to/from */
uint cq_size; /* number of bytes to copy */
int cq_flag; /* SVR 3.2 compatibility */
mblk_t *cq_private; /* private state information */
long cq_filer[4]; /* reserved for future use */
};
The first three members of the structure correspond to those of the iocblk(9) structure in the M_IOCTL(9) message block which allows the same message block to be reused for both structures. The Stream head will guarantee that the message block allocated for the M_IOCTL(9) message is large enough to contain a copyreq(9) structure. The cq_addr field contains the user space address to which the data are to be copied. The cq_size field is the number of bytes to copy to user space. The cq_private field can be used by a module to point to a message block containing the module's state information relating to this ioctl(2s). The Stream head will copy (without processing) the contents of this field to the M_IOCDATA(9) reponse message so that the module can resume the associated state. If an M_COPYIN(9) or M_COPYOUT(9) message is freed, STREAMS will not free any message block pointed to by cq_private. This is the module's responsibility. Data to be copied to user space is contained in the linked M_DATA(9) blocks. The driver or module responding to a tranparent M_IOCTL(9) message issues a M_COPYOUT message when it wishes to copy data out to the user. The message is formulated and issued upstream to the Stream head. When reveived by the Stream head, the Stream head will attempt to copy out the requested amount of data of size cq_size, to the user address cq_addr, using the copyout(9) utility. If the copyout(9) operation succeeds, the Stream head will reply with an M_IOCDATA(9) message block whose cp_rval member is set to (caddr_t)(0), indicating that the operation was successful. If the copyout(9) operation fails, the Stream head will reply with an M_IOCDATA(9) message block whose cp_rval member is set to (caddr_t)(1), to indicate the error, and then aborts the ioctl(2s) operation and returns [EFAULT] to the user in errno(3). This provides the driver or module with the opportunity to clean up the cq_private pointer when the ioctl(2s) operation is aborted. See M_IOCDATA(9), for more information. M_COPYOUT messages cannot be directly generated by a user level process. M_COPYOUT messages arriving at a non-multiplexing driver should be discarded (ignored and freed). M_COPYOUT messages can be generated by a driver or module responding to an M_IOCTL(9) message. USAGEThe following guidelines represent best practise for processing of the M_COPYOUT message by drivers and modules:
EXAMPLESThe following procedure fragment provides an example of handling of M_COPYOUT messages on the read-side of an intermediate module. Note that at line 16, M_COPYOUT (and M_COPYIN(9)) messages are passed upstream without queuing.
1 int
2 xxx_rput(queue_t *q, mblk_t *mp)
3 {
4 int type;
5
6 if ((type = mp->b_datap->db_type) >= QPCTL) {
7 switch (type) {
8 case M_PCPROTO:
9 do_message_processing(q, mp);
10 break;
11 /* ... */
12 case M_FLUSH:
13 /* perform canonical flushing */
14 /* ... */
15 /* fall through */
16 default: /* e.g. M_COPYOUT */
17 /* unhandled high-priority message */
18 putnext(q, mp);
19 break;
20 }
21 } else if (!q->q_first && !q->q_flag & QSVCBUSY
22 && bcanputnext(q, mp->b_band)) {
23 switch (type) {
24 case M_PROTO:
25 case M_DATA:
26 do_message_rpocessing(q, mp);
27 break;
28 /* ... */
29 default:
30 /* unhandled normal priority message */
31 putnext(q, mp);
32 break;
33 }
34 } else {
35 putq(q, mp);
36 }
37 return (0);
38 }
The following code fragment provides an example of proper issuance of an M_COPYOUT message and handling of the response from a driver:
1 void
2 do_ioctl(queue_t *q, mblk_t *mp)
3 {
4 struct iocblk *ioc;
5 struct copyreq *cq;
6 struct copyresp *cp;
7
8 switch (mp->b_datap->db_type) {
9 case M_IOCTL:
10 ioc = (typeof(ioc)) mp->b_rptr;
11 switch (ioc->ioc_cmd) {
12 case KNOWN_IOCTL:
13 if (ioc->ioc_count == TRANSPARENT) {
14 cq = (typeof(cq)) mp->b_rptr;
15 cq->cq_addr =
16 *(typeof(cq->cq_addr) *)
17 mp->b_cont->b_rptr;
18 cq->cq_size = KNOWN_IOCTL_SIZE;
19 cq->cq_private = (mblk_t *) (1);
20 mp->b_datap->db_type = M_COPYIN;
21 freemsg(mp->b_cont);
22 if (!(mp->b_cont =
23 allocb(KNOWN_IOCTL_SIZE,
24 BPRI_MED))) {
25 mp->b_datap->db_type = M_IOCNAK;
26 ioc->ioc_rval = -1;
27 ioc->ioc_error = ENOBUFS;
28 qreply(q, mp);
29 return;
30 }
31 bcopy(data, mp->b_cont->b_wptr,
32 KNOWN_IOCTL_SIZE);
33 mp->b_cont->b_wptr +=
34 KNOWN_IOCTL_SIZE;
35 qreply(q, mp);
36 return;
37 }
38 /* copied in data is in mp->b_cont for
39 I_STR ioctls */
40 break;
41 default:
42 mp->b_datap->db_type = M_IOCNAK;
43 qreply(q, mp);
44 return;
45 }
46 /* fall through */
47 case M_IOCDATA:
48 cp = (typeof(cq)) mp->b_rptr;
49 if (cp->cp_rval) {
50 /* copy error, abort */
51 cp->cp_private = NULL;
52 freemsg(mp);
53 return;
54 }
55 cp->cp_private = NULL;
56 mp->b_datap->db_type = M_IOCACK;
57 ioc = (typeof(ioc)) mp->b_rptr;
58 ioc->ioc_rval = 0;
59 ioc->ioc_error = 0;
60 qreply(q, mp);
61 return;
62 default:
63 freemsg(mp);
64 return;
65 }
66 }
SEE ALSOCOMPATIBILITYThe M_COPYOUT STREAMS message is compatible with SVR 4.2 MP STREAMS, and implementations based on SVR 4, with the following portability considerations:
See STREAMS(9) for additional compatibility information. CONFORMANCEHISTORYThe M_COPYOUT message first appeared in SVR 3[7]. REFERENCES
TRADEMARKS
Other trademarks are the property of their respective owners. IDENTIFICATION
Copyright©1997-2008OpenSS7 Corp.
All Rights Reserved.
Index
This document was created by man2html, using the manual pages. Time: 05:19:38 GMT, May 20, 2013 | ||||||||||||||||
| OpenSS7 SS7 for the Common Man |
| ||||||||||||||||
| Last modified: Sat, 01 Nov 2008 10:41:52 GMT © Copyright 1997-2007 OpenSS7 Corporation All Rights Reserved. |