Deleted Added
full compact
subr_ndis.c (153481) subr_ndis.c (159797)
1/*-
2 * Copyright (c) 2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/compat/ndis/subr_ndis.c 152626 2005-11-20 01:29:29Z wpaul $");
34__FBSDID("$FreeBSD: head/sys/compat/ndis/subr_ndis.c 159797 2006-06-20 20:37:17Z jhb $");
35
36/*
37 * This file implements a translation layer between the BSD networking
38 * infrasturcture and Windows(R) NDIS network driver modules. A Windows
39 * NDIS driver calls into several functions in the NDIS.SYS Windows
40 * kernel module and exports a table of functions designed to be called
41 * by the NDIS subsystem. Using the PE loader, we can patch our own
42 * versions of the NDIS routines into a given Windows driver module and

--- 2838 unchanged lines hidden (view full) ---

2881 *sym = linker_file_lookup_symbol(lf, fullsym, 0);
2882 ExFreePool(fullsym);
2883 if (*sym == 0)
2884 return(ENOENT);
2885
2886 return(0);
2887}
2888
35
36/*
37 * This file implements a translation layer between the BSD networking
38 * infrasturcture and Windows(R) NDIS network driver modules. A Windows
39 * NDIS driver calls into several functions in the NDIS.SYS Windows
40 * kernel module and exports a table of functions designed to be called
41 * by the NDIS subsystem. Using the PE loader, we can patch our own
42 * versions of the NDIS routines into a given Windows driver module and

--- 2838 unchanged lines hidden (view full) ---

2881 *sym = linker_file_lookup_symbol(lf, fullsym, 0);
2882 ExFreePool(fullsym);
2883 if (*sym == 0)
2884 return(ENOENT);
2885
2886 return(0);
2887}
2888
2889struct ndis_checkmodule {
2890 char *afilename;
2891 ndis_fh *fh;
2892};
2893
2894/*
2895 * See if a single module contains the symbols for a specified file.
2896 */
2897static int
2898NdisCheckModule(linker_file_t lf, void *context)
2899{
2900 struct ndis_checkmodule *nc;
2901 caddr_t kldstart, kldend;
2902
2903 nc = (struct ndis_checkmodule *)context;
2904 if (ndis_find_sym(lf, nc->afilename, "_start", &kldstart))
2905 return (0);
2906 if (ndis_find_sym(lf, nc->afilename, "_end", &kldend))
2907 return (0);
2908 nc->fh->nf_vp = lf;
2909 nc->fh->nf_map = NULL;
2910 nc->fh->nf_type = NDIS_FH_TYPE_MODULE;
2911 nc->fh->nf_maplen = (kldend - kldstart) & 0xFFFFFFFF;
2912 return (1);
2913}
2914
2889/* can also return NDIS_STATUS_RESOURCES/NDIS_STATUS_ERROR_READING_FILE */
2890static void
2891NdisOpenFile(status, filehandle, filelength, filename, highestaddr)
2892 ndis_status *status;
2893 ndis_handle *filehandle;
2894 uint32_t *filelength;
2895 unicode_string *filename;
2896 ndis_physaddr highestaddr;
2897{
2898 ansi_string as;
2899 char *afilename = NULL;
2900 struct thread *td = curthread;
2901 struct nameidata nd;
2902 int flags, error;
2903 struct vattr vat;
2904 struct vattr *vap = &vat;
2905 ndis_fh *fh;
2906 char *path;
2915/* can also return NDIS_STATUS_RESOURCES/NDIS_STATUS_ERROR_READING_FILE */
2916static void
2917NdisOpenFile(status, filehandle, filelength, filename, highestaddr)
2918 ndis_status *status;
2919 ndis_handle *filehandle;
2920 uint32_t *filelength;
2921 unicode_string *filename;
2922 ndis_physaddr highestaddr;
2923{
2924 ansi_string as;
2925 char *afilename = NULL;
2926 struct thread *td = curthread;
2927 struct nameidata nd;
2928 int flags, error;
2929 struct vattr vat;
2930 struct vattr *vap = &vat;
2931 ndis_fh *fh;
2932 char *path;
2907 linker_file_t head, lf;
2908 caddr_t kldstart, kldend;
2933 struct ndis_checkmodule nc;
2909
2910 if (RtlUnicodeStringToAnsiString(&as, filename, TRUE)) {
2911 *status = NDIS_STATUS_RESOURCES;
2912 return;
2913 }
2914
2915 afilename = strdup(as.as_buf, M_DEVBUF);
2916 RtlFreeAnsiString(&as);

--- 21 unchanged lines hidden (view full) ---

2938 * list in search of those symbols and we've found the file
2939 * data. As an added bonus, ndiscvt(8) will also generate
2940 * a normal .o file which can be linked statically with
2941 * the kernel. This means that the symbols will actual reside
2942 * in the kernel's symbol table, but that doesn't matter to
2943 * us since the kernel appears to us as just another module.
2944 */
2945
2934
2935 if (RtlUnicodeStringToAnsiString(&as, filename, TRUE)) {
2936 *status = NDIS_STATUS_RESOURCES;
2937 return;
2938 }
2939
2940 afilename = strdup(as.as_buf, M_DEVBUF);
2941 RtlFreeAnsiString(&as);

--- 21 unchanged lines hidden (view full) ---

2963 * list in search of those symbols and we've found the file
2964 * data. As an added bonus, ndiscvt(8) will also generate
2965 * a normal .o file which can be linked statically with
2966 * the kernel. This means that the symbols will actual reside
2967 * in the kernel's symbol table, but that doesn't matter to
2968 * us since the kernel appears to us as just another module.
2969 */
2970
2946 /*
2947 * This is an evil trick for getting the head of the linked
2948 * file list, which is not exported from kern_linker.o. It
2949 * happens that linker file #1 is always the kernel, and is
2950 * always the first element in the list.
2951 */
2952
2953 head = linker_find_file_by_id(1);
2954 for (lf = head; lf != NULL; lf = TAILQ_NEXT(lf, link)) {
2955 if (ndis_find_sym(lf, afilename, "_start", &kldstart))
2956 continue;
2957 if (ndis_find_sym(lf, afilename, "_end", &kldend))
2958 continue;
2959 fh->nf_vp = lf;
2960 fh->nf_map = NULL;
2961 fh->nf_type = NDIS_FH_TYPE_MODULE;
2962 *filelength = fh->nf_maplen = (kldend - kldstart) & 0xFFFFFFFF;
2971 nc.afilename = afilename;
2972 nc.fh = fh;
2973 if (linker_file_foreach(NdisCheckModule, &nc)) {
2974 *filelength = fh->nf_maplen;
2963 *filehandle = fh;
2964 *status = NDIS_STATUS_SUCCESS;
2965 return;
2966 }
2967
2968 if (TAILQ_EMPTY(&mountlist)) {
2969 ExFreePool(fh);
2970 *status = NDIS_STATUS_FILE_NOT_FOUND;

--- 564 unchanged lines hidden ---
2975 *filehandle = fh;
2976 *status = NDIS_STATUS_SUCCESS;
2977 return;
2978 }
2979
2980 if (TAILQ_EMPTY(&mountlist)) {
2981 ExFreePool(fh);
2982 *status = NDIS_STATUS_FILE_NOT_FOUND;

--- 564 unchanged lines hidden ---