ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-NBD/NBD.xs
(Generate patch)

Comparing Linux-NBD/NBD.xs (file contents):
Revision 1.2 by root, Fri May 9 00:15:14 2003 UTC vs.
Revision 1.4 by root, Thu Aug 24 12:13:40 2006 UTC

75MODULE = Linux::NBD PACKAGE = Linux::NBD::Server 75MODULE = Linux::NBD PACKAGE = Linux::NBD::Server
76 76
77void 77void
78_one_request (SV *obj, int fd) 78_one_request (SV *obj, int fd)
79 CODE: 79 CODE:
80{
80 struct nbd_request req; 81 struct nbd_request req;
81 82
82 if (read (fd, &req, sizeof (req)) == sizeof (req)) 83 if (read (fd, &req, sizeof (req)) == sizeof (req))
83 { 84 {
84 if (req.magic == htonl (NBD_REQUEST_MAGIC)) 85 if (req.magic == htonl (NBD_REQUEST_MAGIC))
85 { 86 {
87 req.type = htonl (req.type);
88
86 if (req.type < 2) 89 if (req.type < 2)
87 { 90 {
88 u64 from = ntohll (req.from); 91 u64 from = ntohll (req.from);
89 92
90 PUSHMARK (SP); 93 PUSHMARK (SP);
103 } 106 }
104 } 107 }
105 } 108 }
106 109
107 XSRETURN_YES; 110 XSRETURN_YES;
111}
108 112
109SV * 113SV *
110_format_reply (SV *handle, unsigned int error = 0, SV *data = 0) 114_format_reply (SV *handle, unsigned int error = 0, SV *data = 0)
111 CODE: 115 CODE:
116{
112 struct nbd_reply rep; 117 struct nbd_reply rep;
113 STRLEN len; 118 STRLEN len;
114 char *h = SvPV (handle, len); 119 char *h = SvPV (handle, len);
115 120
116 if (len != sizeof (rep.handle)) 121 if (len != sizeof (rep.handle))
122 127
123 RETVAL = newSVpvn ((char *)&rep, sizeof (rep)); 128 RETVAL = newSVpvn ((char *)&rep, sizeof (rep));
124 129
125 if (data && !error) 130 if (data && !error)
126 sv_catsv (RETVAL, data); 131 sv_catsv (RETVAL, data);
127 132}
128 OUTPUT: 133 OUTPUT:
129 RETVAL 134 RETVAL
130 135

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines