Hi, everybody! Does anybody know, how I can create and config DummyNet pipe via c code?
For example, i can control ipfw table via my program, like this:
So I need create pipes, config them, and destroy. Please help!
Sorry for my English)
For example, i can control ipfw table via my program, like this:
Code:
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/cdefs.h>
#include <strings.h>
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <netinet/ip_fw.h>
int main()
{
unsigned long ip_addr;
unsigned long tag;
uint32_t tbl_num;
int sock;
ipfw_table_entry entry;
printf("%lu\n",sizeof entry);
bzero(&entry, sizeof entry);
tbl_num = 100;
ip_addr = inet_addr("<ip_to_add>");
sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
entry.addr = ip_addr;
entry.tbl = tbl_num;
entry.masklen = 32;
tag = htonl(ip_addr) & 0x0000FFFF;
entry.value = tag;
setsockopt(sock, IPPROTO_IP, IP_FW_TABLE_ADD, &entry, sizeof entry);
}
So I need create pipes, config them, and destroy. Please help!
Sorry for my English)