libhd 5.0
Data Structures | Defines | Typedefs | Functions | Variables
pppoe.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <linux/if.h>
#include <net/ethernet.h>
#include <net/if_arp.h>
#include <netinet/in.h>
#include <netpacket/packet.h>
#include "hd.h"
#include "hd_int.h"
#include "pppoe.h"

Data Structures

struct  PPPoEPacketStruct
struct  PPPoETagStruct
struct  PPPoEConnectionStruct
struct  PacketCriteriaStruct

Defines

#define ETH_PPPOE_DISCOVERY   0x8863
#define ETH_PPPOE_SESSION   0x8864
#define CODE_PADI   0x09
#define CODE_PADO   0x07
#define CODE_PADR   0x19
#define CODE_PADS   0x65
#define CODE_PADT   0xA7
#define TAG_END_OF_LIST   0x0000
#define TAG_SERVICE_NAME   0x0101
#define TAG_AC_NAME   0x0102
#define TAG_HOST_UNIQ   0x0103
#define TAG_AC_COOKIE   0x0104
#define TAG_VENDOR_SPECIFIC   0x0105
#define TAG_RELAY_SESSION_ID   0x0110
#define TAG_SERVICE_NAME_ERROR   0x0201
#define TAG_AC_SYSTEM_ERROR   0x0202
#define TAG_GENERIC_ERROR   0x0203
#define MAX_ATTEMPTS   2
#define PADO_TIMEOUT   3
#define PPPOE_OVERHEAD   6
#define HDR_SIZE   (sizeof (struct ethhdr) + PPPOE_OVERHEAD)
#define MAX_PPPOE_PAYLOAD   (ETH_DATA_LEN - PPPOE_OVERHEAD)
#define TAG_HDR_SIZE   4
#define NOT_UNICAST(e)   ((e[0] & 0x01) != 0)

Typedefs

typedef struct PPPoEPacketStruct PPPoEPacket
typedef struct PPPoETagStruct PPPoETag
typedef void parse_func (uint16_t type, uint16_t len, unsigned char *data, void *extra)
typedef struct
PPPoEConnectionStruct 
PPPoEConnection
typedef struct PacketCriteriaStruct PacketCriteria

Functions

static int check_room (PPPoEConnection *conn, unsigned char *cursor, unsigned char *start, uint16_t len)
static int parse_packet (PPPoEConnection *conn, PPPoEPacket *packet, parse_func *func, void *extra)
static int open_interfaces (int n, PPPoEConnection *conns)
static void close_intefaces (int n, PPPoEConnection *conns)
static int send_packet (int fd, PPPoEPacket *pkt, size_t size)
static int receive_packet (int fd, PPPoEPacket *pkt, size_t *size)
static void parse_hostuniq (uint16_t type, uint16_t len, unsigned char *data, void *extra)
static int packet_for_me (PPPoEConnection *conn, PPPoEPacket *packet)
static void parse_pado_tags (uint16_t type, uint16_t len, unsigned char *data, void *extra)
static int send_padi (int n, PPPoEConnection *conns)
static int wait_for_pado (int n, PPPoEConnection *conns)
static void discovery (int n, PPPoEConnection *conns)
void hd_scan_pppoe (hd_data_t *hd_data2)

Variables

static hd_data_thd_data

Variable Documentation

hd_data_t* hd_data [static]