PPPoE devices (DSL)
Implementation internals » Device handling

PPPoE devices scan functions. More...

## Data Structures

struct | PPPoEPacketStruct
struct | PPPoETagStruct
struct | PPPoEConnectionStruct
struct | PacketCriteriaStruct

## Macros

#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 /* type, code, session, length */
#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)

## 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)

## Detailed Description

PPPoE devices scan functions.

## Macro Definition Documentation

## CODE_PADI

#define CODE_PADI 0x09

Referenced by send_padi().

## CODE_PADO

#define CODE_PADO 0x07

Referenced by wait_for_pado().

## CODE_PADR

#define CODE_PADR 0x19

## CODE_PADS

#define CODE_PADS 0x65

## CODE_PADT

#define CODE_PADT 0xA7

## ETH_PPPOE_DISCOVERY

#define ETH_PPPOE_DISCOVERY 0x8863

Referenced by open_interfaces(), and send_padi().

## ETH_PPPOE_SESSION

#define ETH_PPPOE_SESSION 0x8864

## HDR_SIZE

#define HDR_SIZE (sizeof (struct ethhdr) + PPPOE_OVERHEAD)

Referenced by send_padi(), and wait_for_pado().

## MAX_ATTEMPTS

#define MAX_ATTEMPTS 2

Referenced by discovery().

## MAX_PPPOE_PAYLOAD

#define MAX_PPPOE_PAYLOAD (ETH_DATA_LEN - PPPOE_OVERHEAD)

Referenced by check_room().

## NOT_UNICAST

#define NOT_UNICAST | ( |  | e | ) |

Value:
((e[0] & 0x01) != 0)

Referenced by open_interfaces(), and wait_for_pado().

## PADO_TIMEOUT

#define PADO_TIMEOUT 3

Referenced by wait_for_pado().

## PPPOE_OVERHEAD

#define PPPOE_OVERHEAD 6 /* type, code, session, length */

## TAG_AC_COOKIE

#define TAG_AC_COOKIE 0x0104

## TAG_AC_NAME

#define TAG_AC_NAME 0x0102

Referenced by parse_pado_tags().

## TAG_AC_SYSTEM_ERROR

#define TAG_AC_SYSTEM_ERROR 0x0202

Referenced by parse_pado_tags().

## TAG_END_OF_LIST

#define TAG_END_OF_LIST 0x0000

Referenced by parse_packet().

## TAG_GENERIC_ERROR

#define TAG_GENERIC_ERROR 0x0203

Referenced by parse_pado_tags().

## TAG_HDR_SIZE

#define TAG_HDR_SIZE 4

Referenced by parse_packet(), and send_padi().

## TAG_HOST_UNIQ

#define TAG_HOST_UNIQ 0x0103

Referenced by parse_hostuniq(), and send_padi().

## TAG_RELAY_SESSION_ID

#define TAG_RELAY_SESSION_ID 0x0110

## TAG_SERVICE_NAME

#define TAG_SERVICE_NAME 0x0101

Referenced by parse_pado_tags(), and send_padi().

## TAG_SERVICE_NAME_ERROR

#define TAG_SERVICE_NAME_ERROR 0x0201

Referenced by parse_pado_tags().

## TAG_VENDOR_SPECIFIC

#define TAG_VENDOR_SPECIFIC 0x0105

## Typedef Documentation

## PacketCriteria

typedef struct PacketCriteriaStruct PacketCriteria

## parse_func

typedef void parse_func(uint16_t type, uint16_t len, unsigned char *data, void *extra)

## PPPoEConnection

typedef struct PPPoEConnectionStruct PPPoEConnection

## PPPoEPacket

typedef struct PPPoEPacketStruct PPPoEPacket

## PPPoETag

typedef struct PPPoETagStruct PPPoETag

## Function Documentation

## check_room()

int check_room | ( | PPPoEConnection * | conn,
|  | unsigned char * | cursor,
|  | unsigned char * | start,
|  | uint16_t | len )

static

References ADD2LOG, PPPoEConnectionStruct::ifname, and MAX_PPPOE_PAYLOAD.

Referenced by send_padi().

## close_intefaces()

void close_intefaces | ( | int | n,
|  | PPPoEConnection * | conns )

static

References PPPoEConnectionStruct::fd.

Referenced by discovery().

## discovery()

void discovery | ( | int | n,
|  | PPPoEConnection * | conns )

static

References ADD2LOG, close_intefaces(), MAX_ATTEMPTS, open_interfaces(), send_padi(), and wait_for_pado().

Referenced by hd_scan_pppoe().

## hd_scan_pppoe()

void hd_scan_pppoe | ( | hd_data_t * | hd_data2 | ) |

References ADD2LOG, s_hd_t::base_class, bc_network_interface, discovery(), PPPoEConnectionStruct::fd, PPPoEConnectionStruct::hd, hd_data, hd_probe_feature(), hd_id_t::id, PPPoEConnectionStruct::ifname, s_hd_t::is, mod_pppoe, new_mem(), s_hd_t::next, s_hd_t::is_s::pppoe, pr_pppoe, PROGRESS, sc_nif_ethernet, s_hd_t::sub_class, and s_hd_t::unix_dev_name.

Referenced by hd_scan_no_hal().

## open_interfaces()

int open_interfaces | ( | int | n,
|  | PPPoEConnection * | conns )

static

References ADD2LOG, ETH_PPPOE_DISCOVERY, PPPoEConnectionStruct::fd, PPPoEConnectionStruct::ifname, PPPoEConnectionStruct::my_mac, and NOT_UNICAST.

Referenced by discovery().

## packet_for_me()

int packet_for_me | ( | PPPoEConnection * | conn,
|  | PPPoEPacket * | packet )

static

References PPPoEPacketStruct::ethHdr, PPPoEConnectionStruct::my_mac, parse_hostuniq(), and parse_packet().

Referenced by wait_for_pado().

## parse_hostuniq()

void parse_hostuniq | ( | uint16_t | type,
|  | uint16_t | len,
|  | unsigned char * | data,
|  | void * | extra )

static

References TAG_HOST_UNIQ.

Referenced by packet_for_me().

## parse_packet()

int parse_packet | ( | PPPoEConnection * | conn,
|  | PPPoEPacket * | packet,
|  | parse_func * | func,
|  | void * | extra )

static

References ADD2LOG, PPPoEConnectionStruct::ifname, PPPoEPacketStruct::length, PPPoEPacketStruct::payload, TAG_END_OF_LIST, TAG_HDR_SIZE, PPPoEPacketStruct::type, and PPPoEPacketStruct::ver.

Referenced by packet_for_me(), and wait_for_pado().

## parse_pado_tags()

void parse_pado_tags | ( | uint16_t | type,
|  | uint16_t | len,
|  | unsigned char * | data,
|  | void * | extra )

static

References PacketCriteriaStruct::acname_ok, ADD2LOG, PacketCriteriaStruct::conn, PacketCriteriaStruct::error, PPPoEConnectionStruct::ifname, PacketCriteriaStruct::servicename_ok, TAG_AC_NAME, TAG_AC_SYSTEM_ERROR, TAG_GENERIC_ERROR, TAG_SERVICE_NAME, and TAG_SERVICE_NAME_ERROR.

Referenced by wait_for_pado().

## receive_packet()

int receive_packet | ( | int | fd,
|  | PPPoEPacket * | pkt,
|  | size_t * | size )

static

References ADD2LOG.

Referenced by wait_for_pado().

## send_packet()

int send_packet | ( | int | fd,
|  | PPPoEPacket * | pkt,
|  | size_t | size )

static

References ADD2LOG.

Referenced by send_padi().

## send_padi()

int send_padi | ( | int | n,
|  | PPPoEConnection * | conns )

static

References ADD2LOG, check_room(), PPPoEPacketStruct::code, CODE_PADI, ETH_PPPOE_DISCOVERY, PPPoEPacketStruct::ethHdr, PPPoEConnectionStruct::fd, HDR_SIZE, PPPoEConnectionStruct::ifname, PPPoEPacketStruct::length, PPPoETagStruct::length, PPPoEConnectionStruct::my_mac, PPPoEPacketStruct::payload, PPPoETagStruct::payload, PPPoEConnectionStruct::received_pado, send_packet(), PPPoEPacketStruct::session, TAG_HDR_SIZE, TAG_HOST_UNIQ, TAG_SERVICE_NAME, PPPoEPacketStruct::type, PPPoETagStruct::type, and PPPoEPacketStruct::ver.

Referenced by discovery().

## wait_for_pado()

int wait_for_pado | ( | int | n,
|  | PPPoEConnection * | conns )

static

References PacketCriteriaStruct::acname_ok, ADD2LOG, PPPoEPacketStruct::code, CODE_PADO, PacketCriteriaStruct::conn, PacketCriteriaStruct::error, PPPoEPacketStruct::ethHdr, PPPoEConnectionStruct::fd, HDR_SIZE, PPPoEConnectionStruct::ifname, PPPoEPacketStruct::length, NOT_UNICAST, packet_for_me(), PADO_TIMEOUT, parse_packet(), parse_pado_tags(), PPPoEConnectionStruct::peer_mac, receive_packet(), PPPoEConnectionStruct::received_pado, and PacketCriteriaStruct::servicename_ok.

Referenced by discovery().