Create socket for PPPoE
This commit is contained in:
parent
9425c725c9
commit
ace7452145
2 changed files with 32 additions and 0 deletions
28
pppoe.c
28
pppoe.c
|
|
@ -244,6 +244,34 @@ void init_pppoe(void)
|
|||
STAT(tunnel_created);
|
||||
}
|
||||
|
||||
|
||||
// setup the PPPoE session socket
|
||||
int create_kernel_pppoe_socket(const sessionidt s) {
|
||||
tunnelidt t = TUNNEL_ID_PPPOE;
|
||||
|
||||
int pppox_fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OE);
|
||||
if (pppox_fd < 0) {
|
||||
LOG(2, s, t, "Can't create PPPoE socket: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
struct sockaddr_pppox sax;
|
||||
memset(&sax, 0, sizeof(sax));
|
||||
|
||||
sax.sa_family = AF_PPPOX;
|
||||
sax.sa_protocol = PX_PROTO_OE;
|
||||
sax.sa_addr.pppoe.sid = s;
|
||||
memcpy(sax.sa_addr.pppoe.dev, config->pppoe_if_to_bind, IFNAMSIZ);
|
||||
memcpy(sax.sa_addr.pppoe.remote, session[s].src_hwaddr, ETH_ALEN);
|
||||
|
||||
int ret = connect(pppox_fd, (struct sockaddr *)&sax, sizeof(sax));
|
||||
if (ret < 0) {
|
||||
LOG(2, s, t, "Can't connect PPPoE: %s\n", strerror(errno));
|
||||
close(pppox_fd);
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
char * get_string_codepad(uint8_t codepad)
|
||||
{
|
||||
char * ptrch = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue