Work on winsock stack and indentation corrections.
[reactos.git] / reactos / drivers / net / afd / afd / rdwr.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Ancillary Function Driver
4 * FILE: afd/rdwr.c
5 * PURPOSE: File object read/write functions
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * REVISIONS:
8 * CSH 01/09-2000 Created
9 */
10 #include <afd.h>
11
12 NTSTATUS AfdReadFile(
13 PDEVICE_EXTENSION DeviceExt,
14 PFILE_OBJECT FileObject,
15 PVOID Buffer,
16 ULONG Length,
17 ULONG Offset)
18 /*
19 * FUNCTION: Reads data from a file
20 */
21 {
22 UNIMPLEMENTED
23
24 return STATUS_UNSUCCESSFUL;
25 }
26
27
28 NTSTATUS
29 STDCALL
30 AfdRead(
31 PDEVICE_OBJECT DeviceObject,
32 PIRP Irp)
33 {
34 #if 1
35 UNIMPLEMENTED
36
37 Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
38 Irp->IoStatus.Information = 0;
39 return STATUS_UNSUCCESSFUL;
40 #else
41 PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
42 PIO_STACK_LOCATION IoSp = IoGetCurrentIrpStackLocation(Irp);
43 PFILE_OBJECT FileObject = IoSp->FileObject;
44 NTSTATUS Status;
45 ULONG Length;
46 PVOID Buffer;
47 ULONG Offset;
48
49 Length = IoSp->Parameters.Read.Length;
50 Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
51 Offset = IoSp->Parameters.Read.ByteOffset.u.LowPart;
52
53 Status = AfdReadFile(DeviceExt, FileObject, Buffer, Length, Offset);
54
55 Irp->IoStatus.Status = Status;
56 Irp->IoStatus.Information = Length;
57 IoCompleteRequest(Irp, IO_NO_INCREMENT);
58 return Status;
59 #endif
60 }
61
62
63 NTSTATUS
64 STDCALL
65 AfdWrite(
66 PDEVICE_OBJECT DeviceObject,
67 PIRP Irp)
68 {
69 PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
70 PIO_STACK_LOCATION IoSp = IoGetCurrentIrpStackLocation(Irp);
71 PFILE_OBJECT FileObject = IoSp->FileObject;
72 NTSTATUS Status;
73 ULONG Length;
74 PVOID Buffer;
75 ULONG Offset;
76 PAFDFCB FCB;
77 PAFDCCB CCB;
78
79 FCB = FileObject->FsContext;
80 CCB = FileObject->FsContext2;
81
82 Length = IoSp->Parameters.Write.Length;
83 Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
84 Offset = IoSp->Parameters.Write.ByteOffset.u.LowPart;
85
86 AFD_DbgPrint(MIN_TRACE, ("Called. Length (%d) Buffer (0x%X) Offset (0x%X)\n",
87 Length, Buffer, Offset));
88
89 /* FIXME: Connectionless communication only */
90 //Status = TdiSendDatagram(FCB->TdiAddressObject, WH2N(2000), 0x7F000001, Buffer, Length);
91 //if (!NT_SUCCESS(Status))
92 Length = 0;
93
94 Irp->IoStatus.Status = Status;
95 Irp->IoStatus.Information = Length;
96 IoCompleteRequest(Irp, IO_NO_INCREMENT);
97
98 AFD_DbgPrint(MIN_TRACE, ("Leaving.\n"));
99
100 return Status;
101 }
102
103 /* EOF */