2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
5 * PURPOSE: Internet Protocol module
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * Art Yerkes (arty@users.sourceforge.net)
9 * CSH 01/08-2000 Created
15 LIST_ENTRY PrefixListHead
;
16 KSPIN_LOCK PrefixListLock
;
18 /* --------- The Prefix List ---------- */
21 /* Initialize the prefix list and protecting lock */
22 InitializeListHead(&PrefixListHead
);
23 TcpipInitializeSpinLock(&PrefixListLock
);
27 PPREFIX_LIST_ENTRY
CreatePLE(PIP_INTERFACE IF
, PIP_ADDRESS Prefix
, UINT Length
)
29 * FUNCTION: Creates a prefix list entry and binds it to an interface
31 * IF = Pointer to interface
32 * Prefix = Pointer to prefix
33 * Length = Length of prefix
35 * Pointer to PLE, NULL if there was not enough free resources
37 * The prefix list entry retains a reference to the interface and
38 * the provided address. The caller is responsible for providing
42 PPREFIX_LIST_ENTRY PLE
;
44 TI_DbgPrint(DEBUG_IP
, ("Called. IF (0x%X) Prefix (0x%X) Length (%d).\n", IF
, Prefix
, Length
));
46 TI_DbgPrint(DEBUG_IP
, ("Prefix (%s).\n", A2S(Prefix
)));
48 /* Allocate space for an PLE and set it up */
49 PLE
= PoolAllocateBuffer(sizeof(PREFIX_LIST_ENTRY
));
51 TI_DbgPrint(MIN_TRACE
, ("Insufficient resources.\n"));
55 INIT_TAG(PLE
, TAG('P','L','E',' '));
57 RtlCopyMemory(&PLE
->Prefix
, Prefix
, sizeof(PLE
->Prefix
));
58 PLE
->PrefixLength
= Length
;
60 /* Add PLE to the global prefix list */
61 ExInterlockedInsertTailList(&PrefixListHead
, &PLE
->ListEntry
, &PrefixListLock
);
68 PPREFIX_LIST_ENTRY PLE
)
70 * FUNCTION: Destroys an prefix list entry
72 * PLE = Pointer to prefix list entry
74 * The prefix list lock must be held when called
77 TI_DbgPrint(DEBUG_IP
, ("Called. PLE (0x%X).\n", PLE
));
79 TI_DbgPrint(DEBUG_IP
, ("PLE (%s).\n", PLE
->Prefix
));
81 /* Unlink the prefix list entry from the list */
82 RemoveEntryList(&PLE
->ListEntry
);
84 /* And free the PLE */
92 * FUNCTION: Destroys all prefix list entries
96 PLIST_ENTRY CurrentEntry
;
97 PLIST_ENTRY NextEntry
;
98 PPREFIX_LIST_ENTRY Current
;
100 TI_DbgPrint(DEBUG_IP
, ("Called.\n"));
102 TcpipAcquireSpinLock(&PrefixListLock
, &OldIrql
);
104 /* Search the list and remove every PLE we find */
105 CurrentEntry
= PrefixListHead
.Flink
;
106 while (CurrentEntry
!= &PrefixListHead
) {
107 NextEntry
= CurrentEntry
->Flink
;
108 Current
= CONTAINING_RECORD(CurrentEntry
, PREFIX_LIST_ENTRY
, ListEntry
);
109 /* Destroy the PLE */
111 CurrentEntry
= NextEntry
;
113 TcpipReleaseSpinLock(&PrefixListLock
, OldIrql
);