Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
62b322c2
Commit
62b322c2
authored
May 18, 2001
by
Xavier Marchesini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
5f232025
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
132 additions
and
2 deletions
+132
-2
src/misc/netutils.c
src/misc/netutils.c
+132
-2
No files found.
src/misc/netutils.c
View file @
62b322c2
...
...
@@ -2,11 +2,12 @@
* netutils.c: various network functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: netutils.c,v 1.
29 2001/05/07 04:42:42 sam
Exp $
* $Id: netutils.c,v 1.
30 2001/05/18 09:49:16 xav
Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Benoit Steiner <benny@via.ecp.fr>
* Henri Fallon <henri@videolan.org>
* Xavier Marchesini <xav@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -48,6 +49,14 @@
#include <sys/ioctl.h>
/* ioctl() */
#endif
#ifdef WIN32
/* tools to get the MAC adress from */
#include <windows.h>
/* the interface under Windows */
#include <stdio.h>
#include <iostream>
#include <strstream>
#include <string>
#endif
#ifdef HAVE_NET_IF_H
#include <net/if.h>
/* interface (arch-dependent) */
#endif
...
...
@@ -67,7 +76,6 @@
#include "netutils.h"
/*****************************************************************************
* input_channel_t: channel library data
*****************************************************************************
...
...
@@ -83,6 +91,128 @@ typedef struct input_channel_s
}
input_channel_t
;
#ifdef WIN32
/*****************************************************************************
* GetAdapterInfo : gets some informations about the interface using NETBIOS *
*****************************************************************************/
using
namespace
std
;
bool
GetAdapterInfo
(
int
nAdapterNum
,
string
&
sMAC
)
{
/* Reset the LAN adapter so that we can begin querying it */
NCB
Ncb
;
memset
(
&
Ncb
,
0
,
sizeof
(
Ncb
)
)
;
Ncb
.
ncb_command
=
NCBRESET
;
Ncb
.
ncb_lana_num
=
nAdapterNum
;
if
(
Netbios
(
&
Ncb
)
!=
NRC_GOODRET
)
{
char
acTemp
[
80
]
;
ostrstream
outs
(
acTemp
,
sizeof
(
acTemp
)
)
;
/* FIXME This should use vlc's standard handling error functions */
outs
<<
"error "
<<
Ncb
.
ncb_retcode
<<
" on reset"
<<
ends
;
sMAC
=
acTemp
;
return
false
;
}
/* Prepare to get the adapter status block */
memset
(
&
Ncb
,
0
,
sizeof
(
Ncb
)
)
;
/* Initialization */
Ncb
.
ncb_command
=
NCBASTAT
;
Ncb
.
ncb_lana_num
=
nAdapterNum
;
strcpy
(
(
char
*
)
Ncb
.
ncb_callname
,
"*"
)
;
struct
ASTAT
{
ADAPTER_STATUS
adapt
;
NAME_BUFFER
NameBuff
[
30
]
;
}
Adapter
;
memset
(
&
Adapter
,
0
,
sizeof
(
Adapter
)
)
;
Ncb
.
ncb_buffer
=
(
unsigned
char
*
)
&
Adapter
;
Ncb
.
ncb_length
=
sizeof
(
Adapter
)
;
/* Get the adapter's info and, if this works, return it in standard,
colon-delimited form. */
if
(
Netbios
(
&
Ncb
)
==
0
)
{
char
acMAC
[
18
]
;
sprintf
(
acMAC
,
"%02X:%02X:%02X:%02X:%02X:%02X"
,
int
(
Adapter
.
adapt
.
adapter_address
[
0
]
),
int
(
Adapter
.
adapt
.
adapter_address
[
1
]
),
int
(
Adapter
.
adapt
.
adapter_address
[
2
]
),
int
(
Adapter
.
adapt
.
adapter_address
[
3
]
),
int
(
Adapter
.
adapt
.
adapter_address
[
4
]
),
int
(
Adapter
.
adapt
.
adapter_address
[
5
]
)
);
sMAC
=
acMAC
;
return
true
;
}
else
{
char
acTemp
[
80
]
;
ostrstream
outs
(
acTemp
,
sizeof
(
acTemp
)
)
;
/* FIXME Same thing as up there */
outs
<<
"error "
<<
Ncb
.
ncb_retcode
<<
" on ASTAT"
<<
ends
;
sMAC
=
acTemp
;
return
false
;
}
}
/*****************************************************************************
* GetMacAddress : Extracts the MAC Address from the informations collected in
* GetAdapterInfo
****************************************************************************/
string
GetMacAddress
()
{
/* Get adapter list - support for more than one adapter */
LANA_ENUM
AdapterList
;
NCB
Ncb
;
memset
(
&
Ncb
,
0
,
sizeof
(
NCB
)
)
;
Ncb
.
ncb_command
=
NCBENUM
;
Ncb
.
ncb_buffer
=
(
unsigned
char
*
)
&
AdapterList
;
Ncb
.
ncb_length
=
sizeof
(
AdapterList
)
;
Netbios
(
&
Ncb
)
;
/* Get all of the local ethernet addresses */
string
sMAC
;
for
(
int
i
=
0
;
i
<
AdapterList
.
length
;
++
i
)
{
if
(
GetAdapterInfo
(
AdapterList
.
lana
[
i
]
,
sMAC
)
)
{
cout
<<
"Adapter "
<<
int
(
AdapterList
.
lana
[
i
]
)
<<
"'s MAC is "
<<
sMAC
<<
endl
;
}
else
{
/* FIXME those bloody error messages */
cerr
<<
"Failed to get MAC address! Do you"
<<
endl
;
cerr
<<
"have the NetBIOS protocol installed?"
<<
endl
;
break
;
}
}
return
sMac
;
}
#endif
/*****************************************************************************
* network_BuildLocalAddr : fill a sockaddr_in structure for local binding
*****************************************************************************/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment