More work on winsock stack (ping is now working)
[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 assert(FCB);
83 assert(CCB);
84
85 Length = IoSp->Parameters.Write.Length;
86 Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
87 Offset = IoSp->Parameters.Write.ByteOffset.u.LowPart;
88
89 AFD_DbgPrint(MAX_TRACE, ("Called. Length (%d) Buffer (0x%X) Offset (0x%X)\n",
90 Length, Buffer, Offset));
91
92 assert((FCB->SocketType == SOCK_STREAM) || (FCB->SocketType == SOCK_DGRAM));
93
94 switch (FCB->SocketType) {
95 case SOCK_STREAM:
96 /* FIXME: Support connectionful communication */
97 break;
98 case SOCK_DGRAM:
99 /* Connectionless communication */
100 //Status = TdiSendDatagram(FCB->TdiAddressObject, WH2N(2000), 0x7F000001, Buffer, Length);
101 //if (!NT_SUCCESS(Status)) {
102 Length = 0;
103 //}
104 break;
105 case SOCK_RAW:
106 /* FIXME: Support raw communication */
107 break;
108 }
109
110 Irp->IoStatus.Status = Status;
111 Irp->IoStatus.Information = Length;
112 IoCompleteRequest(Irp, IO_NO_INCREMENT);
113
114 AFD_DbgPrint(MAX_TRACE, ("Leaving.\n"));
115
116 return Status;
117 }
118
119 /* EOF */