diff options
| author | 杨威 <[email protected]> | 2020-05-27 16:44:18 +0800 |
|---|---|---|
| committer | 杨威 <[email protected]> | 2020-05-27 16:44:18 +0800 |
| commit | 8909c32e3697411a32778fc8384ca082de4b94e4 (patch) | |
| tree | a01b321c6eba2cf37dc13c38585038b026bfefa5 | |
| parent | f8435d81830d2aead9736f96a84b4586b7cef2df (diff) | |
g_device_plug更新,按RFC5880,收到DOWN消息时,回复INIT消息,并设置mydiscriminator为自身保活IP
| -rw-r--r-- | .gitignore | 8 | ||||
| -rw-r--r-- | include/private/g_device.h | 6 | ||||
| -rw-r--r-- | src/inner_plug/g_device_plug.c | 11 |
3 files changed, 20 insertions, 5 deletions
@@ -13,7 +13,7 @@ cmake-build-debug .vscode ./build/ version.txt - -/version.txt -/version.txt -/version.txt +GPATH +GRTAGS +GTAGS +cmake-build*
\ No newline at end of file diff --git a/include/private/g_device.h b/include/private/g_device.h index f7a0b39..3324e9c 100644 --- a/include/private/g_device.h +++ b/include/private/g_device.h @@ -10,8 +10,14 @@ extern "C" { #define GDEV_KEEPALIVE_TYPE_ARP (2)
#define GDEV_KEEPALIVE_TYPE_BFD (3)
+
/* �����豸ʹ�õı���Э�� */
#define BFD_DEFAULT_PORT (3784) /* Ĭ�϶˿� */
+
+#define BFD_MSG_FLAGS_INIT 0x80
+#define BFD_MSG_FLAGS_DOWN 0x40
+#define BFD_MSG_FLAGS_UP 0xc0
+
typedef struct{
unsigned char version_diag;
unsigned char flags;
diff --git a/src/inner_plug/g_device_plug.c b/src/inner_plug/g_device_plug.c index 2c5948c..b80b668 100644 --- a/src/inner_plug/g_device_plug.c +++ b/src/inner_plug/g_device_plug.c @@ -157,9 +157,18 @@ static int gdev_keepalive_bfd_plug(const raw_pkt_t *raw_pkt, int thread_id, unsi return -1; } /* ��ȡ����service_id, ����Ӧ�ûظ�����Ӧ��, go on !! */ - + memcpy(payload_buf, bfd_net_hdr, payload_len); + // passive bfdd, DOWN->INIT, UP->UP + if (bfd_send_hdr->flags == BFD_MSG_FLAGS_DOWN) + { + //DOWN->INIT + bfd_send_hdr->flags = BFD_MSG_FLAGS_INIT; + // set keep_alive ip as discriminator + memcpy(bfd_send_hdr->your_discriminator, &ip_hdr->ip_dst.s_addr, 4); + } + // swap discriminator memcpy(bfd_buf, bfd_send_hdr->my_discriminator, 4); memcpy(bfd_send_hdr->my_discriminator, bfd_send_hdr->your_discriminator, 4); memcpy(bfd_send_hdr->your_discriminator, bfd_buf, 4); |
