add winpcap 4.0.2 from url http://www.winpcap.org/
[natblaster.git] / src / peer / peercon.h
blobd4f97d27f67cbc52629a620d4eeb632befc3b310
1 /*****************************************************************************
2 * Copyright 2005 Daniel Ferullo *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 *****************************************************************************/
18 /**
19 * @file peercon.h
20 * @author Daniel Ferullo (ferullo@cmu.edu)
22 * @brief functions to help the peer make a direct connection
25 #ifndef __PEERCON_H__
26 #define __PEERCON_H__
28 #include "errorcodes.h"
29 #include "def.h"
30 #include "peerdef.h"
32 /**
33 * @brief waits until the direct connection flag is set to FLAG_SUCCESS or
34 * FLAG_FAILED
36 * @param check_flag pointer to the flag to wait on
38 * @return SUCCESS, errorcode on failure
40 errorcode wait_for_direct_conn(flag_t *check_flag);
42 /**
43 * @brief finds a network devide (requires root privledge)
45 * this is basically a wrapper for pcap_lookupdev. I assume pcap_lookupdev
46 * uses malloc to allocate the memory for the returned pointer, but I am
47 * not sure. This needs to be checked.
49 * @param dev a pointer to a pointer. When finished, will point to a string
50 * with the network device to use.
52 * @return SUCCESS, neg value on failure
54 errorcode findDevice(char **dev);
56 /**
57 * @brief function to do the SYN flooding to buddy
59 * @param tcp_skeleton a skeleton tcp_packet_info_t to base SYN's on. The
60 * d_addr, d_port, s_addr, and seq_num fields will be inspected.
62 * @param device the device to forge SYNs on
64 * @return SUCCESS, errorcode on failure
66 errorcode flood_syns(tcp_packet_info_t tcp_skeleton, char *device);
68 /**
69 * @brief a function to spawn a thread to look for a SYN/ACK with
71 * @param info pointer to the peer's information structure
73 * @return SUCCESS, errorcode on failure
75 errorcode start_find_synack(peer_conn_info_t *info);
77 /** @brief the entry point for the thread that looks for the SYN/ACK in a
78 * bday flood
80 * @param arg the single pthread arg (should be a pointer to the peer
81 * information structure)
83 * @return SUCCESS, errorcode on failure
85 void *run_find_synack(void* arg);
87 /**
88 * @brief waits for the find syn ack to finish, within a timeout, and then
89 * joins on the thread.
91 * @param info a pointer to the peer_conn_info_t structure
93 * @return SUCCESS, errorcode on failure
95 errorcode wait_and_join_find_synack(peer_conn_info_t *info);
97 /**
98 * @brief sends a bday flood of synacks to the peer
100 * @param info pointer to the peer_conn_info_t structure
101 * @param seq_num the sequence number used in the SYNs in the other bday flood
103 * @return SUCCESS, errorcode on failure
105 errorcode synack_flood(peer_conn_info_t *info, seq_num_t seq_num);
107 #endif /* __PEERCON_H__ */