--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __STC_PLUGIN_PCAP_INTERNAL_H__
+#define __STC_PLUGIN_PCAP_INTERNAL_H__
+
+#include <glib.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <signal.h>
+#include <errno.h>
+#include <pcap.h>
+#include <pcap/nflog.h>
+#include <arpa/inet.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <netinet/ether.h>
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+
+#include "stc-error.h"
+#include "stc-manager.h"
+
+#define BUFF_SIZE_IP 16
+#define BUFF_SIZE_IP6 46
+#define BUFF_SIZE_HOST 32
+#define BUFF_SIZE_ID 64
+#define BUFF_SIZE_TIME 64
+#define BUFF_SIZE_NAME 256
+
+#define PORT_FTP_DATA 20
+#define PORT_FTP_CTL 21
+#define PORT_SMTP 25
+#define PORT_DNS 53
+#define PORT_BOOTP_S 67
+#define PORT_BOOTP_C 68
+#define PORT_HTTP 80
+#define PORT_NTP 123
+#define PORT_HTTPS 443
+#define PORT_SMTP_MSG 587
+#define PORT_HTTP_ALT 8080
+
+#define ARP_REQUEST 1
+#define ARP_REPLY 2
+#define ARP_RREQUEST 3
+#define ARP_RREPLY 4
+
+#define BOOTP_REQUEST 1
+#define BOOTP_REPLY 2
+
+#define BOOTP_CHADDR_LEN 16
+#define BOOTP_SNAME_LEN 64
+#define BOOTP_FILE_LEN 128
+#define BOOTP_MOPTION_LEN 60
+
+#define BOOTP_MAGIC_DHCP 0x63825363
+
+#define DHCP_TAG_SUBNET_MASK 1
+#define DHCP_TAG_ROUTER 3
+#define DHCP_TAG_DNS 6
+#define DHCP_TAG_HOST_NAME 12
+#define DHCP_TAG_REQUESTED_IP 50
+#define DHCP_TAG_IP_LEASE_TIME 51
+#define DHCP_TAG_MSG_TYPE 53
+#define DHCP_TAG_SERVER_ID 54
+#define DHCP_TAG_MSG_SIZE 57
+#define DHCP_TAG_CLIENT_ID 61
+#define DHCP_TAG_END 255
+
+#define DHCP_MSG_TYPE_DISCOVER 1
+#define DHCP_MSG_TYPE_OFFER 2
+#define DHCP_MSG_TYPE_REQUEST 3
+#define DHCP_MSG_TYPE_DECLINE 4
+#define DHCP_MSG_TYPE_ACK 5
+#define DHCP_MSG_TYPE_NAK 6
+#define DHCP_MSG_TYPE_RELEASE 7
+#define DHCP_MSG_TYPE_INFORM 8
+
+#define DHCP_CLIENT_ID_ETHERNET 1
+#define DHCP_CLIENT_ID_IEEE802 2
+#define DHCP_CLIENT_ID_ARCNET 7
+#define DHCP_CLIENT_ID_LOCALTALK 11
+#define DHCP_CLIENT_ID_LOCALNET 12
+#define DHCP_CLIENT_ID_SMDS 14
+#define DHCP_CLIENT_ID_FRAMERELAY 15
+#define DHCP_CLIENT_ID_ATM1 16
+#define DHCP_CLIENT_ID_HDLC 17
+#define DHCP_CLIENT_ID_FIBRECHANNEL 18
+#define DHCP_CLIENT_ID_ATM2 19
+#define DHCP_CLIENT_ID_SERIALLINE 20
+
+#define NTP_STRATUM_UNSPECIFIED 0
+#define NTP_STRATUM_PRIM_REF 1
+#define NTP_STRATUM_INFO_QUERY 62
+#define NTP_STRATUM_INFO_REPLY 63
+
+#define NTP_JAN_1970 2208988800U /* 1970 - 1900 in seconds */
+
+#define DNS_QTYPE_A 1
+#define DNS_QTYPE_CNAME 5
+#define DNS_QTYPE_AAAA 28
+
+#define DNS_QCLASS_IN 1
+#define DNS_QCLASS_CHAOS 3
+#define DNS_QCLASS_HS 4
+#define DNS_QCLASS_ANY 255
+
+#define ETHERTYPE_EAPOL 0x888e
+
+#define HR_SINGLE "----------------------------------------" \
+ "-------------------------"
+#define HR_DOUBLE "========================================" \
+ "========================="
+
+typedef struct {
+ char *ifname;
+ char *nfname;
+ int nflog_group;
+ GThread *thread;
+ pcap_t *handle;
+ int encap_type;
+} stc_pcap_data_s;
+
+typedef struct {
+ uint16_t id;
+ uint16_t flags;
+ uint16_t questions;
+ uint16_t answerRR;
+ uint16_t authorityRR;
+ uint16_t additionalRR;
+} dns_t;
+
+typedef struct {
+ uint16_t type;
+ uint16_t class;
+} dns_query_t;
+
+typedef struct {
+ uint16_t type;
+ uint16_t class;
+ uint16_t ttl;
+ uint16_t rdlen;
+ char rdata[];
+} dns_recode_t;
+
+typedef struct {
+ uint8_t op; /* packet opcode type */
+ uint8_t htype; /* hardware addr type */
+ uint8_t hlen; /* hardware addr length */
+ uint8_t hops; /* gateway hops */
+ uint32_t xid; /* transaction ID */
+ uint16_t secs; /* seconds since boot began */
+ uint16_t flags; /* flags */
+ struct in_addr ciaddr; /* client IP address */
+ struct in_addr yiaddr; /* 'your' IP address */
+ struct in_addr siaddr; /* server IP address */
+ struct in_addr giaddr; /* gateway(relay agent) IP address */
+ uint8_t chaddr[BOOTP_CHADDR_LEN]; /* client hardware address */
+ uint8_t sname[BOOTP_SNAME_LEN]; /* server host name */
+ uint8_t file[BOOTP_FILE_LEN]; /* boot file name */
+ uint32_t magic; /* must be 0x63825363 (network order) */
+ uint8_t moption[BOOTP_MOPTION_LEN];
+} bootp_t;
+
+typedef struct {
+ uint16_t second;
+ uint16_t fraction;
+} ntp_short_t;
+
+typedef struct {
+ uint32_t second;
+ uint32_t fraction;
+} ntp_long_t;
+
+typedef struct {
+ uint8_t flags; /* Mode, version and leap indicator */
+ uint8_t stratum; /* Stratum details */
+ uint8_t poll; /* Maximum interval in log2 seconds */
+ uint8_t precision; /* Clock precision in log2 seconds */
+ ntp_short_t rootdelay; /* Root delay */
+ ntp_short_t rootdisp; /* Root dispersion */
+ uint32_t refid; /* Reference ID */
+ ntp_long_t reftime; /* Reference timestamp */
+ ntp_long_t orgtime; /* Origin timestamp */
+ ntp_long_t rectime; /* Receive timestamp */
+ ntp_long_t xmttime; /* Transmit timestamp */
+} ntp_t;
+
+typedef struct {
+ uint32_t ts[4];
+} nflog_timestamp_s;
+
+typedef struct ether_header eth_t;
+typedef struct ip ip_t;
+typedef struct ip6_hdr ip6_t;
+typedef struct arphdr arp_t;
+typedef struct icmphdr icmp_t;
+typedef struct tcphdr tcp_t;
+typedef struct udphdr udp_t;
+
+#define SIZE_ETHER_HEADER sizeof(eth_t)
+#define SIZE_IP_HEADER sizeof(ip_t)
+#define SIZE_IP6_HEADER sizeof(ip6_t)
+#define SIZE_ARP_HEADER sizeof(arp_t)
+#define SIZE_ICMP_HEADER sizeof(icmp_t)
+#define SIZE_TCP_HEADER sizeof(tcp_t)
+#define SIZE_UDP_HEADER sizeof(udp_t)
+#define SIZE_DNS_HEADER sizeof(dns_t)
+
+#define SIZE_NFLOG_HDR sizeof(nflog_hdr_t)
+#define SIZE_NFLOG_TLV sizeof(nflog_tlv_t)
+
+#define IS_SRC_OR_DST_PORT(p) (source == (p) || dest == (p))
+
+#endif /* __STC_PLUGIN_PCAP_INTERNAL_H__ */
#define __STC_PLUGIN_PCAP_H__
#include <glib.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <signal.h>
-#include <errno.h>
-#include <pcap.h>
-#include <pcap/nflog.h>
-#include <arpa/inet.h>
-#include <net/ethernet.h>
-#include <net/if_arp.h>
-#include <netinet/ether.h>
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-
-#include "stc-error.h"
-#include "stc-manager.h"
-
-#define BUFF_SIZE_IP 16
-#define BUFF_SIZE_IP6 46
-#define BUFF_SIZE_HOST 32
-#define BUFF_SIZE_ID 64
-#define BUFF_SIZE_TIME 64
-#define BUFF_SIZE_NAME 256
-
-#define PORT_FTP_DATA 20
-#define PORT_FTP_CTL 21
-#define PORT_SMTP 25
-#define PORT_DNS 53
-#define PORT_BOOTP_S 67
-#define PORT_BOOTP_C 68
-#define PORT_HTTP 80
-#define PORT_NTP 123
-#define PORT_HTTPS 443
-#define PORT_SMTP_MSG 587
-#define PORT_HTTP_ALT 8080
-
-#define ARP_REQUEST 1
-#define ARP_REPLY 2
-#define ARP_RREQUEST 3
-#define ARP_RREPLY 4
-
-#define BOOTP_REQUEST 1
-#define BOOTP_REPLY 2
-
-#define BOOTP_CHADDR_LEN 16
-#define BOOTP_SNAME_LEN 64
-#define BOOTP_FILE_LEN 128
-#define BOOTP_MOPTION_LEN 60
-
-#define BOOTP_MAGIC_DHCP 0x63825363
-
-#define DHCP_TAG_SUBNET_MASK 1
-#define DHCP_TAG_ROUTER 3
-#define DHCP_TAG_DNS 6
-#define DHCP_TAG_HOST_NAME 12
-#define DHCP_TAG_REQUESTED_IP 50
-#define DHCP_TAG_IP_LEASE_TIME 51
-#define DHCP_TAG_MSG_TYPE 53
-#define DHCP_TAG_SERVER_ID 54
-#define DHCP_TAG_MSG_SIZE 57
-#define DHCP_TAG_CLIENT_ID 61
-#define DHCP_TAG_END 255
-
-#define DHCP_MSG_TYPE_DISCOVER 1
-#define DHCP_MSG_TYPE_OFFER 2
-#define DHCP_MSG_TYPE_REQUEST 3
-#define DHCP_MSG_TYPE_DECLINE 4
-#define DHCP_MSG_TYPE_ACK 5
-#define DHCP_MSG_TYPE_NAK 6
-#define DHCP_MSG_TYPE_RELEASE 7
-#define DHCP_MSG_TYPE_INFORM 8
-
-#define DHCP_CLIENT_ID_ETHERNET 1
-#define DHCP_CLIENT_ID_IEEE802 2
-#define DHCP_CLIENT_ID_ARCNET 7
-#define DHCP_CLIENT_ID_LOCALTALK 11
-#define DHCP_CLIENT_ID_LOCALNET 12
-#define DHCP_CLIENT_ID_SMDS 14
-#define DHCP_CLIENT_ID_FRAMERELAY 15
-#define DHCP_CLIENT_ID_ATM1 16
-#define DHCP_CLIENT_ID_HDLC 17
-#define DHCP_CLIENT_ID_FIBRECHANNEL 18
-#define DHCP_CLIENT_ID_ATM2 19
-#define DHCP_CLIENT_ID_SERIALLINE 20
-
-#define NTP_STRATUM_UNSPECIFIED 0
-#define NTP_STRATUM_PRIM_REF 1
-#define NTP_STRATUM_INFO_QUERY 62
-#define NTP_STRATUM_INFO_REPLY 63
-
-#define NTP_JAN_1970 2208988800U /* 1970 - 1900 in seconds */
-
-#define DNS_QTYPE_A 1
-#define DNS_QTYPE_CNAME 5
-#define DNS_QTYPE_AAAA 28
-
-#define DNS_QCLASS_IN 1
-#define DNS_QCLASS_CHAOS 3
-#define DNS_QCLASS_HS 4
-#define DNS_QCLASS_ANY 255
-
-#define ETHERTYPE_EAPOL 0x888e
-
-#define HR_SINGLE "----------------------------------------" \
- "-------------------------"
-#define HR_DOUBLE "========================================" \
- "========================="
-
-typedef struct {
- char *ifname;
- char *nfname;
- int nflog_group;
- GThread *thread;
- pcap_t *handle;
- int encap_type;
-} stc_pcap_data_s;
-
-typedef struct {
- uint16_t id;
- uint16_t flags;
- uint16_t questions;
- uint16_t answerRR;
- uint16_t authorityRR;
- uint16_t additionalRR;
-} dns_t;
-
-typedef struct {
- uint16_t type;
- uint16_t class;
-} dns_query_t;
-
-typedef struct {
- uint16_t type;
- uint16_t class;
- uint16_t ttl;
- uint16_t rdlen;
- char rdata[];
-} dns_recode_t;
-
-typedef struct {
- uint8_t op; /* packet opcode type */
- uint8_t htype; /* hardware addr type */
- uint8_t hlen; /* hardware addr length */
- uint8_t hops; /* gateway hops */
- uint32_t xid; /* transaction ID */
- uint16_t secs; /* seconds since boot began */
- uint16_t flags; /* flags */
- struct in_addr ciaddr; /* client IP address */
- struct in_addr yiaddr; /* 'your' IP address */
- struct in_addr siaddr; /* server IP address */
- struct in_addr giaddr; /* gateway(relay agent) IP address */
- uint8_t chaddr[BOOTP_CHADDR_LEN]; /* client hardware address */
- uint8_t sname[BOOTP_SNAME_LEN]; /* server host name */
- uint8_t file[BOOTP_FILE_LEN]; /* boot file name */
- uint32_t magic; /* must be 0x63825363 (network order) */
- uint8_t moption[BOOTP_MOPTION_LEN];
-} bootp_t;
-
-typedef struct {
- uint16_t second;
- uint16_t fraction;
-} ntp_short_t;
-
-typedef struct {
- uint32_t second;
- uint32_t fraction;
-} ntp_long_t;
-
-typedef struct {
- uint8_t flags; /* Mode, version and leap indicator */
- uint8_t stratum; /* Stratum details */
- uint8_t poll; /* Maximum interval in log2 seconds */
- uint8_t precision; /* Clock precision in log2 seconds */
- ntp_short_t rootdelay; /* Root delay */
- ntp_short_t rootdisp; /* Root dispersion */
- uint32_t refid; /* Reference ID */
- ntp_long_t reftime; /* Reference timestamp */
- ntp_long_t orgtime; /* Origin timestamp */
- ntp_long_t rectime; /* Receive timestamp */
- ntp_long_t xmttime; /* Transmit timestamp */
-} ntp_t;
-
-typedef struct {
- uint32_t ts[4];
-} nflog_timestamp_s;
-
-typedef struct ether_header eth_t;
-typedef struct ip ip_t;
-typedef struct ip6_hdr ip6_t;
-typedef struct arphdr arp_t;
-typedef struct icmphdr icmp_t;
-typedef struct tcphdr tcp_t;
-typedef struct udphdr udp_t;
-
-#define SIZE_ETHER_HEADER sizeof(eth_t)
-#define SIZE_IP_HEADER sizeof(ip_t)
-#define SIZE_IP6_HEADER sizeof(ip6_t)
-#define SIZE_ARP_HEADER sizeof(arp_t)
-#define SIZE_ICMP_HEADER sizeof(icmp_t)
-#define SIZE_TCP_HEADER sizeof(tcp_t)
-#define SIZE_UDP_HEADER sizeof(udp_t)
-#define SIZE_DNS_HEADER sizeof(dns_t)
-
-#define SIZE_NFLOG_HDR sizeof(nflog_hdr_t)
-#define SIZE_NFLOG_TLV sizeof(nflog_tlv_t)
-
-#define IS_SRC_OR_DST_PORT(p) (source == (p) || dest == (p))
typedef struct {
int (*initialize_plugin) (void);