netutils.h 3.04 KB
Newer Older
1
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
2
 * netutils.h: various network functions
3
 * This header describes miscellanous utility functions shared between several
Michel Kaempf's avatar
Michel Kaempf committed
4
 * modules.
5
 *****************************************************************************
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 * Copyright (C) 1999, 2000 VideoLAN
 *
 * Authors:
 *
 * 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
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *****************************************************************************/

/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
27 28
 * Required headers:
 *  <netinet/in.h>
29
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
30 31


32
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
33
 * if_descr_t: describes a network interface.
34
 *****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
35 36
 * Note that if the interface is a point to point one, the broadcast address is
 * set to the destination address of that interface
37
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
38 39 40 41 42
typedef struct
{
    /* Interface device name (e.g. "eth0") */
    char* psz_ifname;
    /* Interface physical address */
43
    struct sockaddr sa_phys_addr;
Michel Kaempf's avatar
Michel Kaempf committed
44 45 46 47 48 49 50 51 52
    /* Interface network address */
    struct sockaddr_in sa_net_addr;
    /* Interface broadcast address */
    struct sockaddr_in sa_bcast_addr;
    /* Interface flags: see if.h for their description) */
    u16 i_flags;
} if_descr_t;


53
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
54
 * net_descr_t: describes all the interfaces of the computer
55
 *****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
56
 * Nothing special to say :)
57
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
58 59 60 61 62 63 64 65 66
typedef struct
{
    /* Number of networks interfaces described below */
    int i_if_number;
    /* Table of if_descr_t describing each interface */
    if_descr_t* a_if;
} net_descr_t;


67
/*****************************************************************************
Michel Kaempf's avatar
Michel Kaempf committed
68
 * Prototypes
69
 *****************************************************************************/
Michel Kaempf's avatar
Michel Kaempf committed
70 71 72 73 74
int ReadIfConf      (int i_sockfd, if_descr_t* p_ifdescr, char* psz_name);
int ReadNetConf     (int i_sockfd, net_descr_t* p_net_descr);
int BuildInetAddr   ( struct sockaddr_in *p_sa_in, char *psz_in_addr, int i_port );
int ServerPort      ( char *psz_addr );