version 1.1.1.1, 2012/02/21 23:32:47
|
version 1.1.1.3, 2021/03/17 00:39:23
|
Line 16
|
Line 16
|
#include "log.h" |
#include "log.h" |
#include "util.h" |
#include "util.h" |
|
|
|
#include <net/ethernet.h> |
#include <netgraph/ng_message.h> |
#include <netgraph/ng_message.h> |
#include <netgraph/ng_socket.h> |
#include <netgraph/ng_socket.h> |
#include <netgraph/ng_ksocket.h> |
#include <netgraph/ng_ksocket.h> |
Line 125
|
Line 126
|
static void PptpListenUpdate(Link l); |
static void PptpListenUpdate(Link l); |
|
|
static struct pptplinkinfo PptpIncoming(struct pptpctrlinfo *cinfo, |
static struct pptplinkinfo PptpIncoming(struct pptpctrlinfo *cinfo, |
struct u_addr *self, struct u_addr *peer, in_port_t port, int bearType, | struct u_addr *self, struct u_addr *peer, in_port_t port, |
const char *callingNum, |
const char *callingNum, |
const char *calledNum, | const char *calledNum); |
const char *subAddress); | |
|
|
static struct pptplinkinfo PptpOutgoing(struct pptpctrlinfo *cinfo, |
static struct pptplinkinfo PptpOutgoing(struct pptpctrlinfo *cinfo, |
struct u_addr *self, struct u_addr *peer, in_port_t port, int bearType, | struct u_addr *self, struct u_addr *peer, in_port_t port, |
int frameType, int minBps, int maxBps, | const char *calledNum); |
const char *calledNum, | |
const char *subAddress); | |
|
|
static struct pptplinkinfo PptpPeerCall(struct pptpctrlinfo *cinfo, |
static struct pptplinkinfo PptpPeerCall(struct pptpctrlinfo *cinfo, |
struct u_addr *self, struct u_addr *peer, in_port_t port, int incoming, |
struct u_addr *self, struct u_addr *peer, in_port_t port, int incoming, |
const char *callingNum, |
const char *callingNum, |
const char *calledNum, | const char *calledNum); |
const char *subAddress); | |
|
|
static int PptpSetCommand(Context ctx, int ac, char *av[], void *arg); | static int PptpSetCommand(Context ctx, int ac, const char *const av[], const void *arg); |
static int PptpTunEQ(struct ghash *g, const void *item1, const void *item2); |
static int PptpTunEQ(struct ghash *g, const void *item1, const void *item2); |
static u_int32_t PptpTunHash(struct ghash *g, const void *item); |
static u_int32_t PptpTunHash(struct ghash *g, const void *item); |
|
|
Line 195
|
Line 192
|
PptpSetCommand, NULL, 2, (void *) SET_ENABLE }, |
PptpSetCommand, NULL, 2, (void *) SET_ENABLE }, |
{ "disable [opt ...]", "Disable option", |
{ "disable [opt ...]", "Disable option", |
PptpSetCommand, NULL, 2, (void *) SET_DISABLE }, |
PptpSetCommand, NULL, 2, (void *) SET_DISABLE }, |
{ NULL }, | { NULL, NULL, NULL, NULL, 0, NULL }, |
}; |
}; |
|
|
/* |
/* |
Line 213
|
Line 210
|
{ 0, 0, NULL }, |
{ 0, 0, NULL }, |
}; |
}; |
|
|
struct ghash *gPptpTuns; | static struct ghash *gPptpTuns; |
|
|
/* |
/* |
* PptpTInit() |
* PptpTInit() |
Line 590 PptpPeerMacAddr(Link l, void *buf, size_t buf_len)
|
Line 587 PptpPeerMacAddr(Link l, void *buf, size_t buf_len)
|
{ |
{ |
PptpInfo const pptp = (PptpInfo) l->info; |
PptpInfo const pptp = (PptpInfo) l->info; |
|
|
if (pptp->peer_iface[0]) { | if (buf_len >= 18 && pptp->peer_iface[0]) { |
snprintf(buf, buf_len, "%02x:%02x:%02x:%02x:%02x:%02x", | ether_ntoa_r((struct ether_addr *)pptp->peer_mac_addr, buf); |
pptp->peer_mac_addr[0], pptp->peer_mac_addr[1], | |
pptp->peer_mac_addr[2], pptp->peer_mac_addr[3], | |
pptp->peer_mac_addr[4], pptp->peer_mac_addr[5]); | |
return (0); |
return (0); |
} |
} |
((char*)buf)[0]=0; |
((char*)buf)[0]=0; |
Line 670 PptpStat(Context ctx)
|
Line 664 PptpStat(Context ctx)
|
PptpPeerName(ctx->lnk, buf, sizeof(buf)); |
PptpPeerName(ctx->lnk, buf, sizeof(buf)); |
Printf(" (%s)\r\n", buf); |
Printf(" (%s)\r\n", buf); |
if (pptp->peer_iface[0]) { |
if (pptp->peer_iface[0]) { |
Printf("\tCurrent peer : %02x:%02x:%02x:%02x:%02x:%02x at %s\r\n", | ether_ntoa_r((struct ether_addr *)pptp->peer_mac_addr, buf); |
pptp->peer_mac_addr[0], pptp->peer_mac_addr[1], | Printf("\tCurrent peer : %s at %s\r\n", buf, pptp->peer_iface); |
pptp->peer_mac_addr[2], pptp->peer_mac_addr[3], | |
pptp->peer_mac_addr[4], pptp->peer_mac_addr[5], | |
pptp->peer_iface); | |
} |
} |
Printf("\tFraming : %s\r\n", (pptp->sync?"Sync":"Async")); |
Printf("\tFraming : %s\r\n", (pptp->sync?"Sync":"Async")); |
Printf("\tCalling number: %s\r\n", pptp->callingnum); |
Printf("\tCalling number: %s\r\n", pptp->callingnum); |
Line 789 PptpTunEQ(struct ghash *g, const void *item1, const vo
|
Line 780 PptpTunEQ(struct ghash *g, const void *item1, const vo
|
{ |
{ |
const struct pptptun *tun1 = item1; |
const struct pptptun *tun1 = item1; |
const struct pptptun *tun2 = item2; |
const struct pptptun *tun2 = item2; |
|
|
|
(void)g; |
if (u_addrcompare(&tun1->self_addr, &tun2->self_addr) == 0 && |
if (u_addrcompare(&tun1->self_addr, &tun2->self_addr) == 0 && |
u_addrcompare(&tun1->peer_addr, &tun2->peer_addr) == 0) |
u_addrcompare(&tun1->peer_addr, &tun2->peer_addr) == 0) |
return (1); |
return (1); |
Line 799 static u_int32_t
|
Line 792 static u_int32_t
|
PptpTunHash(struct ghash *g, const void *item) |
PptpTunHash(struct ghash *g, const void *item) |
{ |
{ |
const struct pptptun *tun = item; |
const struct pptptun *tun = item; |
|
|
|
(void)g; |
return (u_addrtoid(&tun->self_addr) + u_addrtoid(&tun->peer_addr)); |
return (u_addrtoid(&tun->self_addr) + u_addrtoid(&tun->peer_addr)); |
} |
} |
|
|
Line 918 PptpHookUp(Link l)
|
Line 913 PptpHookUp(Link l)
|
/* increase recvspace to avoid packet loss due to very small GRE recv buffer. */ |
/* increase recvspace to avoid packet loss due to very small GRE recv buffer. */ |
ksso->level=SOL_SOCKET; |
ksso->level=SOL_SOCKET; |
ksso->name=SO_RCVBUF; |
ksso->name=SO_RCVBUF; |
((int *)(ksso->value))[0]=48*1024; | ((int *)(void *)(ksso->value))[0]=48*1024; |
if (NgSendMsg(csock, ksockpath, NGM_KSOCKET_COOKIE, |
if (NgSendMsg(csock, ksockpath, NGM_KSOCKET_COOKIE, |
NGM_KSOCKET_SETOPT, &u, sizeof(u)) < 0) { |
NGM_KSOCKET_SETOPT, &u, sizeof(u)) < 0) { |
Perror("[%s] PPTP: can't setsockopt %s node", |
Perror("[%s] PPTP: can't setsockopt %s node", |
Line 990 PptpHookUp(Link l)
|
Line 985 PptpHookUp(Link l)
|
|
|
static struct pptplinkinfo |
static struct pptplinkinfo |
PptpIncoming(struct pptpctrlinfo *cinfo, |
PptpIncoming(struct pptpctrlinfo *cinfo, |
struct u_addr *self, struct u_addr *peer, in_port_t port, int bearType, | struct u_addr *self, struct u_addr *peer, in_port_t port, |
const char *callingNum, |
const char *callingNum, |
const char *calledNum, | const char *calledNum) |
const char *subAddress) | |
{ |
{ |
return(PptpPeerCall(cinfo, self, peer, port, TRUE, callingNum, calledNum, subAddress)); | return(PptpPeerCall(cinfo, self, peer, port, TRUE, callingNum, calledNum)); |
} |
} |
|
|
/* |
/* |
Line 1009 PptpIncoming(struct pptpctrlinfo *cinfo,
|
Line 1003 PptpIncoming(struct pptpctrlinfo *cinfo,
|
|
|
static struct pptplinkinfo |
static struct pptplinkinfo |
PptpOutgoing(struct pptpctrlinfo *cinfo, |
PptpOutgoing(struct pptpctrlinfo *cinfo, |
struct u_addr *self, struct u_addr *peer, in_port_t port, int bearType, | struct u_addr *self, struct u_addr *peer, in_port_t port, |
int frameType, int minBps, int maxBps, | const char *calledNum) |
const char *calledNum, const char *subAddress) | |
{ |
{ |
return(PptpPeerCall(cinfo, self, peer, port, FALSE, "", calledNum, subAddress)); | return(PptpPeerCall(cinfo, self, peer, port, FALSE, "", calledNum)); |
} |
} |
|
|
/* |
/* |
Line 1028 static struct pptplinkinfo
|
Line 1021 static struct pptplinkinfo
|
PptpPeerCall(struct pptpctrlinfo *cinfo, |
PptpPeerCall(struct pptpctrlinfo *cinfo, |
struct u_addr *self, struct u_addr *peer, in_port_t port, int incoming, |
struct u_addr *self, struct u_addr *peer, in_port_t port, int incoming, |
const char *callingNum, |
const char *callingNum, |
const char *calledNum, | const char *calledNum) |
const char *subAddress) | |
{ |
{ |
struct pptplinkinfo linfo; |
struct pptplinkinfo linfo; |
Link l = NULL; |
Link l = NULL; |
Line 1176 PptpListenUpdate(Link l)
|
Line 1168 PptpListenUpdate(Link l)
|
*/ |
*/ |
|
|
static int |
static int |
PptpSetCommand(Context ctx, int ac, char *av[], void *arg) | PptpSetCommand(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
PptpInfo const pi = (PptpInfo) ctx->lnk->info; |
PptpInfo const pi = (PptpInfo) ctx->lnk->info; |
char **fqdn_peer_addr = &pi->conf.fqdn_peer_addr; |
char **fqdn_peer_addr = &pi->conf.fqdn_peer_addr; |