本文整理汇总了C++中parse_packet函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_packet函数的具体用法?C++ parse_packet怎么用?C++ parse_packet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_packet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: parse_etherip
static buffer *
parse_etherip( const buffer *data ) {
packet_info *packet_info = data->user_data;
if ( packet_info->etherip_version != ETHERIP_VERSION ) {
error( "invalid etherip version 0x%04x.", packet_info->etherip_version );
return NULL;
}
if ( packet_info->etherip_offset == 0 ) {
debug( "too short etherip message" );
return NULL;
}
buffer *copy = duplicate_buffer( data );
if ( copy == NULL ) {
error( "duplicate_buffer failed." );
return NULL;
}
copy->user_data = NULL;
remove_front_buffer( copy, packet_info->etherip_offset );
if ( !parse_packet( copy ) ) {
error( "parse_packet failed." );
free_buffer( copy );
return NULL;
}
debug( "Receive EtherIP packet." );
return copy;
}
开发者ID:Milstein,项目名称:trema,代码行数:30,代码来源:packetin_filter.c
示例2: set_bp
int set_bp(libgdbr_t* g, ut64 address, const char* conditions, enum Breakpoint type) {
char tmp[255] = {};
int ret = 0;
switch (type) {
case BREAKPOINT:
ret = snprintf (tmp, sizeof (tmp)-1,
"%s,%"PFMT64x",1", CMD_BP, address);
break;
case HARDWARE_BREAKPOINT:
ret = snprintf (tmp, sizeof (tmp)-1,
"%s,%"PFMT64x",1", CMD_HBP, address);
break;
case WRITE_WATCHPOINT:
break;
case READ_WATCHPOINT:
break;
case ACCESS_WATCHPOINT:
break;
default:
break;
}
if (ret < 0) return ret;
ret = send_command (g, tmp);
if (ret < 0) return ret;
if (read_packet (g) > 0) {
parse_packet (g, 0);
return handle_setbp (g);
}
return 0;
}
开发者ID:AnwarMohamed,项目名称:radare2,代码行数:31,代码来源:core.c
示例3: parse_message
void
parse_message(unsigned char type, char *buf, int size)
{
char *msgt;
int i;
struct iocblk *iocp;
struct buffer *bp = Pty.inbuff;
if (size != 0) {
switch (Pty.state) {
case PTY_CLOSED:
case PTY_OPERRONLY:
SET_EVENT(EV_UP, EV_UPOPEN, 0, 0);
break;
}
}
if (type == TIOCPKT_DATA) {
# ifdef TSR_MEASURE
devreads++;
devrbytes += size;
# endif
if (size == 0) {
SET_EVENT(EV_UP, EV_UPCLOSE, 0, 0);
}
else {
COPY_TO_BUFFER(bp, buf, size);
SET_EVENT(EV_UP, EV_UPDATA, 0, 0);
}
}
else {
parse_packet((int) type);
}
}
开发者ID:maquefel,项目名称:cyclades-serial-code,代码行数:35,代码来源:aix-dev.c
示例4: rgetdir
void rgetdir(){
// prepare packet to be sent //
send_pack(RGETDIR, command.arguments, sock);
// receive positive/negative acknowledgement (whether the file exists or not) //
strncpy(packet_str, "", PACK_SIZE);
if(recv(sock, packet_str, PACK_SIZE, 0) < 0){
error("recv");
}
parse_packet(packet_str, packet);
if(packet.command_code == INVALID){
fprintf(stderr, "The specified folder does not exist\n");
return;
}
mkdir(command.arguments, S_IRWXU | S_IRWXG | S_IRWXO);
/* send port number for data connection to server */
send_data_port();
// make socket and accept server's Data Connection (active)//
makeDataConnection();
fprintf(stderr, "rgetdir() : data connection accepted\n");
// recieve files //
receive_rgetdir_files();
fprintf(stdout, "rgetdir() : files completely received\n");
fflush(stdout);
// close the data connection //
close(request->serverSocket);
//close(sock_data);
}
开发者ID:pranavgupta21,项目名称:multithreaded-FTP-client-server,代码行数:34,代码来源:client_func.c
示例5: rarch_remote_poll
void rarch_remote_poll(rarch_remote_t *handle)
{
unsigned user;
settings_t *settings = config_get_ptr();
input_remote_state_t *ol_state = input_remote_get_state_ptr();
for(user = 0; user < settings->input.max_users; user++)
{
if (settings->network_remote_enable_user[user])
{
#if defined(HAVE_NETWORK_GAMEPAD) && defined(HAVE_NETPLAY)
char buf[8];
ssize_t ret;
fd_set fds;
struct timeval tmp_tv = {0};
if (handle->net_fd[user] < 0)
return;
FD_ZERO(&fds);
FD_SET(handle->net_fd[user], &fds);
ret = recvfrom(handle->net_fd[user], buf,
sizeof(buf) - 1, 0, NULL, NULL);
if (ret > 0)
parse_packet(buf, sizeof(buf), user);
else
#endif
ol_state->buttons[user] = 0;
}
}
}
开发者ID:carriercomm,项目名称:RetroArch,代码行数:33,代码来源:remote.c
示例6: babel_read_protocol
/* thread reading entries form others babel daemons */
static int
babel_read_protocol (struct thread *thread)
{
int rc;
struct interface *ifp = NULL;
struct sockaddr_in6 sin6;
struct listnode *linklist_node = NULL;
assert(babel_routing_process != NULL);
assert(protocol_socket >= 0);
rc = babel_recv(protocol_socket,
receive_buffer, receive_buffer_size,
(struct sockaddr*)&sin6, sizeof(sin6));
if(rc < 0) {
if(errno != EAGAIN && errno != EINTR) {
zlog_err("recv: %s", safe_strerror(errno));
}
} else {
FOR_ALL_INTERFACES(ifp, linklist_node) {
if(!if_up(ifp))
continue;
if(ifp->ifindex == sin6.sin6_scope_id) {
parse_packet((unsigned char*)&sin6.sin6_addr, ifp,
receive_buffer, rc);
break;
}
}
}
/* re-add thread */
babel_routing_process->t_read =
thread_add_read(master, &babel_read_protocol, NULL, protocol_socket);
return 0;
}
开发者ID:Quagga-RE,项目名称:wip-tcs-rfc6506,代码行数:36,代码来源:babeld.c
示例7: receive_multiple_files
void receive_multiple_files(int no_files, char **file_list){
int file_no = 0, buffer_byte = 0, file_byte = 0;
char ch = ' ';
FILE *file_ptr;
while(recv(request->serverSocket, packet_str, PACK_SIZE, 0)){
parse_packet(packet_str, packet);
strcpy(buffer, packet.buffer);
while(buffer_byte < BUF_SIZE && buffer_byte < strlen(buffer)){
ch = buffer[buffer_byte++];
if(!file_byte++){
if(ch == '0')
fprintf(stdout, "receive_multiple_files() : file number %d : %s : File Not Found\n", file_no, file_list[file_no]);
else{
file_ptr = fopen(file_list[file_no], "w");
}
}
else if(ch == EOF){
fclose(file_ptr);
fprintf(stdout, "receive_multiple_files() : file number %d : %s : Downloaded\n", file_no, file_list[file_no]);
file_byte = 0;
file_no++;
}
else
fputc((int)ch, file_ptr);
}
}
fflush(stdout);
}
开发者ID:pranavgupta21,项目名称:multithreaded-FTP-client-server,代码行数:30,代码来源:client_func.c
示例8: test_parse_packet_snap_succeeds
static void
test_parse_packet_snap_succeeds() {
const char filename[] = "./unittests/lib/test_packets/ipx.cap";
buffer *buffer = store_packet_to_buffer( filename );
assert_true( parse_packet( buffer ) );
packet_info *packet_info = buffer->user_data;
assert_int_equal( packet_info->format, ETH_8023_SNAP );
u_char macda[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
u_char macsa[] = { 0x00, 0x19, 0xdb, 0x17, 0xb9, 0x6f };
assert_memory_equal( packet_info->eth_macda, macda, ETH_ADDRLEN );
assert_memory_equal( packet_info->eth_macsa, macsa, ETH_ADDRLEN );
assert_true( packet_info->eth_type < ETH_MTU );
u_char llc[] = { 0xe0, 0xe0, 0x03 };
u_char oui[] = { 0xff, 0xff, 0x00 };
assert_memory_equal( packet_info->snap_llc, llc, SNAP_LLC_LENGTH );
assert_memory_equal( packet_info->snap_oui, oui, SNAP_OUI_LENGTH );
assert_int_equal( packet_info->snap_type, 0xb700 );
uint16_t sample = ntohs( *( uint16_t * ) packet_info->l2_payload );
assert_int_equal( sample, 0x0400 );
assert_int_equal( packet_info->l2_payload_length, 0xb2 );
free_buffer( buffer );
}
开发者ID:TakumiKomada,项目名称:trema,代码行数:30,代码来源:packet_parser_test.c
示例9: main
int main (int argc, char *argv[]){
pcap_t *handle;
f = fopen("resultat.csv","w");
fprintf(f,"Packet number,SEQ,delay\n");
fclose(f);
if(argc != 2) {
printf("Provide a path to a .pcap file:\n%s filename", argv[0]);
exit(1);
}
if((handle = pcap_open_offline(argv[1], errbuff)) != NULL) {
strcpy(file, argv[1]);
struct pcap_pkthdr header; // The header that pcap gives us
const u_char *packet; // The actual packet
int count = 0;
strcpy(server_ip, determine_server_ip());
while((packet = pcap_next(handle, &header))) {
count++;
parse_packet(packet, count);
}
printf("\n\ntotal packets : %d\nlate packets : %d\n\n", count, late_packets);
}
else{
printf("%s\n", errbuff);
}
return 0;
}
开发者ID:r0ck5tar,项目名称:Internet-et-Reseaux,代码行数:33,代码来源:tcpanalyser.c
示例10: test_parse_packet_ipv6_succeeds
static void
test_parse_packet_ipv6_succeeds() {
const char filename[] = "./unittests/lib/test_packets/icmp6_echo_req.cap";
buffer *buffer = store_packet_to_buffer( filename );
assert_true( parse_packet( buffer ) );
packet_info *packet_info = buffer->user_data;
assert_int_equal( packet_info->ipv6_version, 6 );
assert_int_equal( packet_info->ipv6_tc, 0 );
assert_int_equal( packet_info->ipv6_flowlabel, 0 );
assert_int_equal( packet_info->ipv6_plen, 0x40 );
assert_int_equal( packet_info->ipv6_nexthdr, 0x3a );
assert_int_equal( packet_info->ipv6_hoplimit, 0x40 );
u_char saddr[] = { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x8e, 0x89, 0xa5, 0xff, 0xfe, 0x16, 0x22, 0x09 };
u_char daddr[] = { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x8e, 0x89, 0xa5, 0xff, 0xfe, 0x15, 0x84, 0xcb };
assert_memory_equal( packet_info->ipv6_saddr, saddr, IPV6_ADDRLEN );
assert_memory_equal( packet_info->ipv6_daddr, daddr, IPV6_ADDRLEN );
free_buffer( buffer );
}
开发者ID:TakumiKomada,项目名称:trema,代码行数:25,代码来源:packet_parser_test.c
示例11: test_parse_packet_igmp_query_v2_succeeds
static void
test_parse_packet_igmp_query_v2_succeeds() {
const char filename[] = "./unittests/lib/test_packets/igmp_query_v2.cap";
buffer *buffer = store_packet_to_buffer( filename );
assert_true( parse_packet( buffer ) );
packet_info *packet_info = buffer->user_data;
assert_int_equal( packet_info->format, ETH_IPV4_IGMP );
u_char macda[] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x01 };
u_char macsa[] = { 0x8c, 0x89, 0xa5, 0x15, 0x84, 0xcb };
assert_memory_equal( packet_info->eth_macda, macda, ETH_ADDRLEN );
assert_memory_equal( packet_info->eth_macsa, macsa, ETH_ADDRLEN );
assert_int_equal( packet_info->l2_payload_length, 32 );
assert_int_equal( packet_info->igmp_type, IGMP_MEMBERSHIP_QUERY );
assert_int_equal( packet_info->igmp_code, 100 );
assert_int_equal( packet_info->igmp_checksum, 0xee9b );
assert_int_equal( packet_info->igmp_group, 0 );
assert_true( packet_type_igmp_membership_query( buffer ) );
free_buffer( buffer );
}
开发者ID:TakumiKomada,项目名称:trema,代码行数:27,代码来源:packet_parser_test.c
示例12: test_parse_packet_arp_request_succeeds
static void
test_parse_packet_arp_request_succeeds() {
const char filename[] = "./unittests/lib/test_packets/arp_req.cap";
buffer *buffer = store_packet_to_buffer( filename );
assert_true( parse_packet( buffer ) );
packet_info *packet_info = buffer->user_data;
assert_int_equal( packet_info->format, ETH_ARP );
u_char macda[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
u_char macsa[] = { 0x8c, 0x89, 0xa5, 0x16, 0x22, 0x09 };
assert_memory_equal( packet_info->eth_macda, macda, ETH_ADDRLEN );
assert_memory_equal( packet_info->eth_macsa, macsa, ETH_ADDRLEN );
assert_int_equal( packet_info->eth_type, ETH_ETHTYPE_ARP );
assert_int_equal( packet_info->l2_payload_length, 46 );
assert_int_equal( packet_info->arp_ar_hrd, 0x0001 );
assert_int_equal( packet_info->arp_ar_pro, 0x0800 );
assert_int_equal( packet_info->arp_ar_hln, 6 );
assert_int_equal( packet_info->arp_ar_pln, 4 );
assert_int_equal( packet_info->arp_ar_op, 1 );
assert_int_equal( packet_info->arp_spa, 0xc0a8642c );
assert_memory_equal( packet_info->arp_sha, macsa, ETH_ADDRLEN );
assert_int_equal( packet_info->arp_tpa, 0xc0a8642b );
u_char maczero[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
assert_memory_equal( packet_info->arp_tha, maczero, ETH_ADDRLEN );
assert_true( packet_type_arp_request( buffer ) );
assert_false( packet_type_arp_reply( buffer ) );
free_buffer( buffer );
}
开发者ID:TakumiKomada,项目名称:trema,代码行数:34,代码来源:packet_parser_test.c
示例13: throw
void
Comm::handle_comm (struct sockaddr_in &addr, const char *msg, int len)
throw()
{
if (len == static_cast<int>(strlen(TOOL_REQUEST_MSG)) &&
memcmp(msg, TOOL_REQUEST_MSG, TOOL_REQUEST_LEN) == 0) {
std::string robotName = getRobotName();
const char *name = robotName.c_str();
int len = TOOL_ACCEPT_LEN + 3 + strlen(name);
char *response = (char *) malloc(len);
memcpy(&response[0], TOOL_ACCEPT_MSG, TOOL_ACCEPT_LEN);
response[TOOL_ACCEPT_LEN] = ':';
response[TOOL_ACCEPT_LEN+1] = (char)strlen(name);
response[TOOL_ACCEPT_LEN+2] = ':';
memcpy(&response[TOOL_ACCEPT_LEN+3], name, strlen(name));
struct sockaddr_in r_addr = addr;
r_addr.sin_port = htons(TOOL_PORT);
send(&response[0], len, r_addr);
free(response);
}else {
// validate packet format, check packet timestamp, and parse data
CommPacketHeader packet;
if (validate_packet(msg, len, packet) && timer.check_packet(packet))
parse_packet(packet, msg + sizeof(packet), len - sizeof(packet));
}
}
开发者ID:I82Much,项目名称:nao-man,代码行数:35,代码来源:Comm.cpp
示例14: reply_info_parse
int reply_info_parse(sldns_buffer* pkt, struct alloc_cache* alloc,
struct query_info* qinf, struct reply_info** rep,
struct regional* region, struct edns_data* edns)
{
/* use scratch pad region-allocator during parsing. */
struct msg_parse* msg;
int ret;
qinf->qname = NULL;
*rep = NULL;
if(!(msg = regional_alloc(region, sizeof(*msg)))) {
return LDNS_RCODE_SERVFAIL;
}
memset(msg, 0, sizeof(*msg));
sldns_buffer_set_position(pkt, 0);
if((ret = parse_packet(pkt, msg, region)) != 0) {
return ret;
}
if((ret = parse_extract_edns(msg, edns)) != 0)
return ret;
/* parse OK, allocate return structures */
/* this also performs dname decompression */
if(!parse_create_msg(pkt, msg, alloc, qinf, rep, NULL)) {
query_info_clear(qinf);
reply_info_parsedelete(*rep, alloc);
*rep = NULL;
return LDNS_RCODE_SERVFAIL;
}
return 0;
}
开发者ID:Karm,项目名称:unbound,代码行数:32,代码来源:msgreply.c
示例15: load_from_file
int
load_from_file(const char* file)
{
// PCAP file handler
pcap_t *handle;
// Error text (in case of file open error)
char errbuf[PCAP_ERRBUF_SIZE];
// The header that pcap gives us
struct pcap_pkthdr header;
// The actual packet
const u_char *packet;
// Open PCAP file
if ((handle = pcap_open_offline(file, errbuf)) == NULL) {
fprintf(stderr, "Couldn't open pcap file %s: %s\n", file, errbuf);
return 1;
}
// Get datalink to parse packages correctly
linktype = pcap_datalink(handle);
// Loop through packages
while ((packet = pcap_next(handle, &header))) {
// Parse package
parse_packet((u_char*)"Offline", &header, packet);
}
// Close PCAP file
pcap_close(handle);
return 0;
}
开发者ID:amendiola,项目名称:sngrep,代码行数:30,代码来源:pcap.c
示例16: get
void get(){
// Send command //
send_pack(GET, command.arguments, sock);
// receive positive/negative acknowledgement (whether the file exists or not) //
if(recv(sock, packet_str, PACK_SIZE, 0) < 0){
error("recv");
}
parse_packet(packet_str, packet);
if(!(int)packet.command_code){
fprintf(stderr, "The specified does not exist\n");
return;
}
/* send port number for data connection to server */
send_data_port();
// make socket and accept server's Data Connection (active)//
makeDataConnection();
fprintf(stderr, "get() : data connection accepted\n");
// recieve file //
receive_file();
fprintf(stdout, "get() : complete file received\n");
fflush(stdout);
// close the data connection //
close(request->serverSocket);
}
开发者ID:pranavgupta21,项目名称:multithreaded-FTP-client-server,代码行数:30,代码来源:client_func.c
示例17: traverse_match
/****************************************************************************
tdb traversal fn to find a matching 137 packet
**************************************************************************/
static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
{
struct unexpected_key key;
struct packet_struct *p;
if (kbuf.dsize != sizeof(key)) {
return 0;
}
memcpy(&key, kbuf.dptr, sizeof(key));
if (key.packet_type != match_type) return 0;
p = parse_packet(dbuf.dptr, dbuf.dsize, match_type);
if ((match_type == NMB_PACKET &&
p->packet.nmb.header.name_trn_id == match_id) ||
(match_type == DGRAM_PACKET &&
match_mailslot_name(p, match_name))) {
matched_packet = p;
return -1;
}
free_packet(p);
return 0;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:30,代码来源:unexpected.c
示例18: pcap_callback
void pcap_callback(uint8_t *args, const struct pcap_pkthdr *header, const uint8_t *packet)
{
struct pkt p;
int rc;
bzero(&p, sizeof(p));
p.raw_packet = (uint8_t *)packet;
p.pos = (uint8_t *)packet;
p.len = header->caplen;
p.ifc = (struct iface_config *) args;
p.pcap_header = header;
rc = parse_packet(&p);
if (rc < 0)
return;
if (p.arp) {
if (!check_arp(&p))
process_arp(&p);
} else if (p.ns) {
if (!check_ns(&p))
process_ns(&p);
} else if (p.na) {
if (!check_na(&p))
process_na(&p);
}
}
开发者ID:fln,项目名称:addrwatch,代码行数:32,代码来源:addrwatch.c
示例19: obs_x264_encode
static bool obs_x264_encode(void *data, struct encoder_frame *frame,
struct encoder_packet *packet, bool *received_packet)
{
struct obs_x264 *obsx264 = data;
x264_nal_t *nals;
int nal_count;
int ret;
x264_picture_t pic, pic_out;
if (!frame || !packet || !received_packet)
return false;
if (frame)
init_pic_data(obsx264, &pic, frame);
ret = x264_encoder_encode(obsx264->context, &nals, &nal_count,
(frame ? &pic : NULL), &pic_out);
if (ret < 0) {
warn("encode failed");
return false;
}
*received_packet = (nal_count != 0);
parse_packet(obsx264, packet, nals, nal_count, &pic_out);
return true;
}
开发者ID:AhmedAbdulSalam5,项目名称:obs-studio,代码行数:27,代码来源:obs-x264.c
示例20: parse_data
/* Parse the data stream for packets, and send out replies. */
static void parse_data(Octstr *in, Octstr *out) {
int stx, etx;
Octstr *packet;
for (;;) {
/* Look for start of packet. Delete everything up to the start
* marker. (CIMD2 section 3.1 says we can ignore any data
* transmitted between packets.) */
stx = octstr_search_char(in, STX, 0);
if (stx < 0)
octstr_delete(in, 0, octstr_len(in));
else if (stx > 0)
octstr_delete(in, 0, stx);
etx = octstr_search_char(in, ETX, 0);
if (etx < 0)
return; /* Incomplete packet; wait for more data. */
/* Copy the data between stx and etx */
packet = octstr_copy(in, 1, etx - 1);
/* Then cut the packet (including stx and etx) from inbuffer */
octstr_delete(in, 0, etx + 1);
parse_packet(packet, out);
octstr_destroy(packet);
}
}
开发者ID:armic,项目名称:erpts,代码行数:29,代码来源:test_cimd2.c
注:本文中的parse_packet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论